动画循环播放

 
  
#pragma strict

var t1:boolean=false;
var t2:boolean=false;
var t3:boolean=false;
var currentTime:float;
var indvel:float;

function Start(){
   currentTime = Time.time;
   t1 = true;
}
   
function Update(){
  Play();
}
   
function Play() {
 if(t1){ 
       animation.CrossFade("Run",0.2,PlayMode.StopAll);
    if(Time.time>currentTime+indvel*2) {
        if(!t2)t2=true;
     if(t1) t1=false;
     currentTime=Time.time;
    }
}
else if(t2){
    animation.CrossFade("Walk",0.2,PlayMode.StopAll);
 if(Time.time>currentTime+indvel/2) {
        if(t2)t2=false;
     if(!t3) t3=true;
     currentTime=Time.time;
    }
}
else if(t3){
    animation.CrossFade("Idle",0.2,PlayMode.StopAll);
 if(Time.time>currentTime+indvel) {
        if(t3)t3=false;
     if(!t1) t1=true;
     currentTime=Time.time;
    }
}
 
}
 
  

 

#pragma strict
var AN:Animation;
var bool = true;
var ani:String = "can";
function Start () {
   bool = true;
  AN =  GetComponent.<Animation>();
  print(animation["Run"].clip.length);
  
    do{
      yield StartCoroutine(ani);
    }while(true);
}

function Update(){
   if(bool)
    ani = "can";
    else
    ani = "to";
    
}

function can(){
   yield StartCoroutine("doit");
    yield StartCoroutine("ro");
}

function doit(){
   AN.CrossFade("Run",0.2);
   yield WaitForSeconds (animation["Run"].clip.length*2);
}

function ro(){
   AN.CrossFade("Walk",0.2);// Wait for the animation to have finished
   yield WaitForSeconds (animation["Walk"].clip.length*2);
}

function to(){

   AN.CrossFade("Idle",0.2);// Wait for the animation to have finished
   //yield WaitForSeconds (animation["Walk"].clip.length*5);
}


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值