# Following dynamically changing path

This topic is 3937 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello everyone, I'm working on a project of mine (RTS) and have stumbled upon a problem. What I need to do for the computer, when seeing a group of enemies, is to circle around them on the distance of it's gun range and attack. At the moment, I am able to calculate actual enemy groups (distance sorting via graphing) and get nearest group for computer to attack. However, when approaching such group, I can't make the computer either follow the specified path around enemies group. The path is constructed as a simple convex hull expansion on the weapon range - it's called polygon offsetting. The thing is that player' objects may move, thus requiring calculation of primary/secondary hulls almost per-frame basis, thus I need to re-create hulls each time and cannot have "next" pointers for computer to go to after reaching specified distance to point on secondary, expanded hull. So, my question is as follows: what is the best way to go here? Use forces, ala http://www.red3d.com/cwr/steer/PathFollow.html, or somehow acquire next counter-/clockwise point on secondary hull and go towards it? Please give examples if you can. Thank you.

##### Share on other sites
What I gather is that you're basically constructing a set of waypoints for your attacking unit to follow. And, as the victim group moves, those waypoints become invalid. So what I would do is only calculate one waypoint in advance, and I would keep updating this waypoint to a valid location (by making the waypoint move the same way the victim unit group is moving, or something). Once the attacker reaches that waypoint, construct the next one and do the same thing.

If it's not possible for your current waypoint to remain valid, then I'd tell the attacker to attempt to circle in the opposite direction, if possible.

This method should ensure the attacking unit is always attempting to move to a valid waypoint.

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 12
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632954
• Total Posts
3009444
• ### Who's Online (See full list)

There are no registered users currently online

×