How to stop character controller from accelerating/sliding
I'm using the default Character Controller and for some reason, it keeps on going for a second even after I have stopped moving. Preventing this is the exact reason I switched from a physics controller to the character controller after seeing the Brackeys video about it (same as shown in the Brackeys video, in which the controller does not accelerate/slide).
Here is the script I'm using to move the controller.
public float movementSpeed = 5f, speedH = 2f, yaw;
private void Start() {
controller = GetComponent<CharacterController>();
}
private void Update() {
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * movementSpeed * Time.deltaTime);
yaw += speedH * Input.GetAxis("Mouse X");
transform.eulerAngles = new Vector3(0.0f, yaw, 0.0f);
}
Just to clarify, I'm not using any rigid body components or additional colliders on the player object.
Your answer
Follow this Question
Related Questions
Have an issue with looking and moving Unity3D 1 Answer
How to move character controller on x, z, AND y axes? 2 Answers
Controller script active on both characters. 1 Answer
Error CS0103 0 Answers
I can't seem to get this movement + automatic lookat the direction of movement work for a 2.5D game 0 Answers