Gorilla.PhysicsCharacterController
Unit Gorilla.PhysicsCharacterController.pasClasses
- TGorillaPhysicsCharacterController = class ( TDummy )
TGorillaPhysicsCharacterController
The physics character controller component is a helper component to link physics, character controller and a 3D model together. The component handles movement and viewport updates in an optimized way.
Ancestors
Members
Fields
- protected FModel :
TGorillaModel
- protected FAnimationController :
TGorillaAnimationController
- protected FController :
TGorillaCharacterController
- protected FPhysics :
TGorillaPhysicsSystem
- protected FStarted :
Boolean
- protected FUpdateTime :
Single
- protected FGravityScale :
Single
- protected FCapsulePrefab :
TGorillaColliderSettings
- protected FOnUpdate :
TNotifyEvent
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected function GetGorillaViewport ( ) : TGorillaViewport ;
- protected function GetController ( ) : TGorillaCharacterController ;
- protected procedure SetController ( const AValue : TGorillaCharacterController ) ;
- protected function GetModel ( ) : TGorillaModel ;
- protected procedure SetModel ( const AValue : TGorillaModel ) ;
- protected function GetAnimationController ( ) : TGorillaAnimationController ;
- protected procedure SetAnimationController ( const AValue : TGorillaAnimationController ) ;
- protected function GetPhysics ( ) : TGorillaPhysicsSystem ;
- protected procedure SetPhysics ( const AValue : TGorillaPhysicsSystem ) ;
- protected procedure SetGravityScale ( const AValue : Single ) ;
- protected procedure Resize3D ( ) ; override;
- protected procedure VerifyMoveDir
(
var
ADir :
TPoint3D
)
;
Takes an input direction vector and checks for blocked axis settings to prevent from illegal movement. The method will manipulate the variable parameter.
- protected procedure DoUpdateCapsulePrefab
(
)
;
Updates the physics capsule collider setting, this will not be published here to the physics system! Publishing is done by DoSetupCapsuleCollider().
- protected procedure DoSetupCapsuleCollider
(
)
;
Registers the capsule collider for physics controller in physics system. Any previously registered collider will be removed.
- protected procedure DoApplyCharacterController
(
)
;
Connects a linked character controller with the physics controller.
- protected procedure DoDispatchCharacterState
(
const
AHotKey :
TGorillaCharacterControllerHotKey; const
AStates :
TGorillaCharacterControllerStates
)
;
Dispatches input hotkeys and states to a linked animation controller for automatic animation playback.
- protected procedure DoOnQ3BodySleep
(
ASender :
TObject
)
;
Callback when the capsule collider was set to sleep by the physics system. The method will start idle mode. DoOnIdle() will finally set the collider to sleep.
- protected procedure DoOnHotKey
(
ASender :
TObject; const
AKind :
TGorillaCharacterControllerHotKey; const
AHotKey :
TGorillaHotKeyItem; const
AStates :
TGorillaCharacterControllerStates; const
AMode :
TGorillaInputMode
)
;
Internal callback method to dispatch hotkey settings to the DoDispatchCharacterState() method to automatically playback animations.
- protected procedure DoOnIdle
(
ASender :
TObject; AState :
TGorillaCharacterControllerState; AMode :
TGorillaInputMode
)
;
Internal callback method to handle state changes to idle-mode. The method will potentially set the physics collider to sleep, to stop movement immediately.
- protected procedure DoOnRotate
(
ASender :
TObject; ACurrentRotation :
TQuaternion3D; ANewRotation :
TQuaternion3D; ADelta :
TPointF
)
;
Rotates the character / avatar model by submitted parameters.
- protected procedure DoOnMove
(
ASender :
TObject; AKind :
TGorillaCharacterControllerHotKey; ADir :
TPoint3D; ACurrentSpeed :
Single
)
;
Internal callback method for user specific movements. The mehtod will move the capsule collider in 3D space and by that automatically move the character.
Properties
- public GorillaViewport : TGorillaViewport
Returns the viewport of the physics character controller as destiny for update processes.
read GetGorillaViewport - published Model : TGorillaModel
- published AnimationController : TGorillaAnimationController
An animation controller working with a linked model. Input messages will be pushed to animation controller for automatic animation switching/transitions.
read GetAnimationController
write SetAnimationController - published Controller : TGorillaCharacterController
A linked TGorillaFirstPersonController or TGorillaThirdPersonController will handle character movement and physics collision detection.
read GetController
write SetController - published Physics : TGorillaPhysicsSystem
A linked physics system in which a capsule collider will be added for collision detection. The capsule collider will be controlled by the linked character controller.
read GetPhysics
write SetPhysics - published UpdateTime : Single
Because physics, animation and movement control is very complex and time critical, you can configure the minimum update time limit for animations by the UpdateTime value. The default value is 0.02 (in seconds) = 20ms.
read FUpdateTime
write FUpdateTime - published GravityScale : Single
Get or set speed to influence character movement by capsule collider.
read FGravityScale
write SetGravityScale