summaryrefslogtreecommitdiff
path: root/_ActiveRagdoll/StepHandler.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-03-13 11:38:18 +0800
committerchai <215380520@qq.com>2024-03-13 11:38:18 +0800
commit134f1deb971b0514a26e04e23926f91983a5497f (patch)
treed790681bb000c07abae9f557a7d0ef2442fac467 /_ActiveRagdoll/StepHandler.cs
parent6ce8b9e22fc13be34b442c7b6af48b42cd44275a (diff)
* move
Diffstat (limited to '_ActiveRagdoll/StepHandler.cs')
-rw-r--r--_ActiveRagdoll/StepHandler.cs53
1 files changed, 53 insertions, 0 deletions
diff --git a/_ActiveRagdoll/StepHandler.cs b/_ActiveRagdoll/StepHandler.cs
new file mode 100644
index 0000000..fd8110b
--- /dev/null
+++ b/_ActiveRagdoll/StepHandler.cs
@@ -0,0 +1,53 @@
+using UnityEngine;
+
+public class StepHandler : MonoBehaviour
+{
+ public float staticCounter;
+
+ public Step[] steps;
+
+ public bool isLeft;
+
+ private float counter;
+
+ private Transform leftLeg;
+
+ private Transform rightLeg;
+
+ private AnimationHandler animationHandler;
+
+ private Transform hip;
+
+ private void Start()
+ {
+ if (staticCounter == 0f)
+ {
+ leftLeg = GetComponentInChildren<LegLeft>().transform;
+ rightLeg = GetComponentInChildren<LegRight>().transform;
+ animationHandler = GetComponent<AnimationHandler>();
+ hip = GetComponentInChildren<Hip>().transform;
+ }
+ }
+
+ private void Update()
+ {
+ counter += Time.deltaTime;
+ if (staticCounter != 0f)
+ {
+ if (counter > staticCounter)
+ {
+ Switch();
+ }
+ }
+ else if (counter > steps[animationHandler.animationState].minTime && (steps[animationHandler.animationState].minAngle == 0f || steps[animationHandler.animationState].minAngle < Vector3.Angle(leftLeg.forward, rightLeg.forward)) && isLeft == hip.InverseTransformPoint(leftLeg.position + leftLeg.forward).z > hip.InverseTransformPoint(rightLeg.position + rightLeg.forward).z)
+ {
+ Switch();
+ }
+ }
+
+ private void Switch()
+ {
+ isLeft = !isLeft;
+ counter = 0f;
+ }
+}