Implemented Landing Zone Landing Functionality

This commit is contained in:
Rafal Swierczek 2024-01-14 20:13:17 +00:00
parent 1dacb4f130
commit 195ff80dea
13 changed files with 80 additions and 15 deletions

View File

@ -11,10 +11,14 @@
<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/StarterContent/Audio/Collapse01.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Audio/Collapse01.uasset" 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.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/LandingZone.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/SpaceShip.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/SpaceShip.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/SpaceShip.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/SpaceShip/SpaceShip.h" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -129,7 +133,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1705182847910</updated>
<workItem from="1705182850227" duration="25480000" />
<workItem from="1705182850227" duration="28840000" />
</task>
<servers />
</component>

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:40716dd78ee18731e93233dd0ed13c534868e5e9521a172e8a033011af33363d
size 3336963
oid sha256:9bae1373774782a35a5a728192412fe8577428a4ac37418a878beafe48aa8635
size 3337229

Binary file not shown.

View File

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

View File

@ -213,6 +213,11 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
void AEndlessVendettaCharacter::Interact()
{
if (PlayerOnShip)
{
SpaceShip->PlayerInteracting();
return;
}
FHitResult OutHit;
FCollisionQueryParams QueryParams = FCollisionQueryParams::DefaultQueryParam;
QueryParams.AddIgnoredActor(this);
@ -236,6 +241,7 @@ void AEndlessVendettaCharacter::Interact()
void AEndlessVendettaCharacter::SetCrouch()
{
if (PlayerOnShip) return;
Crouch();
}
@ -279,6 +285,7 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve
void AEndlessVendettaCharacter::ToggleRecon()
{
if (PlayerOnShip) return;
if (!GadgetManager->IsValidReconGadget()) return;
if (IsValid(PrimaryWeapon)) EquipPrimary();
@ -301,6 +308,7 @@ void AEndlessVendettaCharacter::ToggleRecon()
void AEndlessVendettaCharacter::ToggleCombat()
{
if (PlayerOnShip) return;
if (!GadgetManager->IsValidCombatGadget()) return;
if (IsValid(PrimaryWeapon)) EquipPrimary();
@ -325,6 +333,7 @@ void AEndlessVendettaCharacter::ToggleCombat()
//When 1 is pressed it calls EquipPrimary
void AEndlessVendettaCharacter::EquipPrimary()
{
if (PlayerOnShip) return;
FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
@ -376,6 +385,7 @@ void AEndlessVendettaCharacter::EquipPrimary()
void AEndlessVendettaCharacter::EquipSecondary()
{
if (PlayerOnShip) return;
FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
@ -670,12 +680,19 @@ void AEndlessVendettaCharacter::UpdateInventorySize(int Cols, int Rows)
void AEndlessVendettaCharacter::EnterShip(FTransform TakeoffLoc)
{
PlayFadeScreen();
if (IsValid(PrimaryWeapon)) EquipPrimary();
if (IsValid(SecondaryWeapon)) EquipSecondary();
SpaceShip = GetWorld()->SpawnActor<ASpaceShip>(SpaceShipClass, TakeoffLoc.GetLocation(), TakeoffLoc.Rotator());
PlayerOnShip = true;
}
void AEndlessVendettaCharacter::ExitShip(FTransform ExitLoc)
{
UE_LOG(LogTemp, Warning, TEXT("Exitting Ship!!!"));
PlayFadeScreen();
SetActorLocation(ExitLoc.GetLocation());
GetController()->SetControlRotation(ExitLoc.Rotator());
SpaceShip->Destroy();
PlayerOnShip = false;
}

View File

@ -124,6 +124,9 @@ protected:
FTimerHandle RegenHealthTimerHandle;
void Heal(const float Amount);
UFUNCTION(BlueprintImplementableEvent)
void PlayFadeScreen();
public:
int Money = 2000;
AGadgetManager* GadgetManager;

View File

@ -20,10 +20,12 @@ class ENDLESSVENDETTA_API ALandingZone : public AActor, public IInteractionInter
// Hides or shows key aesthetic features of LZ's based on if the player is landing or not
void UpdateAllLandingZones(bool Landing);
protected:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Landing Zone")
bool IsHomeBase_LZ = false;
// Allows player to enter their ship through a LZ
void Interact() override;
void InteractPrompt() override;
@ -32,6 +34,10 @@ 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();
// Ran when a player takes off from any LZ in the world
UFUNCTION(BlueprintImplementableEvent)
void ShowWaypoint();

View File

@ -12,6 +12,21 @@ ASpaceShip::ASpaceShip()
PrimaryActorTick.bCanEverTick = true;
}
void ASpaceShip::SightCheck()
{
FHitResult OutHit;
FCollisionObjectQueryParams ObjectQueryParams;
ObjectQueryParams.AddObjectTypesToQuery(ECollisionChannel::ECC_GameTraceChannel2);
FVector LT_Start = SeatComponent->GetComponentLocation();
FVector LT_End = LT_Start + (SeatComponent->GetForwardVector() * 50000);
GetWorld()->LineTraceSingleByObjectType(OutHit, LT_Start, LT_End, ObjectQueryParams);
ALandingZone* LZ = Cast<ALandingZone>(OutHit.GetActor());
if (!IsValid(LZ)) return;
Potential_LZ = LZ;
LZ->SuggestLandingWidget();
}
// Called when the game starts or when spawned
void ASpaceShip::BeginPlay()
{
@ -30,6 +45,8 @@ void ASpaceShip::Tick(float DeltaTime)
PlayersCharacter->SetActorLocation(SeatComponent->GetComponentLocation());
PlayersController->SetControlRotation(GetActorRotation());
SightCheck();
}
// Called to bind functionality to input
@ -39,6 +56,12 @@ void ASpaceShip::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent
}
void ASpaceShip::PlayerInteracting()
{
if (IsValid(Potential_LZ)) Potential_LZ->Land();
}
void ASpaceShip::MoveShip(FVector2D MovementVector)
{
// Get ships direction vectors, and ignore their pitch
@ -47,7 +70,6 @@ void ASpaceShip::MoveShip(FVector2D MovementVector)
FVector RightVector = GetActorRightVector();
RightVector.Y += RightVector.Z;
RightVector.Z = 0;
UE_LOG(LogTemp, Warning, TEXT("Forward:%f, Sideways:%f"), MovementVector.Y, MovementVector.X);
AddMovementInput(ForwardVector, MovementVector.Y, true);
AddMovementInput(RightVector, MovementVector.X, true);
}

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "LandingZone.h"
#include "GameFramework/Character.h"
#include "SpaceShip.generated.h"
@ -16,6 +17,10 @@ class ENDLESSVENDETTA_API ASpaceShip : public ACharacter
AController* PlayersController;
UArrowComponent* SeatComponent;
ALandingZone* Potential_LZ;
void SightCheck();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
@ -30,6 +35,8 @@ public:
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
void PlayerInteracting();
void MoveShip(FVector2D MovementVector);
void RotateShip(FVector2D LookAxisVector);