How to use PlayClipAtPoint!

Objective: Learn and apply the function of PlayClipAtPoint.

PlayClipAtPoint is a function that plays an audio clip at a given position in the world. It creates an audio source, then automatically deletes it once the clip had played through.

All we need to use this function is an audio clip which you will need to precure.

A variable

Name the variable something appropriate

A reference

If you are using this on multiple objects you could select all the objects and add the audio clip to all at once.

And the position in the world, which will be on the object’s position.

With that mapped out, now you need to select where you want this audio to play, and add the code there.

The code will be the class, followed by the function, parenthesis, audio clip and position.

Now when this is called the audio will play even if the object is destroyed, and once the clip has played it destroys itself leaving nothing behind. Now you can instantiate audio in your games!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store