Skip to content

@fibbojs / 2d / FCharacterControllerKV

Class: FCharacterControllerKV

A pre-defined character controller based on a Kinematic Velocity RigidBody.

Example

ts
import { FCapsule, FCharacterControllerKV, FScene } from '@fibbojs/2d'

const scene = new FScene()

const capsule = new FCapsule()
capsule.controller = new FCharacterControllerKV()
scene.addComponent(capsule)

Extends

Constructors

new FCharacterControllerKV()

new FCharacterControllerKV(options): FCharacterControllerKV

Parameters

options: FCharacterControllerOptions

Returns

FCharacterControllerKV

Overrides

FCharacterControllerK.constructor

Defined in

2d/src/controllers/FCharacterControllerKV.ts:20

Methods

frame()

frame(delta): void

Update the controller. Should be called every frame. The purpose of this method is to update the component transform based on the controller logic.

Parameters

delta: number

The time since the last frame.

Returns

void

Overrides

FCharacterControllerK.frame

Defined in

2d/src/controllers/FCharacterControllerKV.ts:31


getCorrectedMovements()

getCorrectedMovements(delta): object

Return the corrected movements for the current frame.

Parameters

delta: number

Returns

object

x

x: number

y

y: number

Inherited from

FCharacterControllerK.getCorrectedMovements

Defined in

2d/src/controllers/FCharacterControllerK.ts:64

Properties

__LAST_IS_GROUNDED__

__LAST_IS_GROUNDED__: boolean

Tells if the character was grounded in the last frame.

Inherited from

FCharacterControllerK.__LAST_IS_GROUNDED__

Defined in

2d/src/controllers/FCharacterControllerK.ts:28


__RUN_IN_PHYSIC_PIPELINE__

__RUN_IN_PHYSIC_PIPELINE__: boolean

True if the controller should run in the physic pipeline.

Inherited from

FCharacterControllerK.__RUN_IN_PHYSIC_PIPELINE__

Defined in

core/dist/index.d.ts:20


characterController

characterController: KinematicCharacterController

The character controller that will be used to move the character.

Inherited from

FCharacterControllerK.characterController

Defined in

2d/src/controllers/FCharacterControllerK.ts:19


component

component: FComponent

The component attached to the controller. It is redefined here to get the correct type (with 2D properties).

Inherited from

FCharacterControllerK.component

Defined in

2d/src/controllers/FController.ts:17


inputs

inputs: object

The inputs that will be used to move the character.

down

down: boolean

left

left: boolean

right: boolean

up

up: boolean

Inherited from

FCharacterControllerK.inputs

Defined in

2d/src/controllers/FCharacterController.ts:21


isGrounded

isGrounded: boolean

Tells if the character is grounded.

Inherited from

FCharacterControllerK.isGrounded

Defined in

2d/src/controllers/FCharacterControllerK.ts:24


scene

scene: FScene

The scene where the character is.

Inherited from

FCharacterControllerK.scene

Defined in

2d/src/controllers/FCharacterController.ts:36


speed

speed: number

The speed of the character.

Inherited from

FCharacterControllerK.speed

Defined in

2d/src/controllers/FCharacterController.ts:31


yVelocity

yVelocity: number

The y velocity of the character. Used to simulate gravity.

Inherited from

FCharacterControllerK.yVelocity

Defined in

2d/src/controllers/FCharacterControllerK.ts:14