how do i get an npc to react to a "noise" in 3d

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stefan

i have tried using area with a collision object, but this only detects if another body/area enters the area. if the npc is already in the sphere that represents the noise, there is no entered event once the noise is triggered. i have tried disabeling and enabeling the noise area, but this does not trigger the hearing area. does anyone have any idea how this could be done?

:bust_in_silhouette: Reply From: Merlin1846

Use $Area2D.get_overlapping_areas() to get an array of all overlapping areas. And use $Area2D.get_overlapping_bodies() to get an array of all overlapping bodies. Hope that’s what you meant, also you can hold the control key and click on almost anything in the script editor to see its documentation.

thanks, this seems to be what i am looking for. although i work in 3d there are similar functions. however i don’t understand how i can get this to work. the area function requires a collision mask. collision masks are only available for rigid bodys and so on, not for collision shapes. a collision shap however is the node that defines the area of the area node.

so: my area not has a child that is a collision shape. but this needs to be a collision object? how can a collision object define the area of my area node?

stefan | 2021-11-26 19:51

You have to set the collision mask of the area itself. The area also has to have a collision shape as a child to determine its hitbox.

Merlin1846 | 2021-11-27 05:15

thanks. it is working now. some area was set to disabled.

stefan | 2021-11-27 18:29