var sliderValue = 1.0;
//定义动画速度
var animationspeed = 0.5;
//定义两组动画段的名字(这里要事先在max里做好两组动画,导入时设置一下起止时间)
var clip1 : String = "clip1";
var clip2 : String = "clip2";
//定义要做运动的物体的标签
var touchableTag1 : String = "";
//记录开关状态的参数
var animationed1 : boolean = false;
//刷帧函数要检测当左键按下时,做哪个动画段
function Update () {
//以下为点击物体的固定模式,记住就好
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
//当按下左键,并且门为关时,运行开函数,否则运行关函数
if (Physics.Raycast(ray,hit) && Input.GetMouseButtonDown(0) )
{
if (animationed1 == false)
{
if (https://www.docsj.com/doc/5b10497993.html,pareTag(touchableTag1))
actionrun();
}
else if (animationed1 == true)
{
if (https://www.docsj.com/doc/5b10497993.html,pareTag(touchableTag1))
actionrun_fan();
}
}
}
//开门动画
function actionrun() : boolean{
animation.Play(clip2);
animation[clip2].speed = animationspeed; animationed1 = true;//要改变门的状态为开哦
}
//反向开门动画(倒放)
function actionrun_fan() : boolean{
animation.Play(clip2);
animation[clip2].speed = animationspeed * -1.0; animationed1 = false;//要改变门的状态为关哦
}