using UnityEngine; public class CollisionChecker : MonoBehaviour { private Transform head; private Transform hip; private StandingDataHandler data; public bool active = true; public float sinceGrounded; private PickupHandler pickupHandler; private HasControl hasControl; public float allowedSteepnesAngle = 60f; private void Start() { pickupHandler = base.transform.root.GetComponent(); hasControl = base.transform.root.GetComponent(); data = GetComponentInParent(); Head componentInChildren = base.transform.root.GetComponentInChildren(); if ((bool)componentInChildren) { head = componentInChildren.transform; } Hip componentInChildren2 = base.transform.root.GetComponentInChildren(); if ((bool)componentInChildren2) { hip = componentInChildren2.transform; } } private void Update() { sinceGrounded += Time.deltaTime; } private void OnCollisionStay(Collision collision) { Collide(collision); } private void OnCollisionEnter(Collision collision) { Collide(collision); } private void Collide(Collision collision) { if (collision.transform.root == base.transform.root) { return; } if ((bool)collision.rigidbody) { Pickup component = collision.gameObject.GetComponent(); if ((bool)component && !component.GetComponent().isHeld && hasControl.hasControl) { pickupHandler.PickUp(component); } if (collision.rigidbody.mass < 100f || collision.rigidbody.velocity.magnitude > 1f) { return; } } if (active && Vector3.Angle(Vector3.up, collision.contacts[0].normal) < allowedSteepnesAngle) { if ((bool)data) { data.TouchGround(Mathf.Abs(hip.position.y - collision.contacts[0].point.y), collision.contacts[0].normal); } sinceGrounded = 0f; } } public void SwitchActive(bool setActive) { active = setActive; } }