Hello, I’m back and this time making a survivors-like game and I ran into some issues when spawning enemies.
My code to spawn enemies is as above and while it works, it makes the game very choppy when spawning the enemies. The condition “Enemies living on the scene < 10” is only there to limit it so I can actually test other things about the game. I was wondering if there is a more efficient/less choppy way this code can work.
The code basically creates enemies around the camera but not inside the camera itself so the player doesn’t see the spawning happen.
Would appreciate any help!
I don’t know that you need the repeat. You could just as easily create one on each frame. That would allow everything else to update.
I’m a bit concerned about what I’m assuming is the Pathfinder. You’re recalculating the path on each frame. Depending on the number of objects that use it and the number of obstacles that could require a lot of processing. IDK if that’s too much.
You might want to wait until the object reaches it’s destination before recalculating.
I see. Ok I changed it to where when the enemies spawn, they move to a random flag and only start moving towards the player when they’re a certain distance away and it significantly reduced the frame drops.
Not sure if I should make a separate post for this but since it’s related, I’ll post it here.
When I create the enemies (spawning them and not dragging them from objects panel to the scene) they don’t seem to play their animation at all and are always stuck at one frame. I tried to separate the frames and have events to try and change the animation but it still doesn’t work and I haven’t found anything online about it. So how do I make the enemies play their animation when it creates?