public Jump GenerateJump(Vector2 distance) { float angle = CurveRenderer.CalculateAngle(distance); Vector2 velocity = distance * jvc; if (Grounded) { // vertical jump if (angle > 85 && angle < 95) { return(new Jump(new Vector2(0, velocity.y), 90, JumpType.GROUND_VERTICAL)); } else if (angle > 10 && angle < 170) { return(new Jump(velocity, angle, JumpType.GROUND_NOT_VERTICAL)); } } else if (Clinged) { // jump to the right if (transform.localScale.x < 0 && angle > -85 && angle < 65) { return(new Jump(velocity, angle, JumpType.WALL_TO_RIGHT)); } // jump to the left if (transform.localScale.x > 0 && (angle > 115 || angle < -95)) { return(new Jump(velocity, angle, JumpType.WALL_TO_LEFT)); } } return(null); }