需要实现功能
角色移动时,播放对应的动画
知识点
Unity中 Animator 控制器 和 动画混合树
完整代码
using UnityEngine;
public class SimpleMoveAni : MonoBehaviour
{
private Animator _animator;
void Awake()
{
_animator = GameObject.Find("MainPlayer/Player").GetComponent<Animator>();
}
void Update()
{
SetMoveAni();
}
/// <summary>
/// 设置移动动画
/// </summary>
void SetMoveAni()
{
SimpleMsgMechanism.ReceiveMsg("PlayerMove", msg =>
{
float ani = (float) msg;
_animator.SetFloat("ForwardMove", ani);
});
}
}