J
J
Jim Ford2020-11-22 03:14:46
Unity
Jim Ford, 2020-11-22 03:14:46

How to make a bullet whistle near the player in the Unity engine?

Objective: To achieve the effect of a whistling bullet flying near (past) the player at a certain distance in a game with a first-person view. The bullet does not have a collider (the object sends rays that record a collision with something). At the same time, the shooting itself does not occur with a beam, the bullet that was fired moves along the calculated trajectory - that is, it is precisely the object.

Examples of the bullet whistle effect I'm talking about can be heard in COD Warzone, Arma 3, Escape frome Tarkov. It's not about the sound effect that is part of the impact - when the sound of hitting the surface is simply replaced or plus with a whistling sound. As I understand it, this is exactly an object flying by, which can "pierce" any surface 200 meters from the player and he will not hear the sound of the bullet touching the surface.

Trying to just attach an Audio Source with a bullet whistling sound to the pool gives strange results: the sound is heavily distorted and does not always work. It looks like Unity has trouble voicing such fast objects this way.

I heard about two more ways:
1. the distance from the fired bullet to the player is calculated and when the distance is reduced to a certain value, the sound source, hung on the player, and not on the bullet, works and the player hears the whistle of the bullet.
2. SphereCast is hung on the player, which takes into account the moment when the bullet collided with him / entered him (for example, using the tag system) - again, at this moment, the sound source on the player is triggered.

I do not quite understand how this can be implemented, so far all attempts have been unsuccessful. Or maybe there is some other simpler / more reliable way to solve the problem?

Here is a video explaining what I'm talking about: https://www.youtube.com/watch?v=VTuuOiWgVZ0&featur...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Mamchenko, 2021-02-09
@SLiverRU

Hang the sound source component on the bullet, set it to a low volume, that is, the one you need - quiet, and when the bullet flies, just play this sound (whistling).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question