summaryrefslogtreecommitdiff
path: root/HardAnimations.cs
diff options
context:
space:
mode:
Diffstat (limited to 'HardAnimations.cs')
-rw-r--r--HardAnimations.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/HardAnimations.cs b/HardAnimations.cs
new file mode 100644
index 0000000..b14ab1c
--- /dev/null
+++ b/HardAnimations.cs
@@ -0,0 +1,64 @@
+using UnityEngine;
+
+public class HardAnimations : MonoBehaviour
+{
+ public bool isLeft;
+
+ public HardPhysicsAnimation[] animations;
+
+ private AnimationHandler animHandler;
+
+ private Vector3 currentTarget;
+
+ private Vector3 currentTargetGoal;
+
+ private float counter;
+
+ private Vector3 velocity;
+
+ private StepHandler step;
+
+ private ConfigurableJoint joint;
+
+ private Quaternion startRot;
+
+ private Quaternion startRotLocal;
+
+ private CollisionChecker checker;
+
+ private void Start()
+ {
+ animHandler = base.transform.root.GetComponent<AnimationHandler>();
+ joint = GetComponent<ConfigurableJoint>();
+ checker = GetComponent<CollisionChecker>();
+ step = base.transform.root.GetComponent<StepHandler>();
+ startRot = base.transform.rotation;
+ startRotLocal = base.transform.localRotation;
+ }
+
+ private void Update()
+ {
+ Vector3 vector = ((step.isLeft != isLeft) ? animations[animHandler.animationState].targetRotationBack : animations[animHandler.animationState].targetRotationForward);
+ if (currentTargetGoal != vector)
+ {
+ if (counter >= animations[animHandler.animationState].delay)
+ {
+ counter = 0f;
+ currentTargetGoal = vector;
+ }
+ else
+ {
+ counter += Time.deltaTime;
+ }
+ }
+ checker.active = isLeft != step.isLeft;
+ velocity += (currentTargetGoal - currentTarget) * Time.deltaTime;
+ velocity *= animations[animHandler.animationState].friction;
+ currentTarget += velocity * animations[animHandler.animationState].movementAmount * Time.deltaTime;
+ joint.SetTargetRotationLocal(Quaternion.Euler(currentTarget), startRotLocal);
+ }
+
+ private void FixedUpdate()
+ {
+ }
+}