- Home /
Raycast for audio detection in 'echos' general theory.
Hi all, I'm working on a 3D stealth game with a 'thief: deadly shadows' feel and want a more in depth audio detection system than just a simple distance check - to stop guards hearing the player shuffling around when they're only 2 feet away but through 2 feet of stone wall. I'd like to do this with a random 'echoing' raycast from the player.
What I'm picturing for 'coding logic' is to 'hedgehog' multiple raycasts randomly to reflect off walls until a distance equivalent to the player noise at that time has been reached. every enemy hit with any of those rays has heard the player. if the player is making more noise then the raycast length is larger, simulating being heard from further away, although still unhearable from behind walls etc.
the attached image is a very simple 2d sketch of what I mean, if any part of an NPC was in the dark green area they would have been hit by a raycast and heard something, if not they would have missed it, despite both enemies being within the direct line of sight hearing range.
my question is this: is this a sensible way of achieving what I'm aiming at? For now it will only be the player that uses the 'raycast hedgehog' approach, NPC's can still use distance for audio detection to keep performance loss to a minimum if it becomes a factor. This seems like it'll be quite a lot of code for a relatively impercievable change to gameplay, but occasionally it'll break immersion without it.
Would it be significantly more efficient to have a 'noise absorption' slider for all the walls, and modify a direct raycastAll between the player and enemy?
or is there a better third way that I haven't considered?
Hope this wasn't too longwinded, thanks in advance,
Your answer
Follow this Question
Related Questions
enemy raycast to detect player 1 Answer
enemy Raycast cone detection 0 Answers
multiple enemy AI raycast 1 Answer
Raycast not detecting a hit from far away, it only detects when close. 0 Answers