I’m trying to use this.Tag as a variable and I can’t seem to get it working.
Here is a sample of my code.
function Update(){
var myTag : GameObject;
myTag = this.Tag;
print("My tag is" +myTag);
}
I would expect that it would create a variable called “myTag” and then it would assign what ever the objects current tag is to “myTag” and would then print out on the console, "My tag is ‘the objects own tag’ ". If I can print it, I can then use the variable elsewhere and in other ways, correct?
When I run the script, the console spits out:
“”“”“”“”“”“”“”“”“”“”
My tag is
UnityEngine.MonoBehaviour:print(Object)
OnTriggerVersionTwo:Update() (at Assets/Standard Assets/Scripts/General Scripts/OnTriggerVersionTwo.js:7)
“”“”“”“”“”“”“”“”“”“”"
I’m a novice so I might be doing something extremely obvious. Any help would be greatly appreciated.