Character Animation Setup

確認済のバージョン: 5.2


難易度: 初級

In this session, we will look at the basic steps needed to import and setup a rigged character in Unity's animation system.

Character Animation Setup

初級 Animation

Code snippet

using UnityEngine;

public class LocomotionSMB : StateMachineBehaviour
    public float m_Damping = 0.15f;

    private readonly int m_HashHorizontalPara = Animator.StringToHash ("Horizontal");
    private readonly int m_HashVerticalPara = Animator.StringToHash ("Vertical");

    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        float horizontal = Input.GetAxis ("Horizontal");
        float vertical = Input.GetAxis ("Vertical");

        Vector2 input = new Vector2(horizontal, vertical).normalized;

        animator.SetFloat(m_HashHorizontalPara, input.x, m_Damping, Time.deltaTime);
        animator.SetFloat(m_HashVerticalPara, input.y, m_Damping, Time.deltaTime);