Gorilla.Controller.Input.Character Unit Reference

Overview

The Gorilla.Controller.Input.Character unit provides the abstract base class TGorillaCharacterController for all character controllers in Gorilla3D. It manages character states (idle, moving, jumping, crouching, crawling, boosting), default hotkey registration, trigger point integration, and audio manager linking. This class is not used directly — use TGorillaFirstPersonController or TGorillaThirdPersonController instead.

Types

TGorillaCharacterControllerHotKeyCode

Record for hotkey registration.

TGorillaCharacterControllerHotKeyCode = record
  Name: String;
  Code: Integer;
  Device: TGorillaInputDeviceType;
end;

TOnCharacterControllerHotKeyTriggered

TOnCharacterControllerHotKeyTriggered = procedure(ASender: TObject;
  const AKind: TGorillaCharacterControllerHotKey;
  const AHotKey: TGorillaHotKeyItem;
  const AStates: TGorillaCharacterControllerStates;
  const AMode: TGorillaInputMode) of object;

TOnCharacterControllerMoveEvent

TOnCharacterControllerMoveEvent = procedure(ASender: TObject;
  AKind: TGorillaCharacterControllerHotKey;
  ADir: TPoint3D;
  ACurrentSpeed: Single) of object;

TOnCharacterControllerRotateEvent

TOnCharacterControllerRotateEvent = procedure(ASender: TObject;
  ACurrentRotation: TQuaternion3D;
  ANewRotation: TQuaternion3D;
  ADelta: TPointF) of object;

TOnCharacterControllerEvent

TOnCharacterControllerEvent = procedure(ASender: TObject;
  AState: TGorillaCharacterControllerState;
  AMode: TGorillaInputMode) of object;

TOnCharacterControllerTriggerPoint

TOnCharacterControllerTriggerPoint = procedure(ASender: TObject;
  AManager: TGorillaTriggerPointManager;
  APt: TGorillaTriggerPoint;
  ADist: Single) of object;

Classes

TGorillaCharacterController

Abstract base class for character controllers. Inherits from TDummy.

Inheritance: TDummy → TGorillaCharacterController

Public Properties

Property Type Access Description
States TGorillaCharacterControllerStates Read/Write Current set of character states (idle, moving, crouching, etc.)
HotKey[Index] TGorillaHotKeyItem Read Access registered hotkey by enum index
JumpingStartPos TPoint3D Read Starting position for jump animation
CrouchingStartPos TPoint3D Read Starting position for crouch animation
CrawlingStartPos TPoint3D Read Starting position for crawl animation
JumpingEndPos TPoint3D Read Destination position for jump animation
CrouchingEndPos TPoint3D Read Destination position for crouch animation
CrawlingEndPos TPoint3D Read Destination position for crawl animation
CurrentJumpingTime Single Read Current time in jump animation
CurrentCrouchingTime Single Read Current time in crouch animation
CurrentCrawlingTime Single Read Current time in crawl animation
AdjustJumpingPosition Boolean Read/Write Auto-adjust position during jumping
AdjustCrouchingPosition Boolean Read/Write Auto-adjust position during crouching
AdjustCrawlingPosition Boolean Read/Write Auto-adjust position during crawling

Published Properties

Property Type Description
Camera TCamera Linked camera for perspective control
InputController TGorillaInputController Linked input controller for keyboard/mouse/gamepad events
TriggerPoints TGorillaTriggerPointManager Linked trigger point manager
AudioManagerController TGorillaAudioManagerController Linked audio manager for automatic sound playback
LockXAxis Boolean Lock movement on X axis
LockYAxis Boolean Lock movement on Y axis
LockZAxis Boolean Lock movement on Z axis
MoveSideways Boolean If true, left/right keys strafe; if false, they rotate
RotateOnSideways Boolean Rotate controller on sideway movement
CameraYAngleLimit TPointF Min/max horizontal rotation in degrees. Default: (-180, 180)
CameraXAngleLimit TPointF Min/max vertical rotation in degrees. Default: (-45, 45)
Speed Single Base movement speed. Default: 0.25
SidewayRotationSpeed Single Rotation speed on sideway keys. Default: 1.0
CrouchingSpeedReduction Single Speed factor when crouching (0.0–1.0). Default: 0.75
CrawlingSpeedReduction Single Speed factor when crawling (0.0–1.0). Default: 0.9
RunningSpeedBoost Single Speed factor when boosting (1–1000). Default: 2.0
CharacterHeight Single Character height on Y axis
CurrentCharacterHeight Single Current height during crouch/crawl transitions
JumpingHeight Single Jump height. Default: 2.0
CrouchingHeight Single Crouch depth. Default: 0.5
CrawlingHeight Single Crawl depth. Default: 0.25
JumpingAnimationTime Single Jump animation duration in seconds
CrouchingAnimationTime Single Crouch transition duration in seconds
CrawlingAnimationTime Single Crawl transition duration in seconds

Published Events

Event Type Description
OnIdle TOnCharacterControllerEvent Fired on idle state
OnMove TOnCharacterControllerMoveEvent Fired on movement (direction + speed)
OnRotate TOnCharacterControllerRotateEvent Fired on rotation
OnBoost TOnCharacterControllerEvent Fired on boost toggle
OnCrouch TOnCharacterControllerEvent Fired on crouch toggle
OnCrawl TOnCharacterControllerEvent Fired on crawl toggle
OnJump TOnCharacterControllerEvent Fired on jump
OnAim TOnCharacterControllerEvent Fired on aim toggle
OnPush TOnCharacterControllerEvent Fired on push action
OnPull TOnCharacterControllerEvent Fired on pull action
OnCustomAction TOnCharacterControllerHotKeyTriggered Fired by custom hotkeys
OnClick TOnCharacterControllerHotKeyTriggered Fired by mouse clicks
OnStart TOnCharacterControllerEvent Fired on start button
OnMode TOnCharacterControllerEvent Fired on mode button
OnBack TOnCharacterControllerEvent Fired on back button
OnNavigate TOnCharacterControllerHotKeyTriggered Fired on menu navigation
OnHotKey TOnCharacterControllerHotKeyTriggered General hotkey trigger
OnTriggerPoint TOnCharacterControllerTriggerPoint Fired when trigger point detected
OnChangeSize TNotifyEvent Fired when character height changes

Public Methods

constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure AfterConstruction(); override;
function GetCurrentSpeed(): Single; virtual; abstract;

Returns the current effective movement speed (accounting for crouch/boost modifiers).

function GetHotKeyType(AItem: TGorillaHotKeyItem): TGorillaCharacterControllerHotKey; virtual;

Returns the hotkey enum value for a given hotkey item.

class function GetStatesString(AStates: TGorillaCharacterControllerStates): String;

Converts a states set to a string representation like "[fpIdle,fpCrouching]".

class function GetStatesValue(AValue: String): TGorillaCharacterControllerStates;

Parses a states string back to a set value.

procedure AddState(AState: TGorillaCharacterControllerState); virtual;

Adds a state and resolves conflicting states (e.g., idle vs moving).

procedure RemoveState(AState: TGorillaCharacterControllerState); virtual;

Removes a state and resolves conflicts.

procedure Push(AEnabled: Boolean); virtual;

Manually activate or deactivate pushing state.

procedure Pull(AEnabled: Boolean); virtual;

Manually activate or deactivate pulling state.

procedure AbortJumping(); virtual; abstract;

Cancel the current jump animation.