Hello, I’m creating a tower defense game, and I’m struggling with detection system.
First of all I have to clarify something: the game I’m creating doesn’t have just some path for enemies that they follow up to the end, the enemies can attack towers or players, i.e. abandon their path if something has attracted their attention. This brings us from “just fire the closest to the end, but in fire range, enemy”, to something more complicated.
I tried to implement this system using UAISense_Sight, and at first glance it worked perfectly - tower could easily spot an enemy and attack it, but by adding a few more towers in same place they started covering each others vision, so that the ones behind won’t be able to see the enemies in front of it, and like that they just stay AFK. What I want is that a tower can see through other towers, players and other friendly entities.
By the way I also have different collision channels for allies and enemies, so towers and players are in the former layer, while the enemies are in the latter one.
To clarify what exactly I want to scan:
The circle at the bottom is the tower, while the triangle is the tower vision. The picture represent both XY and XZ axis views. The triangle angle nearby the tower and the distance from it may vary depending on parameters. At the end the area that I mean is just a piece of a circle, just as a camera viewport.
Everything that comes to my mind seems odd, I thought about storing every enemy in some container that is accessible for towers, and that they can look for all enemies that are in range, and then check whether LineTraceSingleByChannel using enemy collision channel returns true or not, but it seems non-performant at all.
So how can look for enemies that are in a unique collision layer in a certain area of that shape?
Thanks for reading.