raycasthit2d
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| raycasthit2d [2021/05/05 06:57] – created andrew900460 | raycasthit2d [2025/01/15 04:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | '' | + | ====== |
| - | Example: | + | ==== Casts Implicitly To a Bool ==== |
| - | < | + | RaycastHit2D implements the C# [[https:// |
| + | <code csharp> | ||
| + | public static implicit operator bool(RaycastHit2D hit) => (Object) hit.collider != (Object) null; | ||
| + | </ | ||
| + | ++++ Example | | ||
| + | < | ||
| RaycastHit2D hit = Physics2D.Raycast(someStartPoint, | RaycastHit2D hit = Physics2D.Raycast(someStartPoint, | ||
| Line 9: | Line 14: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | This is also valid: | ||
| + | <code c#> | ||
| + | RaycastHit2D hit = Physics2D.Raycast(someStartPoint, | ||
| + | |||
| + | bool rayHitSomthing = hit; | ||
| + | </ | ||
| + | ++++ | ||
raycasthit2d.1620197842.txt.gz · Last modified: 2025/01/15 04:35 (external edit)