- Home /
jumping at a specific height (using rigid body)
I want my character to jump when I press the space bar but not to keep going up if I keep holding it. I want to use rigidbody but not character controller. Here is my code:
if (Input.GetKey("space")) {
animator.SetBool("Jumping", true );
rigidbody.AddForce(0,100,0);
}else{
animator.SetBool("Jumping", false );
}
PS I have tried GetKeyDown but then my character doesn't go up at all.
Comment
Answer by robertbu · Aug 15, 2013 at 08:35 AM
Try GetKeyDown() again, but use:
rigidbody.AddForce(0,1000,0);
This assumes you left your mass at 1.0.
Your answer
Follow this Question
Related Questions
Jump angle relative to surface? 1 Answer
rigidbody player jump automatically. 0 Answers
moving with rigidbody without acceleration 0 Answers
Rigidbody Stick To Floor 1 Answer
How to get global up vector? 1 Answer