#Add acceleration and decceleration

1 messages · Page 1 of 1 (latest)

ivory forum
#

hello everyone , i making a 2d platformer game and i need to make acceleration and decceleration for smoother movement

i read some articles about using mathf.clamp or rb.addforce but the problem is i using rb.velocity to move my player

i want to know what should i do to fix it
thanks!

primal garden
#

can you switch to adding force instead of modifying velocity?

ivory forum
#

ok i do it but the problem is i cant make acceleration

gusty gate
#

Alternatively, Lerp the Velocity instead of setting it to a fixed value to keep your original workflow

primal garden
#

what

ivory forum
#

i create 2 vector2 variables called moveAmount and moveInput

#

moveInput = new vector2(Input.GetAxisRaw("Horizontal"),0);

#

moveAmount = moveInput.normalized * speed;

#

the on the fixedupdate method i using rb.addForce(moveAmount * Time.fixedDeltaTime);