I’m following this tutorialhttps://youtube.com/watch?v=5LiMUtfW2aYhttps://www.youtube.com/watch?v=760qplc2LYk
to try to get VR working in a C++ project, and finally figured out that the tutorial I’m following works in 4.23.1 but not in 4.24. The motion controller tracking does not work (doesn’t track at all, just sits there). I’m using the original HTC Vive
Any insight on this?
Here are relevant files
VRTest.Build.cs
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class VRTest : ModuleRules
{
public VRTest(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
PrivateDependencyModuleNames.AddRange(new string] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
MyPawn.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "MyPawn.generated.h"
UCLASS()
class VRTEST_API AMyPawn : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
AMyPawn();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class USceneComponent* Scene;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UCameraComponent* Camera;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UMotionControllerComponent* LeftController;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UMotionControllerComponent* RightController;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UStaticMeshComponent* LeftMesh;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class UStaticMeshComponent* RightMesh;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};
MyPawn.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyPawn.h"
#include "Components/SceneComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Camera/CameraComponent.h"
#include "MotionControllerComponent.h"
// Sets default values
AMyPawn::AMyPawn()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Scene = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
LeftController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftController"));
RightController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightController"));
LeftMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("LeftMesh"));
RightMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("RightMesh"));
RootComponent = Scene;
Camera->SetupAttachment(Scene);
LeftController->SetupAttachment(Scene);
RightController->SetupAttachment(Scene);
LeftMesh->SetupAttachment(LeftController);
RightMesh->SetupAttachment(RightController);
LeftController->SetTrackingSource(EControllerHand::Left);
RightController->SetTrackingSource(EControllerHand::Right);
}
// Called when the game starts or when spawned
void AMyPawn::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMyPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}