Hi, Heres some background on the problem. I have the earth tutorial from Cheetah 3D as my game object. It is a child of an empty game object to keep it from moving when the animation starts. I have another empty game object that has a GUI script. Just trying to make a play button that plays the animation. Anyway, when I click the play button, nothing happens. I don't think the problem is with the GUI part of the code, but rather how I'm accessing the animation object. TIA Here's the code: Code (csharp): var hSliderValue : float = 0.0; var showControls = true; var earth : GameObject; function OnGUI () { if(showControls){ showControls = GUI.Toggle (Rect (25,100, 120, 30), showControls, "Hide Controls"); hSliderValue = GUI.HorizontalSlider (Rect (25, 25, 200, 30), hSliderValue, 0.0, 100.0); var line : String; line = ""; line += hSliderValue; GUI.Label (Rect (25, 40, 100, 30), line); if(GUI.Button(Rect(50,60,50,30),"Play")){ print(Time.frameCount); earth.animation.Play("idle"); } if(GUI.Button(Rect(100,60,50,30),"Stop")){ print(Time.frameCount); earth.animation.Stop(); } }else{ showControls = GUI.Toggle (Rect (25,25, 120, 30), showControls, "Show Controls"); } }
After a good night's sleep I got it figured out. here is the code that worked: Code (csharp): var hSliderValue : float = 0.0; var showControls = true; var earth : GameObject; function OnGUI () { if(showControls){ showControls = GUI.Toggle (Rect (25,100, 120, 30), showControls, "Hide Controls"); hSliderValue = GUI.HorizontalSlider (Rect (25, 25, 200, 30), hSliderValue, 0.0, 100.0); var line : String; line = ""; line += hSliderValue; GUI.Label (Rect (25, 40, 100, 30), line); if(GUI.Button(Rect(50,60,50,30),"Play")){ print(Time.frameCount); earth.animation.Play(); } if(GUI.Button(Rect(100,60,50,30),"Stop")){ print(Time.frameCount); earth.animation.Stop(); } }else{ showControls = GUI.Toggle (Rect (25,25, 120, 30), showControls, "Show Controls"); } }