playMaker

Author Topic: How to Get "Audio Clip" from Audio Source  (Read 250 times)

rainexplorer

  • Junior Playmaker
  • **
  • Posts: 61
    • View Profile
How to Get "Audio Clip" from Audio Source
« on: December 09, 2017, 09:49:06 PM »
Hi,

i have a problem here, i have 5 gameobjects, i place an audio source with different audio clip on each audiosource & gameobject.

one time, i choose randomly, get 1 gameobject.

my questions is, How to get audio clip on choosed gameobject then set it to audio player.... ?

nb: i know get component, but it just get audiosource, but no other way to get its audioclip...

thanks in advance...

Deek

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: How to Get "Audio Clip" from Audio Source
« Reply #1 on: December 10, 2017, 06:31:13 AM »
You could use Get Property on the AudioSource instead of Get Component on the GameObject but a better approach is to only have one AudioSource, use my "Select Random Audio Clip" action from the attachments (with which you can also set the weight a.k.a. with what chance a specific Audio Clip will be picked) and then use that variable in "Set Audio Clip" or "Audio Play".

Make sure that your AudioSource is near the AudioListener (usually on your Main Camera), because otherwise you won't hear anything.

rainexplorer

  • Junior Playmaker
  • **
  • Posts: 61
    • View Profile
Re: How to Get "Audio Clip" from Audio Source
« Reply #2 on: December 10, 2017, 11:30:03 PM »
Hi Thanks for replying, i'll try...