Question by
Filters · Jan 13, 2021 at 02:42 AM ·
movementphysicsvelocitycharacter controllermomentum
retain momentum with characterController.Move
When moving the character controller with input everything looks great. i can move on ground or in air. but when the button isn't pressed the character controller immediately stops moving. i am looking for an effect similar to the rigidbody's public method "addrelativeforce" along with it's drag, although i am adamant on not using one.
my goal is to get the character to slow to a stop in the direction it was last going. here's the bulk of it:
void PlayerMovement()
{
isGrounded = controller.isGrounded;
float hor = Input.GetAxisRaw("Horizontal");
float ver = Input.GetAxisRaw("Vertical");
direction = new Vector3(hor, 0, ver);
direction = transform.TransformDirection(direction);
controller.Move(Vector3.ClampMagnitude(direction, 1f) * speed * Time.deltaTime);
}
Comment
Your answer
Follow this Question
Related Questions
Counteracting rigidbody velocity using AddForce? 0 Answers
How do I get an object's velocity in one direction? 4 Answers
Problem with the Character Controller on the Y-Axis,Character Controller drifting in the Y Axis 0 Answers
C# Trying to make SnowBoarding Like Physics 0 Answers
Rigidbody sticks to wall 0 Answers