09072009, 09:40 PM  #1 
User
Join Date: Nov 2008
Posts: 61

Parables
Parabels – how to?
Because I saw lots of threads about this question, I wrote this little tutorial about the parabolic formula of a jump. You have to know that there is not only one formula, but quite a lot of them – depending on the given parameters you put in. You could define a parable by a maximum height, the height difference between target location and start location and a given jumptime. But I think that this solution is not realistic. If some guy jumps even the shortest distance in 2 seconds, but also needs 2 seconds from one end of the map to another, it would be weird. I prefer instead to take the movement speed of the jumping unit, from which you can calculate the complete parable. This way, that's the data we can use: 1. Movement speed 2. Height difference 3. 2DDistance (just like on a map: two points connected with a lineal, no height difference included) Paid attention in Physics? The formula for the vertical throw is this one: y(t) = 0.5 * 9.81m/s² * t² + v * t We have two unknown parameters here: t and v The first one is easy if you look at this picture: (yeah it's paint) The unit will move in xdirection as it did before. With its normal movement speed. Which means that the jumping time is: t = Distance/MovementSpeed v (which is the ascending arrow) is the last unknown. We take our formula and transform it a bit: y(t) =  0.5 * 9.81m/s² * t² + v * t becomes v = ( y(t) + 0.5 * 9.81m/s² * t² ) / t We know that the unit will have a higher position at the end of the jump. y(t) is nothing but height at time t, so we can replace the y(t) by the height difference: v = ( HeightDifference + 0.5 * 9.81m/s² * t² ) / t Calculate v and put it into the old formula. In the trigger, make sure that the unit keeps it movement speed: Polar Offset by (Default ms of unit) * periodic time and set height to 0.5 * 9.81m/s² * t² + v * t – (Z of temporal position of unit – Z of startposition of unit) Remember, it's height at time t, so the t here is NOT the time the units needs for the complete jump, it is the time the unit is already in the air. The last one for providing a smooth jump, it would act strange over cliffs otherwise. Note: 9.81m/s² is far too low for warcraft usage. There is nobody who would jump 700 metres or so. I am using 981m/s². Note2: This will also work if the unit jumps down from a higher level. I have added a example map which leaks and is not smooth over cliffs. It does, though, show the formula in action (Download). Enjoy! Have a nice day! Idontneedaname 
Sponsored Links  Login to hide this ad! 

Thread Tools  Search this Thread 

