private void DoPatrol() { Vector3 velocity = new Vector3(groundSpeed, 0f, 0f) * Time.deltaTime; characterController.Move(velocity); if (groundBloodChecker.IsGroundBloodActive().Both()) { this.state = State.SLIPPING; GameObject.Destroy(this._collider); return; } // check if walking into wall. if (groundSpeed > 0 && characterController.collisionState.right || groundSpeed < 0 && characterController.collisionState.left) { TurnAround(); return; } // check if walked off cliff. GroundChecker.CollisionInfo collisionInfo = groundChecker.GetCollisionInfo(); if (groundSpeed < 0 && !collisionInfo.left) { TurnAround(); } else if (groundSpeed > 0 && !collisionInfo.right) { TurnAround(); } }