diff options
Diffstat (limited to 'ActiveRagdoll/Assets/TABG/Scripts/Data')
3 files changed, 64 insertions, 10 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs index 9a87817..073ecbd 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs @@ -1,3 +1,6 @@ +using Rigging.BodyPart; +using Rigging.Debugging; +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -6,16 +9,48 @@ namespace Rigging.Data { public class MovementDataHandler : RiggingDataBase { - // Start is called before the first frame update - void Start() + + [HideInInspector, NonSerialized] + public Vector3 groundedForward; + + [HideInInspector, NonSerialized] + public Vector3 right; + + [HideInInspector, NonSerialized] + public Vector3 left; + + [HideInInspector, NonSerialized] + public Vector3 groundedBack; + + [HideInInspector, NonSerialized] + public float sinceJump = 1f; + + [HideInInspector, NonSerialized] + public float slopeStrenght; + + public Transform rotationTarget; + + private Rigging.BodyPart.Hip hip; + + protected override void OnStart() { - + base.OnStart(); + + hip = player.body.hip; } - // Update is called once per frame - void Update() + private void Update() { - + sinceJump += Time.deltaTime; + groundedForward = rotationTarget.forward; + groundedForward.y = slopeStrenght * 1f; + groundedForward = groundedForward.normalized; + groundedBack = -groundedForward; + right = rotationTarget.right; + left = -rotationTarget.right; + slopeStrenght = Mathf.Lerp(slopeStrenght, 0f, Time.deltaTime * 1f); + + GLHandle.DrawLine(hip.transform.position, hip.transform.position + groundedForward * 10f); } } diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs index 2afef1d..3a90eb6 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs @@ -5,9 +5,10 @@ using UnityEngine; namespace Rigging.Data { + [DisallowMultipleComponent] public class SetAnimationByInput : RiggingDataBase { - private InputHandler input; + private Rigging.Inputs.InputHandler input; private AnimationHandler anim; @@ -15,14 +16,32 @@ namespace Rigging.Data protected override void OnStart() { - input = player.status.input; + input = player.input; anim = player.status.animation; standingData = player.status.standingData; } private void Update() { - + if ((double)standingData.sinceGrounded > 0.2) + { + anim.animationState = 3; // jump + } + else if (input.inputMovementDirection.magnitude > 0.1f) + { + if (input.isSpringting) + { + anim.animationState = 1; // sprint + } + else + { + anim.animationState = 2; // run + } + } + else + { + anim.animationState = 0; // stand + } } } diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs index 7e673b1..e04ff0d 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs @@ -31,7 +31,7 @@ namespace Rigging.Data { leftLeg = player.body.legLeft.transform; rightLeg = player.body.legRight.transform; -// animationHandler = GetComponent<AnimationHandler>(); + animationHandler = player.status.animation; hip = player.body.hip.transform; } } |