Restrict player movement until he reaches a wall (stuck on wall)
hanetrain
Member Posts: 5
I'm trying to make a game where when a direction (up/down/left/right) is pressed the player moves in that direction until he comes to rest on a wall. Player also cannot change course until he reaches the wall.
I've currently set:
When all "key (direction) is down" and
"if self.motion.linear.Velocity.y = 0"
"if self.motion.linear.Velocity.x = 0"
Do:
"Move To" in a direction with "run to completion" to make the player go all the way to the wall.
The player goes all the way to the wall and can't change course mid way which is good. But he wont move off the wall. I have wall immobile. Friction 0, bounciness 0. Not sure
Comments
@hanetrain You might not have the moving actor reach the point it needs to reach in order for the rule to stop working. Have you tried turning "run to completion" off? This would be my first idea...
Took of "run to completion" and the player can move along wall, but now the movement only moves while pressing down on the key and can change directions before reaching the wall. I want 1 key press to move the player all the way to the wall.
figured it out, used a collide function to reset X and Y velocity to 0 when colliding with walls. All better now.