About 'Hand Controller Components'!

  • Setup hand controller components.
  • Where are the hand controller meshes?
  • Teleporting with hand controllers.

(Unique Video Reference: 16_AE_VR2)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

Hey, this is for anyone who is using UE 4.19.

There have been some changes in the API.
->Hand = EControllerHand:: Left has been deprecated.

Instead use

->MotionSource = FXRMotionControllerBase::LeftHandSourceId;

You will also need the following include.
#include "XRMotionControllerBase.h"

I am typing this message on my phone using my data connection. Hopefully autocorrect didn’t mess anything up.

Cheers!!!

2 Likes

DAMN YOU UNREAL!

But seriously, just finish a bit of content and the go and change the engine. Thanks for sharing this BTW.

Are you using a rift or a vive? I am using the rift and for what ever reason the forwardVector is not working. I know there must be a way to get it since it is used in RoboRecall.

UPDATE
After doing lecture 20 Parabolic Teleport Pointer everything works now. Not sure if the editor was messing up on me or what but for what ever reason everything seems to work as it should

2 Likes

Instead of directly setting the member variable, use (preferred):
SetMotionTrackingSource(“EControllerHand::Left”) and SetMotionTrackingSource(“EControllerHand::Right”)​.
or:
SetTrackingSource(EControllerHand::Left) and SetMotionTrackingSource(EControllerHand::Right)​.

Two advantages:

  1. You don’t need the additional include.
  2. Less likely to break in future.

Infact it did break in 4.19. There is a patch in the video now.

I am having the same issue with my Oculus Rift. Instead of the ring showing up where I am pointing it tends to stay directly under the controller. I guess I will just push forward to lecture 20 to get something working!

Hi!
Using an Oculus Rift can’t display touch model programmatically. I’m trying this with:

LeftController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftController"));
LeftController->SetupAttachment(VRRoot);
LeftController->SetTrackingSource(EControllerHand::Left);
LeftController->SetDisplayModelSource(TEXT("OculusHMD"));
LeftController->SetShowDeviceModel(true);

Using the Motion Controller BP it seems to work ok.

For me the last line is enough. If you have a blueprint child have you checked this boolean isn’t overridden?

I could be wrong about this, but there seems to be an issue when using SetTrackingMotionSource(FXRMotionControllerBase::RightHandSourceId) withUnreal 4.23.1.

I believe that RightController->AddWorldOffset() is ignored and has no effect on the component transform. Because of this, it sits at the VR root which is twice the distance from the center of the play space than it should be. (When standing in the middle, motion controllers are in front of you, but the further you move from center, the further away from you they get – its local transform is exactly double what it should be).

My solution was to add another SceneComponent called HandsRoot which contains the motion controllers, and to add the world offset to that instead. This works perfectly, but seems a bit hacky :sweat_smile:

So you’re saying that the hand controllers appear to be rooted differently to the headset? I would certainly expect the AddWorldOffset to not work. After all, this position should be continually updated by the actual location of the hand controllers.

Thanks for the response. Apologies, but I was mistaken. I think this Unreal bug was causing the odd behaviour when compiling C++ and switching back to Unreal blueprints.

When I make a change to the component passed to SetupAttachment(), compile, return to Unreal, and close/reopen/recompile the blueprint which inherits the C++ class, the component hierarchy does not update. The workaround is to close the project entirely and then reopen.

1 Like

4.25.4 - Click on Display Device Model to automatically … display the mesh model of the device you’re using

2 Likes

And I should also add that we must change header file like below to set Display Device Model true in editor.

	UPROPERTY(VisibleAnywhere)
	class UMotionControllerComponent* LeftController;

	UPROPERTY(VisibleAnywhere)
	class UMotionControllerComponent* RightController;
1 Like

I’m not sure if anyone is still having issues with this, but I thought I would share what worked for me since the UE documentation was a bit confusing for me on this step.

In the character header file, I used:
UPROPERTY(VisibleAnywhere)
class UMotionControllerComponent* LVRController;
UPROPERTY(VisibleAnywhere)
class UMotionControllerComponent* RVRController;

And in the .cpp file, I used:
LVRController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("Left VR Controller"));
LVRController->SetupAttachment(VRRoot);
LVRController->MotionSource = TEXT("Left");

RVRController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("Right VR Controller"));
RVRController->SetupAttachment(VRRoot);
RVRController->MotionSource = TEXT("Right");

Then in BeginPlay, make sure to include:

LVRController->bDisplayDeviceModel = true;
RVRController->bDisplayDeviceModel = true;

The controllers just showed up as soon as I turned them on and moved around perfectly.

If you still can’t see it, then start the game, go to the editor, find the player’s character, go to the missing motion controller’s component, and make sure “Display Device Model” under “Visualization” is checked.

I hope this helps!

1 Like

Privacy & Terms