How to make multiple instances of the same sprite do the same thing?

I’m making a 3D explorer type game, but I’ve run into a problem. I have multiple instances of the same enemy, and I want them all to follow the player. I’m using an extension to add pathfinding to these enemies also. I want the enemies to find a path to the player when they spawn, and refresh their path to the player’s current location every 3 seconds or so. (Also if they complete a path, they refresh their path to the player’s location also)

I have 4 of them, but only 1 seems to function correctly. I know arrays exist, but I can’t seem to understand how they really work, and if they can even help me. Only 1 refreshes their path, the rest make a path, follow it to the very end, then make another one. Leading all 3 of them to not be able to really even chase the player.https://arcade.makecode.com/S12430-17484-25083-91888

1 Like

Your game is awesome!

Every time a new Smiler spawns, Smiler is set to the newly created sprite. In the this code fragment, when any sprite of kind Smile completes path, the last created Smiler start to follow path instead of the one which just finished. Change Smiler to sprite on the event block should do, but it’s a little bit difficult to reproduce, I didn’t verified :joy: :joy: :joy:

Ah, sorry. I added comments to try to point people to the monstrosity that is the Fun Level’s blocks. I guess I should have mentioned which enemy I was referring to in the post, also I don’t think comments may show if you’re viewing someone’s game. But I’m referring to the PartyGoer(s), which you should find in a “When player overlaps tile” near the bottom of the block area, and should be roughly to the left and down of the Smiler code.

And to the right of the Fun Level blocks, there’s 2 un-collapsed blocks that are Game Update and “On sprite completes path” for the PartyGoers also. The initial pathing to the player works for all of them, but only 1 is working with the Game Update path blocks and “On sprite completes path”. Meaning 3 of the PartyGoers will only path to where you spawned at, not follow you if you move from that spot, and will stop moving completely when they finish their path. But sometimes they’re able to refresh their path after they complete one, but it’s still a problem since it will have to fully complete a path before pathing to the player again, which is exactly what the On Game Update bit of code fixes (Still a bit inaccurate though)

Would add another image, but new users can’t put more than one in, so sorry about that.

1 Like

It was that simple? Well thank you! Would’ve took me ages before I thought to do that lol