Actor attributes in Gamesalad

pxlpfctpxlpfct Member Posts: 37
edited April 2012 in Working with GS (Mac)
Is there a way to make a global attribute for an actor? I need this because I'm making a distance from behavior but the actor it checks against will change. Does anyone know how to achieve this?

Best Answer

  • FloridaGamesFloridaGames Posts: 328
    edited April 2012 Accepted Answer
    so for your problem make two game attributes: actor x, and actor y. In the actor add two constrain attribute behaviors: "constrain attribute game.actor x to self.position x" and an identical one substituting "x" with "y".
    EDIT: looks like Photics beat me to it...

Answers

  • PhoticsPhotics Member Posts: 4,172
    The hierarchy is as follows...

    Game -> Scene -> Actor

    If you want one actor to read the attributes of another actor, then transfer that data to a Scene or Game attribute. If you want a global attribute for an actor... you don't have to use actor attributes. You can use game attributes to store data.

    As an example, I usually make Player health a game attribute, as so many other actors may interact with it.

    The problem is when you have multiple copies of the same actor. They'll try to overwrite the game attribute with their own. Example... two enemy actors can't share the same Game attribute for their health, or they'll run out of health at the same time.
  • FloridaGamesFloridaGames Member Posts: 328
    make a game attribute and add a constrain attribute to the actor, linking its self.attribute to a game.attribute.
Sign In or Register to comment.