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
- Head Camera:
- 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:
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:
Modification
Which class to choose?
Most of the time, the default functionality of the pawn is not enough for your application and you need to create your own pawn. Depending on your use-case, there are a few approaches:
- If you want to extend the default pawn, you can just subclass it and add your functionality on top. This won't allow you to modify the structure.
- If you need to modify the structure, you should base your pawn on the
BP_RWTHVRPawn_Base
. Then, compose your pawn by adding the components that you would like to have, or just copy the default pawn and delete what you don't want, both approaches should work. - If you need C++ functionality, you should base your C++ class on the
ARWTHVRPawn
, and then create a Blueprint Pawn that is based on your custom C++ pawn. Make sure you set the LiveLink and IMCs yourself then!
How to add functionality?
There are many ways to add more functionality and logic to your pawn. Once you have decided which class to choose, you can either add your logic to your pawn class directly (in C++ or BP), or use composition. With composition, you encapsulate your logic in your own Actor- or SceneComponent, and simply add the component to the pawn. This is generally preferred (if possible), as it creates a cleaner hierarchy and higher modularity.
How to handle custom input?
When using composition, to receive input in your custom component and bind your own InputActions, you can implement the IInputExtensionInterface
and override IInputExtensionInterface::SetupPlayerInput
to set up your own input. An example can be found in e.g. the UDirectInteractionComponent
class.
Then, you need to bind your InputAction to a button by creating your own InputMappingContext. After creating it, you need to add it to your pawn's InputMappingContexts
property.
The default InputMappingContexts
included in the toolkit use the default trigger behavior. This means that the triggered
-callback is called every frame for as long as the button has a non-zero value. To only catch the beginning/end of a button press use Started
/Completed
instead or copy the InputMappingContext
and set a trigger behavior that better suits your use case.
For more information on Enhanced Input visit the .
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 ARWTHVRPawn
), attach it to your pawn and make sure to call
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. |
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. |
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. |
Interaction
Todo!
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.