Inherit from UJoystickLogic
Related Classes
- UComponentLogic
- SLayoutComponent
- UComponentDecorator
SUMMARY #
An advanced version of the joystick logic. Allows you, for example, to lock the thumbstick in a desired position. Supports advanced features such as drag to sprint and auto move.
WHEN TO USE IT? #
When you want to use advanced joystick-related functions like auto move or drag to sprint.
Auto-move can be useful in games where the character has to travel long distances. It allows players to release the screen while the character continues running.
Drag to sprint is an elegant and natural way to trigger a sprint. It also avoids the need for an additional button to start the sprint.
HOW TO CONFIGURE AUTO MOVE? #
The default values work quite well according to testing, but you can adjust the auto-move behavior using three variables.
- Threshold: Auto-move is triggered only if the thumbstick position is above the threshold. The threshold is expressed as a percentage.
- Direction Threshold: Auto-move will only be triggered if the thumbstick direction remains constant. The algorithm uses a dot product to calculate the angle between two vectors. If the direction changes continuously by a value greater than the direction threshold, then auto-move will not be triggered.
- Hold Duration: Auto-move will only be triggered when the hold time is greater than or equal to the Hold Duration.
If all three conditions are met, then auto-move is triggered.
As an option, you can add a decorator that will appear when auto move is triggered to inform the user that auto move is active.
HOW TO CONFIGURE DRAG TO SPRINT? #
Drag to sprint is controlled by two variables.
- Drag To Sprint Trigger: The sprint will only be triggered if the thumbstick position is equal to or greater than the trigger value. The trigger value is expressed in slate units.
- Drag To Sprint Threshold: The sprint is triggered if the direction is similar to the vector (X: 0.0f, Y:-1.0f). The algorithm uses a dot product to calculate the angle between two vectors. If the direction changes continuously by a value greater than the threshold, then auto-move will not be triggered.
If both conditions are met, then the sprint is triggered. If not, the sprint will not be triggered or will be deactivated if it was previously activated.
Auto Sprint
Auto sprint initiates the sprint and auto move simultaneously if the conditions are met. The thumbstick position must exceed the auto sprint trigger value, which is expressed in slate units, and comply with the drag-to-sprint conditions.
