How to make an actor stay within the bounds of an area?

Hey,

Just wanted to know how to make an actor stay within the bounds of a specific area. Let's say for example the screen size of any device?

Comments

  • BBEnkBBEnk Member Posts: 1,764
    edited December 2017

    This would constrain the actors X position between max scene width.

    self.position.X to: max( scene.Camera.Size.Width /2- scene.Camera.Size.Width /2,min( scene.Camera.Size.Width /2+ scene.Camera.Size.Width /2, self.Position.X ))

    You can also just use actors as walls and have player actor collide with them to keep in bounds.

Sign In or Register to comment.