Help with moving enemy flip

Hi all,
I am trying to create a basic platformer with moving enemies that change direction on collision with a wall. I have used the on of kind hits at with an if/else block to differentiate between left and right side collisions, but my enemy just won’t change direction.

Here is my project link: https://arcade.makecode.com/S75689-23265-06607-63346
Any suggestions would be fabulous!

Thank you in advance :slight_smile:

1 Like

Looks like your problem is with this code here:

Variables only hold the most recent sprite created, so basically the mySprite2 variable is only effecting the enemy that got created last. Instead, you want to be effecting the sprite that touched the wall, so you need to drag that little “sprite” variable in the top of the block out and use it instead, like this:


Whenever you see those little red blocks inside a larger block, it’s possible to drag them out and use them! For example, I believe that “location” variable holds the tile location of the wall that was hit.
If you have more questions, just ask!

3 Likes

Amazing- this solved my issue! Thank you so much for explaining!

1 Like