Update Pawn authored by David Gilbert's avatar David Gilbert
[[_TOC_]]
# Movement
All movement components are C++ derived blueprint components, which can be added to the `RWTHVRPawn`. The blueprints itself can be found in `Components/Movement`. In the movement folder are two InputMappingContexts(IMCs) for either the left or right hand (which can be switched by (un-)ticking ``Move with Right Hand``). If you want to change the button mappings, you can adjust the respective IMC (best make a copy of them into your project first).
## Collision Handling Movement
This component is added to the pawn by default. It adds a configurable movement to your pawn implementation. It can be configured via the `NavigationMode`, which behaves as follows:
* `NAV_NONE` No input is handled
* `NAV_GHOST` Simple flying movement, but no collision with walls
* `NAV_FLY` Flying movement with collision checking
* `NAV_WALK` Walking movement that simulates gravity and collisions for the pawn
Collisions thereby are omitted if the user is virtually steering and also when the user is physically awlking into wall etc. (in this case by moving the world away, since we cannot hinder users to physically walk further)
If you want to use a completely custom-build pawn (not based on the ``AWTHVRPawn``), attach it to your pawn and make sure to call
```cpp
PawnMovement->SetUpdatedComponent(RootComponent);
PawnMovement->SetCameraComponent(CameraComponent);
```
## Continuous Movement
The continuous movement component is an Actor Component that adds continuous movement functionality to the Pawn. Use either the Continuous Movement or the Teleportation component, never both. In the details panel of the component, the following parameters can be used to adjust the behavior:
| Parameter| Description|
| ------ | ------ |
|Steering Mode|Specify if movement should be applied in hand or gaze direction.|
|Move With Right Hand|If true, the right controller's stick is used for movement. Use this to easily specify handedness, note that you might also want to change the handedness of the Turn component as well if you.|
|IMC Movement Right|The Input Mapping Context for the right hand, that maps controller buttons to behavior. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Movement Left|See above.|
|Move|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|Move Up|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
## Teleportation
The teleportation component is an Actor Component that adds teleportation based movement functionality to the Pawn. Use either the Teleportation or the Continuous Movement component, never both. In the details panel of the component, the following parameters can be used to adjust the behavior:
| Parameter| Description|
| ------ | ------ |
|Teleport Launch Speed|Specify the speed at which the projectile that gives the teleport target location is shot out of the controller. Higher values correspond to a larger teleportation range.|
|IMC Teleport Right|The Input Mapping Context for the right hand, that maps controller buttons to behavior. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Teleport Left|See above.|
|Move|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
## Turn
The Turn component adds turning functionality like smooth or snap turning to the pawn. You can combine this component with the Teleportation or the Continuous Movement component. Note that you can also specify which hand is responsible for turning, per default left hand is used for turning and right hand for movement. If you want to change that, you have to change it in the Turning component and in either the Teleportation or the Continuous Movement component. You can also set the Turning hand to the same as the movement hand to allow one-handed usage. In the details panel of the component, the following parameters can be used to adjust the behavior:
| Parameter| Description|
| ------ | ------ |
|Turn With Left Hand|If true, the left controller's stick is used for turning. Use this to easily specify handedness.|
|Allow Turning|Toggle this component on and off.|
|Snap Turn|If true Snap turning is used, if false turning is done continuously.|
|Turn Rate Factor|Adjusts the turning speed. Can only be edited if `Snap Turn` is set to false.|
|Snap Turn Angle|Specify the angle at which the pawn rotates per input. Can only be edited if `Snap Turn` is set to true.|
|Turn|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|Desktop Rotation|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Movement Right|The Input Mapping Context for the right hand, that maps controller buttons to behavior. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Movement Left |See above.|
# Interaction
[IntenSelect+](https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/plugins/rwth-vr-toolkit/-/wikis/Home/Pawn/IntenSelect) is an enhanced object selection technique for immersive virtual environments, designed to improve selection performance and user experience in Unreal Engine. It enables the intuitive selection of objects, including complex shapes, using an improved scoring function and flexible parameterization options on a per-object level.
[[_TOC_]]
# Structure
**ARWTHVRPawn**
The underlying baseclass for our pawn is defined in the `ARWTHVRPawn` C++ class. It inherits from `APawn` and adds some basic required functionality. This class mainly fulfills the following properties/functionalities:
- Create and set up hierarchy for:
- Head Camera: `UReplicatedCameraComponent`
- CollisionHandlingMovement: `UCollisionHandlingMovement`
- RightHand: `UReplicatedMotionControllerComponent`
- LeftHand: `UReplicatedMotionControllerComponent`
- Tick:
- Set Camera offset and update the right hand for desktop simulation
- Evaluate LiveLink
- Initialize Inputs:
- Setup own InputComponent
- Setup Motion Controller Sources
- Call SetupPlayerInput of all components which implement the `UInputExtensionInterface`
- Add all IMCs defined in `InputMappingContexts`, which is empty for this class
- Setup and execute attachment process for Cave/Cluster functionality, if running via nDisplay
As this class does not actually initialize any default values and references, we added two convenience BP classes which add more and more default functionality. Depending on how much you need to modify them, inherit your own pawn from the respective pawn.
**BP_RWTHVRPawn_Base**
This blueprint only adds sane defaults required for basic input binding and livelink functionality:
- InputMappingContexts:
- IMC_General
- IMC_MovementRightHand
- IMC_Cluster
- LiveLink:
- Head Subject Representation: Unknown-DTrack-Body-00
- Left Subject Representation: Unknown-DTrack-Body-01
- Right Subject Representation: DTrack-FlystickBody-00
**BP_RWTHVRPawn_Default**
This blueprint further adds meshes for head and hands and some basic movement and interaction components. It is meant as an example pawn that can be used as-is in basic cases. Usually you would either subclass this or copy it if you need to modify its structure.
It further adds:
- Meshes for head, left and right hand as well as DeviceVisualizations
- Interaction components:
- IntenSelect
- DirectInteractionComponentLeft/Right
- Turn- and ContinuousMovementComponents for navigation
- ClientTransformReplication for client authority needed for VR
A simple **reduced** class diagram can be seen here:
![Pawn.drawio.svg](uploads/1c82e2553216d62d32e988bc3111db49/Pawn.drawio.svg)
# Movement
All movement components are C++ derived blueprint components, which can be added to the `ARWTHVRPawn`. The blueprints itself can be found in `Components/Movement`. In the movement folder are two InputMappingContexts(IMCs) for either the left or right hand (which can be switched by (un-)ticking ``Move with Right Hand``). If you want to change the button mappings, you can adjust the respective IMC (best make a copy of them into your project first).
## Collision Handling Movement
This component is added to the pawn by default. It adds a configurable movement to your pawn implementation. It can be configured via the `NavigationMode`, which behaves as follows:
* `NAV_NONE` No input is handled
* `NAV_GHOST` Simple flying movement, but no collision with walls
* `NAV_FLY` Flying movement with collision checking
* `NAV_WALK` Walking movement that simulates gravity and collisions for the pawn
Collisions thereby are omitted if the user is virtually steering and also when the user is physically awlking into wall etc. (in this case by moving the world away, since we cannot hinder users to physically walk further)
If you want to use a completely custom-build pawn (not based on the ``AWTHVRPawn``), attach it to your pawn and make sure to call
```cpp
PawnMovement->SetUpdatedComponent(RootComponent);
PawnMovement->SetCameraComponent(CameraComponent);
```
## Continuous Movement
The continuous movement component is an Actor Component that adds continuous movement functionality to the Pawn. Use either the Continuous Movement or the Teleportation component, never both. In the details panel of the component, the following parameters can be used to adjust the behavior:
| Parameter| Description|
| ------ | ------ |
|Steering Mode|Specify if movement should be applied in hand or gaze direction.|
|Move With Right Hand|If true, the right controller's stick is used for movement. Use this to easily specify handedness, note that you might also want to change the handedness of the Turn component as well if you.|
|IMC Movement Right|The Input Mapping Context for the right hand, that maps controller buttons to behavior. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Movement Left|See above.|
|Move|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|Move Up|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
## Teleportation
The teleportation component is an Actor Component that adds teleportation based movement functionality to the Pawn. Use either the Teleportation or the Continuous Movement component, never both. In the details panel of the component, the following parameters can be used to adjust the behavior:
| Parameter| Description|
| ------ | ------ |
|Teleport Launch Speed|Specify the speed at which the projectile that gives the teleport target location is shot out of the controller. Higher values correspond to a larger teleportation range.|
|IMC Teleport Right|The Input Mapping Context for the right hand, that maps controller buttons to behavior. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Teleport Left|See above.|
|Move|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
## Turn
The Turn component adds turning functionality like smooth or snap turning to the pawn. You can combine this component with the Teleportation or the Continuous Movement component. Note that you can also specify which hand is responsible for turning, per default left hand is used for turning and right hand for movement. If you want to change that, you have to change it in the Turning component and in either the Teleportation or the Continuous Movement component. You can also set the Turning hand to the same as the movement hand to allow one-handed usage. In the details panel of the component, the following parameters can be used to adjust the behavior:
| Parameter| Description|
| ------ | ------ |
|Turn With Left Hand|If true, the left controller's stick is used for turning. Use this to easily specify handedness.|
|Allow Turning|Toggle this component on and off.|
|Snap Turn|If true Snap turning is used, if false turning is done continuously.|
|Turn Rate Factor|Adjusts the turning speed. Can only be edited if `Snap Turn` is set to false.|
|Snap Turn Angle|Specify the angle at which the pawn rotates per input. Can only be edited if `Snap Turn` is set to true.|
|Turn|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|Desktop Rotation|The reference to the Input Action. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Movement Right|The Input Mapping Context for the right hand, that maps controller buttons to behavior. This can only be set in the components blueprint (EditDefaultsOnly). Only change this if you know what you are doing.|
|IMC Movement Left |See above.|
# Interaction
[IntenSelect+](https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/plugins/rwth-vr-toolkit/-/wikis/Home/Pawn/IntenSelect) is an enhanced object selection technique for immersive virtual environments, designed to improve selection performance and user experience in Unreal Engine. It enables the intuitive selection of objects, including complex shapes, using an improved scoring function and flexible parameterization options on a per-object level.