- Home /
Impulse to reach certain height?
I'm trying to make my character jump to a certain height using only a single impulse.
The only values I have available are Gravity and desired Height. (Using VelocityChange, so mass is irrelevant.)
What is my feeble brain missing to solve for velocity necessary?
this is more of a physics question. you could get an answer on stackexchange in 2 $$anonymous$$utes!
simply search to wikipedia's "projectile equations" page and you will almost certainly instantly find the answer
Answer by SergeantBiscuits · Sep 22, 2012 at 02:49 PM
Physics! I love physics.
maxHeight = (initialVelocity^2) / (2g)
Use that formula... in fact, if you solve for initialVelocity, you can make a "jump to height" line. In javascript:
var jumpHeight;
if(Input.GetButtonDown("Jump")){
transform.velocity.y = Mathf.Sqrt(jumpHeight * -2 * physics.gravity.y);
}
Thanks a bunch! I tried a few formulas that were really close to that, but I must have screwed up big-time somewhere. This worked like a charm.
Your answer
Follow this Question
Related Questions
rigidbody.Velocity stops gravity 2 Answers
Simulate gravity on rigidbody 1 Answer
Keeping character's movement consistent. 1 Answer
Firing projectile in curve 1 Answer