From 6ce8b9e22fc13be34b442c7b6af48b42cd44275a Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Wed, 13 Mar 2024 11:00:58 +0800 Subject: +init --- SetAnimationByInput.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 SetAnimationByInput.cs (limited to 'SetAnimationByInput.cs') diff --git a/SetAnimationByInput.cs b/SetAnimationByInput.cs new file mode 100644 index 0000000..cc50e5a --- /dev/null +++ b/SetAnimationByInput.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +public class SetAnimationByInput : MonoBehaviour +{ + private InputHandler input; + + private AnimationHandler anim; + + private StandingDataHandler standingData; + + private void Start() + { + anim = GetComponent(); + input = GetComponent(); + standingData = GetComponent(); + } + + private void Update() + { + if ((double)standingData.sinceGrounded > 0.2) + { + anim.animationState = 3; + } + else if (input.inputMovementDirection.magnitude > 0.1f) + { + if (input.isSpringting) + { + anim.animationState = 1; + } + else + { + anim.animationState = 2; + } + } + else + { + anim.animationState = 0; + } + } +} -- cgit v1.1-26-g67d0