08-17-2016, 07:20 PM
I think it would be easier to implement a Hysteresis/extra factor for the objects that are not the focus of the zombie.
So if a zombie is going for the barrel the distance to the player needs to be (for example) 75% or less of that of the barrel for the zombie switch his focus to the player.
distance to player = 900
distance to barrel = 1000
No focus switch. Zombie is still going for the barrel.
distance to player = 600
distance to barrel = 1000
Focus switch. Player is way closer, zombie is going for the player.
Now the zombie won't directly focus back on the barrel if the player moves (or a other barrel is closer) because the distance to the player need to be over 1333.
So if a zombie is going for the barrel the distance to the player needs to be (for example) 75% or less of that of the barrel for the zombie switch his focus to the player.
distance to player = 900
distance to barrel = 1000
No focus switch. Zombie is still going for the barrel.
distance to player = 600
distance to barrel = 1000
Focus switch. Player is way closer, zombie is going for the player.
Now the zombie won't directly focus back on the barrel if the player moves (or a other barrel is closer) because the distance to the player need to be over 1333.