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"
// Sets default values
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
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;
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()
{
Super::BeginPlay();
}
// Called every frame
void ABlasterCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void ABlasterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);

View File

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