Table of Contents

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 CameraComponent

The CameraComponent used to calculate the ray.

screenPosition Vector2

The screen position in normalized device coordinates (NDC).

maxDistance float

The maximum distance for the raycast.

hit HitInfo

When this method returns, contains the HitInfo if the raycast hits a collider, otherwise null.

collisionMask CollisionMask

Specifies 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 is null.

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 CameraComponent

The CameraComponent used to calculate the ray.

component ScriptComponent

The ScriptComponent providing access to the mouse position.

maxDistance float

The maximum distance for the raycast.

hit HitInfo

When this method returns, contains the HitInfo if the raycast hits a collider, otherwise null.

collisionMask CollisionMask

Specifies 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 or component is null.