Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
1.1.0:charactercontrolling [2024/01/29 13:33] – [Crouching] admin | 1.1.0:charactercontrolling [2024/01/29 15:05] (current) – [Speed] admin | ||
---|---|---|---|
Line 75: | Line 75: | ||
__**Remark: | __**Remark: | ||
- | ==== 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, | ||
- | |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, | ||
- | |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; | ||
- | |TOnCharacterControllerMoveEvent|procedure(ASender : TObject; AKind : TGorillaCharacterControllerHotKey; | ||
- | |TOnCharacterControllerRotateEvent|procedure(ASender : TObject; ACurrentRotation : TQuaternion3D; | ||
- | |TOnCharacterControllerEvent|procedure(ASender : TObject; AState : TGorillaCharacterControllerState; | ||
- | |TOnCharacterControllerTriggerPoint|procedure(ASender : TObject; AManager : TGorillaTriggerPointManager; | ||
==== 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. | ||
+ | |||
+ | " | ||
+ | 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 177: | Line 155: | ||
|RotationDragMode|Get or set RotationDragMode value, which defines if camera rotation is only been applied, if mouse-down button is active. Set RotationDragModeButton to define the mouse button to be used. Valid states are: LButtonDown, | |RotationDragMode|Get or set RotationDragMode value, which defines if camera rotation is only been applied, if mouse-down button is active. Set RotationDragModeButton to define the mouse button to be used. Valid states are: LButtonDown, | ||
|RotationDragModeButton|Get or set mouse button to be used if RotationDragMode is enabled. Valid states are: LButtonDown, | |RotationDragModeButton|Get or set mouse button to be used if RotationDragMode is enabled. Valid states are: LButtonDown, | ||
+ | |||
+ | === Rotation Around Center === | ||
+ | |||
+ | In case you want to use the first person controller without a free camera rotation, | ||
+ | but instead with a rotating first-person controller, | ||
+ | use the " | ||
+ | |||
+ | // | ||
+ | |||
=== Hide Cursor === | === Hide Cursor === | ||
Line 202: | Line 189: | ||
You can control the jumping height and the time it takes by the " | You can control the jumping height and the time it takes by the " | ||
+ | |||
+ | 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 243: | Line 232: | ||
^Property^Description^ | ^Property^Description^ | ||
- | |CrawlingHeight|Multiplier for originl characters height. Will define the active | + | |CrawlingHeight|Multiplier for originl characters height. Will define the active |
- | |CrawlingAnimationTime|Time in seconds the animation takes to enter or leave the crouching | + | |CrawlingAnimationTime|Time in seconds the animation takes to enter or leave the crawling |
|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); | ||
+ | |procedure Pull(AEnabled : Boolean);| Manually activates/ | ||
+ | |||
+ | === Default Behaviour === | ||
+ | |||
+ | Finally there are 2 important properties to deactivate default behaviour of our character controllers. | ||
+ | |||
+ | ^Property^Description^ | ||
+ | |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.| | ||
+ | |UseDefaultMovement|Allows to disable default movement of the controller. This has no influence on camera rotation.| | ||
+ | |||
+ | ==== 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, | ||
+ | |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, | ||
+ | |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; | ||
+ | |TOnCharacterControllerMoveEvent|procedure(ASender : TObject; AKind : TGorillaCharacterControllerHotKey; | ||
+ | |TOnCharacterControllerRotateEvent|procedure(ASender : TObject; ACurrentRotation : TQuaternion3D; | ||
+ | |TOnCharacterControllerEvent|procedure(ASender : TObject; AState : TGorillaCharacterControllerState; | ||
+ | |TOnCharacterControllerTriggerPoint|procedure(ASender : TObject; AManager : TGorillaTriggerPointManager; | ||
+ | |||
===== FirstPerson Controller ===== | ===== FirstPerson Controller ===== | ||
Line 278: | Line 323: | ||
FFirstPersonCtrl.Camera := FCamera; | FFirstPersonCtrl.Camera := FCamera; | ||
</ | </ | ||
- | |||
- | 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 ===== | ||