Motion Controller setup UE 4.25

For some reason the controller is not being tracked with the:

MotionController->SetTrackingSource(EControllerHand::Right);

So I used the same idea from the previous class, by creating a SetHand() method, so it looks like this:

HandController.h

public:	
	// Sets default values for this actor's properties
	AHandController();

	void SetHand(FName Hand);

HandController.cpp

void AHandController::SetHand(FName Hand)
{
	MotionController->SetTrackingMotionSource(Hand);
}

VRPawn.cpp

// Include this header file
#include "XRMotionControllerBase.h"

// Called when the game starts or when spawned
void AVRPawn::BeginPlay()
{
	Super::BeginPlay();

	// Setup Controllers
	if (HandControllerClass)
	{
		RightController = GetWorld()->SpawnActor<AHandController>(HandControllerClass);
		RightController->AttachToComponent(VRRoot, FAttachmentTransformRules::KeepRelativeTransform);
		RightController->SetOwner(this);
		RightController->SetHand(FXRMotionControllerBase::RightHandSourceId);
	}

}

Now the controller is being tracked correctly. They must have changed the SetTrackingSource() method for 4.25

I wonder what is the Correct Path? https://docs.unrealengine.com/en-US/API/Runtime/HeadMountedDisplay/UMotionControllerComponent/index.html AT the Very Bottom of the Doc’s it shows that the EControllerHand Hand_DEPRECATED… it seems that both ways work just not exactly like was showed…

for me, the difference was
RightController->SetOwner(this);
when that is added, even without SetHand() function, the controller moves fine.

UE 4.27

Privacy & Terms