Finding the length of a ray passing through an object

Topics: User Forum
Apr 4, 2014 at 9:14 PM
I have a fairly interesting problem. In my game I plan on having creatures (zombies) react to sound. The way I thought to implement this would be with raycasting. I plan on casting from the source of a sound to each zombie within an area. What I want to do is reduce the sound intensity as it passes through walls and other wall-like objects. The thing is I want to reduce the intensity by how thick the object is that the ray passes through.

So if I have a rectangular wall of 100 x 50 if a ray passes through top to bottom the intensity should be reduced less than if the ray was to pass through left to right because of the thickness. Is there any way to do this with the current raycast method? Or does anyone have any other ideas on how to implement sound detection? Thanks.