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
cameraCameraComponentThe CameraComponent used to calculate the ray.
screenPositionVector2The screen position in normalized device coordinates (NDC).
maxDistancefloatThe maximum distance for the raycast.
hitHitInfoWhen this method returns, contains the HitInfo if the raycast hits a collider, otherwise
null.collisionMaskCollisionMaskSpecifies the collision mask to filter which objects the raycast can hit. Defaults to Everything.
Returns
- bool
trueif the raycast hit a collider; otherwise,false.
Exceptions
- ArgumentNullException
Thrown if
cameraisnull.
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
cameraCameraComponentThe CameraComponent used to calculate the ray.
componentScriptComponentThe ScriptComponent providing access to the mouse position.
maxDistancefloatThe maximum distance for the raycast.
hitHitInfoWhen this method returns, contains the HitInfo if the raycast hits a collider, otherwise
null.collisionMaskCollisionMaskSpecifies the collision mask to filter which objects the raycast can hit. Defaults to Everything.
Returns
- bool
trueif the raycast hit a collider; otherwise,false.
Exceptions
- ArgumentNullException
Thrown if
cameraorcomponentisnull.