Ue 4.25

This is how I got it working on UE 4.25

HandController.h

void SetHand(FName Hand);

HandController.cpp

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

VCharacter.cpp

// Need to be included
#include "XRMotionControllerBase.h"

// BeginPlay
void AVRCharacter::BeginPlay()
{
	Super::BeginPlay();

	DestinationMarker->SetVisibility(false);

	// Display Tunnel Vision when moving
	if (BlinkerMaterialBase != nullptr)
	{
		BlinkerMaterialInstance = UMaterialInstanceDynamic::Create(BlinkerMaterialBase, this);
		PostProcessComponent->AddOrUpdateBlendable(BlinkerMaterialInstance);		
	}

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

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

}

Hope that helps.

2 Likes

This helps a lot! Thanks for this!

Claps Claps good work! Perfect

Privacy & Terms