/// <summary> /// Casts a ray into the scene and checks if it has hit anything. This can be significantly more efficient than /// other types of cast* calls. /// </summary> /// <param name="ray">Ray to cast into the scene.</param> /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects. /// </param> /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected. /// </param> /// <returns>True if something was hit, false otherwise.</returns> public static bool RayCastAny(Ray ray, ulong layer = ulong.MaxValue, float max = float.MaxValue) { return RayCastAny(ray.origin, ray.direction, layer, max); }
/// <summary> /// Casts a ray into the scene and returns all found hits. /// </summary> /// <param name="ray">Ray to cast into the scene.</param> /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects. /// </param> /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected. /// </param> /// <returns>List of all detected hits.</returns> public static PhysicsQueryHit[] RayCastAll(Ray ray, ulong layer = ulong.MaxValue, float max = float.MaxValue) { return RayCastAll(ray.origin, ray.direction, layer, max); }
/// <summary> /// Checks does the ray hit this collider. /// </summary> /// <param name="ray">Ray to check.</param> /// <param name="hit">Information about the hit. Valid only if the method returns true.</param> /// <param name="maxDist">Maximum distance from the ray origin to search for hits.</param> /// <returns>True if the ray has hit the collider.</returns> public bool Raycast(Ray ray, out PhysicsQueryHit hit, float maxDist) { return Raycast(ray.origin, ray.direction, out hit, maxDist); }
/// <summary> /// Casts a ray into the scene and returns the closest found hit, if any. /// </summary> /// <param name="ray">Ray to cast into the scene.</param> /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param> /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects. /// </param> /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected. /// </param> /// <returns>True if something was hit, false otherwise.</returns> public static bool RayCast(Ray ray, out PhysicsQueryHit hit, ulong layer = ulong.MaxValue, float max = float.MaxValue) { return RayCast(ray.origin, ray.direction, out hit, layer, max); }
private static extern void Internal_ViewportToWorldRay(IntPtr instance, ref Vector2I value, out Ray output);