Implemented Mini Waypoint Direction Toggle

This commit is contained in:
Rafal Swierczek 2023-11-26 22:45:21 +00:00
parent 5a8d8e8284
commit cbf89a2c93
3 changed files with 7 additions and 9 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:adf1682c60d18b92e71347784817def276af822981b49939047b0e98e8d1d1f5
oid sha256:4d5808bd83b46d892a7321c2bad2bee7aec16fbd8b427d0b05b760fcc596c906
size 105318

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9b6671545b77ffaff9044f90b3f250e2384252cb1d7a122617969c932a0f863e
oid sha256:c4ea69a798330d981b7d72fce4e0999e306589ee7e0b3b49ce9a69adf36d6348
size 654898

View File

@ -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;
}