Want the velocity of platforms to add to the players velocity

I want to have “slippery” platforms which im thinking of achieving with surface effectors. Unfortunately in the player script we are directly changing the velocity so it doesnt work. Ive tried adding velocity instead of setting it like

if (rb.velocity.x < speedFactor){
  rb.velocity += new Vector2(moveInput*speedFactor,0)

but this doesnt feel as responsive because the character doesnt immediately stop when we stop pressing the key. Furthermore since im capping the velocity at speedFactor only, the velocity of the surface effector doesnt add to it anyway. What should i do?


In which course and lecture are you?

Hi. Im in the unity 2d course in the platformer section

If you want to stop the movement, you have to set the velocity to Vector.zero. If you want this to happen when a key got released, use GetKeyUp. Alternatively, you could work with GetKey and a bool.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms