private bool IsGrounded(CharacterControl charControl) { if (charControl.RIGIDBODY.velocity.y <= 0.0f && charControl.RIGIDBODY.velocity.y > -0.01f) { groundTimer += Time.deltaTime; if (groundTimer > 0.15f) { return(true); } } if (charControl.RIGIDBODY.velocity.y < 0.0f) { foreach (GameObject o in charControl.bottomSpheres) { Debug.DrawRay(o.transform.position, Vector3.down * distance, Color.yellow); RaycastHit hit; if (Physics.Raycast(o.transform.position, Vector3.down, out hit, distance)) { if (charControl.ragdollParts.Contains(hit.collider) && !Ledge.IsLedge(hit.collider.gameObject)) { return(true); } } } } return(false); }
protected bool CheckEdge(CharacterControl charControl, List <GameObject> sphereList, Vector3 dir) { foreach (GameObject o in sphereList) { self = false; Debug.DrawRay(o.transform.position, dir * blockDistance, Color.yellow); RaycastHit hit; if (Physics.Raycast(o.transform.position, dir, out hit, blockDistance)) { foreach (Collider c in charControl.ragdollParts) { if (c.gameObject == hit.collider.gameObject && !Ledge.IsLedge(hit.collider.gameObject)) { self = true; break; } } if (!self) { return(true); } } } return(false); }