diff --git a/Source/CAVEOverlay/Private/CAVEOverlayController.cpp b/Source/CAVEOverlay/Private/CAVEOverlayController.cpp index d8590930cdbac6dc9955c49a9304a909fba3e3c1..312f084ad1f2426c9c841d78a6979c2ece12a149 100644 --- a/Source/CAVEOverlay/Private/CAVEOverlayController.cpp +++ b/Source/CAVEOverlay/Private/CAVEOverlayController.cpp @@ -184,11 +184,15 @@ void ACAVEOverlayController::BeginPlay() if (!attached_ && cave_origin_) { AttachToComponent(cave_origin_, FAttachmentTransformRules::SnapToTargetNotIncludingScale); attached_ = true; + UE_LOG(CAVEOverlayLog, Log, TEXT("Attached to CaveOrigin")); } } float ACAVEOverlayController::calculateOpacityFromPosition(FVector position) { - return 1 - FMath::Clamp(((FVector2D(position).GetAbs() - FVector2D(wall_distance_ - wall_close_distance_, wall_distance_ - wall_close_distance_)) / wall_fade_distance_).GetAbsMax(), 0.0f, 1.0f); + return FMath::Max( + FMath::Clamp((FMath::Abs(position.X) - (wall_distance_ - wall_close_distance_)) / wall_fade_distance_, 0.0f, 1.0f), + FMath::Clamp((FMath::Abs(position.Y) - (wall_distance_ - wall_close_distance_)) / wall_fade_distance_, 0.0f, 1.0f) + ); } bool ACAVEOverlayController::positionInDoorOpening(FVector position) { @@ -216,6 +220,7 @@ void ACAVEOverlayController::Tick(float DeltaTime) if (!attached_ && cave_origin_) { AttachToComponent(cave_origin_, FAttachmentTransformRules::SnapToTargetNotIncludingScale); attached_ = true; + UE_LOG(CAVEOverlayLog, Log, TEXT("Attached to CaveOrigin")); } if (!shutter_glasses_) return; //Display Cluster not initialized