• Opsive has been nominated for TWO Unity Awards: Publisher of the Year and Best Development Tool (Behavior Designer Pro)! Your support means everything, cast your vote here: https://awards.unity.com/vote

Requesting Guidance on Sound & Visibility Detection

RazoR_Den

New member
Hi everyone,
My name is Denys, and I’m new to the Opsive forum!

Quick intro: I’m a programmer with ~12 years of experience, mainly in iOS development. I’m exploring Unity 6 in my free time to build a top-down horror game focused on stealth and tense combat. To help speed things up, I’m using Ultimate Character Controller and Behavior Designer Pro.

I’m currently working on two mechanics and would appreciate some guidance:
1. Enemy Sound Detection
I want enemies to react to sounds made by the player (running, breaking glass, firing, squeaky doors, melee hits, etc.).
For MVP, I’m using the Atlas player prefab and EnemyAtlas prefab from the demo. I set up a Behavior Tree using CanDetectObject with the Player set in ObjectDetectionMode.
Right now, enemies only react to pistol reloads – not footsteps, gunfire, or melee swings.
I suspect I need to switch to TagDetectionMode or LayerDetectionMode and assign those to objects with audio sources. It seems like AudioSource.PlayClipAtPoint alone doesn’t trigger detection. Am I on the right track?
2. Player Hiding in Grass
I want enemies to ignore the player when crouching in tall grass. My idea: assign a tag like IsInvisible to the player when they enter a grass volume and crouch. Then use CanDetectObject with TagDetectionMode + an Invertor to block detection.
Is this a solid approach, or would you recommend a cleaner method?

Thanks in advance for any tips or best practices you can share!

Cheers,
Denys
 

Attachments

  • sound_detection.png
    sound_detection.png
    284.6 KB · Views: 2
Welcome!

I want enemies to react to sounds made by the player (running, breaking glass, firing, squeaky doors, melee hits, etc.).
For MVP, I’m using the Atlas player prefab and EnemyAtlas prefab from the demo. I set up a Behavior Tree using CanDetectObject with the Player set in ObjectDetectionMode.
Right now, enemies only react to pistol reloads – not footsteps, gunfire, or melee swings.
I suspect I need to switch to TagDetectionMode or LayerDetectionMode and assign those to objects with audio sources. It seems like AudioSource.PlayClipAtPoint alone doesn’t trigger detection. Am I on the right track?
This is a bit trickier since you want to filter out which AudioSource is played and there are some overlaps on which object it is played on. For example, reload and firing plays from the same AudioSource.

In this case I actually recommend creating a new detection mode that will filter out the clip. You could model it off of the ObjectDetectionMode, and then when a clip is played you'd have a separate system which determines if it's a valid clip that should be reacted to.

I want enemies to ignore the player when crouching in tall grass. My idea: assign a tag like IsInvisible to the player when they enter a grass volume and crouch. Then use CanDetectObject with TagDetectionMode + an Invertor to block detection.
Is this a solid approach, or would you recommend a cleaner method?
In general I don't recommend using tags since they are based on strings. Similar to sound, you could create a new detection mode that only detects the object when a new component's IsInvisible flag is false.
 
Hey Justin, thanks a lot for the insights!

From what I understand, you're suggesting it's better to extend the detection system programmatically rather than relying on UI-based tweaks.

That makes sense, appreciate the guidance :)
 
Back
Top