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. Dismiss Notice

Jumping along a Curve like the graph of x^2

Discussion in '2D' started by derixstudio, Mar 24, 2017.

  1. derixstudio

    derixstudio

    Joined:
    Mar 10, 2017
    Posts:
    1
    I want to code a jump that goes along a curve like the graph of x^2. I tried slerp out but I couldnt get it right. I was curious if anyone had any Ideas. I want it a fixed jump though. I code in C#. Not Java.
     
  2. webox

    webox

    Joined:
    Aug 27, 2015
    Posts:
    72
  3. Ferb

    Ferb

    Joined:
    Jan 4, 2014
    Posts:
    21
    All you should need is to start with some velocity upwards and some constant x-velocity, and let gravity do its work.

    The graph y=k x^2 has a second derivative of 2k, which is a constant, so as long as you have constant acceleration (which gravity is), the path of your jump should be of the form y = k x^2. It might be distorted a bit by air resistance if that's enabled, but there will be options to turn that off, and if the object has a reasonable mass and is making a small jump the difference it makes should be negligible.