• [Unity学习随笔4/28] 解决trigger触发累积的方法


    快速触发两次trigger, 人物会跳两次

    为当前状态机添加脚本

    ClearAtEnter:在进入当前状态的时候就需要砍掉的信号,如这里的jump

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class FSMClearSignals : StateMachineBehaviour
    {
        public string[] clearAtEnter;
        public string[] clearAtExit;
        // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            foreach (var signal in clearAtEnter)
            {
                animator.ResetTrigger(signal);
            }
        }
    
        // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
        //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        //{
        //    
        //}
    
        // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
        override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            foreach (var signal in clearAtExit)
            {
                animator.ResetTrigger(signal);
            }
        }
    
        // OnStateMove is called right after Animator.OnAnimatorMove()
        //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        //{
        //    // Implement code that processes and affects root motion
        //}
    
        // OnStateIK is called right after Animator.OnAnimatorIK()
        //override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        //{
        //    // Implement code that sets up animation IK (inverse kinematics)
        //}
    }
    

  • 相关阅读:
    Ubuntu 侧边栏和顶栏设置
    ubuntu 下安装微软字体和 console
    vim 的 auto-pairs 设置
    linux上的常用的一些操作
    断点模式
    GIT(git)简单操作
    制表符 的用法
    如何解决ASCII 字符显示不出来的情况
    01_js 快速入门
    神代码,结束进程神方法
  • 原文地址:https://www.cnblogs.com/Knight02/p/16255357.html
Copyright © 2020-2023  润新知