# Stop player's rotation and movement

Member Posts: 1

I have 4 buttons in a scene to control the rotation and movement of the player.

A button to move the player left
A button to rotate the player left
A button to move the player right
A button to rotate the player right

2 walls to keep the player within the scene.

Moving the player left or right and reaching either wall will stop the player from moving further.
When the player reaches the left wall and I press the rotate left button, the player will push itself off the wall, continue to rotate left and move to the right. This also happens when the player reaches the right wall. Rotating right and hitting the right wall will keep the player rotating to the right and move the player to the left.

Only when I press another button will the rotation and movement stop.

What's the best way to stop the player from rotating and moving when hitting the wall?

Regards,

Justin

• Member, Sous Chef, PRO, Bowlboy Sidekick Posts: 9,025
edited December 2014

I'm not at a computer right now, but try this logic, it seems to make sense so should work:

Create a rule and put it in your moving actor:
When overlaps or collides with walls:
- Constrain rotation to 0 ( or whatever the rotation was prior to hitting the wall)

This will not all the actor to rotate while up against the wall.

Another method is to not allow the player to touch rotate while up against the wall.

Create a game integer attribute call WallTouch. Set it to 0.

In your moving actor create a rule:
When overlaps or collides with walls,
- change attribute game.wallTouch to 1.
- - otherwise
- - - change game.wallTouch to 0

Now, in your rotate button where you already have your touch rule, add another condition that says when game.WallTouch is equal to 0.

This will not all the player to activate the rotate button when game.WallTouch is 1 (when the actor is touching wall).

• Member Posts: 1

Thanks for both of these suggestions. I have a 'collide' behavior in my actor so I'll have to ditch that first.

I'll give these both a try and keep you posted.