Ctrl+K

RayCastComponent

Declaration

public class Strawberry.Components.Physics.RayCastComponent

Casts a ray in a specified direction each FixedUpdate and exposes the hit results. Used for ground detection, wall detection and ledge detection.

Inherits: Strawberry.Core.BaseComponent

Properties

Transform

Gets the transform of the owner.

TransformComponent Transform { get }

Direction

Gets or sets the direction of the ray in world space. (Default: Down)

Vector2 Direction { get set }

Distance

Gets or sets the maximum distance of the ray in pixels. (Default: 10)

float Distance { get set }

Offset

Gets or sets the starting offset of the ray relative to the entity's position, in pixels. (Default: Vector2.Zero)

Vector2 Offset { get set }

CollidesWith

Gets or sets the collision categories the ray will detect. Only fixtures whose CollisionCategories overlap with this value will be detected. (Default: Category.All)

Category CollidesWith { get set }

IsHit

Gets whether the ray is currently hitting a fixture.

bool IsHit { get }

HitDistance

Gets the distance from the ray origin to the hit point, in pixels. Returns 0 if not hitting.

float HitDistance { get }

HitNormal

Gets the normal of the surface at the hit point.

Vector2 HitNormal { get }

HitPoint

Gets the world position where the ray hit a fixture.

Vector2 HitPoint { get }

HitFixture

Gets the fixture that was hit, or null if not hitting.

Fixture HitFixture { get }

RigidBody

Gets the rigid body component of the owner, if any. Used to ignore the owner's own fixtures.

RigidBodyComponent RigidBody { get }

Methods

OnComponentAdded override

void OnComponentAdded(BaseComponent component)

Parameters:

Name Type Description
component Strawberry.Core.BaseComponent

OnFixedUpdate override

void OnFixedUpdate()