Unity_AnimatorLayers动画分层_068

来源:互联网 发布:农村淘宝报名条件 编辑:程序博客网 时间:2024/05/16 06:59

第一步创建动画层
这里写图片描述

这里写图片描述
第二步添加遮罩Avatar Mask
这里写图片描述
第三步设置权重
这里写图片描述

模型上的源码:

using UnityEngine;using System.Collections;public class AvatarMaskTest : MonoBehaviour {    private Animator m_animator;    // Use this for initialization    void Start () {        m_animator = this.GetComponent<Animator>();    }    // Update is called once per frame    void Update () {        if (Input.GetKeyDown(KeyCode.R))        {            m_animator.SetBool("run",true);        }        if (Input.GetKeyUp(KeyCode.R))        {            m_animator.SetBool("run", false);        }        if (Input.GetKeyDown(KeyCode.J))        {            m_animator.SetBool("jump", true);        }        if (Input.GetKeyUp(KeyCode.J))        {            m_animator.SetBool("jump", false);        }        if (Input.GetKeyDown(KeyCode.W))        {            m_animator.SetBool("wave", true);        }        if (Input.GetKeyUp(KeyCode.W))        {            m_animator.SetBool("wave", false);        }    }}

动画效果:
这里写图片描述

原创粉丝点击