Skip to content

@fibbojs / 2d / FCharacterControllerKP

Class: FCharacterControllerKP

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

Example

ts
import { FCapsule, FCharacterControllerKP, FScene } from '@fibbojs/3d'

const scene = new FScene()

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

Extends

Constructors

new FCharacterControllerKP()

new FCharacterControllerKP(scene, options): FCharacterControllerKP

Parameters

scene: FScene

options: FCharacterControllerOptions

Returns

FCharacterControllerKP

Overrides

FCharacterControllerK.constructor

Defined in

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

Methods

getCorrectedMovements()

getCorrectedMovements(): object

Return the corrected movements for the current frame.

Returns

object

x

x: number

y

y: number

Inherited from

FCharacterControllerK.getCorrectedMovements

Defined in

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


onFrame()

onFrame(delta): void

Update the controller. Should be called every frame. The purpose of onFrame on FController is to update the component's transform in the desired way. Any rendering process should be done on the component, not here.

Parameters

delta: number

The time since the last frame.

Returns

void

Overrides

FCharacterControllerK.onFrame

Defined in

2d/src/controllers/FCharacterControllerKP.ts:32

Properties

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:20


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


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:15