public Vector2 FireGrapple(float angleInDegrees, float maxLength) { var origin = _transform.position; //Debug.DrawRay(origin, direction * maxLength, Color.cyan); var angleInRadians = angleInDegrees * 2 * Mathf.PI / 360f; var direction = new Vector2 (Mathf.Sin (angleInRadians), Mathf.Cos (angleInRadians)); var raycastHit = Physics2D.Raycast(origin, direction, maxLength, PlatformMask); if (!raycastHit) return (Vector2) origin + (direction * maxLength); var anchor = raycastHit.point; var length = raycastHit.distance; grappleConstraint = new GrappleConstraint (anchor, length, maxLength); State.IsGrappling = true; GrapplingOn = raycastHit.collider.gameObject; SetGrapplePoints(); return new Vector2(-1, -1); }
public Vector2 FireGrapple(Vector2 direction, float maxLength) { var origin = _transform.position; //Debug.DrawRay(origin, direction * maxLength, Color.cyan); var raycastHit = Physics2D.Raycast(origin, direction, maxLength, PlatformMask); if (!raycastHit) { return (Vector2) origin + (direction * maxLength); } var anchor = raycastHit.point; var length = raycastHit.distance; grappleConstraint = new GrappleConstraint (anchor, length, maxLength); State.IsGrappling = true; GrapplingOn = raycastHit.collider.gameObject; SetGrapplePoints(); return new Vector2(-1, -1); }