Vive Tracker - Can be tracked in editor?

Hello there,
I know it is possibile to have the Vive Tracker to be tracked in editor, without Play or Simulate, but I can’t figure out how to achieve this.
I use Unreal for Virtual Production purpose and I need the Vive Tracker to drive a VCam, possibily without hitting Play.
Thx

Good question…for body mocap I use IKinema Orion, which is a standalone software that gets the Vive Trackers position and send it to UE4, and it does work without being in either Play/Simulate.
I think that you can do the same thing, but using the data coming from SteamVR, but honestly I haven’t found any usefull informations as well.

May I ask why you need it to work without being in Play/Simulate?
Because having a Vive Tracker onto a camera is very easy to integrate and use in Virtual Production.

I was really curious so I tested it. Yes, it’s possible, but with a bit of C++ (only to make it Tick in editor, not to get coordinates of vive tracker).

This isn’t 100% working code, you need to use multiple static mesh components and bind them to device IDs, but I hope it gives an idea.

Header:


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ViewportTicker.generated.h"

UCLASS()
class VIVEMOCAP_API AViewportTicker : public AActor
{
    GENERATED_BODY()

public:    
    AViewportTicker();
    virtual void Tick(float DeltaTime) override;

    UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Components")
    class UStaticMeshComponent* TrackerMesh;

    virtual bool ShouldTickIfViewportsOnly() const override
    {
        return true;
    }
};

Source:


#include "ViewportTicker.h"
#include "Components/StaticMeshComponent.h"
#include "SteamVRFunctionLibrary.h"

AViewportTicker::AViewportTicker()
{
    PrimaryActorTick.bCanEverTick = true;
    PrimaryActorTick.bStartWithTickEnabled = true;

    RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));

    TrackerMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TrackerMesh"));
    TrackerMesh->SetupAttachment(RootComponent);

}

void AViewportTicker::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    TArray<int32> DeviceIds;
    TArray<int32> TrackerIds;
    USteamVRFunctionLibrary::GetValidTrackedDeviceIds(ESteamVRTrackedDeviceType::Controller, DeviceIds);
    USteamVRFunctionLibrary::GetValidTrackedDeviceIds(ESteamVRTrackedDeviceType::Other, TrackerIds);
    DeviceIds.Append(TrackerIds);

    if (DeviceIds.Num() > 0)
    {
        FVector loc;
        FRotator rot;
        USteamVRFunctionLibrary::GetTrackedDevicePositionAndOrientation(DeviceIds[0], loc, rot);
        TrackerMesh->SetRelativeLocationAndRotation(loc, rot);
    }
}


I am building a muticamera setup, that streams to a video mixer via Blackmagic. I use the new features of Composure, and is very handy to have all functioning in editor, for production reasons.

Thank you, i’ll check this. I am not a programmer, so I don’t think i’ll understand everything. Also a cinecamera must be parented to the tracker, so I think i’ll need coordinates to make this useful.
Any chance this thing can be done or explored using blueprints? I understand a little coding, but it is beyond my skills to really use it in production.

@FabioA
You can get tracker’s coordinates in blueprint using the same two functions: GetValidTrackedDeviceIds and GetTrackedDevicePositionAndOrientation. But Tick event doesn’t work in viewport without simulation mode unless ShouldTickIfViewportsOnly function returns true. And you can only override ShouldTickIfViewportsOnly function in c++.

Probably you can use Python instead to extend editor’s functionaliy - but i’m not sure.

So, I added this functionality to my helper mini-plugin. You can download it here, then copy to [your project]/Plugins folder or [engine version]/Engine/Plugins/Marketplace.
In your project, create blueprint inherited from “Editor SteamVR Controller” and place it on level, then in Details panel add any objects to “Tracked Objects” map. Good luck!

Thank you very much! I’ll try today and i’ll let you know.

Thank you again!​​​​​​​

If you needed lastest version:

  • open my ViveMocapKit page on Marketplace (link in my signature)
  • download “Demo Project (for motion capture)” (it won’t work without ViveMocapKit plugin, but you don’t need it)
  • extract and copy ViveMocap/Plugins/SteamVRTrackingLib to you project’s “Plugins” folder.