- Home /
How to turn off inertia when player stops moving?
When I release the character control button, character itself continues to move for about half a second. I want the character to stop right after I release the control button. I’ve tried diffirent methods: AddForce and velocity, but it’s all in vain.
Also, I tried to adjust the mass and drag momentum in Inspector of the character, but it didn’t help.
public class CapsuleMovement : MonoBehaviour
{
Rigidbody rb;
Vector3 playerMovement;
[SerializeField] float speed = 50;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
ProccessCapsuleMovement();
}
void ProccessCapsuleMovement () {
playerMovement = new Vector3 (Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
playerMovement.Normalize();
rb.velocity = playerMovement * speed * Time.deltaTime;
}
}
Answer by JethRow · Nov 25, 2021 at 06:28 PM
When you add Velocity to Rigidbody its like adding some force to it,to the direction, so after you done doing that you should set your velocity to 0 after your move has been performed
for example when i hit the ball i add a velocity to it, and its going down as the forces slow it down, but if i had a Force like a Jedi in real life i could just set its velocity to 0 when i feel like, you get the point? :D
Also check if you are moving on a Slippery material or any Slippery material has been added to player or ground!
Your answer
Follow this Question
Related Questions
Rigidbody inertia recalculation after detaching child colliders ? 2 Answers
Error: Actor::updateMassFromShape 0 Answers
How do I make an imported asset into a character which can only move along one axis? 1 Answer
How to identify ThirdPersonCharacters activities like walking, running, jumping in unity5 0 Answers
Character Controller not working on Unity Editor After doing a Build 1 Answer