36 - Camera and Spring Arm
This commit is contained in:
parent
fc28a43e91
commit
10346c656c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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);
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
protected:
|
|
||||||
// Called when the game starts or when spawned
|
|
||||||
virtual void BeginPlay() override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Called every frame
|
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
// Called to bind functionality to input
|
|
||||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UPROPERTY(VisibleAnywhere, Category="Camera")
|
||||||
|
class USpringArmComponent* CameraBoom;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, Category="Camera")
|
||||||
|
class UCameraComponent* FollowCamera;
|
||||||
|
public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue