aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/AnimatorHandler.cs
diff options
context:
space:
mode:
authorSmallFox <2806143047@qq.com>2026-05-14 21:17:29 +0800
committerSmallFox <2806143047@qq.com>2026-05-14 21:17:29 +0800
commit41def44651b5a7c9e917395fad5e7b480640a3a2 (patch)
treefe99b653b956a1be62392ddb2a5eae31f34e09a9 /Assets/Scripts/AnimatorHandler.cs
parent738e4b973666742b077c285272d9eb50072d49dd (diff)
Movement完工
写完了移动,准备开工相机视角
Diffstat (limited to 'Assets/Scripts/AnimatorHandler.cs')
-rw-r--r--Assets/Scripts/AnimatorHandler.cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/Assets/Scripts/AnimatorHandler.cs b/Assets/Scripts/AnimatorHandler.cs
new file mode 100644
index 0000000..d95d12b
--- /dev/null
+++ b/Assets/Scripts/AnimatorHandler.cs
@@ -0,0 +1,92 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace DS
+{
+ public class AnimatorHandler : MonoBehaviour
+ {
+ public Animator animator;
+ private int _vertical;
+ private int _horizontal;
+ public bool canRotate;
+
+ public void Initialize()
+ {
+ animator = GetComponent<Animator>();
+ _vertical = Animator.StringToHash("Vertical");
+ _horizontal = Animator.StringToHash("Horizontal");
+ }
+
+ public void UpdateAnimatorValues(float verticalMovement, float horizontalMovement)
+ {
+ #region Vertical
+
+ float v = 0;
+
+ if (verticalMovement > 0 && verticalMovement < 0.55f)
+ {
+ v = 0.5f;
+ }
+ else if(verticalMovement > 0.55f)
+ {
+ v = 1;
+ }
+ else if (verticalMovement < 0 && verticalMovement > -0.55f)
+ {
+ v = -0.5f;
+ }
+ else if(verticalMovement < -0.55f)
+ {
+ v = -1;
+ }
+ else
+ {
+ v = 0;
+ }
+
+ #endregion
+
+ #region Horizontal
+
+ float h = 0;
+
+ if (horizontalMovement > 0 && horizontalMovement < 0.55f)
+ {
+ h = 0.5f;
+ }
+ else if(horizontalMovement > 0.55f)
+ {
+ h = 1;
+ }
+ else if (horizontalMovement < 0 && horizontalMovement > -0.55f)
+ {
+ h = -0.5f;
+ }
+ else if(horizontalMovement < -0.55f)
+ {
+ h = -1;
+ }
+ else
+ {
+ h = 0;
+ }
+
+ #endregion
+
+ animator.SetFloat(_vertical,v,0.1f,Time.deltaTime);
+ animator.SetFloat(_horizontal,h,0.1f,Time.deltaTime);
+ }
+
+ public void CanRotate()
+ {
+ canRotate = true;
+ }
+
+ public void StopRotation()
+ {
+ canRotate = false;
+ }
+ }
+
+}