Skip to content

@fibbojs / 2d / FRigidBody

Class: FRigidBody

A 2d rigidBody that can be attached to a component.

Accessors

component

get component(): undefined | FComponent

set component(component): void

Parameters

component: undefined | FComponent

Returns

undefined | FComponent

Defined in

2d/src/core/FRigidBody.ts:318

Constructors

new FRigidBody()

new FRigidBody(scene, options?): FRigidBody

Creates a rigidBody for the given component.

Parameters

scene: FScene

The scene the rigidBody belongs to.

options?: FRigidBodyOptions

The options for the rigidBody.

Returns

FRigidBody

Example

ts
const rigidBody = new FRigidBody(scene, {
  position: { x: 0, y: 0 },
  scale: { x: 1, y: 1 },
  shape: 'CUBOID'
})

Defined in

2d/src/core/FRigidBody.ts:82

Methods

__SET_POSITION__()

__SET_POSITION__(position): void

Set the position of the rigidBody.

Parameters

position: FVector2

The new position of the rigidBody.

Returns

void

Defined in

2d/src/core/FRigidBody.ts:291


__SET_ROTATION__()

__SET_ROTATION__(rotation): void

Set the rotation of the rigidBody.

Parameters

rotation: number

The new rotation of the rigidBody.

Returns

void

Defined in

2d/src/core/FRigidBody.ts:301


__SET_SCALE__()

__SET_SCALE__(scale): void

Set the scale of the rigidBody.

Parameters

scale: FVector2

The new scale of the rigidBody.

Returns

void

Defined in

2d/src/core/FRigidBody.ts:311


__UPDATE_POSITION__()

__UPDATE_POSITION__(initiator): void

Update the position of the rigidBody according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the rigidBody won't be considered as the initiator of the position update. This means the new position will be the position of the attached component, plus the offset. Setting this to true will propagate the event to other objects (component, sensor,...).

Returns

void

Defined in

2d/src/core/FRigidBody.ts:210


__UPDATE_ROTATION__()

__UPDATE_ROTATION__(initiator): void

Update the rotation of the rigidBody according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the rigidBody won't be considered as the initiator of the rotation update. This means the new rotation will be the rotation of the attached component, plus the offset. Setting this to true will propagate the event to other objects (component, sensor,...).

Returns

void

Defined in

2d/src/core/FRigidBody.ts:239


__UPDATE_SCALE__()

__UPDATE_SCALE__(initiator): void

Update the scale of the rigidBody according to the transform. This method should be called after updating the transform properties.

Parameters

initiator: boolean = false

By default (false), the rigidBody won't be considered as the initiator of the scale update. This means the new scale will be the scale of the attached component, plus the offset. Setting this to true will propagate the event to other objects (component, sensor,...).

Returns

void

Defined in

2d/src/core/FRigidBody.ts:265


frame()

frame(_delta): void

Parameters

_delta: number

Returns

void

Defined in

2d/src/core/FRigidBody.ts:172


setAngvel()

setAngvel(velocity): void

Set the angular velocity of the rigidBody.

Parameters

velocity: number

The new angular velocity of the rigidBody.

Returns

void

Defined in

2d/src/core/FRigidBody.ts:199


setLinvel()

setLinvel(velocity): void

Set the linear velocity of the rigidBody.

Parameters

velocity: FVector2

The new linear velocity of the rigidBody.

Returns

void

Defined in

2d/src/core/FRigidBody.ts:191

Properties

__COMPONENT__?

optional __COMPONENT__: FComponent

The component the rigidBody is attached to.

Defined in

2d/src/core/FRigidBody.ts:46


__RIGIDBODY__

__RIGIDBODY__: RigidBody

RAPIER RigidBody

Defined in

2d/src/core/FRigidBody.ts:38


collider

collider: FCollider

Fibbo Collider

Defined in

2d/src/core/FRigidBody.ts:42


offset

offset: FTransform

The transform offset of the rigidBody.

Defined in

2d/src/core/FRigidBody.ts:54


transform

transform: FTransform

The transform of the rigidBody.

Defined in

2d/src/core/FRigidBody.ts:50