Optimised LandingZone Waypoint Transform Update from BP to C++
This commit is contained in:
parent
542b09012b
commit
b167dcca01
@ -8,12 +8,15 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Content/Levels/ControlTutorialLevel.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/ControlTutorialLevel.umap" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Content/Ships/LandingZone.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Ships/LandingZone.uasset" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Particles/P_Ambient_Dust.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Particles/P_Ambient_Dust.uasset" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/LandingZone.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/LandingZone.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/LandingZone.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/LandingZone.h" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -26,37 +29,37 @@
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo"><![CDATA[{
|
||||
"customColor": "",
|
||||
"associatedIndex": 5
|
||||
}]]></component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"customColor": "",
|
||||
"associatedIndex": 5
|
||||
}</component>
|
||||
<component name="ProjectId" id="2bBQ5ZFjKADdlvCf2VePqJdIy1m" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"C++ Project.EndlessVendetta.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "dev",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"C++ Project.EndlessVendetta.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "HomeHub-Tutorial",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
|
||||
"C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src"
|
||||
"keyToStringList": {
|
||||
"rider.external.source.directories": [
|
||||
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache",
|
||||
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
|
||||
"C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src"
|
||||
]
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project">
|
||||
<configuration_1>
|
||||
@ -128,7 +131,8 @@
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1705685810960</updated>
|
||||
<workItem from="1705685813496" duration="640000" />
|
||||
<workItem from="1705685813496" duration="6457000" />
|
||||
<workItem from="1705756768038" duration="3221000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
BIN
EndlessVendetta/Content/Levels/ControlTutorialLevel.umap
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Levels/ControlTutorialLevel.umap
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/Ships/LandingZone.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Ships/LandingZone.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
Binary file not shown.
@ -14,6 +14,44 @@ ALandingZone::ALandingZone()
|
||||
|
||||
}
|
||||
|
||||
void ALandingZone::BeginPlay()
|
||||
{
|
||||
WaypointWidgetComponent = Cast<UWidgetComponent>(GetComponentByClass(UWidgetComponent::StaticClass()));
|
||||
PlayersPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
|
||||
|
||||
// Tick updates the waypoints transform base on players location
|
||||
if (!IsValid(WaypointWidgetComponent) || !IsValid(PlayersPawn)) SetActorTickEnabled(false);
|
||||
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
void ALandingZone::Tick(float DeltaSeconds)
|
||||
{
|
||||
Super::Tick(DeltaSeconds);
|
||||
if (!IsWaypointVisible) return;
|
||||
UpdateWaypointTransform();
|
||||
}
|
||||
|
||||
void ALandingZone::UpdateWaypointTransform()
|
||||
{
|
||||
FVector WaypointLoc = WaypointWidgetComponent->GetComponentLocation();
|
||||
FVector PlayerLoc = PlayersPawn->GetActorLocation();
|
||||
|
||||
// Update rotation
|
||||
FVector LocationDiffVector = PlayerLoc - WaypointLoc;
|
||||
FRotator LookAtPlayerRotator = LocationDiffVector.Rotation();
|
||||
WaypointWidgetComponent->SetWorldRotation(LookAtPlayerRotator);
|
||||
|
||||
// Update scale
|
||||
double DistanceFromPlayer = LocationDiffVector.Length();
|
||||
double ScaleMagnitude = (12.f - 0.15f) / (48000.f - 900.f);
|
||||
double ScaleIntercept = 12.f - (48000.f * ScaleMagnitude);
|
||||
double ResultingScale = (DistanceFromPlayer * ScaleMagnitude) + ScaleIntercept;
|
||||
FVector WaypointScale = FVector(1, ResultingScale, ResultingScale);
|
||||
WaypointWidgetComponent->SetWorldScale3D(WaypointScale);
|
||||
}
|
||||
|
||||
|
||||
void ALandingZone::UpdateAllLandingZones(bool Landing)
|
||||
{
|
||||
TArray<AActor*> AllLandingZones;
|
||||
@ -22,6 +60,7 @@ void ALandingZone::UpdateAllLandingZones(bool Landing)
|
||||
{
|
||||
ALandingZone* LZ = Cast<ALandingZone>(LZ_Actor);
|
||||
Landing ? LZ->HideWaypoint() : LZ->ShowWaypoint();
|
||||
LZ->IsWaypointVisible = !Landing;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/WidgetComponent.h"
|
||||
#include "EndlessVendetta/InteractionInterface.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "LandingZone.generated.h"
|
||||
@ -11,29 +12,49 @@ UCLASS()
|
||||
class ENDLESSVENDETTA_API ALandingZone : public AActor, public IInteractionInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
// ------------------------------ Attributes -------------------------------------------------
|
||||
UPROPERTY(EditAnywhere, Category = "Landing Zone")
|
||||
FTransform LZ_ExitTransform;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Landing Zone")
|
||||
FTransform LZ_TakeoffTransform;
|
||||
|
||||
// Hides or shows key aesthetic features of LZ's based on if the player is landing or not
|
||||
void UpdateAllLandingZones(bool Landing);
|
||||
|
||||
|
||||
UWidgetComponent* WaypointWidgetComponent;
|
||||
|
||||
APawn* PlayersPawn;
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Landing Zone")
|
||||
bool IsHomeBase_LZ = false;
|
||||
|
||||
public:
|
||||
bool IsWaypointVisible = false;
|
||||
// ------------------------------ Methods -------------------------------------------------
|
||||
private:
|
||||
// Runs when game starts or this actor spawns
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
// Runs once per frame
|
||||
virtual void Tick(float DeltaSeconds) override;
|
||||
|
||||
// Hides or shows key aesthetic features of LZ's based on if the player is landing or not
|
||||
void UpdateAllLandingZones(bool Landing);
|
||||
|
||||
// Updates waypoints rotation and scale based on players location, only if visible
|
||||
void UpdateWaypointTransform();
|
||||
|
||||
protected:
|
||||
// Allows player to enter their ship through a LZ
|
||||
void Interact() override;
|
||||
|
||||
// Used to implement a pop up for interaction
|
||||
void InteractPrompt() override;
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
ALandingZone();
|
||||
|
||||
|
||||
// Waypoint will display something along the lines of Press F to Land
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void SuggestLandingWidget();
|
||||
@ -41,12 +62,14 @@ public:
|
||||
// Ran when a player takes off from any LZ in the world
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void ShowWaypoint();
|
||||
|
||||
// Ran when player lands at any LZ in the world
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void HideWaypoint();
|
||||
|
||||
// Updates all LZ's, then runs exit ship func on player and passes the exit transform
|
||||
void Land();
|
||||
|
||||
// Updates all LZ's, then runs enter ship func on player passing the correct takeoff transform
|
||||
void Takeoff();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user