use the tag of a gameobject to assign a string variable
Hey i have a empty string variable. I want to access the tag name of a gameobject and assign it to my string variable.
public string shiptag;
currently its empty, but i try this way to access the gameobject tag and assign it.
shipTag = aquiredShip.gameObject.tag;
but it doesnt seem to work. Looking in the inspector, the string is still empty.
aquiredShip is the Gameobject i want to access and use its tag.
Comment
Answer by jgodfrey · Apr 28, 2016 at 08:44 PM
If acquiredShip is a gameObject, then you'd want:
shipTag = acquiredShip.tag;
Your answer
Follow this Question
Related Questions
how to find gameobject using a varable 1 Answer
Variable not assigned but is. 0 Answers
UnassignedReferenceException: The variable enemy of EnemiesSpawner has not been assigned 0 Answers
[Help] Getting variable based on string value. 2 Answers
How to assign slider to float: Spin, on a gameobject 1 Answer