min and max...

GnomerGnomer Member Posts: 292
edited January 2012 in Working with GS (Mac)
So i have a block that moves across the screen horizontally at a constant speed, when pressed it follows the mouse. How can i set a minimum and maximum vertical position for this block?

Thanks

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2012
    Hi @Gnomer

    Rule: When
    attribute self.YourActor.Position X > 30
    attribute self.YourActor.Position X < 450
    ---your preferred moving behaviour


    This is for the horizontal limits for an actor moving horizontally, use similar above for vertical movements but using Position.y

    ----------------------------------------------
    http://davidgriffinapps.co.uk/


    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • GnomerGnomer Member Posts: 292
    Thanks @gyroscope :)
  • GnomerGnomer Member Posts: 292
    @gyroscope Okay that kind of worked, but when the mouse is outside of the boundaries it jumps back to the constrain attribute i set. I had to set a constrain attribute because i have gravity in my scene. Anyway to do this?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    you're welcome!

    i've just thought; depending on how your actor is moving, the above might not register. If that's the case, make real attributes, for x and y, call them YourActorX and YourActor Y, for instance; then use a constrain behaviour: constrain attribute myActor X to self.YourActor.Position.x
    Then the rule is:
    When YourActorX > 30
    When YourActorX <450
    ---your moving stuff.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • GnomerGnomer Member Posts: 292
    Okay thanks, I'll give it a go now :)
Sign In or Register to comment.