bool IsGrounded(CharacterControl control) { if (control.contactPoints != null) { foreach (ContactPoint c in control.contactPoints) { float colliderBottom = (control.transform.position.y + control.boxCollider.center.y) - (control.boxCollider.size.y / 2f); float yDifference = Mathf.Abs(c.point.y - colliderBottom); if (yDifference < 0.01f) { if (Mathf.Abs(control.RIGID_BODY.velocity.y) < 0.001f) { control.animationProgress.Ground = c.otherCollider.transform.root.gameObject; control.animationProgress.LandingPosition = new Vector3( 0f, c.point.y, c.point.z); if (control.SubComponentsDic.ContainsKey(SubComponents.MANUALINPUT)) { TESTING_SPHERE.transform.position = control.animationProgress.LandingPosition; } return(true); } } } } if (control.RIGID_BODY.velocity.y < 0f) { foreach (GameObject o in control.collisionSpheres.BottomSpheres) { Debug.DrawRay(o.transform.position, -Vector3.up * Distance, Color.yellow); RaycastHit hit; if (Physics.Raycast(o.transform.position, -Vector3.up, out hit, Distance)) { if (!control.RagdollParts.Contains(hit.collider) && !Ledge.IsLedgeChecker(hit.collider.gameObject) && !Ledge.IsCharacter(hit.collider.gameObject)) { control.animationProgress.Ground = hit.collider.transform.root.gameObject; control.animationProgress.LandingPosition = new Vector3( 0f, hit.point.y, hit.point.z); if (control.SubComponentsDic.ContainsKey(SubComponents.MANUALINPUT)) { TESTING_SPHERE.transform.position = control.animationProgress.LandingPosition; } return(true); } } } } control.animationProgress.Ground = null; return(false); }
private void OnTriggerExit(Collider other) { if (!Ledge.IsCharacter(other.gameObject) && !MeleeWeapon.IsWeapon(other.gameObject)) { if (CollidedObjects.Contains(other.gameObject)) { CollidedObjects.Remove(other.gameObject); } } }