How do I make an event stop moving when it hits a wall?

Here's the coding :3
Screen Shot 2020-12-01 at 7.29.56 PM.png

Screen Shot 2020-12-01 at 7.30.01 PM.png


Soooo with the way this coding is currently setup, the snowball will travel repeatedly in the direction the player pushes it towards. (It's a sliding snowball, and the player is immune to the sliding effect)

However, I ran into a previously unnoticed issue...

Whenever the snowball touches a wall, it's still "repeating" the pushed movements. I know this because you can push the snowball against a wall that the player can also push. When I pushed the moveable wall that was blocking the snowball, the snowball continued moving in that direction despite not being pushed.

I previously did not notice this, but just discovered it when play testing.

How do I get the ball to stop repeating the movements once it touches something? I can't seem to find a way around that.
You can actually simplify that whole thing (including the "only move if I can" to this):

Code:
If Script: this.character(0).canPass(this.character(0).x, this.character(0).y, $gamePlayer.direction())
  Set Movement Route: [This Event] Move Away from Player
  Wait 9 Frames
  Set Movement Route: [Player] One Step Foward
End

That is the snowball, saying "if I can move in the direction that the player is facing, then move away from the player, and make the player move as well". It works because in order to activate the event, the player will be facing in the direction the event needs to move, and will activate it from the opposite side.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-an-event-stop-moving-when-it-hits-a-wall.130520/