Looking for a good (and SIMPLE) way to throw knives

Hey all, so I had a look at FastCast and while the module looks very robust, it does seem a bit elaborate for my needs. Even currently trying to set it up, it yields my whole game by just requiring the module perhaps something to a recent update to the module.

Knife throwing isn’t central to my game, and most abilities the player has are close range melee, I just need some ideas on how to set something up that actually works and isn’t too complicated/overkill.

thanks for any advice or ideas!

4 Likes

There’s alot of ways to do this,one would be with velocity but i do not recommend such, as you’d need to manipulate network ownerships which would turns out too overcomplicated.
You could try using tween or lerp to interpolate the knife position in the desired target,tween would be easier but i personally prefer lerp so you should go for that.

I will be moving the knife for visual effects on all clients and moving a hitbox without the actual knife model on the server for hit detection. at least that the non-FastCast plan so far.

I am thinking bodymovers might be a good idea though, since tweening on the server and the clients might not be the best plan.

One way is you can use Mouse button down and get the mouse hit position you can also use tick on how long they hold the button, fire an event. Then on server get the event and use body velocity or vector force if you want it to glide.

I know you didn’t want to use FastCast, but I’d suggest looking into it a bit. It’s not that bad to setup, and would work for knife throwing, melee hit detection, and of course guns as well.

Moving parts, .Touched, collisions in general, are all very inconsistent. The main benefit of raycasting is just the reliability of it.

1 Like

I posted on the FastCast thread and it currently seems to be bugged due to Luau and other features I dont need. As it is, I can’t use it at all.

I’m worried the module is becoming over feature filled and is including so many new things for every edge case imaginable.

It also requires me to creat just one Caster object for each player and leaves the responsibility of cleaning these up to me when the player leaves. It was recommended that I creat the Caster object through a local script, but this is forcing a paradigm contrary to my entire framework right now.

That’s why I’m here, it doesn’t work right now, it’s including way more features and complexity than I need, and it’s making my setup more of a pain than it should be.

As a note, I’m thinking about using the RayCastHiitbox module instead, just haven’t satisfied how I will sync server and client projectiles

Please excuse typos on I’m my phone

I am hoping someone here can help with an idea regarding this. I just tried setting up FastCast and again, no offense to the creator of the module, but its just overly complicated and the provided example gun is also also full of so much extra stuff, picking it all apart is incredibly difficult. I get errors from FastCast that have no infomration on how to solve them.

I am not a beginning programmer by any means, but I am just finding this so difficult to use.

I really just need to move a hitbox on the server and keep it synced on the clients, is there anything out there that can help me do this?

  1. Create the actual, invisible projectile on the server, move it with a bodyvelocity and set the networkowner of it to nil

  2. Have the server send a signal to other clients to create a visual that’s synched to the flightpath of the server-generated bullet (except your own, your client should create the effect immediately before telling the server you threw a knife)

  3. Rig up touched events on both the server knife and the visual knife; automatically trust hits confirmed by the server, but check against the position of hits confirmed by the client

simple as can be

sounds like what I wanted to do originally before going down the FastCast rabbit hole. Again no hate on FastCast I’m sure its robust set of features really fit the needs of some people.

I have already a pretty solid system for doing logical stuff on server and rendering effects on the client. While most of my game deals with melee abilities I am at the point of adding in a few projectiles such as knife throw and/or other slower moving, non-bullet type projectiles.

In your suggestion here on #2, how do you propose syncing what on the server and client? i have no problem generating and moving invisible hitboxes on the server and cosmetic projectiles on each client, but how do i get them to stay reasonably synced? I don’t need perfect, just good.

People tend to say that touched events are unreliable and inconsistent but we’re using them for a notably large project of ours and they remain 100% consistent serverside up to speeds of about 700 - 800 studs per second and magnificently higher from the client - and under normal circumstances our projectiles are maybe about a tenth of that speed

Fastcast is meant for people that want to simulate physics-based projectiles without actually using physics, meaning they’re probably working with speedy bullets and should probably just progress to hitscan anyway

As far as synching goes, all you need is to determine the average transfer speed of client-to-server signals (aka determine the player’s ping) to see how much time transpires between the client sending the signal and the other clients receiving it - then you just move the visual from the shot’s origin based on the bullet’s travel speed and the elapsed time - simple math

Yeah, agreed I’m not concerned about using Touched event or I might use the RayCastHitbox module which I have already setup in my game for other purposes.

How are you determining a player ping and they how are you using this to affect the travel speeds? I could sue some help with this :slight_smile:

this would be a good module! something simple to sync hitboxes

The most barebones way of doing it is:

Client fires a remote with its current tick()

-- Client
game.ReplicatedStorage.Ping:FireServer(tick())

Server receives signal, compares the send time to its own tick()

--- Server
local Pings = {}

game.ReplicatedStorage.Ping.OnServerEvent:Connect(player, sent)
     local difference = (tick() - sent)
     local MS = math.ceil(difference/10) -- Games tend to display ping in milliseconds
     Pings[player] = MS
end)

I chose to store the value in a table but you could put it in a NumberValue if you wanted both ends to see the value, and you might if you plan to have a ping display

BodyVelocity speeds are expressed in studs per second, and your ping is expressed in milliseconds, so it’s a simple conversion

interesting!

can i also ask why you would set networking ownership to nil instead of server?

You can use Tween service and use .Touched event

oh thanks but but dont recommend using TweenService on the server for stuff like this, bodymovers are much cheaper on resources.

the issue here is not to move things, but to keep my server and client objects synced

1 Like

Setting network ownership to nil is server.

This is required because network ownership means all unanchored parts around you get their physics calculated by your client, so a exploiter can just do something like aimbot forcing the knife to follow player and guaranteeing hits, by setting it to nil no one owns the part so players can do nothing

1 Like