Optimised LandingZone Waypoint Transform Update from BP to C++
This commit is contained in:
parent
542b09012b
commit
b167dcca01
@ -8,12 +8,15 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" name="Changes" comment="">
|
<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$/.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/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/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/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>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -26,37 +29,37 @@
|
|||||||
<component name="MarkdownSettingsMigration">
|
<component name="MarkdownSettingsMigration">
|
||||||
<option name="stateVersion" value="1" />
|
<option name="stateVersion" value="1" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectColorInfo"><![CDATA[{
|
<component name="ProjectColorInfo">{
|
||||||
"customColor": "",
|
"customColor": "",
|
||||||
"associatedIndex": 5
|
"associatedIndex": 5
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="ProjectId" id="2bBQ5ZFjKADdlvCf2VePqJdIy1m" />
|
<component name="ProjectId" id="2bBQ5ZFjKADdlvCf2VePqJdIy1m" />
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"C++ Project.EndlessVendetta.executor": "Run",
|
"C++ Project.EndlessVendetta.executor": "Run",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"git-widget-placeholder": "dev",
|
"git-widget-placeholder": "HomeHub-Tutorial",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"rider.external.source.directories": [
|
"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\\DecompilerCache",
|
||||||
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
|
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
|
||||||
"C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src"
|
"C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
<configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project">
|
<configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1>
|
<configuration_1>
|
||||||
@ -128,7 +131,8 @@
|
|||||||
<option name="number" value="Default" />
|
<option name="number" value="Default" />
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1705685810960</updated>
|
<updated>1705685810960</updated>
|
||||||
<workItem from="1705685813496" duration="640000" />
|
<workItem from="1705685813496" duration="6457000" />
|
||||||
|
<workItem from="1705756768038" duration="3221000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</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)
|
void ALandingZone::UpdateAllLandingZones(bool Landing)
|
||||||
{
|
{
|
||||||
TArray<AActor*> AllLandingZones;
|
TArray<AActor*> AllLandingZones;
|
||||||
@ -22,6 +60,7 @@ void ALandingZone::UpdateAllLandingZones(bool Landing)
|
|||||||
{
|
{
|
||||||
ALandingZone* LZ = Cast<ALandingZone>(LZ_Actor);
|
ALandingZone* LZ = Cast<ALandingZone>(LZ_Actor);
|
||||||
Landing ? LZ->HideWaypoint() : LZ->ShowWaypoint();
|
Landing ? LZ->HideWaypoint() : LZ->ShowWaypoint();
|
||||||
|
LZ->IsWaypointVisible = !Landing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "Components/WidgetComponent.h"
|
||||||
#include "EndlessVendetta/InteractionInterface.h"
|
#include "EndlessVendetta/InteractionInterface.h"
|
||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
#include "LandingZone.generated.h"
|
#include "LandingZone.generated.h"
|
||||||
@ -12,22 +13,42 @@ class ENDLESSVENDETTA_API ALandingZone : public AActor, public IInteractionInter
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
// ------------------------------ Attributes -------------------------------------------------
|
||||||
UPROPERTY(EditAnywhere, Category = "Landing Zone")
|
UPROPERTY(EditAnywhere, Category = "Landing Zone")
|
||||||
FTransform LZ_ExitTransform;
|
FTransform LZ_ExitTransform;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Landing Zone")
|
UPROPERTY(EditAnywhere, Category = "Landing Zone")
|
||||||
FTransform LZ_TakeoffTransform;
|
FTransform LZ_TakeoffTransform;
|
||||||
|
|
||||||
// Hides or shows key aesthetic features of LZ's based on if the player is landing or not
|
UWidgetComponent* WaypointWidgetComponent;
|
||||||
void UpdateAllLandingZones(bool Landing);
|
|
||||||
|
|
||||||
|
|
||||||
|
APawn* PlayersPawn;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Landing Zone")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Landing Zone")
|
||||||
bool IsHomeBase_LZ = false;
|
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
|
// Allows player to enter their ship through a LZ
|
||||||
void Interact() override;
|
void Interact() override;
|
||||||
|
|
||||||
|
// Used to implement a pop up for interaction
|
||||||
void InteractPrompt() override;
|
void InteractPrompt() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -41,12 +62,14 @@ public:
|
|||||||
// Ran when a player takes off from any LZ in the world
|
// Ran when a player takes off from any LZ in the world
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void ShowWaypoint();
|
void ShowWaypoint();
|
||||||
|
|
||||||
// Ran when player lands at any LZ in the world
|
// Ran when player lands at any LZ in the world
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void HideWaypoint();
|
void HideWaypoint();
|
||||||
|
|
||||||
// Updates all LZ's, then runs exit ship func on player and passes the exit transform
|
// Updates all LZ's, then runs exit ship func on player and passes the exit transform
|
||||||
void Land();
|
void Land();
|
||||||
|
|
||||||
// Updates all LZ's, then runs enter ship func on player passing the correct takeoff transform
|
// Updates all LZ's, then runs enter ship func on player passing the correct takeoff transform
|
||||||
void Takeoff();
|
void Takeoff();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user