Tags help identify one object from another and can define how one object is different from other objects.
Tags are identifiers that help to establish relationships in the Game Maker.
The use of Tags allows one Object to be distinguished from another, essentially giving that object a unique identifier within your logic system, making it easier to isolate the right Object when you need it.
But it’s not just about identification, it’s about identity. A Tag can change what your Object is ‘seen as’ in your experience. Two identical Objects could be recognised, and responded to, in completely different ways depending on how they are Tagged.
You will see this in action when applying Behaviours. Adding a Behaviour to an object will assign a set of Tags, along with a series of variables, that make your object identifiable within your experience as a certain type of entity.
For example, adding the Predator Behaviour applies the 'RequiresMovement', 'Predator', 'Health Component', and 'Hostile' Tags. Adding the Prey Behaviour applies 'RequiresMovement', 'Prey', and the 'HealthComponent' Tags.
Remember, at the end of the day, everything in your experience is a collection of voxels. The only thing that makes a tree a passive part of your scenery, rather than a vicious enemy, is your decision to set its Behaviours and Tags a certain way.
For your logic to work properly, you will need to have these Tags clearly established, so that it is easy to call on those identifiers when defining if something is true or false, collected or not collected, defeated or not defeated, friend or enemy.
A key may look like a key, but it won't function as a key until you establish the framework for it to be seen as and received as a key. The Object needs to be built into the logic in a way that makes it identifiable as serving that function, rather than, say, existing in your experience as a plant.
To set a tag, click your object and navigate to the very bottom of the Properties Panel, where you will find Tags as a heading.
If you have added a Behaviour, or the Asset you are using came predefined with a particular Behaviour or Components, then the chances are some Tags will already be present.
Adding new Tags or removing the ones that are already listed is straightforward.
To Remove an existing Tag, just click the little 'X' located at the right of the relevant tag.
To add a new Tag, click in the 'Add Tag' box, type your desired tag, and press 'Enter' to add it. This will apply the Tag to the Object, which you will see populates in the Properties Panel above the Add Tag box.
This is a really powerful aspect of the Game Maker that is useful to play with and try out.
Tags are case sensitive, meaning the tag 'Predator' with a capital 'P' and 'predator' with a lower case 'p' are considered seperate tags.
For example, some Messages require a tag to be identified as the target for a message, as a generic broadcast won’t necessarily trigger the required outcome.
Speaking of Messages, now that you know about how Tags work, a good next step is to learn about what Messages are, and how they can be used along with Tags!