How can i add multiple tags from script?
I used @Xarbrough 's CustomTags script from his answer on this question: https://answers.unity.com/questions/1470694/multiple-tags-for-one-gameobject.html
But somehow i can't comment there, because it seems like there is bug in that thread so i wanted to know how can i add a tag to any instance CustomTags List through script.
I have a character that shoots objects with a raycast, and upon contact i want it to tag the hit targets with "Hit" so i can group them for later use
Answer by Xarbrough · Oct 11, 2020 at 06:40 PM
Well, not being able to comment or reply on the other thread seems weird, but anyway: To add tags via script at runtime, you would simply need to extend the script and add a public method that adds into the list of tags.
public void AddTag(string tag)
{
if (HasTag(tag) == false)
tags.Add(tag);
}
Your answer
Follow this Question
Related Questions
tagged objects problem 0 Answers
Having problem with scoring system., 0 Answers
Unity2D raycast to check for a wall, Issues. 0 Answers
Tag Editor is all grayed out 0 Answers
How to change another object's Tag 1 Answer