I have created a c++ project, i want to make a First Person Shooter, so i have already created the XTypeCharacter.h and cpp, and a blueprint from that, but no matter what i type of code, changes are not visible in the editor, i have compiled the project, fixed some errors, but now that they are no errors the code doesnt seems to work or do anything at all. Here it is my character class.-
// Fill out your copyright notice in the Description page of Project Settings.
#include "XTypeCharacter.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
// Sets default values
AXTypeCharacter::AXTypeCharacter()
{
// 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(RootComponent);
CameraBoom->TargetArmLength = 300.f;
CameraBoom->bUsePawnControlRotation = true;
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
FollowCamera->bUsePawnControlRotation = false;
}
// Called when the game starts or when spawned
void AXTypeCharacter::BeginPlay()
{
Super::BeginPlay();
}
void AXTypeCharacter::MoveForward(float Value)
{
if((Controller != nullptr) && (Value != 0.0f))
{
const FRotator Rotation{ Controller->GetControlRotation() };
const FRotator YawRotation{ 0, Rotation.Yaw, 0 };
const FVector Direction{ FRotationMatrix{YawRotation}.GetUnitAxis(EAxis::X) };
AddMovementInput(Direction, Value);
}
}
void AXTypeCharacter::MoveRight(float Value)
{
if((Controller != nullptr) && (Value != 0.0f))
{
const FRotator Rotation{ Controller->GetControlRotation() };
const FRotator YawRotation{ 0, Rotation.Yaw, 0 };
const FVector Direction{ FRotationMatrix{YawRotation}.GetUnitAxis(EAxis::Y) };
AddMovementInput(Direction, Value);
}
}
// Called every frame
void AXTypeCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AXTypeCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
check(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveForward", this, &AXTypeCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AXTypeCharacter::MoveRight);
}
Here it is the header
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "XTypeCharacter.generated.h"
UCLASS()
class XTYPE_API AXTypeCharacter : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AXTypeCharacter();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void MoveForward(float Value);
void MoveRight(float Value);
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, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;
public:
FORCEINLINE USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FollowCamera; }
};
When i open the Blueprint theres no spring arm, neither a camera following the Character