Search Unity

Smooth landing after jump ?

Discussion in 'Physics' started by Mehd, Feb 5, 2019.

  1. Mehd

    Mehd

    Joined:
    Apr 29, 2016
    Posts:
    91
    Hi friends !

    After fighting for a long time with my code I decided to ask for some help. I'm designing a TPS controller for some small demo and I have a problem handling the landing phase. Explicitely, my character loses all its speed when landing. I have tried to add a fraction of its speed horizontal speed on landing but this is not optimal in the sense that the character is propulsed with too much instantaneous force.

    How do you guys handle these situations ? Any tips for good landing ?

    Thanks a lot!
     
  2. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Can you describe the situation more?
    From what you wrote I can only imagine two scenarios:

    1) A character falling straight down and hitting the ground. In that case completely losing all speed is what you probably want, right?

    2) A character is in the air, falling down, but also has a great forward velocity (like a landing airplane or something).
    In that case you probably already "cast" (as in the cast functions in Unitys Physics class) your path ahead to know what you will be colliding with. And in that case the result from Vector3.ProjectOnPlane() could be essentially viewed as "all the remaining velocity along the ground", which is what you want, right?
    https://docs.unity3d.com/ScriptReference/Vector3.ProjectOnPlane.html