Hi all, I’m working on a 3D stealth game with an old ‘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 solid 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 makes 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 imperceivable change to gameplay, but occasionally it’ll break immersion without it.
Would it be significantly more performant to have a ‘noise absorption’ slider for all the walls, and modify a direct raycastAll between the player and enemy within a given ‘noise sphere’? this would be less ‘realistic’, but maybe not detectably so for a player?
or is there a better third way that I haven’t considered?
Hope this wasn’t too longwinded, thanks in advance,
Sundown