Stop Drag Through Walls
![Gendude](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I am working on a game that require objects to be drag around and I was able to setup the drag & drop part of it, but I can't figure out how to prevent the objects to drag through the walls and floor. I have a collide behavior on the objects, but only works when the objects are not been drag.
Thanks in advance to the person that help
Gendude
Thanks in advance to the person that help
Gendude
Comments
Anyhow, the following still works with the standard dragging Rules (created by Tshirtbooth, I believe), just not quite as well; the following will be for the left wall. Duplicate for right, top and bottom, changing the Move To accordingly, eg. for top, figures will be Move To position self.Position.X, self.Position.Y-20; etc.
Rule: When Actor overlaps or collides with Actor of type LeftWall
Change attribute self.DragAndDrop to false
Collide Bounce when colliding with actor of type LeftWall
Move To self.position.X+20, self.position.Y speed 300
Rule: when all conditions are valid
When touch is pressed
when touch is inside
Change attribute self.DragAndDrop to true
otherwise
Change attribute self.DragAndDrop to false
---then the following amended so that the item dragged doesn't jump to the touch point but is still draggable---
Rule: When attribute self.DragAndDrop is true
Constrain Attribute self.Position.X to game.Touch. touch 1.Position.X
Constrain Attribute self.Position.Y to game.Touch. touch 1.Position.Y
Hope this sorts this for you.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps