Compare commits

...

3 Commits

Author SHA1 Message Date
baz a5cfef827b Update Level 2024-06-04 20:24:11 +01:00
baz 5be0c02e69 Add Camera Volume 2024-06-04 20:24:02 +01:00
baz 3678ce7e1d Update default level 2024-06-04 16:01:45 +01:00
6 changed files with 75 additions and 3 deletions

View File

@ -1,9 +1,10 @@
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Engine/Maps/Templates/OpenWorld
GameDefaultMap=/Game/Levels/Level.Level
GameInstanceClass=/Game/Gamemodes/BP_TankGameinstance.BP_TankGameinstance_C
GlobalDefaultGameMode=/Game/Gamemodes/BP_TankGamemode.BP_TankGamemode_C
EditorStartupMap=/Game/Levels/Level.Level
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12

BIN
Content/Levels/Level.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -0,0 +1,32 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "CameraVolume.h"
#include "TankPlayerCharacter.h"
ACameraVolume::ACameraVolume()
{
ArrowComponent = CreateDefaultSubobject<UArrowComponent>(TEXT("Arrow Component"));
ArrowComponent->SetupAttachment(RootComponent);
DebugCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("Debug Camera"));
DebugCamera->SetupAttachment(ArrowComponent);
DebugCamera->SetActive(false);
}
void ACameraVolume::BeginPlay()
{
Super::BeginPlay();
this->OnActorBeginOverlap.AddDynamic(this, &ACameraVolume::OnBeginOverlap);
}
void ACameraVolume::OnBeginOverlap(AActor* OverlappedActor, AActor* OtherActor)
{
if (ATankPlayerCharacter* PlayerCharacter = Cast<ATankPlayerCharacter>(OtherActor))
{
FTransform transform = PlayerCharacter->CameraComponent->GetComponentTransform();
transform.SetLocation(ArrowComponent->GetComponentTransform().GetLocation());
transform.SetRotation(ArrowComponent->GetComponentTransform().GetRotation());
PlayerCharacter->CameraComponent->SetWorldTransform(transform);
}
}

View File

@ -0,0 +1,34 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Camera/CameraComponent.h"
#include "Components/ArrowComponent.h"
#include "Engine/TriggerVolume.h"
#include "CameraVolume.generated.h"
/**
*
*/
UCLASS(Blueprintable)
class TANK_API ACameraVolume : public ATriggerVolume
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UArrowComponent* ArrowComponent;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UCameraComponent* DebugCamera;
ACameraVolume();
protected:
virtual void BeginPlay() override;
private:
UFUNCTION()
void OnBeginOverlap(AActor* OverlappedActor, AActor* OtherActor);
};

View File

@ -14,6 +14,7 @@ ATankPlayerCharacter::ATankPlayerCharacter()
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera Component"));
}
// Called when the game starts or when spawned

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/Character.h"
#include "TankPlayerCharacter.generated.h"
@ -26,6 +27,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* YawAction;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UCameraComponent* CameraComponent;
public:
// Sets default values for this character's properties
ATankPlayerCharacter();