Defaultcontrolswrapper

DefaultControlsWrapper class

This class implements the default platformer controls, with support for jumping, running, etc

the controls use keyboard keys W, A, S, D or Arrow keys for movement, and SPACE for jumping;

The meaning of object & target options is intepreted as follows:

  • The object is moved by the controls actions

  • The target is used to determine the forward direction of the movement

The behavior of the controls can be customized using the params object. See DefaultControlParams for more info

Signature:

export declare class DefaultControlsWrapper extends ControlsAbstract 

Extends: ControlsAbstract

Constructors

Constructor

Modifiers

Description

(constructor)(opts)

Constructs a new instance of the DefaultControlsWrapper class

Properties

Property

Modifiers

Type

Description

_active

boolean

_animState

{ wasJumping: boolean; jumpAnimCount: number; isDropAnimPlaying: boolean; }

_jumpState

{ speed: number; delay: number; jumpedCount: number; jumped: boolean; isJumping: boolean; reachedPeak: boolean; coyoteTimeLeft: number; elapsedTime: number; jumpGravity: number; jumpVelocity: number; currentHeight: number; jumpMaxHeight: number; prevJumpKeyState: boolean; }

_keyActive

boolean

_seqId

number

_state

{ isMoving: boolean; onFloor: boolean; speed: number; }

actions

PCActions

The actions influence the movement of the attached object. Those are typically set automtically from the user input.

If you deactivate the controls's controller, you can set those manually to control the movement of the attached object

active

boolean

advancedAnimations

boolean

animations

{ idle: string; run: string; sprint: string; jump_idle: string; jump_walking: string; jump_sprinting: string; jump_running: string; falling: string; drop_idle: string; drop_walking: string; drop_walking_roll: string; drop_running: string; drop_running_roll: string; drop_sprinting: string; drop_sprinting_roll: string; walk: string; jump_double: string; }

autoAnimate

boolean

autoRotate

boolean

autoUpdate

boolean

characterController

BasicCharacterController

collidesWith

any[]

controller

Controller

The controller handles the input events and sets the corresponding actions

direction

Vector3

dirtyJoystick

Vector3

gravity

{ x: number; y: number; z: number; }

jump

{ airAcceleration: number; hold: boolean; duration: number; height: number; max: number; coyote: number; maxFallSpeed: number; peakSpeed: number; delay: number; }

jumpPromise

any

keyActive

boolean

playAnimationIfNotPlaying

(animationName: any, animationsToCheck?: any[]) => void

playAnimationOnceIfNotPlaying

(animationName: any, animationsToCheck: any, opts?: {}) => Promise<unknown>

prevDirection

Vector3

quaternion

Quaternion

run

{ maxSpeed: number; maxAcceleration: number; maxDeceleration: number; accelerationFactor: number; decelerationFactor: number; boost: number; }

showJoystick

boolean

targetQuaternion

Quaternion

targetRot

number

update

(deltaTime: any) => void

velocity

Vector3

Methods

Method

Modifiers

Description

_animation()

calcVelocity(deltaTime)

reset()

restoreState(state)

saveState()

setForce(impulse)

triggerJump({ duration, height })