Bullet Near-Miss Sound Effects

So, I have a gun system using worldroot:Raycast() and I’m curious, how would I go about checking if the ray passes near a player? So if a shot is fired, passing close to the player, the classic whoosh sound can be played.

Maybe you can weld a bigger part on the player’s head and when the ray intercepts that part you play the sound.

1 Like

That’s not a bad idea I suppose. I’ve been thinking maybe there is a way to check the 2d coordinates of the mouse and the relative vector3 coordinates of the mouse in world space, then check if there is a player within a specified range of the vector3 translated from the 2d mouse coordinates. There would be some issues with that of course, but it would be mostly effective I think.

Or maybe instead of using worldroot:Raycast() use raycast.new() and iterate through all player characters and checking proximity to the raycast using raycast:distance(character.head)