-
Notifications
You must be signed in to change notification settings - Fork 76
DirectMovement
Direct movement allows the user to move using controller input, it uses either the joystick or thumbpad that can be found on many XR controllers.
It uses the 'PlayerBody' node to support collisions with the environment. This node will be added automatically to your scene if it doesn't exist yet.
The main issue with direct movement is that it can easily result in dizzyness on the part of the player. Especially rotating the player leads to many players getting nauseated.
We combat this in three ways:
- direction of movement is always in relation to the direction the player is looking.
- it is possible to configure a step value for the rotation. Instead of smoothly rotating around the player the direction the player is looking will rotate a fixes number of degrees at a fixed pace. While this looks jerky it is a very efficient way to combat nausia.
- you can add a Vignette that blacks out the players peripheral vision.
The direct movement is implemented as a function scene that needs to be added to the controller node whose input we are using.
So if we want to implement the direct movement feature on the right hand controller we need to add the scene to the right hand:
Gravity is implemented in this logic so if you do not have a floor the player will keep falling. Note in the image that we've added a static body as a floor.
Note that we recommend adding the ability to your game for the user to select whether the left hand or right hand controller is used. You can simple re-parent the direct movement function to the correct controller.
The functionality works out of the box but can be further configured.
Property | Description |
---|---|
Enabled | When ticked the movement function is enabled. |
Order | The order in which this movement is applied when multiple movement functions are used. |
Smooth Rotation | If disabled rotation is applied in steps, if enabled the player rotates smoothly (can cause motion sickness). |
Smooth Turn Speed | Maximum turn speed when Smooth Rotation is enabled |
Step Turn Delay | Seconds between the player turning when Smooth Rotation is disabled. |
Step Turn Angle | Turn angle we turn each turn step when Smooth Rotation is disabled. |
Max Speed | The maximum speed at which we can move, note that this is never reached depending on the drag factor configured on the player body. |
Move Type | Defines whether left/right results in rotation or strafe. |
Can Fly | When ticked we can fly. |
Fly Move Button id | When this controller button is pressed and we're in fly mode, we move in the direction we're looking. |
Fly Activate Button Id | When this button is pressed and Can Fly is true we turn on fly mode, when pressed again its turned off. |