- Home /
Unable to change gameObject tags from within function?
For whatever reason, I'm unable to change a tag from within a function. The function is a public void, and the gameObject I'm changing is itself. The strange part is that I was able to change the gameObject's tag when I put the code in the Start() function, but it failed to work anywhere else. Please help. I'm not certain whether it's relevant information, but the gameObject is a prefab variant.
Code that doesn't work :
public void ProcessAction(string action)
{
if (action == "hit")
{
gameObject.tag = "Untagged";
}
}
how do you determine that it did not work? Also does the tag "Untagged" exist? You can afaik only assign tags that actually are defined in your projects tags.
Apart from that this will afaik not change a prefab, only instances of prefabs in your scene. Please clarify the point about the "it is a prefab variant". What exactly do you mean with that?
Your answer
Follow this Question
Related Questions
How can i destroy spawned objects according a indicator? 2 Answers
I want to turn on Sprite Renderer for ALL of a specific prefab if it has right Tag 0 Answers
Is there a way to get the actual joystick.Vertical and joystick.Horizontal Value?, 0 Answers
Camera not following a GameObject with Tag after spawned in the scene? 1 Answer
Are tag settings passed down from Game Object parent to mesh child? 1 Answer