|
Managed to get it fixed, how.. no idea.
(comments are locked)
|
|
In the Unity documentation, the example scripts usually have a dropdown list where it says (f.ex) Javascript, where you can switch to C# or Boo. http://unity3d.com/support/documentation/ScriptReference/AudioSource.Play.html Should be no exception. Ohh gawd, I feel so stupid right now. I completely overlooked that part :|. Thanks
Jun 10 '12 at 11:02 PM
Suraci
(comments are locked)
|
|
First thing: to which object this script is attached? If this object is too far from the camera, the sound may be heard too low, or not be heard at all. You must also attach an AudioSource to this object and set its Clip property to the desired sound, or you will get Null Reference errors (pay attention to the Console!).
public AudioClip errorSound; // drag the desired sound here
void OnLeftClickUp(SimonLightPlate.eType color)
{
...
if (!VerifySequence())
{
AudioSource.PlayClipAtPoint(errorSound, Camera.main.transform.position);
ResetGame();
}
...
This will instantiate a temporary AudioSource and play the sound at the camera position (where the game "ears" usually are), destroying automatically the AudioSource when the sound finishes. I am having some problems with loading in my sound, I am trying to use errorSound = (AudioClip)Resources.Load("Assets/wrong.wav"); but it's not working nor am I sure if this is the proper way to do so, what am I doing wrong if I may ask? (I've attached my sound file to the object that needs it, and when I run the program without the extra errorSound it's working but without sound obviously.)
Jun 11 '12 at 11:53 AM
Suraci
From the docs, I think you should do the following: Additionally, the sound should be stored in the Resources folder.
Jun 11 '12 at 02:05 PM
aldonaletto
Getting 4 errors, '=' and ')' invalid token, method must have a return type and identifier expected. I'm completely lost on this part now.
Jun 11 '12 at 03:22 PM
Suraci
My bad! I copied part of the instruction from the docs, and made a big mess. It should be:
Jun 11 '12 at 04:58 PM
aldonaletto
When I use errorSound = Resources.Load("wrong", typeof(AudioClip)); I still get some errors about invalid tokens '(' ')' '='. But when I run it as public AudioClip errorSound = Resources.Load("wrong", typeof(AudioClip)); I get "Cannot implicitly convert type unityEngine.Object to UnityEngine.AudioClip. An explicit conversion exists ( are you missing a cast?)" Any idea on what's going wrong? (going to give "audio.clip = (AudioClip)Resources.Load("wrong.wav");" a shot, hopefully this will do the trick).
Jun 11 '12 at 05:32 PM
Suraci
(comments are locked)
|
|
I am now trying it with Could someone help me with this problem?
(comments are locked)
|
