Can Hear Object

For some reason, I can't get the can hear object to fire using tags or layer masks. If I add both feet as targets the can hear object works as intended for footsteps but not for weapons. The same problem extends to the demo scenes as in it the Demo AI cant hear either footsteps or gun sounds. I saw this workaround here but it seems to be outdated... is there any way to fix this problem or am I doing something wrong? I am using the demo behaviors with sounds way above my audibility threshold ( I set the threshold to .001 for testing sake to no avail)
 

Justin

Administrator
Staff member
Unfortunately that workaround is the current approach. I still haven't figured out a better way to handle that case.
 
do I still add this line
if ((colliderAudioSource = targetObject.GetComponentsInChildren<AudioSource>(targetObject)) != null) {
to line 199 on the "MovementUtility" script? That line seems to just be a "}". or has the line I need to edit changed?
 
Hey one more quick question, I wanted to know how I would go about making runtime weapons from the UIS work with this workaround. I got it to work for the demo scene and a basic UCC character but I am unable to do the same when using UIS as the item object there is added at runtime and the target tag and layer mask options refuse to work...
 

Justin

Administrator
Staff member
GetComponentsInChildren searches through the child hierarchy at the time that it is called so it'll work with runtime items. Are you sure your item has an AudioSource?
 
GetComponentsInChildren searches through the child hierarchy at the time that it is called so it'll work with runtime items. Are you sure your item has an AudioSource?
I actually got it to work. when using first-person characters or a character that can go into the first person you will also have to add the camera component to the target list in order for the AI to hear him.
 
Top