Download

CreateDefaultSubobject Causing Fatal Exception, Need Help as a Newbie.

Hi, I am a newbie here and just started to use Unreal Engine for game developing for days ago. I also do know about the basics of C++ and have very little info about the methods, structure of the library of the UE4.

MY PURPOSE is simply to create a third person template via C++ in which you can perform basic things like camera movement, camera collision, making the player character disappear when the camera gets too close to the character.

MY PROBLEM is with the CreateDefaultSubObject. Every time I try to debug my project, the exceptions “pausing” the editor keep evolving around this “method” or “function” (I don’t even know what this really is, lol).

So, here are my simple lines of codes and screenshots of the exceptions.CAN YOU HELP ME FINDING THE SOLUTION? I will be much appreciated.




//***C_CPPTemplate.h***

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Camera/CameraComponent.h"
#include "C_TPPTemplate.generated.h"

class UCameraComponent;

UCLASS()
class C_FIRSTTPSTEMPCPP_API AC_TPPTemplate : public ACharacter
{
    GENERATED_BODY()

public:
    // Sets default values for this character's properties
    AC_TPPTemplate();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public:    
    // Called every frame
    virtual void Tick(float DeltaTime) override;
    UCameraComponent* CameraComponent;

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;






};






//***C_CPPTemplate.cpp***

// Fill out your copyright notice in the Description page of Project Settings.

#include "C_TPPTemplate.h"



// Sets default values
AC_TPPTemplate::AC_TPPTemplate()
{
     // 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;

}

// Called when the game starts or when spawned
void AC_TPPTemplate::BeginPlay()
{
    Super::BeginPlay();


}

// Called every frame
void AC_TPPTemplate::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
}

// Called to bind functionality to input
void AC_TPPTemplate::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

}



ScreenShots:

https://forums.unrealengine.com/filedata/fetch?filedataid=148181&type=thumb

https://forums.unrealengine.com/filedata/fetch?filedataid=148182&type=thumb

I know from my experince with coding that the more the errors get complicated, the the simpler and the more stupid the solution will be. BUT PLEASE GIVE ME SIMPLE AND CLEAR EXPLENATIONS ABOUT THE MATTER as I have just started game programming with UE4 and C++.

P.S. My Engine Version is 4.20.3 and I got the instructions from probably earlier version of the UE. I will give you the links of the tutorials if it is allowed in the forums.

Thanks in Advance!