summaryrefslogtreecommitdiff
path: root/_ActiveRagdoll/Handlers/StandingDataHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '_ActiveRagdoll/Handlers/StandingDataHandler.cs')
-rw-r--r--_ActiveRagdoll/Handlers/StandingDataHandler.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/_ActiveRagdoll/Handlers/StandingDataHandler.cs b/_ActiveRagdoll/Handlers/StandingDataHandler.cs
new file mode 100644
index 0000000..a72ec09
--- /dev/null
+++ b/_ActiveRagdoll/Handlers/StandingDataHandler.cs
@@ -0,0 +1,69 @@
+using UnityEngine;
+
+public class StandingDataHandler : MonoBehaviour
+{
+ public Rigidbody mainRig;
+
+ public float sinceGrounded; // ÀëµØÊ±¼ä
+
+ public float sinceLanded;
+
+ public bool isGrounded;
+
+ public float distanceToGround = 1f;
+
+ private bool hasRecievedTouchedGround;
+
+ private MovementDataHandler moveMentData;
+
+ private PlayerKnockback knockback;
+
+ private WobbleShake wobbleShake;
+
+ private void Start()
+ {
+ wobbleShake = GetComponentInChildren<WobbleShake>();
+ knockback = GetComponent<PlayerKnockback>();
+ }
+
+ private void FixedUpdate()
+ {
+ sinceGrounded += Time.fixedDeltaTime;
+ sinceLanded += Time.fixedDeltaTime;
+ moveMentData = GetComponent<MovementDataHandler>();
+ if ((double)sinceGrounded > 0.1)
+ {
+ isGrounded = false;
+ }
+ }
+
+ private void LateUpdate()
+ {
+ hasRecievedTouchedGround = false;
+ }
+
+ public void TouchGround(float distance, Vector3 normal)
+ {
+ if (sinceGrounded > 0.5f && (bool)wobbleShake)
+ {
+ wobbleShake.AddShake(-Vector3.up * 5f * Mathf.Pow(sinceGrounded, 1.5f), 0.8f);
+ }
+ if (sinceGrounded > 0.5f)
+ {
+ Land(sinceGrounded);
+ }
+ sinceGrounded = 0f;
+ isGrounded = true;
+ if (distance > distanceToGround || !hasRecievedTouchedGround)
+ {
+ distanceToGround = distance;
+ }
+ hasRecievedTouchedGround = true;
+ moveMentData.SetSlope(normal);
+ }
+
+ private void Land(float landForce)
+ {
+ sinceLanded = 0f;
+ }
+}