Restricting an object within a boundary

Nov 25, 2023

Hello,

I'm creating PACMAN game. When I use a motion path (up/down/left/right), the object is moving out of the boundary. Is there a way I can restrict the object to move (up/down/left/right) within a square/rectangle? Appreciate any help. Thanks. 

1 Reply
Catherine Gorman

Hi Jagadish,

There may be more elegant solutions, but the solution that I've come up with for this problem is to use variables and "boundary objects." I placed rectangles at the outer limit of where I wanted my player to be able to go and then set up true/false variables that would trigger when intersecting with the boundary object. When the boundary variables are true, players can no longer move in that direction.