Map Unity Tags to Astar Tags?

Hello,

I would like to set the GraphUpdateObject tag to the value of a new object’s tag.

guo.setTag = newObj.tag;

However, setTag expects an int, whereas gameobject.tag returns a string. Is there a clean way to map the two?

Hi

There is no out of the box way to do this as they are fundamentally different tags.
However one relatively simple option is to copy the relevant tag names to the A* Inspector -> Settings -> Tags list and then do something like this:

guo.setTag = Mathf.Max(0, System.Array.IndexOf(this.GetTagNames(), newObj.tag));

This will set the tag to the A* tag with the same name as the Unity tag if one can be found and otherwise it will set it to tag zero.

1 Like