• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Math Formula :/

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Ok, I am currently making a spell that uses missiles and i need a formula to make the missile turn in a specefic way.

I cannot explain alot more if i dont show a pic.

The Red dot is the target, the Blue dot is the caster, the Yellow dot is the missile and the Black line is the trail of the missile.

NOTE: All this is not moving in the air, it is turning(moving) on the ground.
attachment.php

What i want the formula to do is that you get some variables to work with
  1. constant real Speed ( How fast the missile moves )
  2. constant real Interval ( Interval for when the missile is moved )
  3. Arch ( It is how great the arch will be, This will be defined on the launch. Missiles go off from different angles then with different arches )
  4. Distance ( The distance from the missile to the target. This will be updated every interval )
  5. Angle ( The angle from the missile to the target " in radians ", and This will be updated every interval )

The missiles moves with "Speed" every "Interval". So i need a formula to 'parabolic' move the missile on ground from the caster to the target


Regards, Dynasti
 

Attachments

  • Example.png
    Example.png
    26.4 KB · Views: 464
Level 20
Joined
Apr 22, 2007
Messages
1,960
Speed, Angle, Arc and Distance conflict. Either you use Speed and Distance and Angle, Speed and Distance and Arc, Speed and Angle, Speed and Arc, Angle and Distance or Arc and Distance. I'd reccomend Speed and Distance, Time and Distance or Speed and Arc.
 
Level 18
Joined
Oct 18, 2007
Messages
930
Speed, Angle, Arc and Distance conflict. Either you use Speed and Distance and Angle, Speed and Distance and Arc, Speed and Angle, Speed and Arc, Angle and Distance or Arc and Distance. I'd reccomend Speed and Distance, Time and Distance or Speed and Arc.

huh? What you mean?

And btw, i want it to act the same all the time. If the distance is different the result could get messed up.
 
Level 6
Joined
Sep 5, 2007
Messages
264
I have seen this done before... I remember it, because it reminded me of the Magic Missile spell in Neverwinter Nights.

I know that I have it on my PC... somewhere...
I was just checking the forum before going to bed :slp:, so I'll post it in about 9-12 hours (depends on when I wake up, and how long it takes to find it). That is, of course, if you don't have a solution by then.

Well, good luck :thumbs_up:
 
Level 7
Joined
Jul 20, 2008
Messages
377
Actually, using a parabola formula will not work for something like this. Dynasti, I'm assuming you're moving the projectiles periodically. You will want local values for each projectile for:

  • Current angle of projectile's motion (think projectile's facing)
  • Speed
  • Turn rate (the rate at which its current angle approaches the angle from the missile to the target)
  • Its target

Note that these are really the only 3 things you need to know for each projectile (although arguably, turn rate could be treated as a global constant). The arc generated by the missile path will be a function of turn rate, speed, and initial angle. The faster it moves and slower it turns, the wider the arc. The slower it moves and faster it turns, the narrower the arc (and ergo better homing). Of course, if you do NOT want the missile to "circle" around a target, you could accelerate its turn rate over time.

Did that make sense?

The reason I said a parabola formula will not work is because the target is assumed to be moving. If you used a parabola, it would be a pain to have to calculate that constantly to ensure your parabola's path is correct. That's just a headache. Rather, the parabola should be a result of the missile's turn rate, speed, and initial angle.
 
Level 18
Joined
Oct 18, 2007
Messages
930
Actually, using a parabola formula will not work for something like this. Dynasti, I'm assuming you're moving the projectiles periodically. You will want local values for each projectile for:

  • Current angle of projectile's motion (think projectile's facing)
  • Speed
  • Turn rate (the rate at which its current angle approaches the angle from the missile to the target)
  • Its target

Note that these are really the only 3 things you need to know for each projectile (although arguably, turn rate could be treated as a global constant). The arc generated by the missile path will be a function of turn rate, speed, and initial angle. The faster it moves and slower it turns, the wider the arc. The slower it moves and faster it turns, the narrower the arc (and ergo better homing). Of course, if you do NOT want the missile to "circle" around a target, you could accelerate its turn rate over time.

Did that make sense?

The reason I said a parabola formula will not work is because the target is assumed to be moving. If you used a parabola, it would be a pain to have to calculate that constantly to ensure your parabola's path is correct. That's just a headache. Rather, the parabola should be a result of the missile's turn rate, speed, and initial angle.

What you tell would work but it will not give the same result on long and short range.
 
Level 7
Joined
Jul 20, 2008
Messages
377
Just toy around with how you do turn rate and speed, you'll get something you'd like. For example, the closer the projectile was initially to the target could determine its turn rate, or the turn rate could get faster the closer the projectile gets to the target, etc. Just do some trial and error tests with this system.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Oh wait. Nevermind I just understood that it's not a projectile. Okay lemme see how this works out then. :p

I guess you could define some sort of abstract axis along a line that connects the caster to the target, and then use kinematics equations to work it out? Would be kind of complicated considering your axis will be tilted. I'll work it out on paper and post again if I find something.

EDIT: OR, you could use 3d kinematics and project the position of the projectile onto the ground. I'll try this first.
 
Level 12
Joined
Mar 16, 2006
Messages
992
I wish I knew more JASS so I could be more helpful, but this is what I would probably do.:

I would write a script that moved the missile unit towards its current facing angle, adjusting the facing angle every X intervals, starting at certain angles slowly turning by a percentage(based on the difference of current facing and angle from A to B) towards the target. Because of the percentage, you would be able to somewhat randomize the starting angle of the missiles as well as control the turning speed completely. I would probably use a method that took a halfway point((distance from A to B)*.6), and check when the missile is that far from the unit, to update the curve more or less so that it starts with a curve and straightens out, or the opposite. To find out the angle that you'd need to turn, you could just compare the current facing angle and the slope/angle from A to B. Since you'd be checking every halfway point until it reached its target, you could compensate for a moving target much easier, and the visual would look much more transitional.

Not to mention you'd have all the variables that you could use/adjust. Starting angle, angle of approach, adjusting angle of approach(at each halfway), constant speed(how many times/second it updates), speed adjustment(at each halfway), adjustment of scale of unit missile(my favorite), as well as how many random angle starting missiles to create, as well as two starting angle constants which the random chooses a number between(so they don't fly out of your back, unless you allow it).

I'm not sure how understandable what I wrote is, but if you end up getting it working and my suggestions helped you, I would appreciate it if you sent me a copy of the trigger so I could check out how you ended up achieving the effect. I am quite curious and I am fairly positive what I've envisioned in my head would work.
 
Level 18
Joined
Oct 18, 2007
Messages
930
Ok i maybe got a simpler solution but it still requires a formula.

If we have an angle that is the launching angle from the caster( It is stored ). And another Calculated value that is the angle decrease each interval.

So.. now i need some kind of formula that would make the angle decrease be a low value for long distances and a high value for short distances.
 
Level 12
Joined
Mar 16, 2006
Messages
992
Except the angle decrement can't be a constant because that would make a circular trajectory, not a parabolic one.

You could either use an equation for that, or manually set the points where it starts curving more/less. Personally, I'm all for manually setting everything so that you can fully control and design the spell to act how you want it to. There's almost always a way to simplify a difficult task, and in this case, there most definitely is one.

Plus, it's less difficult for those who aren't actively studying/using math equations.
 
Level 6
Joined
Sep 5, 2007
Messages
264
Like I said above, "it could still help"...
The arcing of the missiles is still there, you could use the formulas in that map as a good starting point. Then you'd just have to stick 'em to the ground.

Or do you mean: "You want missiles that travel in a homing arc at the target, if target is higher, then the missiles won't stick to the ground, they'll impact with terrain"

Either way, the formulas in that map, MAY be able to assist you... :thumbs_up:
 
Level 4
Joined
Dec 10, 2005
Messages
73
I have a lazy approach to this.

The middle missile will just head straight for the target. The other two will have a perpendicular displacement dependant on the distance from the target. The point where the missle is order to go will be a point offset from the target. You can use this formula, x=sqrt(y), where y is the distance from the target, to find this offset.The missle coming from the caster would look like it diverging, sort of in a straight line ( depending on update rate, see below), so no need to do anything there.

Only problem I can see is updating of location points. If you don't generate fast enough the missle might just sit there for a short duration.

To fix this you would need to make the missle keep moving forward heading towards the point. Calulating the angle between it's current position to the generated one.But then you can get funny trajectories again depending on update rate.

Hope this helps.
 
Status
Not open for further replies.
Top