Keep Actor Out Of Area

joshuawildejoshuawilde Member Posts: 96
edited March 2012 in Working with GS (Mac)
How can I keep an actor, movable or not movable, from going inside a certain area, without making that area a collidable actor

Comments

  • joshuawildejoshuawilde Member Posts: 96
    Thanks for the response @tshirtbooth but i don't want to use a collidable actor because the actor is constrained to the mouse x and y position so it wont collide with the collidable area anyway. the dead zone is located around another actor (the end of the level actor) and i don't want other objects to be able to go through to the area around the end of the level.
  • joshuawildejoshuawilde Member Posts: 96
    anyone care to help out a fellow GS User in need
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2012
    I'm thinking you could use magnitude to restrict the constrain behavior so that when your player actor is less than or equal to a certain distance from the end of level actor, the player actor is no longer constrained to the mouse x,y. I'll see if I can get this to work...

    I can get the player actor to stop moving (e.g. if the condition is that DistanceToLevelEndActor>150 and touch is pressed then constrain to mouse x,y) but I can't start moving it again because the condition is then false (e.g. DistanceToLevelEndActor is 145). Maybe someone else will have an idea.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • joshuawildejoshuawilde Member Posts: 96
    yes. i know what you mean. i was having similar problems
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    since its constraing to the mouse, you can make an attribute called constrainOff (boolean) and have it set to false. Then wherever you want to not be able to get to, have an invisible actor there and have a rule when mouse position is inside change attribute constrainOff to true, otherwise change constrain off to false

    then in the actor thats constrained to the mouse, have the constrain behaviors in a rule when attribute constrainOff is false

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I also tried to keep track of LastValidX and LastValidY positions right before the player actor crosses the line (e.g. in my example above, going from 151 distance to 149 distance) and then doing a change attribute self.position.X to LastValidX, but alas that didn't work either.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2012
    Aw, tshirtbooth beat me to the answer. Argh! I even have that template file on my computer. =)

    Well, for what it's worth, I came up with something that works for the most part, but it requires re-spawning the player actor: http://dl.dropbox.com/u/19602014/KeepAwayArea.zip

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.