how to jump to desired distance.

i need to do jumping my player to the fixed target position.i did it position.that’s why it is not good to see .he is not jumping smoothly.I want to jump my player with physics.so it will looking good. and also the player has to reach the target with parabola shape.

i forgot to mention it’s 2d game.the player is contentious jumping person.just like in #Give_it_Up game.

how can i do it …help me out …

thank you

The solution I’d recommend to you is by using the physics engine of Unity. It will cost you a lot of test to adjust to the correct behaviour you’re looking for, but when you’ll have finished, it will be cool.

Add a RigidBody2D and a boxcollider2D to your character. Don’t set it in kinematics. When you jump, you will call the function (addForce) to make your player jump. You’ll have a public vector and a public value to configure your jump.
Here is the code :

EDIT : Correct version of the code

 public Vector2 m_jumpDirection; // You can choose the perfect angle
 public float m_force;             // You can choose the right strengh for the impulse

 private bool m_isPlayerGoingToRight = true;

 void Update()
 {
     if (Input.GetButton("Jump"))
     {
         jump();
     }
 }

 void jump()
 {
     Vector2 playerDirection;

     if (!m_isPlayerGoingToRight)
     {
         playerDirection = configureJumpDirection(-1);
     }
     else
     {
         playerDirection = configureJumpDirection(-1);
     }

     gameObject.GetComponent<Rigidbody2D>().AddForce(playerDirection * m_force, ForceMode2D.Impulse);
 }

 Vector2 configureJumpDirection(int m_direction)
 {
     return new Vector2(m_direction * m_jumpDirection.x, m_jumpDirection.y);
 }

I’m currently installing Unity 5.3, so I couldn’t test my code. If there is something wrong, write it, then I will correct my code.

it giving the error. can’t multiply vector2 with vector2.

i.e playerDirection * m_jumpDirection

here it gives the error.

getComponent().AddForce(playerDirection * m_jumpDirection * m_force, ForceMode2D.Impulse);