When you create the zombie, add an object timer in the same group, leave the initial Pathfinder move to get it moving
New event
Add condition
Zombie Object timerName elapsed >= .3
Actions
Pathfinder Move zombie to players position
Reset timer
IDK the ideal amount of time. Too large and the zombie will always target the players previous position. Since the timer is started when the zombie is created the timers should mostly expire at different times. That will reduce and spread out the recalculations.
Small changes add up fast when you’re doing studs 60 times per second times the number of objects. If you build in efficient code from the start then you’ll have less to optimize later.
You might find an ideal timer amount with a simple project without a lot of moveable objects and/or obstacles.
If you check the distance, you could use 2 events
Distance between objects => 300
Object timer >= 1 second
Move zombie
Restart zombie timer
Distance between objects < 300
Object timer >=. 3 second
Move zombie
Restart zombie timer
Since each group would be targeting the same location, I don’t think you would need for each object I could be wrong.
If **for each object ** is needed, I usually put it after the shared condition. Conditions work like filters. It’s better to filter the list first and just loop through them instead of looping through every object whether it’s needed or not.
Example
Distance between objects => 300
Object timer >= 1 second
(the Subevents would be)
For each zombie
Move zombie
Restart zombie timer
Alternatively, since all objects are being moved you could use a **for each object ** with both distance conditions.
I wasn’t going to make an example but I wanted to test my idea. Something like this. It’s not completely test. So, there could be bugs.
I know you don’t delete your dead zombies. You would have to either check if the zombie is alive through the animation before the timer and move conditions or I guess you could just delete the zombie timer when they die. Although it would still be calculating the distance between player and zombie. So, you could check the animation first.
A better way might be when the zombies die, add a different object of a dead zombie in its x, y and delete the active zombie. Then you wouldn’t have to filter between living and dead zombie.
You could then control how many dead zombies are on screen. Maybe delete the dead zombies after a certain time with their own timer or an animation. They could decay or sink into the ground. That would keep the object count down. Otherwise, things might eventually start to lag.
Edit: I see you are deleting the zombies. It would still apply because you don’t want dying (for a second time) zombies to move.
I wonder if dead zombies could comeback to “life” after a certain amount of time. It’s a bit like a skeleton that turns into a pile of bones reforming after a certain amount of time. I like that concept. I need to try that.