Game stutters a lot

I’m making a top down shooter where you have to kill zombies, the problem is: when it’s like 10 zombies on screen the game stutters a lot and my PC is not that bad I have 16gb of ram and an RX480 8gb, so it’s not the problem…

This is basically the zombies code:

Hmm. Once I previewed a game after closing my laptop and opening it again and it was like 1FPS. I closed and opened it again and it ran fine. Maybe that’ll work? If it doesn’t work IDK what the problem is.

Pathfinding is an expensive action. As you add more zombies you will get more lag as each zombie is recalculating its path every frame.

To get around this, I would suggest making an object timer for the zombies and only have the path updated when the timer condition is met, reset timer, then rinse and repeat.

Updating the zombies path to once per second instead of every frame will dramatically improve your performance.

You can make the timers slower if you want some zombies to be a bit ‘dumber’ too