Class CameraComponentExtensions
- Namespace
- Stride.CommunityToolkit.Bepu
- Assembly
- Stride.CommunityToolkit.Bepu.dll
Provides extension methods for CameraComponent to facilitate raycasting functionality.
public static class CameraComponentExtensions
- Inheritance
-
CameraComponentExtensions
Methods
Raycast(CameraComponent, Vector2, float, out HitInfo, CollisionMask)
Performs a raycast using a screen position.
public static bool Raycast(this CameraComponent camera, Vector2 screenPosition, float maxDistance, out HitInfo hit, CollisionMask collisionMask = CollisionMask.Everything)
Parameters
camera
CameraComponentThe CameraComponent used to calculate the ray.
screenPosition
Vector2The screen position in normalized device coordinates (NDC).
maxDistance
floatThe maximum distance for the raycast.
hit
HitInfoWhen this method returns, contains the HitInfo if the raycast hits a collider, otherwise
null
.collisionMask
CollisionMaskSpecifies the collision mask to filter which objects the raycast can hit. Defaults to Everything.
Returns
- bool
true
if the raycast hit a collider; otherwise,false
.
Exceptions
- ArgumentNullException
Thrown if
camera
isnull
.
RaycastMouse(CameraComponent, ScriptComponent, float, out HitInfo, CollisionMask)
Performs a raycast using the mouse's screen position.
public static bool RaycastMouse(this CameraComponent camera, ScriptComponent component, float maxDistance, out HitInfo hit, CollisionMask collisionMask = CollisionMask.Everything)
Parameters
camera
CameraComponentThe CameraComponent used to calculate the ray.
component
ScriptComponentThe ScriptComponent providing access to the mouse position.
maxDistance
floatThe maximum distance for the raycast.
hit
HitInfoWhen this method returns, contains the HitInfo if the raycast hits a collider, otherwise
null
.collisionMask
CollisionMaskSpecifies the collision mask to filter which objects the raycast can hit. Defaults to Everything.
Returns
- bool
true
if the raycast hit a collider; otherwise,false
.
Exceptions
- ArgumentNullException
Thrown if
camera
orcomponent
isnull
.