1
\$\begingroup\$

I have 5 cubes and all 5 cubes have an audiosource. When my player jumps into those cubes, the audiosource is playing just once. It was working. But then, I decided to re-organize my hierarchy and audiosource didn’t work well.

When I jump to first cube, the audio plays but then if I try to jump to the other cubes, the audio does not play. I have a prefab cube and all 5 cubes are the created from that prefab. It gives Can not play a disabled audio source and I don’t know why? I haven’t changed about coding part.

This is my first cube component :

The other 4 cubes (actually they all the same as with the first cube): enter image description here

enter image description here

Coding Part :

//Eğer karakter ses efekti tamamlanmadan diğer paddle'a atlarsa paddle ses çıkarmıyor. Bunu düzelt

[SerializeField] AudioSource clickSound;

bool landedorNot = false;

void Start()
{
}

private void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.name == "Ship New Pos" && landedorNot == false )
    {
        landedorNot = true;
        
        if (!clickSound.isPlaying)
        {
            clickSound.Play(); // this is where the error occurs according to Unity
        }
    }
}
\$\endgroup\$
4
  • \$\begingroup\$ Can you show us your ClickSound object in the inspector, just after it fails to play a sound? \$\endgroup\$ Commented Feb 20, 2021 at 11:31
  • \$\begingroup\$ I added that. @DMGregory \$\endgroup\$ Commented Feb 20, 2021 at 21:06
  • \$\begingroup\$ Start the game, then switch back to the scene editor. While it's running, check all the clicksound objects... Does the AudioSource still have a tick next to it, like in the screenshot above? \$\endgroup\$ Commented Feb 20, 2021 at 21:07
  • 1
    \$\begingroup\$ I checked. There is no problem. AudioSource has tick while game is running @Basic \$\endgroup\$ Commented Feb 21, 2021 at 12:05

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.