How can we determine where an object we move will go beforehand?

I am working on a throwing knife script, we will throw the knife from our hand and when it touches anywhere the knife will stop and we will calculate the point of view of the sword in our hand with the point we clicked and we will stab the sword correctly (player or BasePart Object).

However, if the player throws the sword just under it, it detects the touch late and stays in the object, the blade is not visible.
Or it senses that the knife is touching, but when we turn it, it stays in the air as if it had never been touched.

It will work perfectly if I find in advance the destination of the object we are moving and place its coordinate on the blade.
but how can i do this?

Knife It should be just like this game:
https://www.roblox.com/games/379614936

INFO: I used “BodyForce” to reduce the gravity of the blade,
I used BodyAngularVelocity to rotate the blade,
I used the “Touched” event on the blade to detect if the blade was touched,
The blade moves fast and its speed is always constant,
I adjust the speed by changing the “Velocity” of the blade,
Wherever the player’s mouse clicks, I get the coordinate from there, it falls to an uncertain place with gravity, or the knife hits the moving player.

This sounds like an issue with the .Touched function, you could alternatively use Raycasts to potentially fix this issue.

Like mentioned above, you can cast a ray from the knife to where the player is looking (Or in whatever direction the knife is being thrown in) and then return the value of whatever touches the ray using raycasting. There are tutorials on raycasting, but I am on my phone right now so I cannot link them. Either way, hope this helps and good luck!

Isn’t RayCast straight? But this blade has gravity, it doesn’t go straight

Right, theres many ways to approach this but ideally you’d want to create 4 rays (up, down, left, right) and detect any hits from there. This should be put within a loop and the loop should only run when the knife is in its flying state.

Hope this helps! :wink:

I suggest using Fastcast module which will definitely be very helpful in this scenario.
FastCast Module by EtiTheSpirit

1 Like