36 - Camera and Spring Arm

This commit is contained in:
Kingsmedia 2022-04-28 12:41:43 +02:00
parent fc28a43e91
commit 10346c656c
6 changed files with 22 additions and 14 deletions

Binary file not shown.

View File

@ -3,29 +3,36 @@
#include "BlasterCharacter.h" #include "BlasterCharacter.h"
// Sets default values #include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
ABlasterCharacter::ABlasterCharacter() ABlasterCharacter::ABlasterCharacter()
{ {
// 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; PrimaryActorTick.bCanEverTick = true;
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(GetMesh());
CameraBoom->TargetArmLength = 600.f;
CameraBoom->bUsePawnControlRotation = false;
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
FollowCamera->bUsePawnControlRotation = false;
} }
// Called when the game starts or when spawned
void ABlasterCharacter::BeginPlay() void ABlasterCharacter::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
} }
// Called every frame
void ABlasterCharacter::Tick(float DeltaTime) void ABlasterCharacter::Tick(float DeltaTime)
{ {
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
} }
// Called to bind functionality to input
void ABlasterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) void ABlasterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{ {
Super::SetupPlayerInputComponent(PlayerInputComponent); Super::SetupPlayerInputComponent(PlayerInputComponent);

View File

@ -12,18 +12,19 @@ class BLASTER_API ABlasterCharacter : public ACharacter
GENERATED_BODY() GENERATED_BODY()
public: public:
// Sets default values for this character's properties
ABlasterCharacter(); ABlasterCharacter();
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected: protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override; virtual void BeginPlay() override;
public: private:
// Called every frame UPROPERTY(VisibleAnywhere, Category="Camera")
virtual void Tick(float DeltaTime) override; class USpringArmComponent* CameraBoom;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
UPROPERTY(VisibleAnywhere, Category="Camera")
class UCameraComponent* FollowCamera;
public:
}; };