Help with creating a detailed area based npc aggro system

I am attempting to make an enemy detection system for my npcs that can handle both players and npcs (with humanoids) being within range.

Displayed in image is my npc with a ball basepart I would like to use as the aggro range. I originally was using a touched/touchEnded system but I found issues with it randomly firing touchEnded after a few minutes within the part. It would also play upon jumping.

I tried swapping over to ZonePlus but it seemed to be more designed for static zones.

What would be the best way to handle this?

Edit: Forgot to mention, the red zone is welded to the npc’s HumanoidRootPart. I also need to be able to detect when characters enter AND exit.

7 Likes

So I ended up putting this specific project on hold but recently found the solution to this while working on a different project. What I ended up doing was having a large sphere attached to the player with a touch interest specifically looking for the sphere attached to the enemy (I did this using collision groups). Once it gets a touch it fires a “WakeUp” event inside the enemy. This then tells the enemy to start repeating a GetPartBoundsInRadius check looking for HumanoidRootParts.

I also look for touchedStopped from the sphere attached to the player, when this is fired I use the “WakeUp” event with a different value to “Sleep” the GetPartBoundsInRadius checks, stopping it to save resources.

Feel free to use this method for your own projects if it helps.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.