====== RaycastHit2D ====== ==== Casts Implicitly To a Bool ==== RaycastHit2D implements the C# [[https://forum.unity.com/threads/c-beginner-tips-1-your-friend-the-implicit-bool.185761/|implicit bool]] operator. This allows it to be used in an if statement to check whether a hit is found. public static implicit operator bool(RaycastHit2D hit) => (Object) hit.collider != (Object) null; ++++ Example | RaycastHit2D hit = Physics2D.Raycast(someStartPoint, someDirection); if(hit) { Debug.Log("yaaay I hit something!"); } This is also valid: RaycastHit2D hit = Physics2D.Raycast(someStartPoint, someDirection); bool rayHitSomthing = hit; ++++