From 153e02635408f1ffda28006000dfe5bc031d6b4a Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Sun, 26 Nov 2023 16:39:39 +0000 Subject: [PATCH] Added New Mini Waypoint Class with Visibility Toggle --- .../BountySystem/Waypoint/BP_Waypoint.uasset | 4 ++-- .../Waypoint/WBP_MiniWaypoint.uasset | 3 +++ .../BountySystem/WaypointActor.cpp | 7 +++++-- .../BountySystem/WaypointActor.h | 6 ++++++ .../UserWidgets/MiniWaypoint.cpp | 5 +++++ .../UserWidgets/MiniWaypoint.h | 21 +++++++++++++++++++ 6 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 EndlessVendetta/Content/BountySystem/Waypoint/WBP_MiniWaypoint.uasset create mode 100644 EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp create mode 100644 EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.h diff --git a/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset b/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset index fea9a176..020a3c2c 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:7f2025158a6ae81155530070b6becb40850e60358ca27e87bee12a410a19bb53 -size 100344 +oid sha256:a523b2149e46a3b369ca97e969d9a3f241a7af78f45b6500febbe252b9a53193 +size 100785 diff --git a/EndlessVendetta/Content/BountySystem/Waypoint/WBP_MiniWaypoint.uasset b/EndlessVendetta/Content/BountySystem/Waypoint/WBP_MiniWaypoint.uasset new file mode 100644 index 00000000..b4cca8c2 --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/Waypoint/WBP_MiniWaypoint.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48aab2df957e2a9988712c7a2913d041000b8948f572298a8d8f23c759161e0a +size 39684 diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp index 939bbd9e..ce186cbb 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp @@ -16,7 +16,6 @@ AWaypointActor::AWaypointActor() // Called when the game starts or when spawned void AWaypointActor::BeginPlay() { - SetActorTickEnabled(false); Super::BeginPlay(); SetActorTickInterval(0.05); @@ -24,7 +23,9 @@ void AWaypointActor::BeginPlay() PlayersCam = Cast(PlayerActor->GetComponentByClass(UCameraComponent::StaticClass())); ScalingMagnitude = (ScaleAtMaxDist - ScaleAtMinDist) / (MaxDist - MinDist); ScalingY_Intercept = ScaleAtMaxDist - (MaxDist * ScalingMagnitude); - if (PlayersCam) SetActorTickEnabled(true); + + MiniWaypoint = CreateWidget(GetWorld(), MiniWaypointClass); + MiniWaypoint->AddToViewport(1); } // Called every frame @@ -36,10 +37,12 @@ void AWaypointActor::Tick(float DeltaTime) { UpdateVisibility(true); UpdateScaleAndRotation(); + MiniWaypoint->UpdateVisibility(false); return; } UpdateVisibility(false); + MiniWaypoint->UpdateVisibility(true); } diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h index e8936dec..d86c1207 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "Camera/CameraComponent.h" +#include "EndlessVendetta/UserWidgets/MiniWaypoint.h" #include "GameFramework/Actor.h" #include "WaypointActor.generated.h" @@ -21,6 +22,11 @@ class ENDLESSVENDETTA_API AWaypointActor : public AActor UPROPERTY(EditDefaultsOnly, Category = "Waypoint") float WaypointFocusDistance = 3000; + UPROPERTY(EditDefaultsOnly, Category = "Waypoint") + TSubclassOf MiniWaypointClass; + + UMiniWaypoint* MiniWaypoint; + UPROPERTY(EditDefaultsOnly, Category = "Waypoint Scaling") float MaxDist = 16000.f; diff --git a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp new file mode 100644 index 00000000..68f8f0f4 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "MiniWaypoint.h" + diff --git a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.h b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.h new file mode 100644 index 00000000..a556167d --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/MiniWaypoint.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Blueprint/UserWidget.h" +#include "MiniWaypoint.generated.h" + +/** + * + */ +UCLASS() +class ENDLESSVENDETTA_API UMiniWaypoint : public UUserWidget +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintImplementableEvent) + void UpdateVisibility(bool IsVisible); + +};