How do I access a VR Motion Controller's location in C++? Help

I’m really struggling to learn here; I could really use some patient help.


I’m just trying to get a motion controller’s world location.
I can see it in VR, I can find it in the Unreal Engine Editor.

Ideally I’m looking for a line of code that does something like:

FVector LeftXYZ = GetWorld(MotionControllerLeft);

but I’ve been trying things more like:

	USceneComponent* RootSceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
	RootComponent = RootSceneComponent;
	LeftMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftMotionController"));
	LeftMotionController->SetupAttachment(RootComponent);
	RightMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightMotionController"));
	RightMotionController->SetupAttachment(RootComponent);


	FVector LeftXYZ = GetActorLocation(LeftMotionController);
	FVector RightXYZ = GetActorLocation(RightMotionController);

So far I’ve read thru and tried all of these:
_https://community.gamedev.tv/t/accessing-pawn-motion-controllers-from-c/4357/8
_https://answers.unrealengine.com/questions/424684/how-to-access-the-motion-controllers-in-c.html
_https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/XRDevelopment/VR/VRHowTos/AttachingItemsToHMD/
_https://answers.unrealengine.com/questions/464372/get-motioncontroller-location-in-c.html
_https://forums.unrealengine.com/t/how-to-get-world-position-of-the-hands-controllers/109518
_https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/XRDevelopment/VR/VRHowTos/MotionController/
_https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/XRDevelopment/VR/
_https://docs.unrealengine.com/4.26/en-US/API/Runtime/HeadMountedDisplay/UMotionControllerComponent/
_https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/XRDevelopment/VR/VRHowTos/UsingTouchControllers/
_https://answers.unrealengine.com/questions/604992/how-to-access-to-vive-controller-in-c.html
_https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/XRDevelopment/VR/VRPlatforms/SteamVR/
_https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/XRDevelopment/VR/VRPlatforms/SteamVR/HowTo/SteamVRInput/

I’m using Win10, Visual Studio 2019, Unreal 4.27.1, Valve Index.

Same way you get the location of any scene component

LeftController->GetComponentLocation()

Does anyone here besides me see a problem with Dan’s response?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms