How to change Tag by script?

How to change Tag by scripting?

I want if enemy dead, I want to change its tag from [enemy] to another or untagged. Thus become no more enemy.

Can I do this?

2 Likes

As long as the Tag exists, you can access and set it with:

transform.gameObject.tag = “SomeTagName”;

17 Likes

Does it have to have the transform infront of the GameObject ?

Or can it be gameObject.tag = “SomeTagName”; ? :smile:

7 Likes

Either way is fine.

3 Likes

Thank you!!!

4 Likes
  • Brand new account, first reply
  • Reply that adds nothing to the conversation
  • The last comment in this thread is ELEVEN YEARS OLD

This one goes in the necroposting hall of fame

6 Likes

It’s probably a bot.

3 Likes