Enemy follow in a maze game

I’m making a pacman style maze game and I want to have my enemies follow my sprite, but with more logic than the “enemy follow mysprite” block. I want them to follow the maze pathways. The “enemy follow” block just makes the enemies run into walls and get stuck in corners. Is there any way to do this?
Thanks!

1 Like

Absolutely, @bee

There was a trick back in the old Shang Chi map that did something just like this:

—-

A little barrier wouldn’t stop a Ten Rings assassin. Let’s teach them to jump when something stands in their way.


► From ||scene:Scene||, drag
||scene:on [sprite] of kind [Player] hits wall at [location]|| into an empty area of the workspace and change ||scene:Player|| to ||scene:Enemy||.

► From ||sprites:Sprites|| drag ||sprites:make [mySprite] hurdle side wall|| into the empty container.

► Drag the ||variables(noclick):sprite|| value from the outer container down to replace ||variables(noclick):mySprite||.

scene.onHitWall(SpriteKind.Enemy, function (sprite, location) {
    sprites.wall_jump(sprite)
})

(You obviously don’t need to make them jump at a wall, you can have them turn around or otherwise change their velocity, instead.)

Thanks! This looks like it might do what I want. I can’t find the “make MySprite hurdle side wall” block. It seems to be from an extension, but I can’t figure out which one.

The Tilemap Path Finding extension works great for this!

or you can mak a path form your enemy to your sprite using :its a path finder

This extension is great! I"ve got the enemy to follow my sprite. But it only follows the path exactly, I can’t seem to get it to update the path. I’ve tried putting the “sprite ducks follow path” block in a game update or forever loop, but it doesn’t work. Any suggestions? https://arcade.makecode.com/S84836-56548-19698-75495