Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Im making an AI that checks if the player exists or not. How do I check if a certain object exists and put it in a boolean variable?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

try using GameObject.FindGameObjectsWithTag or GameObject.FindWithTag or by name (or namepath) GameObject.Find

bool playerexists = (GameObject.Find("player") != null)
share|improve this answer
    
But is there a way to not use a tag? That would be better. –  ElPolloLoco999 Aug 21 at 10:28
    
edited: added find (no tag) –  dnk drone.vs.drones Aug 21 at 10:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.