diff options
Diffstat (limited to 'ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs')
-rw-r--r-- | ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs index 032cf3f..7e673b1 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs @@ -1,23 +1,65 @@ +using Rigging.BodyPart; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Rigging.Data { - + //Player <StepHandler> 更新脚步切换状态,返回哪个脚在前,哪个在后,配合AnimationObject使用 public class StepHandler : RiggingDataBase { - // Start is called before the first frame update - void Start() + + public float staticCounter; + + public Step steps; + + public bool isLeft;//左脚还是右脚在前面 + + private float counter; + + private Transform leftLeg; + + private Transform rightLeg; + + private AnimationHandler animationHandler; + + private Transform hip; + + protected override void OnStart() { - + if (staticCounter == 0f) + { + leftLeg = player.body.legLeft.transform; + rightLeg = player.body.legRight.transform; +// animationHandler = GetComponent<AnimationHandler>(); + hip = player.body.hip.transform; + } } - // Update is called once per frame - void Update() + protected override void OnUpdate() { - + counter += Time.deltaTime; + if (staticCounter != 0f) + { + if (counter > staticCounter) + { + Switch(); + } + } + else if (counter > steps.minTime + && (steps.minAngle == 0f || steps.minAngle < Vector3.Angle(leftLeg.forward, rightLeg.forward)) + && isLeft == hip.InverseTransformPoint(leftLeg.position + leftLeg.forward).z > hip.InverseTransformPoint(rightLeg.position + rightLeg.forward).z) + { + Switch(); + } } + + private void Switch() + { + isLeft = !isLeft; + counter = 0f; + } + } }
\ No newline at end of file |