分享

(Unity3d)Vuforia开发基础七-动画系统

 雪柳花明 2016-12-08

Unity3D动画系统主要有两种:Animator和Animation.
Animation:
Animation Clip 动画剪辑
对于Animation Clip可以进行动画分割
对于每一个clip,在使用脚本来控制播放。


Animator:
任何一个拥有avatar的GameObject都将拥有一个Animator组件用来连接角色和他的行为。
Animator Controller:动画控制器


一般只需要选择一种方式。
本篇主要介绍的是Animation。

1、首先导入大白的动画模型,FBX格式模型,包含有动画帧。
U3d导入动画有两种,一种是包含动画,即动画和模型一体,一种是动画和模型分离,分别导入,这时需要使用动画系统来进行操作。
我这里使用第一种方式,这两种方式都需要CG工程师配合来完成。

在成功导入模型后,如果发现Animations中没有内容,那么就将Rig设置为Generic:


2、导入之后,是一个整体的动画,需要对动画进行分解:

首先新建Animation Clip,并命名:

然后设置起始帧,一般起始帧是由建模时确定。
在大白模型目录下,就多出来这几个Animation clips:

3、给模型添加Animation组件

设置Animationsize,然后来写脚本进行控制。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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场景中即可。



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多