About 'Connecting a LeftHandController'!

In this video(objectives)…

  1. Create the PaletteMenuHandController.
  2. Add and spawn a left hand controller.
  3. Connecting in blueprint.
  4. Setting the MotionController hand.

After watching(learning outcomes)…

Revision of the HandController architecture.

(Unique Video Reference: 39_LP_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!

Remember, if you are using UE4 4.23 or higher, the motion source uses FStrings instead of the Enum states. I had to change my code as follows:

HandControllerBase.h
public:
virtual void TriggerPressed() {}
virtual void TriggerReleased() {}
void SetHand(FString Hand);

HandControllerBase.cpp
void AHandControllerBase::SetHand(FString Hand)
{
if (Hand == “Left”) {
MotionController->SetTrackingMotionSource(“EControllerHand::Left”);
}
else if (Hand == “Right”) {
MotionController->SetTrackingMotionSource(“EControllerHand::Right”);
}
}

VRPawn.cpp
void AVRPawn::BeginPlay()
{
Super::BeginPlay();

if (RightHandControllerClass) {
	RightHandController = GetWorld()->SpawnActor<AHandControllerBase>(RightHandControllerClass);
	RightHandController->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::SnapToTargetIncludingScale);
	RightHandController->SetHand("Right"); //Use FString here instead of Enum
	RightHandController->SetOwner(this); //SetOwner must be included for 4.23 or higher
}

if (LeftHandControllerClass) {
	LeftHandController = GetWorld()->SpawnActor<AHandControllerBase>(LeftHandControllerClass);
	LeftHandController->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::SnapToTargetIncludingScale);
	LeftHandController->SetHand("Left"); //Use FString here instead of Enum
	LeftHandController->SetOwner(this); //SetOwner must be included for 4.23 or higher
}

}

Both Controllers are spawning properly using the Enum - UE 4.26

void AVRPawn::BeginPlay()
{
	Super::BeginPlay();
	
	if (RightHandControllerClass)
	{
		RightHandController = GetWorld()->SpawnActor<AHandControllerBase>(RightHandControllerClass);
		RightHandController->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::SnapToTargetIncludingScale);
		RightHandController->SetHand(EControllerHand::Right);
		RightHandController->SetOwner(this); // Set Owner UE4.20~

	}

	if (LeftHandControllerClass)
	{
		LeftHandController = GetWorld()->SpawnActor<AHandControllerBase>(LeftHandControllerClass);
		LeftHandController->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::SnapToTargetIncludingScale);
		LeftHandController->SetHand(EControllerHand::Left);
		LeftHandController->SetOwner(this); // Set Owner UE4.20~
	}
}

Privacy & Terms