hey folks, another newbie question, likely from a JavaScript sytax angle.
i want to send a message to select a specific loop number and have the receiving Game Object trigger that sound from an array. Heres what i have so far:
var targetObject : GameObject;
var soundNum : int;
function OnTriggerEnter()
{
targetObject.SendMessage(targetObject, soundNum );
}
i believe this sets a Game Object to look for and should send an int variable called numSound to the game object
on the receiving end is an object with an AudioSource on it and this script:
var clipNumber : AudioClip[];
function PlayNumberSound(soundNum : int)
{
audio.clip = clipNumber[soundNum - 1]; // i-1 because array starts at 0
audio.loop = true;
audio.play();
}
this sets up an array of sounds which i would like to pass the value soundNum to from the sending script. the following compiles fine but results in a rather ominous MissingMethodException: Method not found: ‘UnityEngine.AudioSource.play’. also the sound does not trigger. when the trigger is reached the loop cuts out but no other loop plays.
i’m suspecting a syntax error in terms of my javascript and have tried variations but no luck so far.
any help vastly appreciated,
scott