5#include "HeadMountedDisplayFunctionLibrary.h"
6#include "Engine/Engine.h"
7#include "IXRTrackingSystem.h"
9#include "Components/BoxComponent.h"
10#include "Kismet/GameplayStatics.h"
11#include "Kismet/KismetMathLibrary.h"
15 PrimaryActorTick.bCanEverTick =
true;
17 BoxCollision = CreateDefaultSubobject<UBoxComponent>(
"BoxCollision");
24 if (UGameplayStatics::GetPlatformName() ==
"Android" && GEngine->XRSystem->IsHeadTrackingAllowed())
32 FRotator DeviceOrientation;
33 FVector DevicePosition;
36 UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition(DeviceOrientation, DevicePosition);
39 if (UHeadMountedDisplayFunctionLibrary::GetHMDDeviceName() ==
"OculusHMD")
45 const float RelativeHeight = UKismetMathLibrary::TransformLocation(
BoxCollision->GetComponentTransform(), DevicePosition).Z;
53 if (Height > 100.0 || Height < -100.0)
55 GEngine->AddOnScreenDebugMessage(-1, 10.0, FColor::Red, TEXT(
"Error - Floor height is more/less than 100 units"));
56 UE_LOG(LogTemp,
Error, TEXT(
"Error - Floor height is more/less than 100 units"));
59 BoxCollision->SetRelativeLocation(FVector(.0, .0, Height));
class UBoxComponent * BoxCollision
UPROPERTY(EditAnywhere, BlueprintReadWrite)
virtual void BeginPlay() override
void SetFloorHeight(float Height)
UFUNCTION(BlueprintCallable, Category = "Dynamic Floor")
float DesiredCameraHeight
UPROPERTY(EditAnywhere, BlueprintReadWrite)
void AdjustCameraHeight()
UFUNCTION(BlueprintCallable, Category = "Dynamic Floor")