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);