- Home /
How would I do this? Please help me
Hello I am making a script that does the fallowing:
finds all game objects with the tag enemy
puts them in a array of objects
draws a line to the objects
destroys the objects if they get more then 10 feet away from the main object
If someone could help me with this, You are awesome :D
Answer by Sequence · Aug 25, 2012 at 07:00 AM
To find objects with the tag "enemy"
GameObject.FindGameObjectsWithTag("enemy");
To get the array of those objects, just make it equal a new array.(Since that function returns an array)
var newArray : GameObject[] = GameObject.FindGameObjectsWithTag("enemy");
As for the lines, I think Unity includes line renderers. Try looking into those.
As for checking distance, give this function two positions, and it returns distance.
Vector3.Distance(player.transform.position, enemy.transform.position);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Changing or replace objects 2 Answers
Can somebody help me out with a jumpscare? (Like from the game "Slender") 1 Answer
Line Renderer Collision Detection. 2 Answers
OnTriggerEnter firing late? 1 Answer