Hey guys i can get my model to play its animation on a GUI button press but when i want to do i have it play forward on first press then play the animtion in reverse on the second press and so on. Here is what i have so far but it dosnt seem to like the animation.time and animation.speed.
var time:float;
var speed:float;
function OnGUI()
{
//Button 1
if(GUI.Button (Rect(1060,0,200,100), "Explode View"))
{
{
(animationstate.time = 0.0)
animation.Play();
}
else
{
animation.Play();
animationstate.speed = -1.0
}
}
}
Thanks D
Hope this code helps. i am not good in Unity Javascript, so watch out for errors
var time:float;
var speed:float;
var isMoveForwardAnim:boolean = true; //Initialy its set to True to move forward
function OnGUI()
{
//Button 1
if(GUI.Button (Rect(1060,0,200,100), "Explode View"))
{
if(!animation.isPlaying) //Prevent from playing if animation is already playing
{
if(isMoveForwardAnim)
{
animationstate.speed = 1.0;
animation.Play("Walk");
isMoveForwardAnim = false;
}
else
{
animationstate.speed = -1.0;
animation.Play("Walk");
isMoveForwardAnim = true;
}
}
}
}
Thanks but im getting this error from it and im not sure how to give it access.
Assets/MyScripts/ExplodeView.js(27,42): BCE0020: An instance of type ‘UnityEngine.AnimationState’ is required to access non static member ‘speed’.