CoinSFX Issue

Hello!

It seems like some other people have had the same issue but there hasn’t been a solution yet.

I used PlayClipAtPoint with the proper Camera.main.transform.position as its playing point
My main camera contains the AudioListener and CinemachineBrain components. The coinSFX is very distorted and plays in one ear or another depending where the camera is on the scene. Has anyone found a solution for this?

Here is my code for the coin

private void OnTriggerEnter2D(Collider2D other)
{
    if(other.gameObject.layer == LayerMask.NameToLayer("Player"))
    {
        //Play Sound & Add to Score & Destroy
        FindObjectOfType<GameSession>().AddToScore(pointValue);

        AudioSource.PlayClipAtPoint(coinSFX, Camera.main.transform.position);

        Destroy(gameObject);
    }
}

Here is an image of my Main Camera Inspector

Hi,

Which version of Unity do you use? How many cameras are there in your scene, and how many game objects have the “MainCamera” tag assigned?

Hey Nina!

I only have the Main camera tagged as “Main Camera”. I am currently using the newest version of Unity. I was doing some research on the topic and it does seem to be an issue with the camera moving and the “PlayClipAtPoint” playing the sound where the camera was a few moments ago (since the camera is moving). It is a type of Doppler effect that occurs, but instead of having a realistic distortion of the sound as we hear it in real life, it distorts in a glitchy manner.

That makes sense. Maybe you could test a different “Blend Update Method” and/or “Update Method”. See the CinemachineBrain.

Also take a look at the “Order of execution for event functions” in the manual. If you cannot find a good method which gets executed before OnTriggerEnter2D, start a coroutine which calls PlayClipAtPoint at the end of the frame. Given your assumption is correct, that should solve the problem.

Thank you once again Nina! I will definitely try this!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms