diff --git a/Source/CAVEOverlay/Private/CAVEOverlayController.cpp b/Source/CAVEOverlay/Private/CAVEOverlayController.cpp index d10d2db2daf8ad5968324dcded16a959d052ddfb..d8590930cdbac6dc9955c49a9304a909fba3e3c1 100644 --- a/Source/CAVEOverlay/Private/CAVEOverlayController.cpp +++ b/Source/CAVEOverlay/Private/CAVEOverlayController.cpp @@ -156,7 +156,7 @@ void ACAVEOverlayController::BeginPlay() if (!display_cluster_mode_) return; // Not our business //Actor config - InputComponent->BindAction("DisplayClusterAction1", EInputEvent::IE_Pressed, this, &ACAVEOverlayController::CycleDoorType); + InputComponent->BindAction("Action1", EInputEvent::IE_Pressed, this, &ACAVEOverlayController::CycleDoorType); InputComponent->BindKey(EKeys::F10, EInputEvent::IE_Pressed, this, &ACAVEOverlayController::CycleDoorType); //Determine the screentype for later usage @@ -180,15 +180,20 @@ void ACAVEOverlayController::BeginPlay() player_pawn_ = Cast<AVirtualRealityPawn>(GetWorld()->GetFirstPlayerController()->GetPawn()); refreshPawnComponents(); + + if (!attached_ && cave_origin_) { + AttachToComponent(cave_origin_, FAttachmentTransformRules::SnapToTargetNotIncludingScale); + attached_ = true; + } } float ACAVEOverlayController::calculateOpacityFromPosition(FVector position) { - return 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 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); } bool ACAVEOverlayController::positionInDoorOpening(FVector position) { - return FMath::IsWithinInclusive(position.X, wall_distance_ + 10 - 20 - wall_close_distance_, wall_distance_ + 10) //Overlap both sides 10cm - && FMath::IsWithinInclusive(position.Y, wall_distance_ + 10 - door_current_opening_width_absolute_, wall_distance_ + 10); //Overlap one side 10cm + return FMath::IsWithinInclusive(-position.X, wall_distance_ + 10 - 20 - wall_close_distance_, wall_distance_ + 10) //Overlap both sides 10cm + && FMath::IsWithinInclusive(-position.Y, wall_distance_ + 10 - door_current_opening_width_absolute_, wall_distance_ + 10); //Overlap one side 10cm } void ACAVEOverlayController::refreshPawnComponents(){ @@ -208,10 +213,12 @@ void ACAVEOverlayController::Tick(float DeltaTime) if (!display_cluster_mode_) return; // Not our business refreshPawnComponents(); - if (!cave_origin_ || !shutter_glasses_) return; //Display Cluster not initialized + if (!attached_ && cave_origin_) { + AttachToComponent(cave_origin_, FAttachmentTransformRules::SnapToTargetNotIncludingScale); + attached_ = true; + } - //Move complete actor around - SetActorLocationAndRotation(cave_origin_->GetComponentLocation(), cave_origin_->GetComponentQuat()); + if (!shutter_glasses_) return; //Display Cluster not initialized //Tape Logic FVector shutter_position = shutter_glasses_->GetRelativeTransform().GetLocation(); diff --git a/Source/CAVEOverlay/Public/CAVEOverlayController.h b/Source/CAVEOverlay/Public/CAVEOverlayController.h index 89679d1aa456a928911b368e77c85fafd2596fd6..08a7110d5ce2ebe8462cef24bdf0509d7bea69a8 100644 --- a/Source/CAVEOverlay/Public/CAVEOverlayController.h +++ b/Source/CAVEOverlay/Public/CAVEOverlayController.h @@ -72,6 +72,7 @@ private: bool positionInDoorOpening(FVector position); //Pawn Components + bool attached_ = false; void refreshPawnComponents(); AVirtualRealityPawn* player_pawn_; UDisplayClusterSceneComponent* cave_origin_;