Using tags to identify objects

Hi,

instead of creating a ‘Gravestone’ class like Rick did, Gravestone defenders could be assigned a tag and the Fox class could identify it to make the fox jump.

Is this a accepted/good method to differentiate game objects in real games? And if so, is there anything I should be aware of when utilizing tags for this purpose?

Thanks!
Luis.

1 Like

Hi Luis,

In many cases, there are multiple ways to make something work in Unity, and Rick cannot show all of them. If your code works, it’s a solution by definition. :slight_smile:


See also:

1 Like

As Nina said, there’s nothing wrong with your solution, just want to add something.

There’s indeed something you should be aware of when using tags, especially when working with a team. A lot of coders don’t like tags because they are strings, and strings are bad because even the tiniest mistake can result in an error, they are also very hard to change, if you do, you’ll have to go through all the times you use it in your code increasing the chances for errors.

In small projects is not a big deal, but as things get more complex it becomes a larger issue. So, keep that in mind.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms