Also what is the relation between the array of IMotionControllers and the index that the GetControllerOrientationAndPosition function takes as a first argument?
Figured out a solution. This requires that a blueprint exists with at least one Motion Controller Component as part of the child tree of the Scene Root.
On begin play:
TArray<UMotionControllerComponent*> comps;
this->GetComponents(comps);
for (UMotionControllerComponent* motionController : comps)
{
if (motionController->Hand == EControllerHand::Left) {
leftHand = motionController;
}
else if (motionController->Hand == EControllerHand::Right) {
rightHand = motionController;
}
}
//If you don't want to use a MotionController component and still need to access motion controllers in C++
TArray<IMotionController*> controllers = ModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());