Camera Dissapiaring when restarting engine

So i have a simple car physics in my project but i have been stuck cause my camera keeps disappering when i restart the engine. When i make a blueprint based of my vehicle code the camera is there until i close my engine and open it again then it has disappeared.

.h file

UPROPERTY(Category = Camera, EditDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
     class USpringArmComponent* SpringArm;
 UPROPERTY(Category = Camera, EditDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
     class UCameraComponent* Camera;

.cpp file

 SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
 SpringArm->TargetArmLength = 500.0f;
 SpringArm->bUsePawnControlRotation = true;
 Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("ChaseCamera"));
 Camera->SetupAttachment(SpringArm, USpringArmComponent::SocketName);
 Camera->FieldOfView = 90.0f;



so i would appreciate help cause i cannot make progress on my project cause i am stuck!

Hi @OpePlays ,

I’d suggest check you code for RootComponent be setting to something:

VehicleMesh = CreateDefaultSubobject<UVehicleMesh>(TEXT("Mesh"));
RootComponent = VehicleMesh;

What I usually do is:


UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
USceneComponent* SceneRoot;


SceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
RootComponent = SceneRoot;

If it still doesn’t work could you post your constructor code?

Well i kinda figured it out, it only appears on the wheeled vehicle class so i don’t know why does it do that?
i works normally on the normal pawn class but on the wheeled vehicle pawn type the same code makes the camera disappear!