- Home /
RTS Style Unit: How to surround enemy when attacking
Im making an RTS game and have units that will attack each other when I give my unit the command to attack. If my unit cannot see the enemy unit I want it to go closer to the enemy. Heres my problem: I want my unit to go closer to the gameobject -which right now it does- but I want each unit I send to attack the enemy to "circle" the enemy so that it has a clear line of sight to the enemy and no other friendly units are in the way blocking its sight. Im not sure what would be the best way of doing this. Ive already researched how to create a circle of gameobjects as points to move to around the enemy gameobject then I was thinking about moving the units to the closest point?
Recap: Each new friendly unit to attack the enemy gameobject should move next to another friendly unit that is already attacking the enemy gameobject creating a "semicircle" depending on how many units there are
What would be the best way of doing this? Please comment if you don't understand!! Thank you.
Answer by Mr_Teels · Jul 20, 2018 at 07:13 AM
Use the NavMesh and every Unit (Friendly and Enemy) is a Obstacle https://docs.unity3d.com/Manual/class-NavMeshObstacle.html
Your answer
Follow this Question
Related Questions
Getting a navmeshagent back on a navmesh. 1 Answer
Update Graph after GameObject destruction 1 Answer
Disable NavMeshAgent sticking to NavMesh 0 Answers
Modify NavMeshPath for Tactical FPS (slicing the pie/sweeping maneuver) 0 Answers
NavMeshAgent Move towardes the final point in the path directly 0 Answers