Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
1.1.0:charactercontrolling [2024/01/29 13:37] – [Crawling] admin1.1.0:charactercontrolling [2024/01/29 15:05] (current) – [Speed] admin
Line 75: Line 75:
 __**Remark:**__ All available input codes are defined in **Gorilla.Controller.Input.Consts.pas**. __**Remark:**__ All available input codes are defined in **Gorilla.Controller.Input.Consts.pas**.
  
-==== User-Friendly Events  ==== 
  
-For individual treatment you can disable or overwrite those predefined hotkeys. 
-The basic character controller component catches all input events, handles them and throws back user-friendly events. 
- 
-^Event ^Callback^Description^ 
-|OnIdle|TOnCharacterControllerEvent|OnIdle event getting raised when first person controller switches to idle mode.| 
-|OnMove|TOnCharacterControllerMoveEvent|OnMove event getting raised in doOnMoveForward, doOnMoveBackward, doOnMoveLeft, doOnMoveRight and DoOnGamePadThumbstickPos methods, used by keyboard hotkeys and gamepad thumbstick movement.| 
-|OnRotate|TOnCharacterControllerRotateEvent|OnRotate event getting raised if the view was rotated by DoOnGamePadThumbstickPos or DoOnMouseMove.| 
-|OnBoost|TOnCharacterControllerEvent|OnBoost event getting raised when boost mode was activated or deactivated.| 
-|OnCrouch|TOnCharacterControllerEvent|OnCrouch event getting raised when crouching was activated or deactivated.| 
-|OnCrawl|TOnCharacterControllerEvent|OnCrawl event getting raised when crawling was activated or deactivated.| 
-|OnJump|TOnCharacterControllerEvent|OnJump event getting raised when first person controller is jumping.| 
-|OnAim|TOnCharacterControllerEvent|OnAim event getting raised when aiming mode was activated or deactivated.| 
-|OnPush|TOnCharacterControllerEvent|OnPush event getting raised when pushing mode was activated or deactivated| 
-|OnPull|TOnCharacterControllerEvent|OnPull event getting raised when pulling mode was activated or deactivated.| 
-|OnCustomAction|TOnCharacterControllerHotKeyTriggered|OnCustomAction event getting raised by keyboard custom action hotkeys and gamepad buttons.| 
-|OnClick|TOnCharacterControllerHotKeyTriggered|OnClick event getting raised by clicking left, middle or right mouse button.| 
-|OnStart|TOnCharacterControllerEvent|OnStart event getting raised when start hotkey was activated.| 
-|OnMode|TOnCharacterControllerEvent|OnMode event getting raised when mode hotkey was activated.| 
-|OnBack|TOnCharacterControllerEvent|OnBack event getting raised when back hotkey was activated.| 
-|OnNavigate|TOnCharacterControllerHotKeyTriggered|OnNavigate event getting raised when menu navigation was triggered.| 
-|OnChangeSize|TNotifyEvent|Getting called, when leaving crouching or crawling mode.| 
-|OnHotKey|TOnCharacterControllerHotKeyTriggered|OnHotKey event getting raised when a registered hotkey was triggered. It's a central callback event for all hotkeys. Parallel to it hotkey specific events will be raised: OnIdle, OnMove, OnBoost, OnCrouch, OnJump, OnCustomAction, OnClick, OnStart, OnMode, OnBack and OnNavigate| 
-|OnTriggerPoint|TOnCharacterControllerTriggerPoint|If a TGorillaTriggerPointManager component was linked to the first person controller, a trigger-point check will automatically be performed on movement. If then a trigger-point is in reach, the OnTriggerPoint event will be raised.| 
- 
-^Name^Declaration^ 
-|TOnCharacterControllerHotKeyTriggered|procedure(ASender : TObject; const AKind : TGorillaCharacterControllerHotKey; const AHotKey : TGorillaHotKeyItem; const AStates : TGorillaCharacterControllerStates; const AMode : TGorillaInputMode) of object;| 
-|TOnCharacterControllerMoveEvent|procedure(ASender : TObject; AKind : TGorillaCharacterControllerHotKey; ADir : TPoint3D; ACurrentSpeed : Single) of object;| 
-|TOnCharacterControllerRotateEvent|procedure(ASender : TObject; ACurrentRotation : TQuaternion3D; ANewRotation : TQuaternion3D; ADelta : TPointF) of object;| 
-|TOnCharacterControllerEvent|procedure(ASender : TObject; AState : TGorillaCharacterControllerState; AMode : TGorillaInputMode) of object;| 
-|TOnCharacterControllerTriggerPoint|procedure(ASender : TObject; AManager : TGorillaTriggerPointManager; APt : TGorillaTriggerPoint; ADist : Single) of object;| 
 ==== Modification  ==== ==== Modification  ====
  
Line 125: Line 94:
 You can implement that yourself by OnMove and OnRotate event You can implement that yourself by OnMove and OnRotate event
  
-=== Speed  ===+=== Speed ===
  
 In case movement or rotation speed does not suit your needs. In case movement or rotation speed does not suit your needs.
Line 138: Line 107:
 |CrouchingSpeedReduction|Factor of reduction on speed if state is fpCrouching. Values between 0.0 - 1.0 are allowed. Default value is 0.15.| |CrouchingSpeedReduction|Factor of reduction on speed if state is fpCrouching. Values between 0.0 - 1.0 are allowed. Default value is 0.15.|
  
 +=== Boost ===
 +
 +The boost mode getting triggered by the OnBoost event.
 +By default boost mode is active by holding the left shift key down or the left shoulder button on your gamepad.
 +
 +"RunningSpeedBoost" is multiplied with the current speed value.
 +And the current speed value can be the normal speed or reduced speed by crawling and crouching.
 +
 +If boost movement is active, states should contain the fpBoost flag.
 === Rotation Sideways  === === Rotation Sideways  ===
  
Line 211: Line 189:
  
 You can control the jumping height and the time it takes by the "JumpingAnimationTime" and the "JumpingHeight" property. You can control the jumping height and the time it takes by the "JumpingAnimationTime" and the "JumpingHeight" property.
 +
 +While jumping, states should contain the **fpJumping** state.
  
 JumpingHeight is a multiplier for the character height. JumpingHeight is a multiplier for the character height.
Line 255: Line 235:
 |CrawlingAnimationTime|Time in seconds the animation takes to enter or leave the crawling state.| |CrawlingAnimationTime|Time in seconds the animation takes to enter or leave the crawling state.|
 |CrawlingSpeedReduction|Multiplier to reduce regular speed while in crawling mode.| |CrawlingSpeedReduction|Multiplier to reduce regular speed while in crawling mode.|
 +
 +=== Push / Pull ===
 +
 +Two states are not automatically handled, because developers always have to decide when pushing or pulling is activated.
 +
 +When pushing is active states should contain the **fpPushing** state.
 +
 +When pulling is active states should contain the **fpPulling** state.
 +
 +^Method^Description^
 +|procedure Push(AEnabled : Boolean);|Manually activates/deactivates the pushing state and calls the OnPush event.|
 +|procedure Pull(AEnabled : Boolean);| Manually activates/deactivates the pulling state and calls the OnPull event.|
  
 === Default Behaviour === === Default Behaviour ===
Line 261: Line 253:
  
 ^Property^Description^ ^Property^Description^
-|UseDefaultBehaviour |Will deactivate any automatic operation handling like jumping, +|UseDefaultBehaviour |Will deactivate any automatic operation handling like jumping, crouching, crawling, moving and so on. But the user-specific callback events like OnMove, OnJump or OnCrawl and so on, are still getting called.| 
-crouching, crawling, moving and so on. +|UseDefaultMovement|Allows to disable default movement of the controller. This has no influence on camera rotation.| 
-But the user-specific callback events like OnMove, OnJump or OnCrawl and so on, + 
-are still getting called.| +==== User-Friendly Events  ==== 
-|UseDefaultMovement|Allows to disable default movement of the controller. + 
-This has no influence on camera rotation.|+For individual treatment you can disable or overwrite those predefined hotkeys. 
 +The basic character controller component catches all input events, handles them and throws back user-friendly events. 
 + 
 +^Event ^Callback^Description^ 
 +|OnIdle|TOnCharacterControllerEvent|OnIdle event getting raised when first person controller switches to idle mode.| 
 +|OnMove|TOnCharacterControllerMoveEvent|OnMove event getting raised in doOnMoveForward, doOnMoveBackward, doOnMoveLeft, doOnMoveRight and DoOnGamePadThumbstickPos methods, used by keyboard hotkeys and gamepad thumbstick movement.| 
 +|OnRotate|TOnCharacterControllerRotateEvent|OnRotate event getting raised if the view was rotated by DoOnGamePadThumbstickPos or DoOnMouseMove.| 
 +|OnBoost|TOnCharacterControllerEvent|OnBoost event getting raised when boost mode was activated or deactivated.| 
 +|OnCrouch|TOnCharacterControllerEvent|OnCrouch event getting raised when crouching was activated or deactivated.| 
 +|OnCrawl|TOnCharacterControllerEvent|OnCrawl event getting raised when crawling was activated or deactivated.| 
 +|OnJump|TOnCharacterControllerEvent|OnJump event getting raised when first person controller is jumping.| 
 +|OnAim|TOnCharacterControllerEvent|OnAim event getting raised when aiming mode was activated or deactivated.| 
 +|OnPush|TOnCharacterControllerEvent|OnPush event getting raised when pushing mode was activated or deactivated| 
 +|OnPull|TOnCharacterControllerEvent|OnPull event getting raised when pulling mode was activated or deactivated.| 
 +|OnCustomAction|TOnCharacterControllerHotKeyTriggered|OnCustomAction event getting raised by keyboard custom action hotkeys and gamepad buttons.| 
 +|OnClick|TOnCharacterControllerHotKeyTriggered|OnClick event getting raised by clicking left, middle or right mouse button.| 
 +|OnStart|TOnCharacterControllerEvent|OnStart event getting raised when start hotkey was activated.| 
 +|OnMode|TOnCharacterControllerEvent|OnMode event getting raised when mode hotkey was activated.| 
 +|OnBack|TOnCharacterControllerEvent|OnBack event getting raised when back hotkey was activated.| 
 +|OnNavigate|TOnCharacterControllerHotKeyTriggered|OnNavigate event getting raised when menu navigation was triggered.| 
 +|OnChangeSize|TNotifyEvent|Getting called, when leaving crouching or crawling mode.| 
 +|OnHotKey|TOnCharacterControllerHotKeyTriggered|OnHotKey event getting raised when a registered hotkey was triggered. It's a central callback event for all hotkeys. Parallel to it hotkey specific events will be raised: OnIdle, OnMove, OnBoost, OnCrouch, OnJump, OnCustomAction, OnClick, OnStart, OnMode, OnBack and OnNavigate| 
 +|OnTriggerPoint|TOnCharacterControllerTriggerPoint|If a TGorillaTriggerPointManager component was linked to the first person controller, a trigger-point check will automatically be performed on movement. If then a trigger-point is in reach, the OnTriggerPoint event will be raised.| 
 + 
 +And the corresponding event method declarations look like: 
 + 
 +^Name^Declaration^ 
 +|TOnCharacterControllerHotKeyTriggered|procedure(ASender : TObject; const AKind : TGorillaCharacterControllerHotKey; const AHotKey : TGorillaHotKeyItem; const AStates : TGorillaCharacterControllerStates; const AMode : TGorillaInputMode) of object;| 
 +|TOnCharacterControllerMoveEvent|procedure(ASender : TObject; AKind : TGorillaCharacterControllerHotKey; ADir : TPoint3D; ACurrentSpeed : Single) of object;| 
 +|TOnCharacterControllerRotateEvent|procedure(ASender : TObject; ACurrentRotation : TQuaternion3D; ANewRotation : TQuaternion3D; ADelta : TPointF) of object;| 
 +|TOnCharacterControllerEvent|procedure(ASender : TObject; AState : TGorillaCharacterControllerState; AMode : TGorillaInputMode) of object;| 
 +|TOnCharacterControllerTriggerPoint|procedure(ASender : TObject; AManager : TGorillaTriggerPointManager; APt : TGorillaTriggerPoint; ADist : Single) of object;| 
 ===== FirstPerson Controller ===== ===== FirstPerson Controller =====
  
Line 299: Line 323:
 FFirstPersonCtrl.Camera := FCamera; FFirstPersonCtrl.Camera := FCamera;
 </file> </file>
- 
-You have some properties to optimize or configure your specific character movement: 
- 
-^Property ^Description ^ 
-|MouseControllerSpeed|Get or set mouse controller speed. The value reduces movement speed on mouse interaction. Default value is 0.075.| 
-|GamePadThumbstickSpeed|Get or set gamepad controller speed, when using thumbsticks to move. The value reduces movement speed on gamepad interaction. Default value is 0.5.| 
-|Speed |Get or set speed of movement. A basis speed value applied to direction vector. Default value is 1.0.| 
-|CrouchingSpeedReduction|Factor of reduction on speed if state is fpCrouching. Values between 0.0 - 1.0 are allowed. Default value is 0.15.| 
-|RunningSpeedBoost|Boost factor on speed if state is fpBoost. Values between 1-1000 are allowed. Default value is 2.0.| 
-|JumpingHeight |Get or set jumping height value. The value defines the height of jumping. Default value is 4.0.| 
-|CrouchingHeight |Get or set crouching height value. The value defines how deep the character getting down. Default value is 0.5. 
-|ShowCursor |You can show/hide mouse cursor while first person controller is running. (not working properly)| 
-|RotationDragMode |Get or set FRotationDragMode value, which defines if camera rotation is only been applied, if mouse down is active.| 
-|UseDefaultBehaviour |Activate / Deactivate default behaviour on hotkeys triggered.| 
-|UseDefaultMovement |Activate / Deactivate default movement behaviour. This flag allows to disable default HotKey (W-A-S-D keys) / Gamepad (thumbstick) movement. This has no influence on camera rotation.| 
 ===== ThirdPerson Controller ===== ===== ThirdPerson Controller =====