summaryrefslogtreecommitdiff
path: root/ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-04-16 15:12:46 +0800
committerchai <215380520@qq.com>2024-04-16 15:12:46 +0800
commit84fcf0834583d755c1cfdb90d2b93e8ad2964065 (patch)
treee2ad33902ae36b49617b05362715e75ae12dfe25 /ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs
parent80983c575ec565078f757f638f3726708647080a (diff)
*misc
Diffstat (limited to 'ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs')
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs84
1 files changed, 83 insertions, 1 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs b/ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs
index 781e998..742ad29 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs
@@ -1,3 +1,5 @@
+using Rigging.Data;
+using Rigging.Inputs;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -7,7 +9,87 @@ namespace Rigging.Action
public class Movement : RiggingActionBase
{
-
+
+ private InputHandler inputHandler;
+
+ public float friction = 0.9f;
+
+ public Vector3 movementVector;
+
+ public AnimationParam<float> animationForceAmounts;
+
+ private AnimationHandler animationHandler;
+
+ private RigidbodyHolder allRigs;
+
+ public AnimationCurve jumpCurve;
+
+ public float jumpForce;
+
+ private StandingDataHandler standingData;
+
+ private MovementDataHandler data;
+
+ //private PlayerDeath death;
+
+ [HideInInspector]
+ public float multiplier = 1f;
+
+ //private WobbleShake wobbleShake;
+
+ protected override void OnStart()
+ {
+ animationForceAmounts.SetPlayer(player);
+ //wobbleShake = GetComponentInChildren<WobbleShake>();
+ //death = GetComponent<PlayerDeath>();
+ standingData = player.status.standingData;
+ inputHandler = player.input;
+ animationHandler = player.status.animation;
+ allRigs = player.status.body;
+ data = player.status.movementData;
+ }
+
+ private void FixedUpdate()
+ {
+ data.sinceJump += Time.fixedDeltaTime;
+ movementVector += inputHandler.inputMovementDirection * animationForceAmounts.current;
+ movementVector *= friction;
+ //for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
+ //{
+ // allRigs.GetAllRigs()[i].AddForce(movementVector * multiplier, ForceMode.Acceleration);
+ //}
+ allRigs.AddForceToAll(movementVector * multiplier, ForceMode.Acceleration);
+ }
+
+ public void Jump()
+ {
+ if (!(data.sinceJump < 0.5f) && !(standingData.sinceGrounded > 0.3f))
+ {
+ data.sinceJump = 0f;
+ StartCoroutine(AddJumpForce());
+ //wobbleShake.AddShake(Vector3.up * 2f, 0.8f);
+ }
+ }
+
+ private IEnumerator AddJumpForce()
+ {
+ float counter = 0f;
+ //for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
+ //{
+ // allRigs.GetAllRigs()[i].velocity = new Vector3(allRigs.GetAllRigs()[i].velocity.x, 0f, allRigs.GetAllRigs()[i].velocity.z);
+ //}
+ allRigs.ModifyVelocityForEach((_rig) => { return new Vector3(_rig.velocity.x, 0f, _rig.velocity.z); });
+ while (counter < jumpCurve.keys[jumpCurve.length - 1].time)
+ {
+ counter += Time.deltaTime;
+ //for (int j = 0; j < allRigs.GetAllRigs().Length; j++)
+ //{
+ // allRigs.GetAllRigs()[j].AddForce(Vector3.up * multiplier * jumpForce * jumpCurve.Evaluate(counter) * Time.deltaTime, ForceMode.Acceleration);
+ //}
+ allRigs.AddForceToAll(Vector3.up * multiplier * jumpForce * jumpCurve.Evaluate(counter) * Time.deltaTime, ForceMode.Acceleration);
+ yield return null;
+ }
+ }
}
} \ No newline at end of file