Table of Contents

Class CameraComponentExtensions

Namespace
Stride.CommunityToolkit.Bullet
Assembly
Stride.CommunityToolkit.Bullet.dll

Provides a set of static methods for working with CameraComponent instances.

public static class CameraComponentExtensions
Inheritance
CameraComponentExtensions

Remarks

This class includes extension methods for performing various operations with CameraComponent instances, such as raycasting, converting screen positions to world positions, and more. These methods are useful for implementing features like object picking, camera control, and coordinate transformations in a 3D environment.

Methods

Raycast(CameraComponent, ScriptComponent, Vector2, CollisionFilterGroups, CollisionFilterGroupFlags)

Performs a raycasting operation from the specified CameraComponent's position through the specified screen position in world coordinates, using the Simulation from the specified ScriptComponent, and returns information about the hit result.

public static HitResult Raycast(this CameraComponent camera, ScriptComponent component, Vector2 screenPosition, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)

Parameters

camera CameraComponent

The CameraComponent from which the ray should be cast.

component ScriptComponent

The ScriptComponent that contains the Simulation used for raycasting.

screenPosition Vector2

The screen position in world coordinates through which the ray should be cast.

collisionGroups CollisionFilterGroups

Optional. The collision filter group to consider during the raycasting. Default is DefaultFilter.

collisionFilterGroupFlags CollisionFilterGroupFlags

Optional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.

Returns

HitResult

A HitResult containing information about the hit result, including the hit location and other collision data.

Raycast(CameraComponent, Simulation, Vector2, CollisionFilterGroups, CollisionFilterGroupFlags)

Performs a raycasting operation from the specified CameraComponent's position through a specified screen position, using the provided Simulation, and returns information about the hit result.

public static HitResult Raycast(this CameraComponent camera, Simulation simulation, Vector2 screenPosition, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)

Parameters

camera CameraComponent

The CameraComponent from which the ray should be cast.

simulation Simulation

The Simulation used to perform the raycasting operation.

screenPosition Vector2

The screen position in normalized screen coordinates (e.g., mouse position) where the ray should be cast.

collisionGroups CollisionFilterGroups

Optional. The collision filter group to consider during the raycasting. Default is DefaultFilter.

collisionFilterGroupFlags CollisionFilterGroupFlags

Optional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.

Returns

HitResult

A HitResult containing information about the raycasting hit, including the hit location and other collision data.

Remarks

This method is useful for implementing features like object picking, where you want to select or interact with objects in the 3D world based on screen coordinates.

RaycastMouse(CameraComponent, ScriptComponent, CollisionFilterGroups, CollisionFilterGroupFlags)

Performs a raycasting operation from the specified CameraComponent's position through the mouse cursor position in screen coordinates, using input from the specified ScriptComponent, and returns information about the hit result.

public static HitResult RaycastMouse(this CameraComponent camera, ScriptComponent component, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)

Parameters

camera CameraComponent

The CameraComponent from which the ray should be cast.

component ScriptComponent

The ScriptComponent from which the mouse position should be taken.

collisionGroups CollisionFilterGroups

Optional. The collision filter group to consider during the raycasting. Default is DefaultFilter.

collisionFilterGroupFlags CollisionFilterGroupFlags

Optional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.

Returns

HitResult

A HitResult containing information about the hit result, including the hit location and other collision data.

RaycastMouse(CameraComponent, Simulation, Vector2, CollisionFilterGroups, CollisionFilterGroupFlags)

Performs a raycasting operation from the specified CameraComponent's position through a specified screen position, using the provided Simulation, and returns information about the hit result.

public static HitResult RaycastMouse(this CameraComponent camera, Simulation simulation, Vector2 screenPosition, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)

Parameters

camera CameraComponent

The CameraComponent from which the ray should be cast.

simulation Simulation

The Simulation used to perform the raycasting operation.

screenPosition Vector2

The screen position in screen coordinates (e.g., mouse position) from which the ray should be cast.

collisionGroups CollisionFilterGroups

Optional. The collision filter group to consider during the raycasting. Default is DefaultFilter.

collisionFilterGroupFlags CollisionFilterGroupFlags

Optional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.

Returns

HitResult

A HitResult containing information about the hit result, including the hit location and other collision data.