About 'Extracting A Hand Controller Actor'!

  • Why should hand controllers be actors?
  • Spawn actors on BeginPlay.
  • Move UMotionControllerComponent into Actors.
  • Fix other build errors.
  • Create a Blueprint child actor.

(Unique Video Reference: 21_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!

How would I mirror the Oculus controller for the right hand now that I can’t access the static mesh in the cpp file?

i also faced the problem to mirror my oculus controller

i added a function under the HandController.cpp

void AHandleController::SetMirrorHand()
{
UStaticMeshComponent* controllerMesh = this->FindComponentByClass();
controllerMesh->SetWorldScale3D(FVector(1, -1, 1));
}

and called it after creating the right controller in the VRCharacter - this solution actually mirrored the controller but created another problem that inverting the normals of the mesh caused the texture to appear inside out:

when i set the scale -1 during runtime - its working fine.
from the code it causing this problem - please assist.

the only other option i know is to create a separate BP for the right controller.

Double click on the material for the oculus material and under the General tab in Details, drop down the Material Property Overrides and check both check boxes for Two Sided.

For Unreal Engine 4.23 and above, the EControllerHand is no longer an enum, but an FName. So, when you spawn it from the character.cpp, you have to use:
LeftController->SetHand(“EControllerHand::Left”);

Then, in the HandController.h file, you have to declare:
void SetHand(FName Hand);

And for the definition, use:
void AHandController::SetHand(FName Hand)
{
MotionController->SetTrackingMotionSource(Hand);
}

3 Likes

Be sure that the static mesh you add in for the motion controller has the OverlapAllDynamic collision, otherwise the teleport arch will not show up, nor will you be able to walk correctly! Only took me about 5 hours to figure this out once I created the blueprint.

1 Like

Hmm, wonder if that’s why my character randomly starts moving in a given direction occasionally. I’ll change the collision settings and see if that fixes it!

For this lecture I got very deep in pondering the question about how to adequately set up the attachment hierarchy given that the controllers are now separate from the character. In the end I decided I would create a “proxy” USceneComponent which would track the position and rotation of the right controller so that I could have the teleport spline and mesh still parented to something within the AVRCharacter. Then in Tick()I had the following code:

	if (RightController) {
		RightControllerProxy->SetWorldTransform(RightController->GetTransform());
	}

It seemed that relative transforms weren’t available unless I missed a function. But now I can see from the video that having the parent of the spline and spline mesh seems to be unnecessary as long as the starting location and direction tracks the right controller (actor). I wonder if there are any other implications of the two different approaches?

Privacy & Terms