- Home /
Is there a way to use a WireSphere instead of a trigger collider to get targets.
I was watching tutorials on Tower Defense games, and I was wondering if I could use a Gizmo.DrawWireSphere for a Turret, where whenever an enemy walks into the circumference, the enemy becomes a target.
To make it more interesting, I wanted the array to be only up to 3 targets, so an index of 2. If there is only one enemy in the circumference, it will only fire at the one target, but if more than one, it will also fire at them simultaneously. Once the enemy is out of the circumference, the target becomes null, and will get the next enemy, if one ever enters. Per my question: is it possible to do this only using a WireSphere?
I struggle to come up with the logic. could anyone assist me? thanks in advance!
Answer by logicandchaos · Jan 17, 2020 at 05:12 PM
You don't need any colliders to do that, you can use Vector3.Distance, you could do that with a sphere trigger as well, it's all in the coding, using Vector3.Distance you would need to check all the enemies, probably need a list of them, so using a trigger might be easiest way. Here is some pseudo code: https://pastebin.com/swE6MbRc
Your answer
Follow this Question
Related Questions
Tower Defense turret with multiple targets within range. Help with targeting and nulling. 1 Answer
How to create a view angle where the turret can see the enemy and start shooting 1 Answer
How to determine a "cone of influence" used for targeting an object. 2 Answers
Combat Script 2 Answers
How to save position of camera 1 Answer