HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Angled Jump/Parabola

06-26-2009, 07:54 PM#1
Gwypaas
I've used this http://www.wc3c.net/showthread.php?t=102077 function for a while but now it doesn't really fit my needs. I have a jump which does not get affected by the terrain because it shifts too much so now I want it like this.

If the jump starts at 400 height and ends at 50 height then the Jump should be perfectly angleded for that but I have no idea how to do that. I dont want to have a sudden decrease of height in the end to restore the values to normal.

I think this picture illustrates my needs very well.
Zoom (requires log in)
Attached Images
File type: jpgAngled_Jump.jpg (10.6 KB)
06-26-2009, 08:37 PM#2
Zerzax
I think a parametric curve with the angle of projection and initial height might work for you. I'll look it up now.

EDIT: x = VoCos(Theta)t
y = -1/2gt^2 + VoSin(Theta)t + Ho

Where Theta is the angle of projection, t is time from 0 to 1, g is -9.81meters/sec/sec, Vo is initial velocity, and Ho is the initial height.

Well that might be too much, I remember from my old math books simply plugging the t value in and having the rest of the coefficients preset without all this parametric mumbo jumbo.
To make it simpler, you could just define what x velocity you want and what y velocity you want. That way, you can avoid using sin and cos and simply plug in the value in your custom function.
06-26-2009, 09:42 PM#3
moyack
This is a parabolic code which is independent of the height. It uses gravity.

http://www.wc3c.net/attachment.php?a...7&d=1245294708
Attached Files
File type: w3xjump test.w3x (18.2 KB)
06-26-2009, 10:16 PM#4
grim001
Why do people always prefer these fake looking parabolic jumps over a vector-based iterative approach? It's easy enough to control where the jump will land absent drag.
06-26-2009, 10:52 PM#5
Gwypaas
Quote:
Originally Posted by Zerzax
I think a parametric curve with the angle of projection and initial height might work for you. I'll look it up now.

EDIT: x = VoCos(Theta)t
y = -1/2gt^2 + VoSin(Theta)t + Ho

Where Theta is the angle of projection, t is time from 0 to 1, g is -9.81meters/sec/sec, Vo is initial velocity, and Ho is the initial height.

Well that might be too much, I remember from my old math books simply plugging the t value in and having the rest of the coefficients preset without all this parametric mumbo jumbo.
To make it simpler, you could just define what x velocity you want and what y velocity you want. That way, you can avoid using sin and cos and simply plug in the value in your custom function.

I have x, y and z velocities but could you show me some code of how I would use this.

Quote:
Originally Posted by moyack
This is a parabolic code which is independent of the height. It uses gravity.

http://www.wc3c.net/attachment.php?a...7&d=1245294708
The problem is that I want to control the exact position that it lands on.

Quote:
Originally Posted by grim001
Why do people always prefer these fake looking parabolic jumps over a vector-based iterative approach? It's easy enough to control where the jump will land absent drag.
Because it's very easy to use them and they look good enough in most cases, but not in this one. Could you please show me some code of how to use a Vector based approach?
06-28-2009, 02:26 PM#6
Gwypaas
I still need help with this.
06-28-2009, 02:39 PM#7
moyack
Quote:
Originally Posted by Gwypaas
The problem is that I want to control the exact position that it lands on.
To know the exact position, you need to know the starting speed and the angle, so, we need to have one of then constant and in this way you can define as parameter the final distance.

Quote:
If the jump starts at 400 height and ends at 50 height then the Jump should be perfectly angleded for that but I have no idea how to do that. I dont want to have a sudden decrease of height in the end to restore the values to normal.
BTW, this is a total misconception, parabolic movement never gets angled.
06-28-2009, 03:25 PM#8
Zerzax
Here is how you might use the method I mentioned. Because you are moving in three dimensions and the two equations I gave you only apply to two, you have to treat the x/y axis as the x axis in your calculations. Also, these two equations are making use of vectors, because an angled initial velocity is being resolved into an x axis vector and a y axis vector by multiplying the magnitude of the velocity times the sin/cos (direction) of the angle.

I've seen Anitarf often explain how to incorporate this type of equation into JASS. Treat g as 1000 Warcraft Units per second squared (constant acceleration due to gravity). To save function calls (not totally necessary, since the trig functions are said to be quite fast), you could store the sine and cosine of your angle of projection as variables or struct members. The angle is up to you, you can find what a resulting parabola looks like by drawing out different angles. Initial height is simple enough - at what point on the z-axis are you starting? Now comes initial velocity of the x/y and z axes combined. Lets say 500 Warcraft units per second (this is also arbitrary, you might need to test this out to find the best speed for you). Now some simple algebra to find out the base interval you will use for t.

Let's say that the total distance of the parabola is 650 units (along the x/y axes).
If theta = 45 degrees (pi/4 rad), since the velocity is 500units/sec, the x/y velocity would be:

500cos45 = 250 times the square root of 2.

650 units / 250Sqrt(2) units/sec = 1.84 seconds to cross the parabola.

If your timer interval is 0.04 seconds, it would take 46 (1.84 / 0.04) intervals to cross the parabola. 1/46 = 0.021 seconds = your t parameter, which is incremented by the same value at each interval. Your parabola is done when t = 1 or when t is greater than 1 (since the total time divided by the timer interval will probably not be an integer and you will have to round up or down). You could also check if your accumulated distance is greater than or equal to the total distance.

Remember that you might just want to parametrize the line between the starting coordinates and ending coordinates so you don't have to do any silly polar projections.
In which case,
x(t) = X1 + (X2-X1)*t
y(t) = Y1 + (Y2-Y1)*t

Therefore,
x,y(t) = 250Sqrt2(2)*t (the old, clunky way, putting it up here anyway)
z(t) = -1/2*(1000)*t*t + 500sin(45)*t + Ho

Make sense?
06-29-2009, 12:34 AM#9
Anitarf
Try this.

Maybe I should make a tutorial out of this...
06-29-2009, 02:34 AM#10
moyack
Gwypass: Check this: http://www.wc3c.net/showpost.php?p=1091485&postcount=32