- Home /
gameObject.tag == "Respawn"; won't do anything...
This was supposed to be easy but it's giving me a headache:
I have a simple untagged cube made by Unity.
I attach to it the following script:
function Awake (){
gameObject.tag == "Respawn";
}
Respawn is in the tags list (by default).
When I hit "play", shouldn't I see the cube's tag field in the Inspector change the display from "Untagged" to "Respawn"?
No change happens. The tag field continues to show "Untagged". What am I missing here?
Answer by Mike 3 · Jan 03, 2011 at 12:46 PM
It should be:
gameObject.tag = "Respawn";
== should really be throwing a warning at you
I must be blind! Of course! because == is for comparing values. Thanks $$anonymous$$ike! (been working for too many hours today...). That's strange though - I didn't get a warning...
Your answer
Follow this Question
Related Questions
Changing tag via scripting.... 1 Answer
Creating enum using a string array 3 Answers
Tiny tag changing and checking problem 2 Answers