- Home /
How can I draw indicators from my ship to off-screen enemies?
I want to have some indicator near the player's ship that points to enemies that are off the screen. How do I find the position of all enemy objects in the scene and then draw an indicator (at some small radius from the ship) in each of those directions? I do know how to use renderer.isVisible.
Thanks in advance. :)
get Vectrosity,
or grab this amazing little package
http://gameassets.net/demo/dynamiccircles.html
from the asset store,
or use Unity's "LineRenderer" (search on here for 100s questions about LineRenderer)
to find the position of enemy objects use ".position"
Thanks, Fattie and whydoidoit. LineRenderer will do the trick and those assets looks great.
FindWithTag returns one object, if I read the description correctly. Is there a systematic way of cycling through all enemies each frame? Do I need to come up with a tricky way of alternating their tag each frame to make sure I get to all of them? If it returned a list of all objects with a tag, that would be useful.
You can use FindGameObjectsWithTag to get all game objects with the tag. And cycling through all enemies each frame is not good. Hold a list of references to those enemies and modify the references when a new enemy born or die might be better(or any other solutions, but try to avoid doing duplicated things for every frame)
Your answer
![](https://koobas.hobune.stream/wayback/20220613082548im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Local Direction of Vector3 1 Answer
How to calculate direction between 2 objects 2 Answers
2d fire from player towards mouse 1 Answer
Quaternion multiplication 1 Answer
Adding force to an object based on its current angle. (2D) 1 Answer