Jump to content
Sign in to follow this  
CN-bbdnmd

track a moving enemy

Recommended Posts

How to enable a unit to track a moving enemy unit without stopping

Share this post


Link to post
Share on other sites

Do you mean track like in following at a distance (without getting too close) or just trying to catch up with the tracked unit?

 

Trying to catch a unit would be fairly simple, you set the tracking unit to move to the position of the tracked unit and loop it every few seconds.

 

//Set _trackerUnit and _targetUnit to the tracker and the tracked

while { alive _trackerUnit && alive _targetUnit } do {
  _trackerUnit doMove getPos _targetUnit;
  sleep 5;
}

Remaining at a distance (without stopping) is a bit trickier, but the basics are the same. You just also need to check the distance to the target in the loop and setting the speed mode (and perhaps the behaviour) of the tracker depending on the distance to the target. If the target is very far away, set the tracker to full speed, then reduce it as the distance gets shorter and stop it completely if it gets too close.

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×