您的位置:首页 > 移动开发 > Unity3D

【unity3d study ---- 麦子学院】---------- unity3d常用组件及分析 ---------- Animator动画状态机

2016-10-18 12:11 423 查看
Animator是unity 4版本之后的新动画

可以在编辑器中直接编辑连线各个动画的转换,也可以是用代码直接调用底层来转换动画

代码:

1 using UnityEngine;
2 using System.Collections;
3
4 public class AnimationTest : MonoBehaviour {
5
6     // Animation animation;
7     Animator animator;
8
9     // Use this for initialization
10     void Start () {
11
12         // animation = GetComponent<Animation> ();  // 获取 Animation组件
13         animator = GetComponent<Animator> ();
14     }
15
16     // Update is called once per frame
17     void Update () {
18
19         // animation.Play ("walk"); // 播放动画 , 动画名称
20
21         // 参数:动画名称,间隔(当前动画到指定动画之间的过渡时间,为0的话就直接执行下一动画,为1的话就在当前动画播放完成后执行指定动画)
22         // layer(当前所在的那个layer),
23         animator.CrossFade ("walk", 0, -1, 0); // 在不使用unity的animator编辑器中的连线时,直接调用底层来播放动画
24
25     }
26 }


使用unity直接编辑动画转换 unity 版本是4.7.2f
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐