using UnityEngine; public class MovementDataHandler : MonoBehaviour { [HideInInspector] public Vector3 groundedForward; [HideInInspector] public Vector3 right; [HideInInspector] public Vector3 left; [HideInInspector] public Vector3 groundedBack; private Transform hip; private Transform torso; public Transform rotationTarget; [HideInInspector] public float slopeStrenght; public float slopeVelocityStrenght; [HideInInspector] public float sinceJump = 1f; [HideInInspector] public Vector3 groundNormal; private InputHandler inputHandler; private Transform leftKnee; private Transform rightKnee; private void Start() { inputHandler = GetComponent(); hip = GetComponentInChildren().transform; torso = GetComponentInChildren().transform; if (!rotationTarget) { rotationTarget = GetComponentInChildren().transform; } KneeLeft componentInChildren = GetComponentInChildren(); if ((bool)componentInChildren) { leftKnee = componentInChildren.transform; } KneeRight componentInChildren2 = GetComponentInChildren(); if ((bool)componentInChildren2) { rightKnee = componentInChildren2.transform; } } 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); Debug.DrawLine(hip.position, hip.position + groundedForward * 10f); } public void SetSlope(Vector3 normal) { groundNormal = normal; slopeStrenght = Vector3.Cross(rotationTarget.right, normal).y; Vector3 lhs = Vector3.Cross(Vector3.up, inputHandler.inputMovementDirection); slopeVelocityStrenght = Vector3.Cross(lhs, normal).y; } public float GetSmallestLegAngle() { float num = Vector3.Angle(leftKnee.forward, Vector3.down); float num2 = Vector3.Angle(rightKnee.forward, Vector3.down); if (num < num2) { return num; } return num2; } }