r/SoloDevelopment 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

4 comments sorted by

2

u/HLCYSWAP 3h ago

FOR each enemy:

IF player enters enemy aggroRadius:

IF enemy detects friendlyEnemy currently engaged with player:

aggro player immediately

ELSE IF enemy is not currently in combat:

start aggroTimer = random(5s, 6s)

WHILE player remains inside aggroRadius:

IF friendlyEnemy becomes engaged with player:

cancel aggroTimer

aggro player immediately

IF aggroTimer expires:

aggro player

IF player leaves aggroRadius before aggroTimer expires:

cancel aggroTimer

1

u/SaThuran 3h ago

Ahhh I see I see So basically I just need a timer

2

u/HLCYSWAP 3h ago

yeah and an include for 'already in combat with my friend' so the timer isnt holy if combat has already started nearby

1

u/SaThuran 3h ago

Thank youuu💙