Quantcast
Channel: Questions in topic: "tagging"
Viewing all articles
Browse latest Browse all 120

What is the problem with this script?

$
0
0
Hey, I was making this script for some time and I wanted it to work that way: I have two tags and two objects; If I click on object one it will change it's tag to tagOne; If I click on the other object it will change it's tag to tagOne + the other object that is tagged with tagOne will change it's tag to the original tag, but what I get is when I change both their tags to tagOne(which happens for some reason) both of their tags are unchangeable. Here is the script: using UnityEngine; using System.Collections; public class Main : MonoBehaviour { void OnMouseDown() { GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Respawn"); foreach (GameObject go in gameObjects) { if (go != this.gameObject) { gameObject.tag = "Player"; } } if (gameObject.tag == "Player") { gameObject.tag = "Respawn"; } else if (gameObject.tag == "Respawn") { gameObject.tag = "Player"; } } }

Viewing all articles
Browse latest Browse all 120

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>