4.7.VR Root Component
This component only offsets the collision and movement logic of the root component, if you want attachments to follow the HMD you still need a Parent Relative Attachment Component.
How do I use it?
Replace your current root component with a VRRootComponent (plugin characters come with it already)
Set the capsule size and VROffset that you want.
Make sure that the pawn either is locally controlled or has a camera component attached to the VRRootComponent
USceneComponent * TargetPrimitiveComponent: Is automatically filled by searching children for a camera component.
FTransform OffsetComponentToWorld: Is created each tick, represents the LocalToWorld of the component from the HMDs relative position. Can get the world position / rotation from it. Some helper functions are also below.
FVector VRCapsuleOffset: Offset from center on the HMD to place the capsule (X: -10 places it around your head instead of in front of you at the headset).
bUseWalkingCollisionOverride – Whether to use the override collision when walking around.
WalkingCollisionOverride – An alternative collision set up to use when walking around in the real world. Can be used to separate movement function collision from room scale walking collision. Use case: set to a new object collision channel that is defaulted ignore, then when walking around you can walk into walls (and run screen blacking / allow some walkthrough) but when using character movement (controller / input) you will still collide with the environment.
- Standard directional vectors and locations don’t represent the collision location as this keeps the same world position and just offsets collision. The following functions are for getting the correct locations and vectors for game logic.*
GetVRForwardVector – Gets the forward vector from the capsules offset rotation.
GetVRRightVector – Gets the right vector from the capsules offset rotation.
GetVRUpVector – Gets the up vector from the capsules offset rotation.
GetVRLocation – Gets the capsules location from the offset location
GetVRRotation – Gets the capsules rotation from the offset location
Networked / Multiplayer Setup
You shouldn’t have to do anything different, if the root component is locally controlled then it will get the HMD location directly, if it is not then it will use the location of TargetPrimitiveComponent instead which is automatically assigned to the first camera component found directly attached to the root component during Begin Play. You can manually override the TargetPrimitiveComponent after BeginPlay to force it to align to a different component, but I can’t see a reason to do it.
If no HMD is detected (or not locally controlled) and there is no child camera component to use instead it will revert to placing the capsule at 0,0,0 like a normal capsule component.