首页 > 技术文章 > u3d animation运用明细

dragon2012 2014-08-27 10:59 原文

u3d的动作legacy模式,经测试得出

using UnityEngine;
using System.Collections;

public class AnimateCon : MonoBehaviour
{

    // Use this for initialization
    void Start () 
    {
    
    }
    
    // Update is called once per frame
    void Update ()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            animation.Play("Wait");
            Debug.Log("key a");
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            animation.Play("right");
            Debug.Log("key b");
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            animation.Play("left");
            Debug.Log("key c");
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            animation.Stop();
        
        }
    }
}

1.在播放动作a的时候,你按下键,还是播放a,如果此时a动作没播放结束,那么继续播放a动作,既不起反应

2.在播放动作a的时候,你按下键,播放b动作,那么此时,结束动作a的播放,开始播放b动作

3.在播放动作a的时候,你按键发送animation.Stop();,那么此时  ,a动作不管有没有播放完,立即停在按键的那一时刻,摆个pos

 

推荐阅读