How can I make an knockback without delay?

Hello everyone. I want to know how to make a knockback without delay.

Often times when I use BodyVelocity or LinearVelocity to create a knockback within the enemy’s HumanoidRootPart, there is always a very noticeable delay before the knockback actually takes effect. I am assuming this is because the velocity constraints take time to build up force and eventually kick in.

I was thinking of using TweenService on the HumanoidRootPart as a method for knockback. However that wouldn’t be efficient as that would take away the enemy’s any chance of moving during the knockback tween. TweenService also ignores the CanCollide property and is determined to take the tweening part to its goal destination by phasing through walls, objects, etc.

I have seen some games achieve this kind of “instant knockback” effect. But I am not sure how they do it… If anyone knows, Please share your knowledge with me!

2 Likes

I’m not super experienced with this, but I think calculating and using this kind of stuff client-side would be the best bet?

1 Like

This is because of client-server lag.
I’m assuming you’re sending a message from the client to the server to add a bodyVelocity to the enemy. However, in the time it takes to send that message to the server and then back to the client, a bit of lag time is created.

The only way I can imagine doing this would be to handle everything on the client, then replicate it to the server.

4 Likes

How can I make a safe and secure way to implement a BodyVelocity or LinearVelocity on the client?

1 Like

Maybe store the attributes you want to protect server-side, or with some sort of encryption, then use them locally!

1 Like

Although I personally don’t have much experience with this, I would recommend looking into VectorForce and ApplyImpulse.

You can also try directly setting the AssemblyLinearVelocity of the characters you’re trying to knock back, but I would imagine that would have some undesirable results.

Hope this helps!

1 Like