hello,
i actually try to make a simple script that launch an animation when i clic an a GUI button.
the script is on main camera and the animation is on an animated object tagged “player”.
after this i will have to launch sound attached to helico.
function OnGUI ( ) {
instructionText = "Instructions\nPress Left and Right arrows to move\nPress spacebar to fire";
GUI.Label(Rect(10,10,300,200), instructionText);
if(GUI.Button(Rect(10,60,200,50),"Start")){
GameObject.Find (helico);
(animation.Play ("turn") );
Your animation call there is trying to call an animation on the camera, rather than the player you’re after.
Try something like this :
function OnGUI ( )
{
instructionText = "Instructions\nPress Left and Right arrows to move\nPress spacebar to fire";
GUI.Label(Rect(10,10,300,200), instructionText);
if(GUI.Button(Rect(10,60,200,50),"Start"))
{
// You need to store the object you search for
var playerObject : GameObject = GameObject.Find (helico);
// then use the stored reference to that object to play it's animation.
playerObject.animation.Play ("turn");
}
}