• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Parabola Movement

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

I'm a bit ashamed to ask, but i'd like to know how to make a missile(dummy move as a parabola considering different heights. I just know how to do it in straight line :(

I've seen the formulas around and else, but I don't really get the hang about how to move the unit with those values.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Curved motion is really just velocity that changes over time.

"Ground" velocity remains constant; the distance the dummy is moved every iteration.

When the dummy begins flying, you start by setting an initial "height" velocity, which is the amount by which the dummy will rise during the next iteration.

In the first iteration, let's have
Flying height = 0
Height velocity = 20

Flying height will increase by height velocity, to 20.
But height velocity also changes! Due to gravity. Let's have gravity at 1.
So at the end of this iteration, we have
height = 20
velocity = 19

Next iteration:
height = 20 + 19 = 39
velocity = 19 - 1 = 18

and so on.

When velocity reaches 0, it's at the apex of the curve, and exactly halfway.

Some useful reading:
http://library.thinkquest.org/2779/
http://www.physicsclassroom.com/Class/vectors/U3L2e.cfm

The formulas you've seen around are only useful for calculating trajectories; using them in your loop is horribly inefficient.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I read everything, but never solved it. This is beyond my actual capabilities. Fuck Venezuela education system. I left the thing with straight shooting. Thanks everyone.
 
Level 2
Joined
Jun 15, 2013
Messages
10
maybe you understand it if i explain it in a 3 line algorythm:
Integer: V
Integer: X

(in the start trigger)
Set V=10
Set X=0

(in the loop trigger)
Set X=X+V
Set Flying Heigth of (yourunit)=X
Set V=V-2

you can see that the units heigth will develope like this
0->10->18->24->28->30->28->24->18->10->0

sorry for not putting this in trigger tags i'm in a hurry atm
and note that these numbers are just made up to help understand how it works
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I can see that Luckbot, the thing is that, in your example, you have 11 ticks. What if my offset movement doesn't reach the target at the same 11 ticks? What if the target moves?

I managed to have my dummies "jump" towards the target, but the movement was a bit "hardcoded", i mean, i could fix the offset by an specific value, and height by an specific value, but having the target moving around was messing with my values, making the dummy reach the target when it was at the mas height distance (so, it was falling on it's head, rather than reaching it) or was falling to the ground and moving there towards the target if it was too far.
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
IIRC, it is impossible to have a dynamic parabola trajectory that accommodates a moving target. The target has to be a fixed point. Ofc there MAY actually be a way to do that since, well, nothing is impossble. However, a basic imagining indicates that the movement would be very ugly if the target uses a Blink skill. To clarify, the caster is now at the height of X and with a periodic offset of Y. The target moves a long distance -> parabola recalculated somehow -> abnormal change of height and offset.

edit
Actually, there does exist a way. Blizzard created homing, arcing projectiles with it. I take back what I just said.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
imo you could calculate yourself how many ticks it should do depending on distance.
For example 100 range; you want tick every 10 range so you end up with 10 tick (10*10 = 100 range).

Each tick you would have to recalculate the range and from it a new amount of ticks, to get correct distance; then you could simply pick Max value of projectile's current height and it's supposed to be height (to prevent the projectile from going down and then suddenly up).

That won't make a perfect parabole, however I can't really think of a way to make a projectile move on perfect parabole when one of its ends moves.


You can make yourself a test map and create a unit that shoots slow projectiles (with high arc); order that unit to attack another unit and then start moving with that other unit... you will see how the projectile moves.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Since this is a for some kind of net throwing, i could just make the net be lost if it doesn't reaches the target and height reaches 0. Like "You missed", or re-create the item there so the caster has to go and pick it (it's an item)

I can also make it ok a straigth line

I could adjust it by distance % (which would make the net remain flying up and down as the target comes closer and further away).

If i make it timed (like in 2.1 seconds the net will reach the target) then i can calculate the distance, height and everything based on the ticks i'll have, almost by a %. it will make the net move sometimes faster (if the target is far) or slower (if the target is near). Maybe if i think a bit more I could find a formula for time and ticks and height and offset based on distance.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Tiny's Throwing is timed, no matter the distance. I think it takes a second to reach max height and then fall down over the target even if it's moving. That's the only missile with parabola I recall from Dota right now. Parabola is always the same, but Ground speed does change to reach the target.
 
JASS:
function Parabola takes real height, real current, real max returns real
    return 4 * height * current * (max - current) / (max * max)
endfunction
This equation allows you to retrieve a parabola.
Height refers to the highest point of a parabola
Current refers to a value between the 0 and the "max" value
Max refers to the max distance.

The formula currently doesn't take account terrain height.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
About the moving targets, there are two situations:
1. You know the targets moving and you can predict the targets position at the time when the missile lands before you launched your missile. Then you can calculate a parabola which makes sure that your missile will hit the target when it lands.
2. The more general situation: you dont know how the target is moving. Then you still can make the missile hit the target but it wont necessarily result in a parabola. You can for example simulate a rubberband connecting the target and the missile, that way the missile gets dragged to the target.

These two situations require very different calculation of the movement. The first situation only requires you to calculate a parabola with specified heigth, start and target, the second situation requires you to simulate the missiles velocity and acceleration and all forces that influence the missile (this is what all the physics engines do, its way more flexible than simply following a parabola, needs much more calculating). Mathematically speaking: The movement is describe by a differential equation, in the first situation you simply calculate the analytical solution and use it to move the missile, in the second situation you numerically sample from the differential equation itself.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
About the moving targets, there are two situations:
1. You know the targets moving and you can predict the targets position at the time when the missile lands before you launched your missile. Then you can calculate a parabola which makes sure that your missile will hit the target when it lands.

AFAIK OP wants a homing missile, and this solution requires calculus.

But yeah as you say, the ideal solution isn't exactly a parabola.
 
Status
Not open for further replies.
Top