The Difference between Constrain and Change??

AldoAldo Member Posts: 53
edited November -1 in Working with GS (Mac)
What's the difference between Constrain Attribute and Change Attribute???

Comments

  • HachikoHachiko Member Posts: 330
    Constrain constantly changes an attribute, meaning that for example you do actor.x = actor.x+1, the actor will continuosly move towards the right.
    If you do change attribute actor.x = actor.x+1, the actor will move only one pixel to the right, to never move again until that condition is triggered again.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Change attribute changes one time where as constrain constatly check what its constraining to.

    For instance if you wanted an actor to follow another you would create a game attribute called actor1.x and constrain the self.position.x value of the actor you wish to follow to game.actor1.x

    then you can constrain actor2 self.position.x to game.actor1.x-25
    Doing this will make actor 2 always be 25px behind actor 1 no matter where actor 1 moves.

    f you where to use change attribute instead it would change to 25px behind the current position but would not check actor 1 position again without other actions forcing another check.

    I'm not sure that constraining can simply move an actor by itself. I guess in theory it could but this would not be a very good way move actors around
Sign In or Register to comment.