From aac09873f2ff46f9c67b3019d9bef73f840f5be3 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek <34179rs@gmail.com> Date: Thu, 19 Oct 2023 16:22:13 +0100 Subject: [PATCH] Implemented Waypoint Functionality and UI To be reworked later down the line --- .../Checkpoints/CP_PickUpWeapons.uasset | 3 ++ .../IntroCutscene/WBP_IntroCutscene.uasset | 4 +- .../MB_TutorialFacility.uasset | 4 +- .../BountySystem/Waypoint/BP_Waypoint.uasset | 3 ++ .../Waypoint/TempMainBountyIcon.png | 3 ++ .../Waypoint/TempMainBountyIcon.uasset | 3 ++ .../Waypoint/WBP_WaypointWidget.uasset | 3 ++ .../BaseWeapons/BP_BaseWeapon.uasset | 4 +- .../Content/Levels/TrainingFacility.umap | 2 +- .../Architecture/Floor_400x400.uasset | 4 +- .../HDRI/HDRI_Epic_Courtyard_Daylight.uasset | 4 +- .../BountySystem/BountyDirector.h | 2 +- .../BountySystem/CheckpointClass.cpp | 13 ++++- .../BountySystem/CheckpointClass.h | 7 +++ .../BountySystem/WaypointActor.cpp | 48 +++++++++++++++++++ .../BountySystem/WaypointActor.h | 47 ++++++++++++++++++ 16 files changed, 141 insertions(+), 13 deletions(-) create mode 100644 EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/CP_PickUpWeapons.uasset create mode 100644 EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset create mode 100644 EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.png create mode 100644 EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.uasset create mode 100644 EndlessVendetta/Content/BountySystem/Waypoint/WBP_WaypointWidget.uasset create mode 100644 EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp create mode 100644 EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h diff --git a/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/CP_PickUpWeapons.uasset b/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/CP_PickUpWeapons.uasset new file mode 100644 index 00000000..840c9d68 --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/CP_PickUpWeapons.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5c15f23ffe72a5addc71f6982edf1d60d246b1b4a174e9db4f737ee71480dfd +size 23100 diff --git a/EndlessVendetta/Content/BountySystem/TutorialFacility/IntroCutscene/WBP_IntroCutscene.uasset b/EndlessVendetta/Content/BountySystem/TutorialFacility/IntroCutscene/WBP_IntroCutscene.uasset index 3959c58c..1dc0a9e5 100644 --- a/EndlessVendetta/Content/BountySystem/TutorialFacility/IntroCutscene/WBP_IntroCutscene.uasset +++ b/EndlessVendetta/Content/BountySystem/TutorialFacility/IntroCutscene/WBP_IntroCutscene.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:180441e7a8699c746681518a9eb4ed35ef57a39bb90960f2d7e3f4296e8d33ec -size 140142 +oid sha256:3a7a738aafe69d411cab17f80fea465b635afdabd14e6df72feea23331cf45a8 +size 137946 diff --git a/EndlessVendetta/Content/BountySystem/TutorialFacility/MB_TutorialFacility.uasset b/EndlessVendetta/Content/BountySystem/TutorialFacility/MB_TutorialFacility.uasset index b1c4ef92..cdb5de9f 100644 --- a/EndlessVendetta/Content/BountySystem/TutorialFacility/MB_TutorialFacility.uasset +++ b/EndlessVendetta/Content/BountySystem/TutorialFacility/MB_TutorialFacility.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:31105f41e86fa2a2f7921c640c940139f3ed1720613b723fcd42a8c2f9abf309 -size 14056 +oid sha256:264017fbfa9d46717dac13e666eef14f4d1732cd7a3e26ab4a91f5d381586757 +size 14244 diff --git a/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset b/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset new file mode 100644 index 00000000..0caa296f --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/Waypoint/BP_Waypoint.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b261ee9bb3d384362cc7fe462df6c011c322f91efb4722e3a8d1ed5a4e05c69c +size 47976 diff --git a/EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.png b/EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.png new file mode 100644 index 00000000..61ddbe03 --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f99a94e75ec8bbb52399da3df66d97452a3028a8503a1945ba03b9618ff979d8 +size 258434 diff --git a/EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.uasset b/EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.uasset new file mode 100644 index 00000000..ecc25e4a --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/Waypoint/TempMainBountyIcon.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:390c4b654a6b0b7d80e3324f08f237801727353022d6ae28926992cf0cf4e579 +size 211682 diff --git a/EndlessVendetta/Content/BountySystem/Waypoint/WBP_WaypointWidget.uasset b/EndlessVendetta/Content/BountySystem/Waypoint/WBP_WaypointWidget.uasset new file mode 100644 index 00000000..09b70476 --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/Waypoint/WBP_WaypointWidget.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b07b293876d399dfdce186c99573c335e2e2e509856f7a67a2a463569b4f23d +size 30404 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset index f2c7b766..5995b7ce 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:754ba6fc86e8d96dbe2fade3d515f45b10eefd1e3c7ac9115658daa2b251622e -size 76327 +oid sha256:5fd67b08624a4a707041edc782af848e1042237175152a5faf6db5b2d4ec997c +size 75188 diff --git a/EndlessVendetta/Content/Levels/TrainingFacility.umap b/EndlessVendetta/Content/Levels/TrainingFacility.umap index 19f57dd6..fc188df6 100644 --- a/EndlessVendetta/Content/Levels/TrainingFacility.umap +++ b/EndlessVendetta/Content/Levels/TrainingFacility.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ba58db7f928d8f925388a4881468d0576d4f4a748ee0a7368391e6ca732cdb3 +oid sha256:50c23f300085d150ffc94cfe05fb67283e7a15ee0bdb526c4473aace7620aa97 size 388285 diff --git a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset index fc989d88..c2a34afc 100644 --- a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset +++ b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6f0925b53326aad3da5286726b9e6c54e9618957e1d5e88484c1911197ae5ba1 -size 14831 +oid sha256:4c0ecf0ac0702cc2bd355ec050232a61c49e10f102448efbeb735a51824adef6 +size 14948 diff --git a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset index 0f990580..138b8d8d 100644 --- a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset +++ b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc35eb2d43a47427d30aba0196f9eac90d089dd3abca319528c5d25c83510d0d -size 72364642 +oid sha256:dbdee5fb4cee49c21e18629a5c34a184b942058f45eb244b319810963e616c2c +size 66790690 diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h index 5c3a9719..73795c2e 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h @@ -30,7 +30,7 @@ class ENDLESSVENDETTA_API ABountyDirector : public AActor, public IInteractionIn UPROPERTY(EditDefaultsOnly, Category = "Bounty Director") TSubclassOf PC_DisplayWidgetClass; - + UUserWidget* PC_DisplayWidget; UPC_Display* PC_Display; diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp index 630725e4..393b942b 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp @@ -15,7 +15,12 @@ ACheckpointClass::ACheckpointClass() void ACheckpointClass::BeginPlay() { Super::BeginPlay(); - + if (!IsValid(WaypointActorClass)) return; + + FActorSpawnParameters SpawnParams; + SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + WaypointActor = Cast(GetWorld()->SpawnActor(WaypointActorClass, WaypointLoc, GetActorRotation(), SpawnParams)); + WaypointActor->SetupWaypoint(WaypointIcon, CheckpointDescription); } // Called every frame @@ -25,3 +30,9 @@ void ACheckpointClass::Tick(float DeltaTime) } +void ACheckpointClass::Destroyed() +{ + if (WaypointActor) WaypointActor->Destroy(); +} + + diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h index 6991181a..13f5c09a 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "WaypointActor.h" #include "GameFramework/Actor.h" #include "CheckpointClass.generated.h" @@ -22,6 +23,10 @@ class ENDLESSVENDETTA_API ACheckpointClass : public AActor UTexture2D* WaypointIcon; UPROPERTY(EditDefaultsOnly, Category = "Checkpoint") FTransform CheckpointSpawnTransform; + UPROPERTY(EditDefaultsOnly, Category = "Checkpoint") + TSubclassOf WaypointActorClass; + + AWaypointActor* WaypointActor; // ---------------------------------------- UFUNCTION(BlueprintCallable, Category = "Checkpoint") @@ -34,6 +39,8 @@ class ENDLESSVENDETTA_API ACheckpointClass : public AActor protected: // Called when the game starts or when spawned virtual void BeginPlay() override; + + virtual void Destroyed() override; public: FCompletedCheckpoint CompletedCheckpoint; diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp new file mode 100644 index 00000000..0c9320cb --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.cpp @@ -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(GetWorld()->GetFirstPlayerController()->GetPawn()); + PlayersCam = Cast(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)); +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h new file mode 100644 index 00000000..0dba8a7b --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/WaypointActor.h @@ -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); + +};