Need help to make the Game object jump

Updated on January 10, 2017 in [A] Unity Scripting
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
1 on January 10, 2017

I’ve been using this script to make my ball jump and move. I’m happy with the movement of the ball but the jump doesn’t seem right. When I move the ball then jump and when I keep on pressing the movement key the ball seems to make a very long distance jump. So can someone please help me with this.
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis (“Horizontal”);
float moveVertical = Input.GetAxis (“Vertical”);

Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

rb.AddForce (movement * speed );
if (Input.GetKeyDown(KeyCode.Space) && isfalling==0) {

Vector3 jump = new Vector3 (0.0f, 350.0f, 0.0f);

// GetComponent<Rigidbody>().AddForce(jump);
}
isfalling=1;

}

void OnCollisionStay()
{
isfalling = 0;

}

Thankyou :)

  • Liked by
Reply
0 on January 10, 2017

What is it that you want. You say it’s making a “long distance jump” but that’s it we need to at least know the way you want the player to jump

  • Liked by
Reply
Cancel