Announcement

Collapse
No announcement yet.

Motion Controller SetTrackingSource doesn't seem to be working in 4.24.1

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Motion Controller SetTrackingSource doesn't seem to be working in 4.24.1

    I'm following this tutorial
    https://www.youtube.com/watch?v=5LiMUtfW2aY
    https://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
    HTML Code:
    // 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
    HTML Code:
    // 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
    HTML Code:
    // 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);
    
    }

    #2
    I recently had an issue that I thought was related to 4.24. I can't confirm if it really is due to a change in the engine code, but I did find a solution for my issue with the motion controllers not picking up my Oculus touch controllers.

    In my case, the difference was setting the "owner" to Self when spawning the motion controller blueprints. I went back and forth, and not setting the owner, the controllers just sit there. Setting the owner to "self" (which is how it's done in the default VR pawn when attaching the motion controllers), magically they spring to life. Being new to UE4, the description of the Owner parameter didn't seem to correspond to anything meaningful, so if someone has some insight as to why owner is so vital, it would be helpful. In particular if that is a change in 4.24+. Hope this helps someone!

    Comment


      #3
      Still having the same issue. Steps to reproduce - 4.24.2 - Create VR Template - Play in VR. Controllers are not being tracked. Has anyone figured out how to solve the issue?

      Comment

      Working...
      X