Implemented Landing Zone Entering Functionality and Space Ship Controls

This commit is contained in:
Rafal Swierczek 2024-01-14 19:09:17 +00:00
parent 7cc605b5e6
commit 1dacb4f130
13 changed files with 254 additions and 13 deletions

View File

@ -9,12 +9,12 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="42162083-13f4-4956-90b7-146c4a08f785" name="Changes" comment=""> <list default="true" id="42162083-13f4-4956-90b7-146c4a08f785" name="Changes" comment="">
<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/BountySystem/ControlsTutorial/Bounty/Checkpoints/CP_GoToParkourRoom.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/BountySystem/ControlsTutorial/Bounty/Checkpoints/CP_GoToParkourRoom.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/BountySystem/ControlsTutorial/Bounty/MB_Training.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/BountySystem/ControlsTutorial/Bounty/MB_Training.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/StarterContent/Architecture/Floor_400x400.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" 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/StarterContent/Audio/Collapse01.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Audio/Collapse01.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.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" />
</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" />
@ -129,7 +129,7 @@
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1705182847910</updated> <updated>1705182847910</updated>
<workItem from="1705182850227" duration="7499000" /> <workItem from="1705182850227" duration="25480000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:22cfe5fb6fc5e12348a76a250e903d182d8950b6cb54aba5a557ed0a643791e5 oid sha256:84374622c6dc77769d398e52fdd2dcacc7eab0bc4c651ac6ec3b77a019ed52f7
size 68896 size 68984

View File

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

View File

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

View File

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

Binary file not shown.

View File

@ -550,6 +550,12 @@ void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
// input is a Vector2D // input is a Vector2D
FVector2D MovementVector = Value.Get<FVector2D>(); FVector2D MovementVector = Value.Get<FVector2D>();
if (PlayerOnShip)
{
SpaceShip->MoveShip(MovementVector);
return;
}
if (Controller != nullptr) if (Controller != nullptr)
{ {
// add movement // add movement
@ -611,6 +617,12 @@ void AEndlessVendettaCharacter::Look(const FInputActionValue& Value)
// input is a Vector2D // input is a Vector2D
FVector2D LookAxisVector = Value.Get<FVector2D>(); FVector2D LookAxisVector = Value.Get<FVector2D>();
if (PlayerOnShip)
{
SpaceShip->RotateShip(LookAxisVector);
return;
}
if (Controller != nullptr) if (Controller != nullptr)
{ {
// add yaw and pitch input to controller // add yaw and pitch input to controller
@ -655,3 +667,15 @@ void AEndlessVendettaCharacter::UpdateInventorySize(int Cols, int Rows)
UE_LOG(LogTemp, Warning, TEXT("No Vaild Inventory")); UE_LOG(LogTemp, Warning, TEXT("No Vaild Inventory"));
} }
} }
void AEndlessVendettaCharacter::EnterShip(FTransform TakeoffLoc)
{
SpaceShip = GetWorld()->SpawnActor<ASpaceShip>(SpaceShipClass, TakeoffLoc.GetLocation(), TakeoffLoc.Rotator());
PlayerOnShip = true;
}
void AEndlessVendettaCharacter::ExitShip(FTransform ExitLoc)
{
UE_LOG(LogTemp, Warning, TEXT("Exitting Ship!!!"));
}

View File

@ -10,6 +10,7 @@
#include "GadgetSystem/GadgetManager.h" #include "GadgetSystem/GadgetManager.h"
#include "Inventory/InventoryComponent.h" #include "Inventory/InventoryComponent.h"
#include "Pawn/VICharacter.h" #include "Pawn/VICharacter.h"
#include "SpaceShip/SpaceShip.h"
#include "EndlessVendettaCharacter.generated.h" #include "EndlessVendettaCharacter.generated.h"
@ -245,4 +246,14 @@ public:
UInventoryComponent* InventoryComponent; UInventoryComponent* InventoryComponent;
UFUNCTION(Exec) UFUNCTION(Exec)
void UpdateInventorySize(int Cols, int Rows); void UpdateInventorySize(int Cols, int Rows);
// Space Ship
private:
bool PlayerOnShip = false;
UPROPERTY(EditDefaultsOnly, Category = "Space Ship")
TSubclassOf<ASpaceShip> SpaceShipClass;
ASpaceShip* SpaceShip;
public:
void ExitShip(FTransform ExitLoc);
void EnterShip(FTransform TakeoffLoc);
}; };

View File

@ -0,0 +1,53 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "LandingZone.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
ALandingZone::ALandingZone()
{
// 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;
}
void ALandingZone::UpdateAllLandingZones(bool Landing)
{
TArray<AActor*> AllLandingZones;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ALandingZone::StaticClass(), AllLandingZones);
for (auto LZ_Actor : AllLandingZones)
{
ALandingZone* LZ = Cast<ALandingZone>(LZ_Actor);
Landing ? LZ->HideWaypoint() : LZ->ShowWaypoint();
}
}
void ALandingZone::Interact()
{
Takeoff();
}
void ALandingZone::InteractPrompt()
{
}
void ALandingZone::Land()
{
AEndlessVendettaCharacter* PlayerChar = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
if (!IsValid(PlayerChar)) return;
UpdateAllLandingZones(true);
PlayerChar->ExitShip(LZ_ExitTransform);
}
void ALandingZone::Takeoff()
{
AEndlessVendettaCharacter* PlayerChar = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
if (!IsValid(PlayerChar)) return;
UpdateAllLandingZones(false);
PlayerChar->EnterShip(LZ_TakeoffTransform);
}

View File

@ -0,0 +1,46 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "EndlessVendetta/InteractionInterface.h"
#include "GameFramework/Actor.h"
#include "LandingZone.generated.h"
UCLASS()
class ENDLESSVENDETTA_API ALandingZone : public AActor, public IInteractionInterface
{
GENERATED_BODY()
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);
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;
public:
// Sets default values for this actor's properties
ALandingZone();
// 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();
};

View File

@ -0,0 +1,64 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SpaceShip.h"
#include "Components/ArrowComponent.h"
// Sets default values
ASpaceShip::ASpaceShip()
{
// Set this pawn 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 ASpaceShip::BeginPlay()
{
Super::BeginPlay();
PlayersCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter();
PlayersController = PlayersCharacter->GetController();
TArray<UActorComponent*> SeatComps = GetComponentsByTag(UArrowComponent::StaticClass(), FName("Seat"));
SeatComponent = Cast<UArrowComponent>(SeatComps[0]);
}
// Called every frame
void ASpaceShip::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
PlayersCharacter->SetActorLocation(SeatComponent->GetComponentLocation());
PlayersController->SetControlRotation(GetActorRotation());
}
// Called to bind functionality to input
void ASpaceShip::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void ASpaceShip::MoveShip(FVector2D MovementVector)
{
// Get ships direction vectors, and ignore their pitch
FVector ForwardVector = GetActorForwardVector();
ForwardVector.Z = 0;
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);
}
void ASpaceShip::RotateShip(FVector2D LookAxisVector)
{
FRotator shipRotator = GetActorRotation();
shipRotator.Yaw += LookAxisVector.X;
shipRotator.Pitch -= LookAxisVector.Y;
shipRotator.Pitch = shipRotator.Pitch < -30 ? -30 : shipRotator.Pitch;
shipRotator.Pitch = shipRotator.Pitch > 30 ? 30 : shipRotator.Pitch;
SetActorRotation(shipRotator);
}

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "SpaceShip.generated.h"
UCLASS()
class ENDLESSVENDETTA_API ASpaceShip : public ACharacter
{
GENERATED_BODY()
ACharacter* PlayersCharacter;
AController* PlayersController;
UArrowComponent* SeatComponent;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Sets default values for this pawn's properties
ASpaceShip();
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
void MoveShip(FVector2D MovementVector);
void RotateShip(FVector2D LookAxisVector);
};