Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Parabolic jump

Discussion in 'Scripting' started by gushavi, Jan 13, 2020.

  1. gushavi

    gushavi

    Joined:
    Dec 22, 2019
    Posts:
    7
    I'm trying to simulate a parabolic jump on a player game object with kinematic rigidbody. I've found several solutions online, but they usually include the destination point, which is something I don't have, since the player can change its speed in mid jump. The only parameter I have are the max jump height and the speed
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,745
    do you want it to look physically correct or just move along parabollic trajectory?
     
  3. gushavi

    gushavi

    Joined:
    Dec 22, 2019
    Posts:
    7
    A parabolic trajectory will be good enough. Maybe to make what I'm trying to perform more understandable, I'm trying to simulate the jumping buggy in Moon Patrol. As the buggy jumps, you can increase or decrease speed in mid air, which will change your final landing point.
    Currently, It's jumping at a constant y velocity which I reverse once a certain height is reached.
     
  4. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,745
    Then you should just split your horizontal and vertical movement. Calculate horizontal from speed and for vertical use initial speed and apply gravity every fixed frame. Combined, this will give you desired parabollic-like trajectory .
     
  5. gushavi

    gushavi

    Joined:
    Dec 22, 2019
    Posts:
    7
    I'll try that, thanks.
     
  6. gushavi

    gushavi

    Joined:
    Dec 22, 2019
    Posts:
    7
    @palex-nx

    It worked just like I wanted it. Thanks a lot.
     
  7. Saraphin34

    Saraphin34

    Joined:
    Jun 22, 2020
    Posts:
    1
    I know i'm a little late, but could you share your code snippet on how did you achieve it ?