How to limit only the Rigidbody.velocity from player input?

Hi all. Been stuck solving this problem for a week now, and thought I’d try you guys.

Basicallly I want to create a rigidbody controller that responds to both player input and forces from other rigidbodies (ie. from player movement, and collision with other gameobjects, speeding the player up).

I’ve tried several methods, all which were successful in limiting the player velocity. Examples of them were clamping the velocity to maxSpeed, and adding a force opposite to the force added, if the player exceeds maxSpeed.

The problem with these methods is that they limit maxSpeed from player input and also from external forces. So when another (fast-moving) rigidbody collides with the player, the player doesn’t “fly off” as fast because of the maxSpeed limiting the player velocity.
I’m looking for a way to limit only the velocity caused by player input, and leave external forces be. Is there a way to do this?

Any help is appreciated. Thank you!

Hello!

yes, its very simply!

What you really want, is NOT to limit the speed of the rigidboy, what you really want i only disable “addForce” from key Input detection if rigidbody speed reached a limit!

So you only need to detect the player input keyboard if the speed of the rigidbody is lower than the speed limit. So, do not limit the spped, just disable the Input detection if reached the limit speed.

In addition, also add a limit, (much more highr than limit disabling input), i mean, for example, input is disabled at 50 km/h and max speed limit is 200 km/h. (Unity can do strange things at very high speed moving objects… :smiley:

Bye!