Quantcast
Channel: Answers for "Find Game Objects With Tag"
Viewing all articles
Browse latest Browse all 4

Answer by SuperMasterBlasterLaser

$
0
0
I think you should add boolean in your GhostScript: private bool chasingPlayer; void Start() { chasingPlayer = true; // Here will be other things for start } void Update() { if (chasingPlayer) { // chasing player algorithm } else { // going back to base } } public void goBack() { chasingPlayer = false; } After that in your PlayerScript you will write this: function OnTriggerEnter(ghost:Collider){ if(ghost.gameObject.tag=="Ghosts"){ lives--; monsters=GameObject.FindGameObjectsWithTag("Ghosts"); for(var monster in monsters){ GhostScript script = monster.GetComponent(); script.goBack(); } transform.position=Vector3(0,1,-16); } } That how I do.

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images