Discussion Non-homing but unit targeting projectiles

Furby

Current occupation: News poster
Reaction score
144
I was always wondering how Blizzard made wc3 missiles, I just mean those non-homing ones. They are really not homing to target, but they hit it even if it's moving. How's that possible?

Missiles guesses the position of target. This is what I lack in projectile systems. I recently downloaded and implemented Kenny's projectile system to my map, applied to units and then when I tested map, everything worked just perfectly except the arrow from archers looked really unrealistic, homing arrow.. that is unnatural.

So, I decided to make some formula to calculate the position of target when attacking it with ranged unit with non-homing missiles.

Here's some more exaplanation:

25s22bo.png


First is normal non-homing missile, as you can see if the target is moving the missile will miss the target.

Second is with base formula to calculate target's position after time in which the missile will travel to the point.
This way is little inaccurate, because the missile needs more time to get to target or less depends which angle is the target faced, in the example the missile would hit the dark-blue point position, but target would be already in teal point position.

Here's fix for this, we use the previous calculation to get the exact position.

Problem is that attacker will always miss the target when unit is turning around, I'm looking for the most efficient fix for this.

Any help, comments, constructive criticism or ideas appreciated. :thup:

Check out the demo map.
 

Attachments

  • projectieTest.w3x
    86.5 KB · Views: 212

Weep

Godspeed to the sound of the pounding
Reaction score
401
In first-person shooters, this is known as leading one's shots. ;)

Problem is that attacker will always miss the target when unit is turning around, I'm looking for the most efficient fix for this.
Units may not be moving in the direction they are facing (eg. take a Lich and rapidly order it to move in a circle.) In fact, the mysterious "Propulsion Window Angle" unit data field controls how far away from straight forward a unit may move.

A unit may also not be moving at its movement speed due to sliding triggers (and detecting whether it is moving at all is another problem - it may have null orderstring yet be moving to intercept a nearby enemy.)

Most efficient solution? Look for an is-unit-moving system, if one exists - otherwise, you'd need to write one, periodically checking each unit's position and comparing it to the position from the previous check. You could even save two or more previous positions so you can calculate acceleration, in an attempt to account for a unit that's moving on a curved path...
 

Furby

Current occupation: News poster
Reaction score
144
I already have this IsUnitMoving system, that is implemented and it works good. Problem is that when unit goes in one direction and suddenly it turns around 180° and goes back.. and when a missile is launched just when it's turning around.. then the missile will be shot far in front of unit.. totally missing the target..
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Calculate the angle from missle to target before calling SetUnitX/Y.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
where is this IsUnitMoving system? i was looking for a similar thing (not for projectiles though)
 

cleeezzz

The Undead Ranger.
Reaction score
268
then again, what if they use Hold position after you fire your arrow? then it will look wrong. unless you check the units movement using the periodic user event on Projectile, and adjust your projectile accordingly.. but then again, wouldn't that look like homing? :D
 

Viikuna

No Marlo no game.
Reaction score
265
Wait, you want somekind of targetting AI?

Some system which can guess where unit might move and shoot projectile there?
 

13lade619

is now a game developer :)
Reaction score
400
yeah.. some movement prediction i think.

but the first one is good enough for most of us.
just shoot and aim at where the target currently is.
the targets run because they dont want to get hit..., making movement prediction seems to break the 'non-homing'..
 

Viikuna

No Marlo no game.
Reaction score
265
It should be a little random, so you cant predict it.

Humans can try to guess where target is gonna move, because they can take in account all the other stuff happening in the area, but in this case, you just can make your sytem to use all the needed data, so it should just randomly pick one of the possible spots that unit might move to.

If you dont want homing, this is really the best you can do.
 

Furby

Current occupation: News poster
Reaction score
144
then again, what if they use Hold position after you fire your arrow? then it will look wrong. unless you check the units movement using the periodic user event on Projectile, and adjust your projectile accordingly.. but then again, wouldn't that look like homing? :D

That's dodge. That's how you would dodge in real life. This is what I want to achieve. Because with homing missiles every damn arrow will always hit ya.

Here's demo map I made.

Dryad uses normal wc3 missiles, archer uses triggered ones.

Calculate the angle from missle to target before calling SetUnitX/Y.

Eh.. wtf? I ain't setting any X and Y.. this is about guessing target's position after time.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
I already have this IsUnitMoving system, that is implemented and it works good. Problem is that when unit goes in one direction and suddenly it turns around 180° and goes back.. and when a missile is launched just when it's turning around.. then the missile will be shot far in front of unit.. totally missing the target..
So if I took you right, you basicly just need a system which can detect a unit's movement vector without just getting GetUnitFacing()? I think that would be almost impossible, as you can never know the real unit's move speed (I think GetUnitMoveSpeed only returns the object data constant and doesn't take slow effects into account) nor the movement direction.

The only thing you can do is a short duration timer that is saving the old position of a unit, compares it to the actual one and thus calculates the movement vector. It would still be just an approximation, but it comes the closest to what you are trying to achieve.

However, this would take a very small delay in the calculation, so you might add a small firing delay to you missile. (I think 0.05 seconds would be enough to get a good approximation on the movement vector)
 

Furby

Current occupation: News poster
Reaction score
144
Well, this doesn't have to be that exact.. you just imagine you on place of that archer, how you'd shoot.

Though, I'm still wondering how Blizzard their missiles. :rolleyes:

Is there a possible way to find it somewhere, though I doubt it's that easy to find something like that in a game.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
you could periodically check the displacement of all units (or maybe only units which have been attacked recently?) and approximate their average velocity from that
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
you could periodically check the displacement of all units (or maybe only units which have been attacked recently?) and approximate their average velocity from that
There no need to do it periodically. It's enough to do it once per missile firing. You do not need to know the correct movement vector at once (as the initial tick only spawns the missile). It's perfectly fine if you got it on the second tick - and this is possible with just comparing the displacement between the initial and the second tick.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top