About 'PlayClipAtPoint()'!

In this video (objectives)…

  1. Examine our problem with destroying our GameObject and therefore destroying the ability to play our destroyed SFX.
  2. Use PlayClipAtPoint() to solve the issue of our AudioSource being destroyed.

After watching (learning outcomes)… Play sounds from objects which are being destroyed.

(Unique Video Reference: 20_BR_CUD)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

4 posts were split to a new topic: PlayClipAtPoint() causes a NullReferenceException error

2 posts were split to a new topic: Are there any advantages/disadvantages in the different approaches to playing audio?

I actually ended up doing the sounds as an if-statement for different tags in the Ball. I mean, PlayClipAtPoint() seems like a nifty command but tags just made it so easy. Am I messing up the code efficiency by doing tags and if-statements or is it alright?

Oh, right. I also randomized the pitch of the sound in a seperate method, just to spice it up.

if (hasStarted)
        {
            if (collision.gameObject.tag == "Paddle" || collision.gameObject.tag == "Block")
            {
                RandomPitch();
                myAudioSource.PlayOneShot(sfx[0]);
            }

            if (collision.gameObject.tag == "Wall")
            {
                RandomPitch();
                myAudioSource.PlayOneShot(sfx[1]);
            }

        }```
1 Like

I’m just confused as to why we would have our break sound playing from the camera’s position and not the position of the block itself.

I use this statement and it seems to work just fine:

AudioSource.PlayClipAtPoint(breakSound, transform.position);

Is there a hidden reason I’m not seeing that we’re instructed to play it at the camera’s position instead?

Privacy & Terms