Is there a better way to check if HMD is connected?

I am currently using

EHMDWornState::Worn == UHeadMountedDisplayFunctionLibrary::GetHMDWornState()

But for some reason, my Oculus says it’s activated even though the proximity sensor is not covered.

I tried using

UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled()

but it only detects whether it’s activated at beginplay, and not in realtime.

Any ideas???

Do you check in an Tick, this should allow you to respond properly to the sensor.

virtual void Tick(float DeltaTime) override
{
    Super::Tick(DeltaTime);

    EHMDWornState::Type WornState = UHeadMountedDisplayFunctionLibrary::GetHMDWornState();
    if (WornState == EHMDWornState::Worn)
    {
        // HMD is being worn
    }
    else if (WornState == EHMDWornState::NotWorn)
    {
        // HMD is not being worn
    }
    else if (WornState == EHMDWornState::Unknown)
    {
        // HMD state is unknown
    }
}

Other option is the subscribe to the event with the OculusSDK

OculusSDK::OnHMDWornStateChanged.AddUObject(this, &AYourActor::OnHMDWornStateChanged);

void AYourActor::OnHMDWornStateChanged(EHMDWornState::Type NewState)
{
    if (NewState == EHMDWornState::Worn)
    {
        // HMD is being worn
    }
    else if (NewState == EHMDWornState::NotWorn)
    {
        // HMD is not being worn
    }
}

Hope that helps, :wink:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.