using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerAnimationHandler : MonoBehaviour { public Animator animator; private float previousMop1Clean; private float previousMop2Clean; void Start() { animator = GetComponentInChildren(); previousMop1Clean = BloodComputeShader.Instance.mop1Clean; previousMop2Clean = BloodComputeShader.Instance.mop2Clean; } private void Update() { var playerInput = GetComponent(); if (playerInput.PlayerNum == 0) { RunMop1(BloodComputeShader.Instance.mop1Clean >= 10); } else { RunMop2(BloodComputeShader.Instance.mop2Clean >= 10); } // Current frame values //float currentMop1Clean = BloodComputeShader.Instance.mop1Clean; //float currentMop2Clean = BloodComputeShader.Instance.mop2Clean; //RunMop(currentMop1Clean < previousMop1Clean); //RunMop(currentMop2Clean < previousMop2Clean); //// Update previous values for the next frame //previousMop1Clean = currentMop1Clean; //previousMop2Clean = currentMop2Clean; } public void Idle() { animator.SetTrigger("Idle"); } public void Run(bool state) { animator.SetBool("IsRunning", state); } public void Swing(bool state) { animator.SetBool("IsSwinging", state); } public void Mop() { animator.SetTrigger("Mop"); } public void RunMop1(bool active) { animator.SetBool("RunMop1", active); } public void RunMop2(bool active) { animator.SetBool("RunMop2", active); } }