Animation:
Animation Clip 动画剪辑
对于Animation Clip可以进行动画分割
对于每一个clip,在使用脚本来控制播放。
Animator:
任何一个拥有avatar的GameObject都将拥有一个Animator组件用来连接角色和他的行为。
Animator Controller:动画控制器
一般只需要选择一种方式。
本篇主要介绍的是Animation。
1、首先导入大白的动画模型,FBX格式模型,包含有动画帧。
U3d导入动画有两种,一种是包含动画,即动画和模型一体,一种是动画和模型分离,分别导入,这时需要使用动画系统来进行操作。
我这里使用第一种方式,这两种方式都需要CG工程师配合来完成。
在成功导入模型后,如果发现
2、导入之后,是一个整体的动画,需要对动画进行分解:
首先新建Animation Clip,并命名:
然后设置起始帧,一般起始帧是由建模时确定。
在大白模型目录下,就多出来这几个Animation clips:
3、给模型添加Animation组件
设置Animation的size,然后来写脚本进行控制。
复制代码
using UnityEngine;
using System.Collections;
public class AnimateControl : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
if (GUI.Button (new Rect (0, 0, 100, 80),"完整动画")) {
animation.Play();
}
if (GUI.Button (new Rect (0, 100, 100, 80),"站立")) {
transform.animation.Play("Test01");
}
if (GUI.Button (new Rect (0, 200, 100, 80),"张望")) {
transform.animation.Play("Test02");
}
if (GUI.Button (new Rect (0, 300, 100, 80),"跑动")) {
transform.animation.Play("Test03");
}
if (GUI.Button (new Rect (0, 400, 100, 80),"招手")) {
transform.animation.Play("Test04");
}
}
}
4、AR场景
将上面的脚本绑定到模型上,然后将模型放到AR场景中即可。
请尊重所有作者的劳动,转载请注明原帖来自 AR学院 !