From cbf89a2c938c0061c717a3f565b9c93a095d052b Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Sun, 26 Nov 2023 22:45:21 +0000 Subject: [PATCH] Implemented Mini Waypoint Direction Toggle --- .../Content/BountySystem/Waypoint/BP_Waypoint.uasset | 2 +- EndlessVendetta/Content/Levels/TrainingFacility.umap | 2 +- .../EndlessVendetta/UserWidgets/MiniWaypoint.cpp | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset b/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset index d2678445..dc557ee3 100644 --- a/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset +++ b/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:adf1682c60d18b92e71347784817def276af822981b49939047b0e98e8d1d1f5 +oid sha256:4d5808bd83b46d892a7321c2bad2bee7aec16fbd8b427d0b05b760fcc596c906 size 105318 diff --git a/EndlessVendetta/Content/Levels/TrainingFacility.umap b/EndlessVendetta/Content/Levels/TrainingFacility.umap index afb2d366..2ebfb2cd 100644 --- a/EndlessVendetta/Content/Levels/TrainingFacility.umap +++ b/EndlessVendetta/Content/Levels/TrainingFacility.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b6671545b77ffaff9044f90b3f250e2384252cb1d7a122617969c932a0f863e +oid sha256:c4ea69a798330d981b7d72fce4e0999e306589ee7e0b3b49ce9a69adf36d6348 size 654898 diff --git a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp index 6ee988a9..bb2d4640 100644 --- a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp @@ -17,17 +17,12 @@ void UMiniWaypoint::NativeTick(const FGeometry& MyGeometry, float InDeltaTime) // Check if waypoint is outside of players vision frustum if (FMath::IsWithin(ScreenLoc.X, -0.01, 0.01) && FMath::IsWithin(ScreenLoc.Y, -0.01, 0.01)) { - //UE_LOG(LogTemp, Warning, TEXT("IconPos: %f"), IconCanvasPanelSlot->GetPosition().X); - float PlayerYaw = PlayerController->GetControlRotation().Yaw; float TargetYaw = (WorldLoc - PlayerController->GetPawn()->GetActorLocation()).Rotation().Yaw; if (TargetYaw < 0 ) TargetYaw += 360; - UE_LOG(LogTemp, Warning, TEXT("Yaw: %f"), PlayerController->GetControlRotation().Yaw); - UE_LOG(LogTemp, Warning, TEXT("Look at Yaw: %f"), TargetYaw); - // Check if waypoint is closer to the players right - bool TargetOnTheRight = false; + bool TargetOnTheRight; if (PlayerYaw >= TargetYaw) { TargetOnTheRight = FMath::Abs(TargetYaw - PlayerYaw) >= 180; @@ -37,7 +32,10 @@ void UMiniWaypoint::NativeTick(const FGeometry& MyGeometry, float InDeltaTime) TargetOnTheRight = TargetYaw - PlayerYaw <= 180; } - UE_LOG(LogTemp, Warning, TEXT("On the right?...%s"), TargetOnTheRight ? TEXT("true") : TEXT("false")); + FVector2D NewPos = IconCanvasPanelSlot->GetPosition(); + if ((TargetOnTheRight && NewPos.X < 0) || (!TargetOnTheRight && NewPos.X > 0)) NewPos.X *= -1; + + IconCanvasPanelSlot->SetPosition(NewPos); return; }