Calling an AudioSource rather than AudioClip

Can anyone tell me how to call an AudioSource rather than an AudioClip?

My problem is I need to alter the components of the sound i.e. looping, pitch, volume etc rather than it just playing the clip once straight from the project folder.

Here is what I have so far:

Code:

var footstep : AudioClip;

function Update () {

if (Input.GetButtonDown (“Horizontal”)){
audio.PlayOneShot (footstep);
}
if (Input.GetButtonDown (“Vertical”)){
audio.PlayOneShot (footstep);
}
}

Thanks

You are already accessing the AudioSource component by writing audio !

Ok, cool. But I’m still unsure how to alter the pitch and looping of the audioclip…

If I change the “PlayOneShot” to “Play”, “Stop”, or “Loop” I get an error stating that it is not compatible with the argument ist ‘(UnityEngine.AudioClip)’.

That’s because there is no such function as Play (clip : AudioClip).

It’s like going to the market to buy “something” without stating that thing.

This is the inverse for Play : it will always play the clip attached to the AudioSource. Stating anything else will result in troubles, since given information is unneeded in order to make Play works.

Nice one thanks.

So it was because I put the audiosource in as a variable it was reading straight from the project folder?

I’ve only been attampting script since last Monday!

Thanks again.

No, it happens because Play () do not require an argument (you can give an optionnal argument, of type UInt64, but not AudioClip).