Added New Mini Waypoint Class with Visibility Toggle

This commit is contained in:
Rafal Swierczek 2023-11-26 16:39:39 +00:00
parent 787c9c76f1
commit 153e026354
6 changed files with 42 additions and 4 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:7f2025158a6ae81155530070b6becb40850e60358ca27e87bee12a410a19bb53 oid sha256:a523b2149e46a3b369ca97e969d9a3f241a7af78f45b6500febbe252b9a53193
size 100344 size 100785

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:48aab2df957e2a9988712c7a2913d041000b8948f572298a8d8f23c759161e0a
size 39684

View File

@ -16,7 +16,6 @@ AWaypointActor::AWaypointActor()
// Called when the game starts or when spawned // Called when the game starts or when spawned
void AWaypointActor::BeginPlay() void AWaypointActor::BeginPlay()
{ {
SetActorTickEnabled(false);
Super::BeginPlay(); Super::BeginPlay();
SetActorTickInterval(0.05); SetActorTickInterval(0.05);
@ -24,7 +23,9 @@ void AWaypointActor::BeginPlay()
PlayersCam = Cast<UCameraComponent>(PlayerActor->GetComponentByClass(UCameraComponent::StaticClass())); PlayersCam = Cast<UCameraComponent>(PlayerActor->GetComponentByClass(UCameraComponent::StaticClass()));
ScalingMagnitude = (ScaleAtMaxDist - ScaleAtMinDist) / (MaxDist - MinDist); ScalingMagnitude = (ScaleAtMaxDist - ScaleAtMinDist) / (MaxDist - MinDist);
ScalingY_Intercept = ScaleAtMaxDist - (MaxDist * ScalingMagnitude); ScalingY_Intercept = ScaleAtMaxDist - (MaxDist * ScalingMagnitude);
if (PlayersCam) SetActorTickEnabled(true);
MiniWaypoint = CreateWidget<UMiniWaypoint>(GetWorld(), MiniWaypointClass);
MiniWaypoint->AddToViewport(1);
} }
// Called every frame // Called every frame
@ -36,10 +37,12 @@ void AWaypointActor::Tick(float DeltaTime)
{ {
UpdateVisibility(true); UpdateVisibility(true);
UpdateScaleAndRotation(); UpdateScaleAndRotation();
MiniWaypoint->UpdateVisibility(false);
return; return;
} }
UpdateVisibility(false); UpdateVisibility(false);
MiniWaypoint->UpdateVisibility(true);
} }

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Camera/CameraComponent.h" #include "Camera/CameraComponent.h"
#include "EndlessVendetta/UserWidgets/MiniWaypoint.h"
#include "GameFramework/Actor.h" #include "GameFramework/Actor.h"
#include "WaypointActor.generated.h" #include "WaypointActor.generated.h"
@ -21,6 +22,11 @@ class ENDLESSVENDETTA_API AWaypointActor : public AActor
UPROPERTY(EditDefaultsOnly, Category = "Waypoint") UPROPERTY(EditDefaultsOnly, Category = "Waypoint")
float WaypointFocusDistance = 3000; float WaypointFocusDistance = 3000;
UPROPERTY(EditDefaultsOnly, Category = "Waypoint")
TSubclassOf<UMiniWaypoint> MiniWaypointClass;
UMiniWaypoint* MiniWaypoint;
UPROPERTY(EditDefaultsOnly, Category = "Waypoint Scaling") UPROPERTY(EditDefaultsOnly, Category = "Waypoint Scaling")
float MaxDist = 16000.f; float MaxDist = 16000.f;

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MiniWaypoint.h"

View File

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