How to Counteract Inertia After LinearVelocity

I’m working on a dash mechanic similar to the one in Combat Warriors, using LinearVelocity. The issue is that when the player dashes in the air, it continues to move forward due to momentum, even after the dash ends (which lasts 0.1 seconds).

I want to know how to effectively counteract this inertia without manually setting a new velocity for the player. Specifically, I need to determine how much force to apply to push the player backward after the dash ends, effectively cancelling out the momentum gained during the dash.

I’m not 100% sure but you could anchor the HumanoidRootPart for a brief period of time

Apply an opposite force to the player’s character, which will cancel out the inertia (depends on how much force you apply)

Most of the dashing abilities I’ve seen in games appear to instantly change the speed of the player, which isn’t actually possible in any realistic physics simulation. This is because using the impulse equation J = F * t would require the time t to be zero, which leads to problems like division by zero. If you want something similar, you would need to apply a large amount of force over a very short period of time.

That being said, this seems to me like an XY problem; what is stopping you from setting the player’s velocity directly or using the ApplyImpulse method on the player’s root part? It doesn’t make much sense to apply a backward counteractive force after a dash when they are typically a single impulse in one direction.

2 Likes

I’m currently working on my own movement system, and I think changing the actual values of the LinearVelocity as you dash is the way to go. If you take a look at the video below, you can see the inertia itself is essentially canceled by the LinearVelocity itself. The way I do this is by tweening the total velocity to 0 through the 0.2 seconds or whatever. This prevents your player from going anywhere after the dash. Just make sure you’re choosing an appropriate EasingStyle for your tween to make it look alright.

External Media
2 Likes

This might be the dumbest suggestion, but try making the character massless for a very brief amount of time. Inertia is “the reluctance of an object to change its state of motion due to its mass”, so having 0 mass would result in 0 inertia. Like I said, its a dumb choice but it’s the best I could think of without the need of another force

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