using System.Collections; using System.Collections.Generic; using UnityEngine; public class AnimatorEvent : StateMachineBehaviour { static int statePropertyId = Animator.StringToHash("State"); static Dictionary<int, string> hashToName = new Dictionary<int, string>(); static AnimatorEvent() { foreach (string name in new string[] { "eat", "hit", "animation"}) hashToName.Add(Animator.StringToHash(name), name); } override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { animator.SetInteger(statePropertyId, -1); } }
Unity AnimatorEvent
最新推荐文章于 2024-06-04 09:00:35 发布
本文深入探讨Unity中的AnimatorEvent,讲解如何利用它实现游戏对象的行为控制。我们将学习AnimatorEvent的工作原理,创建自定义事件,以及在C#脚本中响应这些事件的方法。通过实例,了解如何在游戏场景中无缝集成动画与逻辑,提升游戏交互体验。
摘要由CSDN通过智能技术生成