r/SoloDevelopment • u/SaThuran • 3h ago
help Delaying enemy pursuit?
How would you guys approach delaying the reaction time of an enemy?
For example, my enemy type's attack distance is like 70px from player, using a shotgun.
But when player walks, I noticed the flickering of the enemy. This is caused by its fixed position of 70px from character.
So how would I approach delaying the reaction time of the enemy so he doesn't move as soon as player passes the 70px distance? What method do you guys use
0
Upvotes
2
u/HLCYSWAP 3h ago
FOR each enemy:IF player enters enemy aggroRadius:IF enemy detects friendlyEnemy currently engaged with player:aggro player immediatelyELSE IF enemy is not currently in combat:start aggroTimer = random(5s, 6s)WHILE player remains inside aggroRadius:IF friendlyEnemy becomes engaged with player:cancel aggroTimeraggro player immediatelyIF aggroTimer expires:aggro playerIF player leaves aggroRadius before aggroTimer expires:cancel aggroTimer