Falco Engine 3.9.0.1 (beta)
Physics.cs
Go to the documentation of this file.
1using System.Runtime.CompilerServices;
2
3namespace FalcoEngine
4{
5 public static class Physics
6 {
13 public static RaycastHit Raycast(Vector3 from, Vector3 to)
14 {
15 RaycastHit hit;
16
17 INTERNAL_raycast(ref from, ref to, LayerMask.All.ToULong(), out hit);
18
19 return hit;
20 }
21
29 public static RaycastHit Raycast(Vector3 from, Vector3 to, LayerMask layerMask)
30 {
31 RaycastHit hit;
32
33 INTERNAL_raycast(ref from, ref to, layerMask.ToULong(), out hit);
34
35 return hit;
36 }
37
44 public static Rigidbody[] OverlapSphere(Vector3 center, float radius)
45 {
46 return INTERNAL_overlapSphere(ref center, radius, LayerMask.All.ToULong());
47 }
48
56 public static Rigidbody[] OverlapSphere(Vector3 center, float radius, LayerMask layerMask)
57 {
58 return INTERNAL_overlapSphere(ref center, radius, layerMask.ToULong());
59 }
60
61 [MethodImpl(MethodImplOptions.InternalCall)]
62 private static extern void INTERNAL_raycast(ref Vector3 from, ref Vector3 to, ulong layer, out RaycastHit hit);
63
64 [MethodImpl(MethodImplOptions.InternalCall)]
65 private static extern Rigidbody[] INTERNAL_overlapSphere(ref Vector3 center, float radius, ulong layer);
66 }
67}
static LayerMask All
Return layer mask with all layers selected
Definition: LayerMask.cs:16
ulong ToULong()
Convert this layer mask to ulong
Definition: LayerMask.cs:62
static Rigidbody[] OverlapSphere(Vector3 center, float radius)
Return an array of colliders which are overlapped by a sphere
Definition: Physics.cs:44
static Rigidbody[] OverlapSphere(Vector3 center, float radius, LayerMask layerMask)
Return an array of colliders which are overlapped by a sphere with layer mask
Definition: Physics.cs:56
static RaycastHit Raycast(Vector3 from, Vector3 to)
Check a ray intersection
Definition: Physics.cs:13
static RaycastHit Raycast(Vector3 from, Vector3 to, LayerMask layerMask)
Check a ray intersection by layer mask
Definition: Physics.cs:29