From 6ce8b9e22fc13be34b442c7b6af48b42cd44275a Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Wed, 13 Mar 2024 11:00:58 +0800 Subject: +init --- FootHandler.cs | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 FootHandler.cs (limited to 'FootHandler.cs') diff --git a/FootHandler.cs b/FootHandler.cs new file mode 100644 index 0000000..7343e21 --- /dev/null +++ b/FootHandler.cs @@ -0,0 +1,75 @@ +using UnityEngine; + +public class FootHandler : MonoBehaviour +{ + private AnimationHandler animHandler; + + private Collider collider; + + public PhysicMaterial slippery; + + private PhysicMaterial footMaterial; + + private Transform torso; + + private MovementDataHandler moveData; + + private Rigidbody rig; + + private RotationHandler rot; + + private Vector3 rotationDif; + + private AnimationObject anim; + + private StepHandler handler; + + private void Start() + { + animHandler = base.transform.root.GetComponent(); + moveData = base.transform.root.GetComponent(); + collider = GetComponentInChildren(); + rig = GetComponent(); + footMaterial = collider.material; + torso = base.transform.root.GetComponentInChildren().transform; + rot = base.transform.root.GetComponent(); + handler = base.transform.root.GetComponent(); + anim = GetComponentInChildren(); + } + + private void Update() + { + float num = Mathf.Abs(torso.position.x - base.transform.position.x) + Mathf.Abs(torso.position.z - base.transform.position.z); + if (rot.hipCorrectionAmount > 30f || ((bool)anim && anim.isLeft != handler.isLeft)) + { + SetFoot(active: false); + } + else if (animHandler.animationState == 0) + { + if (num > 0.1f || rotationDif.magnitude > 15f) + { + SetFoot(active: false); + } + else + { + SetFoot(active: true); + } + } + else + { + SetFoot(active: true); + } + } + + private void FixedUpdate() + { + } + + private void SetFoot(bool active) + { + if (active) + { + collider.material = footMaterial; + } + } +} -- cgit v1.1-26-g67d0