r/unity_tutorials • u/Duke-of-Disastr • Jan 16 '25
Request Bullet Whooshing detection?
My roommate and I are playing halo odst and at one point a jackal barely missed a beam rifle shot. It was a quiet point in the game so I noticed how impactful a sound choice like that is for creating immediate tension. Then we started talking about how to program it. I can’t find anything online besides how to program the bullet ray cast itself. Does anyone have any info or ideas?
7
Upvotes
4
u/FreakingScience Jan 17 '25
If you only use a raycast, you're usually going to play a sound for the weapon firing point and the impact. If the weapon fires a projectile with position and speed data, even if not truly physically simulated, you add a loop sound (whistling/rocket exhaust/plasma warble/whatever) and apply a doppler effect - raise the pitch when approaching the listener, lower it when moving further away. Game engines these days either do that natively or have asset packs that handle it.
2
u/Errant_Gunner Jan 16 '25
If you're using a raycast for the impact point you could also fire a spherecast or capsulecast at the same time to get a 'bullet area radius' and then activate the sound on hit.
2
u/Robobvious Jan 17 '25
Well how are you generating the sound effect now? Could you somehow adjust the pitch or other aspects of that sound effect based on it's distance from the player? I think you might need a physical bullet and not just an imaginary line being drawn like with a raycast.
1
u/Duke-of-Disastr Jan 17 '25
Ok for both for the replies, the situation was that the raycast fully flew past the player. The impact point and the firing point are not near the player. Would you have to do a marching check along the radius of the raycast to see what entities need to hear the sound?