Added a Directional Arrow to Mini Waypoints
This commit is contained in:
parent
cbf89a2c93
commit
c51f2ab7b6
BIN
EndlessVendetta/Content/BountySystem/Waypoint/WBP_MiniWaypoint.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/BountySystem/Waypoint/WBP_MiniWaypoint.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/BountySystem/Waypoint/WaypointArrow.png
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/BountySystem/Waypoint/WaypointArrow.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/BountySystem/Waypoint/WaypointArrow.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/BountySystem/Waypoint/WaypointArrow.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c4ea69a798330d981b7d72fce4e0999e306589ee7e0b3b49ce9a69adf36d6348
|
||||
oid sha256:d3943e1a064276d17b897a7a10a3c42a35c75d6c02117bd1ea962544f3576a9b
|
||||
size 654898
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "MiniWaypoint.h"
|
||||
|
||||
|
||||
|
||||
void UMiniWaypoint::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||
{
|
||||
Super::NativeTick(MyGeometry, InDeltaTime);
|
||||
@ -14,13 +13,15 @@ void UMiniWaypoint::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||
FVector2D ScreenLoc;
|
||||
PlayerController->ProjectWorldLocationToScreen(WorldLoc, ScreenLoc);
|
||||
|
||||
float TargetYaw = (WorldLoc - PlayerController->GetPawn()->GetActorLocation()).Rotation().Yaw;
|
||||
float PlayerYaw = PlayerController->GetControlRotation().Yaw;
|
||||
if (TargetYaw < 0 ) TargetYaw += 360;
|
||||
|
||||
ArrowImage->SetRenderTransformAngle(TargetYaw - PlayerYaw);
|
||||
|
||||
// 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))
|
||||
{
|
||||
float PlayerYaw = PlayerController->GetControlRotation().Yaw;
|
||||
float TargetYaw = (WorldLoc - PlayerController->GetPawn()->GetActorLocation()).Rotation().Yaw;
|
||||
if (TargetYaw < 0 ) TargetYaw += 360;
|
||||
|
||||
// Check if waypoint is closer to the players right
|
||||
bool TargetOnTheRight;
|
||||
if (PlayerYaw >= TargetYaw)
|
||||
@ -57,7 +58,8 @@ void UMiniWaypoint::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||
IconCanvasPanelSlot->SetPosition(ScreenLoc);
|
||||
}
|
||||
|
||||
void UMiniWaypoint::SetIconPanelSlot(UImage* IconImage)
|
||||
void UMiniWaypoint::SetIconPanelSlot(UCanvasPanel* IconParent, UImage* ArrowImageComp)
|
||||
{
|
||||
IconCanvasPanelSlot = Cast<UCanvasPanelSlot>(IconImage->Slot);
|
||||
ArrowImage = ArrowImageComp;
|
||||
IconCanvasPanelSlot = Cast<UCanvasPanelSlot>(IconParent->Slot);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "Components/CanvasPanelSlot.h"
|
||||
#include "Components/CanvasPanel.h"
|
||||
#include "Components/Image.h"
|
||||
#include "MiniWaypoint.generated.h"
|
||||
|
||||
@ -19,10 +20,11 @@ class ENDLESSVENDETTA_API UMiniWaypoint : public UUserWidget
|
||||
void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
|
||||
|
||||
UCanvasPanelSlot* IconCanvasPanelSlot;
|
||||
UImage* ArrowImage;
|
||||
|
||||
protected:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetIconPanelSlot(UImage* IconImage);
|
||||
void SetIconPanelSlot(UCanvasPanel* IconParent, UImage* ArrowImageComp);
|
||||
|
||||
public:
|
||||
FVector WorldLoc = FVector(0, 0, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user