Plz help me

So I have been making a Fnaf rippoff and freddy keeps on clipping past the wall is using https://github.com/jwunderl/arcade-tilemap-a-star
My project is https://arcade.makecode.com/S02481-84227-53317-72066

2 Likes

I meant I’m and not is

1 Like

Here is the edited verson https://arcade.makecode.com/S06350-29163-00717-48088

1 Like

I looked into the code of the A-Star extension and found a comment:

“TODO: probably should have logic to bail when a tile that wasn’t a wall is set to be a wall. Or just use velocity, and let enemy run into wall”

It looks like the A-star extension just teleports the sprite every game update, so the sprites will go through walls if the wall gets placed while they are following the path. Basically, you really can’t get them to stop unless you edit the extension and make your own. I don’t know if teleporting the sprite back will work either, as the path following function doesn’t even look at where the sprite is, it just teleports the sprite to the next spot on the path. There is also code here that makes the sprite teleport to the nearest next tile in the path if they are in a wall.

Basically what I’m saying is that you can’t use the A-star extension because it’s not made to do what you want it to. There isn’t even a block to pause the sprite before they have completed their path!

Sorry I couldn’t really help. Maybe @jwunderl would be willing to add the needed functionality?

that todo is for if a location is set to be a wall while the sprite is following the path – paths are calculated one time (at the start), so if the tilemap changes you would need to refollow the path to get up to date. I can double check but i believe current behavior is as described, just that sprite will keep trying to run into the wall if it is set and not recalculated.

the teleportation you’re referring to happens in a few spots to get things to ‘feel right’, but is just a few pixels – when you’re starting to follow a path it might snap you to the right location if the sprite is currently inside a wall, or at the end of a path so that you are sitting nicely on the end tile and not a few pixels off.

re: this game, trying to get it to repro but first thing that stands out is that the enemies seem to be slightly larger than a tile; if you can make them fit in 16x16 that’d work better, as the paths are intend for sprites that can ‘fit’ in a path (e.g. if it’s 20 pixels tall, it might not be able to go through a doorway a 16x16 sprite can)

2 Likes

Thx for the help