Implemented Waypoint Functionality and UI

To be reworked later down the line
This commit is contained in:
Rafal Swierczek 2023-10-19 16:22:13 +01:00
parent 81105bf0d1
commit aac09873f2
16 changed files with 141 additions and 13 deletions

View File

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

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:180441e7a8699c746681518a9eb4ed35ef57a39bb90960f2d7e3f4296e8d33ec oid sha256:3a7a738aafe69d411cab17f80fea465b635afdabd14e6df72feea23331cf45a8
size 140142 size 137946

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:31105f41e86fa2a2f7921c640c940139f3ed1720613b723fcd42a8c2f9abf309 oid sha256:264017fbfa9d46717dac13e666eef14f4d1732cd7a3e26ab4a91f5d381586757
size 14056 size 14244

View File

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

Binary file not shown.

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:390c4b654a6b0b7d80e3324f08f237801727353022d6ae28926992cf0cf4e579
size 211682

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:754ba6fc86e8d96dbe2fade3d515f45b10eefd1e3c7ac9115658daa2b251622e oid sha256:5fd67b08624a4a707041edc782af848e1042237175152a5faf6db5b2d4ec997c
size 76327 size 75188

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:8ba58db7f928d8f925388a4881468d0576d4f4a748ee0a7368391e6ca732cdb3 oid sha256:50c23f300085d150ffc94cfe05fb67283e7a15ee0bdb526c4473aace7620aa97
size 388285 size 388285

View File

@ -30,7 +30,7 @@ class ENDLESSVENDETTA_API ABountyDirector : public AActor, public IInteractionIn
UPROPERTY(EditDefaultsOnly, Category = "Bounty Director") UPROPERTY(EditDefaultsOnly, Category = "Bounty Director")
TSubclassOf<UPC_Display> PC_DisplayWidgetClass; TSubclassOf<UPC_Display> PC_DisplayWidgetClass;
UUserWidget* PC_DisplayWidget; UUserWidget* PC_DisplayWidget;
UPC_Display* PC_Display; UPC_Display* PC_Display;

View File

@ -15,7 +15,12 @@ ACheckpointClass::ACheckpointClass()
void ACheckpointClass::BeginPlay() void ACheckpointClass::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
if (!IsValid(WaypointActorClass)) return;
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
WaypointActor = Cast<AWaypointActor>(GetWorld()->SpawnActor<AActor>(WaypointActorClass, WaypointLoc, GetActorRotation(), SpawnParams));
WaypointActor->SetupWaypoint(WaypointIcon, CheckpointDescription);
} }
// Called every frame // Called every frame
@ -25,3 +30,9 @@ void ACheckpointClass::Tick(float DeltaTime)
} }
void ACheckpointClass::Destroyed()
{
if (WaypointActor) WaypointActor->Destroy();
}

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "WaypointActor.h"
#include "GameFramework/Actor.h" #include "GameFramework/Actor.h"
#include "CheckpointClass.generated.h" #include "CheckpointClass.generated.h"
@ -22,6 +23,10 @@ class ENDLESSVENDETTA_API ACheckpointClass : public AActor
UTexture2D* WaypointIcon; UTexture2D* WaypointIcon;
UPROPERTY(EditDefaultsOnly, Category = "Checkpoint") UPROPERTY(EditDefaultsOnly, Category = "Checkpoint")
FTransform CheckpointSpawnTransform; FTransform CheckpointSpawnTransform;
UPROPERTY(EditDefaultsOnly, Category = "Checkpoint")
TSubclassOf<AWaypointActor> WaypointActorClass;
AWaypointActor* WaypointActor;
// ---------------------------------------- // ----------------------------------------
UFUNCTION(BlueprintCallable, Category = "Checkpoint") UFUNCTION(BlueprintCallable, Category = "Checkpoint")
@ -34,6 +39,8 @@ class ENDLESSVENDETTA_API ACheckpointClass : public AActor
protected: protected:
// Called when the game starts or when spawned // Called when the game starts or when spawned
virtual void BeginPlay() override; virtual void BeginPlay() override;
virtual void Destroyed() override;
public: public:
FCompletedCheckpoint CompletedCheckpoint; FCompletedCheckpoint CompletedCheckpoint;

View File

@ -0,0 +1,48 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "WaypointActor.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
// Sets default values
AWaypointActor::AWaypointActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AWaypointActor::BeginPlay()
{
SetActorTickEnabled(false);
Super::BeginPlay();
SetActorTickInterval(0.05);
AActor* PlayerActor = Cast<AActor>(GetWorld()->GetFirstPlayerController()->GetPawn());
PlayersCam = Cast<UCameraComponent>(PlayerActor->GetComponentByClass(UCameraComponent::StaticClass()));
ScalingMagnitude = (ScaleAtMaxDist - ScaleAtMinDist) / (MaxDist - MinDist);
ScalingY_Intercept = ScaleAtMaxDist - (MaxDist * ScalingMagnitude);
if (PlayersCam) SetActorTickEnabled(true);
}
// Called every frame
void AWaypointActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (!PlayersCam) SetActorTickEnabled(false);
FVector WaypointLoc = GetActorLocation();
FVector PlayerCamLoc = PlayersCam->GetComponentLocation();
FRotator NewRot = UKismetMathLibrary::FindLookAtRotation(WaypointLoc, PlayerCamLoc);
SetActorRotation(NewRot);
float DistanceToPlayer = FVector::Distance(WaypointLoc, PlayerCamLoc);
// S for Scale
float S = (DistanceToPlayer * ScalingMagnitude) + ScalingY_Intercept;
S = FMath::Clamp(S, ScaleAtMinDist, ScaleAtMaxDist);
SetActorScale3D(FVector(1.f, S, S));
}

View File

@ -0,0 +1,47 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/Actor.h"
#include "WaypointActor.generated.h"
UCLASS()
class ENDLESSVENDETTA_API AWaypointActor : public AActor
{
GENERATED_BODY()
UCameraComponent* PlayersCam;
float ScalingMagnitude;
float ScalingY_Intercept;
UPROPERTY(EditDefaultsOnly, Category = "Waypoint Scaling")
float MaxDist = 8000.f;
UPROPERTY(EditDefaultsOnly, Category = "Waypoint Scaling")
float ScaleAtMaxDist = 8.f;
UPROPERTY(EditDefaultsOnly, Category = "Waypoint Scaling")
float MinDist = 900.f;
UPROPERTY(EditDefaultsOnly, Category = "Waypoint Scaling")
float ScaleAtMinDist = 0.15;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Sets default values for this actor's properties
AWaypointActor();
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintImplementableEvent)
void SetupWaypoint(UTexture2D* Icon, const FString& Desc);
};