Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a problem that can't solve. I have my char standing in a fixed spot, a fixed jump force (hey the guy can jump very high but has his limits!) and a fixed landing spot(the one I want the char to land) but I must find if I'm in the right spot to jump(the jump is achievable, there are no obstable and my the char jump force can land in the right spot) then I must apply the right xforce and zforce (yforce is fixed remember? ) to steer the guy on the right spot. I've tried to implement the formula suggested but my character jumps away from the pad xD

deltaPosition = target - character_position;
sqrtTerm = Sqrt(2*-gravity.y * deltaPosition.y + MaxYVelocity* character_MaxForce);
time = (MaxYVelocity-sqrtTerm) /gravity.y;
speedSq = jumpVelocity.x* jumpVelocity.x + jumpVelocity.z *jumpVelocity.z;

if speedSq < (character_MaxForce * character_MaxForce) we have the right time so we can store the value

jumpVelocity.x = deltaPosition.x / time;
jumpVelocity.z = deltaPosition.z / time;

otherwise we try the other solution

time = (MaxYVelocity+sqrtTerm) /gravity.y; 

and then store it

jumpVelocity.x = deltaPosition.x / time;
jumpVelocity.z = deltaPosition.z / time;
jumpVelocity.y = MaxYVelocity;

rigidbody_velocity = jumpVelocity;
share|improve this question

closed as off topic by Ross Millikan, M Turgeon, William, Thomas, J. M. Sep 29 '12 at 10:42

Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

I think this question would be better suited for physics.stackexchange –  M Turgeon Sep 24 '12 at 14:31

2 Answers 2

up vote 0 down vote accepted

In response to the new question, where the arrival location is not at the same altitude as the departure location, let $v_y$ be the initial vertical velocity and $v_x$ the initial horizontal velocity. The path is then $(v_xt,v_yt-\frac 12 gt^2)$ Since you say $v_y$ is fixed, you can solve the quadratic to find the arrival time. You want the greater of the two values so you arrive on the downward trajectory. Given the time, you can calculate the $v_x$ you want.

share|improve this answer

Instead of force, think of initial velocity. Let $v_x$ be horizontal and $v_y$ be vertical. Your limit is then $v_{max} \ge \sqrt{v_x^2+v_y^2}$. The altitude at a given time will be $y=v_yt-\frac 12 gt^2$, so the time of flight is $t_f=\frac {2v_y}g$ and the distance tavelled in $x$ is $\frac {2v_xv_y}g$ You can rotate to get the jump along the right direction in the $xz$ plane. Is this in the direction you were looking for?

share|improve this answer
Ross thank for the fast answer, I will try to implement in the code and will report if works. I guess I need a specific force in x and z. In Unity 3d you can add force as vector3 to achieve a jump... I like you "push" the object in a direction with a precise force and if you are right the object will land in the spot you want :D –  Kahel Sep 24 '12 at 18:33
@PasqualeSada: In real physics, force divided by mass gives acceleration. The change in velocity is acceleration times time. So if the time is short, you can just work with change in velocity. For separating $x$ and $z$, you can regard the $v_x$ above as $v_r$, the radial velocity change. Then $v_x=v_r \cos \theta, v_z=v_r \sin \theta$ –  Ross Millikan Sep 24 '12 at 19:11
Thanks Ross for your patience :D I will try to make it works on Unity but I thinks that is a pretty easy task after you explanations :D –  Kahel Sep 24 '12 at 22:42
@PasqualeSada: Is this related to your question on Physics, where the landing altitude is different from the launching altitude? I explicitly assumed they were the same in calculating the time of flight. –  Ross Millikan Sep 25 '12 at 14:29
I've edited the question! –  Kahel Sep 27 '12 at 8:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.