Adding target image above random gameobject (enemy)
In my script I try to target a random enemy in the level (which I did) and then adding a target image above that specific enemy's head. I can't seem to get the last part working.
So: how do I add a target image above the randomly selected enemy in the level?
I have the following code so far
GameObject target;
GameObject targetImage = GameObject.FindWithTag("Target");
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Target();
}
void Target()
{
if(target==null)
{
GameObject[] PossibleTargets = GameObject.FindGameObjectsWithTag("Enemy");
target = PossibleTargets[Random.Range(0, PossibleTargets.Length)];
Debug.Log(target);
}
}
Comment
Your answer
Follow this Question
Related Questions
Survival Shooter Error CS0120 1 Answer
How to make a 2D array of buttons? 2 Answers
ios app crashes on start 0 Answers
The referenced script on the behaviour is missing error help plz 2 Answers
Issues w/ Creating a target system 2 Answers