- Home /
Is there a way to set or entirely cancel the velocity of a character controller?
I'm using the unity standard assets first person controller, and I'd like a void that removes all velocity from it. CharacterController.velocity is read only, and CharacterController.Move affects position, not velocity.
Answer by Bunny83 · Jul 08, 2017 at 10:37 PM
The character controller itself doesn't have any velocity. That's the main point of the character controller. It provides manual control over it's movement. If you don't call any Move or SimpleMove on that controller it would be still as a rock. It can't receive any external forces (since it doesn't have any velocity)
A barely use the stardard assets. However as far as i remember the actual control of the charactercontroller is done by a script called "CharacterMotor". It has a sub class which actually introduces a velocity variable. It depends on the version of that script but usually you can set the velocity to 0 like this:
GetComponent<CharacterMotor>().movement.velocity = Vector3.zero;
Though keep in mind that the CharacterMotor script will apply an acceleration based on the input which is usually provided though another script called "FPSInputController".
Your answer
Follow this Question
Related Questions
Moving the floor flings First Person Controller 1000m backwards 2 Answers
How to tell if the player is turning? 2 Answers
[Closed] Find the velocity of the Character Controller 1 Answer
How does the premade FPSController handle character physics? 1 Answer
Main Camera won't rotate left or right 0 Answers