diff options
Diffstat (limited to 'ActiveRagdoll/Assets/TABG/Scripts/Action')
-rw-r--r-- | ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs | 19 | ||||
-rw-r--r-- | ActiveRagdoll/Assets/TABG/Scripts/Action/Movement.cs | 84 | ||||
-rw-r--r-- | ActiveRagdoll/Assets/TABG/Scripts/Action/Standing.cs | 7 |
3 files changed, 99 insertions, 11 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs b/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs index 2e25b68..a15d114 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs @@ -27,9 +27,13 @@ namespace Rigging.Action } } - public float balanceForce; + public AnimationParam<float> balanceForces; - public float footCenterForces; + //public float balanceForce; //50 + + public AnimationParam<float> footCenterForces; + + //public float footCenterForces;//100 private float muscleMultiplier; //1 @@ -42,6 +46,9 @@ namespace Rigging.Action footLeft = player.body.kneeLeft.GetComponent<Rigidbody>(); footRight = player.body.kneeRight.GetComponent<Rigidbody>(); hip = player.body.hip.GetComponent<Rigidbody>(); + + footCenterForces.SetPlayer(player); + balanceForces.SetPlayer(player); } private void BalanceLegs() @@ -73,8 +80,8 @@ namespace Rigging.Action GLHandle.DrawLine(vector, vector + vector4); GLHandle.DrawLine(vector2, vector2 + vector4); - footLeft.AddForceAtPosition(vector4 * muscleMultiplier * crouchMultiplier * balanceForce, vector, ForceMode.Acceleration); - footRight.AddForceAtPosition(vector4 * muscleMultiplier * crouchMultiplier * balanceForce, vector2, ForceMode.Acceleration); + footLeft.AddForceAtPosition(vector4 * muscleMultiplier * crouchMultiplier * balanceForces.current, vector, ForceMode.Acceleration); + footRight.AddForceAtPosition(vector4 * muscleMultiplier * crouchMultiplier * balanceForces.current, vector2, ForceMode.Acceleration); } } @@ -95,7 +102,7 @@ namespace Rigging.Action if (vector.y + 0.3f < hip.worldCenterOfMass.y) { vector3.y = 0f; - footLeft.AddForceAtPosition((centerOfMass - vector3) * muscleMultiplier * footCenterForces, vector, ForceMode.Acceleration); + footLeft.AddForceAtPosition((centerOfMass - vector3) * muscleMultiplier * footCenterForces.current, vector, ForceMode.Acceleration); GLHandle.DrawLine(vector, vector + (centerOfMass - vector3)); } @@ -104,7 +111,7 @@ namespace Rigging.Action if (vector4.y + 0.3f < hip.worldCenterOfMass.y) { vector4.y = 0f; - footRight.AddForceAtPosition((centerOfMass - vector4) * muscleMultiplier * footCenterForces, vector2, ForceMode.Acceleration); + footRight.AddForceAtPosition((centerOfMass - vector4) * muscleMultiplier * footCenterForces.current, vector2, ForceMode.Acceleration); GLHandle.DrawLine(vector2, vector2 + (centerOfMass - vector4)); } } 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 diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Action/Standing.cs b/ActiveRagdoll/Assets/TABG/Scripts/Action/Standing.cs index 2500de5..a4eefd8 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Action/Standing.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Action/Standing.cs @@ -21,20 +21,19 @@ namespace Rigging.Action private StandingDataHandler standingData; - public AnimationCurve curve; + public AnimationParam<AnimationCurve> curves; protected override void OnStart() { standingData = player.status.standingData; - + curves.SetPlayer(player); } protected override void OnFixedUpdate() { - Stand(curve); + Stand(curves.current); } - private void Stand(AnimationCurve curve) { //float num = 0f; |