Attributes are values stored on each object to be accessed later. For example, if you want to keep track of the health of each enemy in your game you can create a health attribute. When the enemy receives damage, you can set the health attribute to a new value.
Attributes can be more flexible than this. You can also set, and get attributes dynamically without predefining them first, allowing you to create data structures.
Using behaviors you can access attributes from any object in your scene, or even add attributes dynamically.
You can predefine attributes from the Attributes tab in the Object Properties (see Object Properties for more information).
To add an attribute first enter a name for the attribute in the search field (this is sometimes referred to a key). If the attribute already exists, the search will filter it out for you. If it doesn't exist tap the + icon to add the new attribute.
Once your attribute is added, you can enter any number or text in the input field to preset it. You can also leave it blank and set it dynamically using behaviors.
Set Attribute Behavior:
Using the Set Attribute behavior (located in the Object category) you can update the value for any predefined attribute on a selected object. You also have the option to dynamically set or create an attribute for your specified object.
By default the "Predefined" attribute key type is selected from the drop down list. With this option selected, you can set the value for any predefined attribute. Tap "Select Attribute Key" to display a list of attributes applied to your selected object.
Once you have selected the desired attribute, you can set the "Attribute Value" to anything you want. Once the Set Attribute behavior is executed, the attribute will be set to this new value.
If you select the "Dynamic" key type from the drop down list you can manually enter a key (name), and a value for an attribute to set.
If the key you enter exists for the selected object, then the specified attribute will be set with the new value. However, if you enter a key that does not exist for your object, the attribute will be created for you once this behavior is executed.
Get Attribute Behavior:
With the Get Attribute behavior you can get the value of any predefined or dynamic attribute, then output it to another behavior (see Sharing Values).
The Get Attribute behavior works similarly to the Set Attribute behavior. You can select a Predefined attribute or Dynamic.
However, if you select a Dynamic Attribute with the Get Attribute behavior, the entered key must already exist. This means the attribute must be predefined, or created dynamically before the Get Attribute behavior is executed. If you enter a key for na attribute that does not exist, then nothing will be returned.