LinearVelocity or ApplyImpulse, which is better for different situations?

I am making a ability for a character where it pushes the character forwards by a certain distance with the click of a button, and I was wondering if I should use LinearVelocity for this, or ApplyImpulse?

Yes, these two systems are very different as one is a constraint and the other is a function but they both happen to suit the system that I’m making.

For LinearVelocities, the length and speed it pushes the player is more consistent, but it is less stable which makes it more likely to fling the player (especially when it collides into walls).

For ApplyImpulses, it is more stable in pushing the player and is less jankier overall than LinearVelocities, but since it uses force to push the player, the length it pushes depends on the friction of the surface the player is standing on which makes it less predictable to use.

I don’t mind having different pushing distances with ApplyImpulses, but I would prefer the distance pushed being manually set instead of depending on external factors (part friction, character mass, etc)

I’ll show you videos of the pushing mechanic with LinearVelocity vs ApplyImpulse

LinearVelocity Pushing Mechanic:

I’ve improved it from the video shown so that it no longer flings the player unless it pushes the player into walls which gives it a chance to fling the player

ApplyImpulse Pushing Mechanic:

3 Likes

A different way to think of them is that LinearVelocity/LinearForce is for flying rockets and ApplyImpulse is for shooting cannonballs. One happens continuously and one happens instantaneously. If you want to FLING the player, use ApplyImpulse. If you want to give the player flyhacks, use LinearVelocity.

LinearVelocity is just LinearForce that’s automated in such a way that the average velocity doesn’t change. And LinearForce is just ApplyImpulse being applied constantly.

1 Like

I see, so LinearVelocity is better for controlled movement whereas ApplyImpulse is better for uncoordinated movement, something like that?

Pretty much. But “uncoordinated” isn’t the word I would use. ApplyImpulse is more primitive, down-to-the-earth, because you are directly changing the momentum of a solid body to a specific value. LinearVelocity also does that but it depends on a bunch of other factors, such as the mass of the body.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.