• 🏆 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!

Future Point

Status
Not open for further replies.
Level 5
Joined
Jun 12, 2016
Messages
74
I'm making an AI to one of my bosses, one of it's skill is a sniping skill. Idk how to program the physics behind this, but I want this: The boss will shot a projectile that must intercept the target on it's future position (point). It sounds easy enougth but that is bugging my head since yesterday.

I did calculate the target's velocity by taking the diference of it's position on a time span of 0,1s, with that I have everything with it, it's angle, it's speed and it's direction and I have the speed of the projectile as a constant 1000 but I need to know the angle that my boss should shot it.

Please, realy need a help with this.
 
Level 12
Joined
Jun 12, 2010
Messages
413
I'm making an AI to one of my bosses, one of it's skill is a sniping skill. Idk how to program the physics behind this, but I want this: The boss will shot a projectile that must intercept the target on it's future position (point). It sounds easy enougth but that is bugging my head since yesterday.

I did calculate the target's velocity by taking the diference of it's position on a time span of 0,1s, with that I have everything with it, it's angle, it's speed and it's direction and I have the speed of the projectile as a constant 1000 but I need to know the angle that my boss should shot it.

Please, realy need a help with this.


Let's try to represent this problem:

With t as the moment the collision occurs (0 is moment of launch), vX as the x component of the unit's velocity, vY as the y component of the unit's velocity, a as the angle the boss must launch the missile from, u as the speed of the missile, (x,y) as the coordinates of the unit, (x',y') as the coordinates of the boss,

t > 0
vX, vY are known
a is unkown
u is 1000

We have:

uX = u*cos(a)
uY = u*sin(a)

Both objects most collide, so:

x + vX*t = x' + uX*t
y + vY*t = y' + uY*t

x - x' + vX*t = u*cos(a)*t
(x - x' + vX*t) / u*t = cos(a)

And:
(y - y' + vY*t) / u*t = sin(a)

Finally:

a = arctan( sin(a) / cos(a) )
a = arctan( (y - y' + vY*t) / (x - x' + vX*t) )



So we need to know t to know a, and we need to know a to know t. This problem might be a little hard to solve in JASS.

You could calculate the result for a few values of t and use the closest approximation.
 
Last edited:
Status
Not open for further replies.
Top