• I really don't get how atributes work. When you set an atribute to an object with the atribute of another object does it like give the same behaviours to it. In conclusion how atributes work?

  • First, create an attribute - it doesn't matter what object it's on! However, take the note of the object, because that's what you're assigning the attribute to.

    With the get attribute behavior you get the value of it so that you can do stuff with it. For example, you can have an attribute for the speed of a character, and get the attribute to input his speed into another behavior.

    With the set attribute behavior you can change that same attribute. Set attribute usually works well with the simple math behaviors in te "logic" section. Maybe every 2 seconds you want to set the speed 2 seconds faster.

    You can use this logic to move values easily through behavior chains found in all types of objects. Or you can use attributes for organization and temporary storage. Think of them as related to arrays, dictionaries, box containers, etc.

  • @DGames135 you can use attributes like box containers, they just Store a value. The advantage is that objects can get each others' attributes.

  • I still don't get it

  • @DGames135 what don't you get? Set attribute sets an attribute to a value. For example, you can have an attribute called age and add 1 to it every second. Get attribute can then get the value associated with it, so if your character has an attribute, other objects can get that attribute.

    For example, say you have a tower defence game and you want your towers to attack enemies and lower their hit points. You could give each of your enemies an attribute called HP and then when an enemy is in range of the tower, the tower can get its HP attribute, subtract 1, then set its HP attribute to that every so often to simulate an attack, then destroy the enemy when the attribute is 0.

  • Admin

    To address your original question, no it doesn't give it the same behaviours.

    Attributes are sort of like box containers. They're another way of storing data. BUT the key difference is using the GET attribute or SET attribute you can find out about a value from another object.

    Say you have a game where you have some enemies, each with their own health.
    Before attributes you would have a complicated way of handling the logic because it wasn't so easy to get each enemies health. You would either need to have all your attack logic on each object, use send/receive message, or do other messy things. Now every object can share it's health with any other object in the scene.

    So essentially, attributes are a way for objects to tell other objects about them self.

    Another example is the built in physics behaviours, each object has a gravity, mass, etc. These are attributes predefined by hyperPad. We have "Set Gravity" and "Get Gravity" and you can do that to any object in your scene.
    But with attributes you can do things like "Get bannanas" Or "get sdgldfjkgjldkfgsd" what ever you want. Now what you do with those heavily depends on the rest of your behaviours.

Log in to reply