x


Audio source problem

I have this

var clip : AudioClip;

function Update () { if( Input.GetButtonDown("w") ) { audio.Play(AudioClip);
} }

but unity says: no appropriate version of unityengine.audiosource,...

what do i need to do??

more ▼

asked Dec 19, 2010 at 08:03 PM

user-7113 (google) gravatar image

user-7113 (google)
11 21 14 17

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Change to:

audio.PlayOneShot(clip);
more ▼

answered Dec 21, 2010 at 02:52 AM

uhahaha gravatar image

uhahaha
432 7 7 21

(comments are locked)
10|3000 characters needed characters left

You're using the type instead of the variable. Should be just "audio.Play()", and assign the clip using "audio.clip = clip".

more ▼

answered Dec 19, 2010 at 08:10 PM

Eric5h5 gravatar image

Eric5h5
113k 59 216 712

I now have this: var clip : AudioClip;

function Update () { if( Input.GetButtonDown("w") ) { audio.Play(clip);
} }

still the same error

Dec 19, 2010 at 08:15 PM user-7113 (google)

I now have audio.clip = Clip;

function Update () { if( Input.GetButtonDown("w") ) { audio.Play();
} }

But it now says clip is an unknown identifier,..

sorry for being a noob

Dec 19, 2010 at 10:08 PM user-7113 (google)

Don't remove "var clip : AudioClip". Put audio.clip = clip in Start or wherever.

Dec 19, 2010 at 10:41 PM Eric5h5
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5040
x1753
x363

asked: Dec 19, 2010 at 08:03 PM

Seen: 2227 times

Last Updated: Dec 19, 2010 at 08:03 PM