- Home /
How to stop input after hitting a certain velocity
I've looked so many places and just can't find anything. All I am looking to do is see how to have player input stop once I have reached a certain velocity. I do not want to clamp velocity. Just cancel out the oncoming input so there is no more force added.
Why?
I want my character to have the option to go higher than max speed for a second using impulse. But if velocity is clamped that won't work. I do not want the velocity to seem jittery. I want it to stay at a constant speed, and ONLY fluctuate when told to.
I would prefer to not just rip someone's code off so if any of you could as much as point me in the right direction that would be fine.
P.S. - I AM USING RIGIDBODY FOR MOVEMENT.
If you ignore the input then velocity will start to decrease, right?
Answer by spooneystone · Sep 23, 2020 at 01:11 PM
float maxVelocity = 10;
if(rigidbody.velocity.magnitude <= maxVelocity)
{
Debug.Log("Move");
}
Something like this.