I want to move the springarm to the top to raise the field of view. But the springarm won’t move.
// Fill out your copyright notice in the Description page of Project Settings.
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "Tank.h"
ATank::ATank(){
USpringArmComponent* SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
SpringArm->SetupAttachment(RootComponent);
//RootComponent = BasePawn의 CapsuleComp
UCameraComponent* Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);
}
void ATank::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) {
//상위 버전 호출
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis(TEXT("MoveForward"), this, &ATank::Move);
}
void ATank::Move(float Value){
UE_LOG(LogTemp,Warning,TEXT("Value : %f"),Value);
}
// Fill out your copyright notice in the Description page of Project Settings.
//중복 방지
#pragma once
#include "CoreMinimal.h"
#include "BasePawn.h"
#include "Tank.generated.h"
/**
*
*/
UCLASS() //BasePawn클래스 상속함
class TOONTANKS_API ATank : public ABasePawn
{
GENERATED_BODY()
public:
ATank();
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
private:
UPROPERTY(VisibleAnywhere, Category = "Components")
class UCameraComponent* CameraComponent;
UPROPERTY(VisibleAnywhere, Category = "Components")
class USpringArmComponent* SpringComponent;
void Move(float Value);
};
And in the lecture, when I declared SpringArm and Camera, I didn’t make a Type Declaration before. But because I didn’t make a Type Declaration, I had a problem and made a voluntary declaration, but why didn’t I declare it in the lecture?
.