# Some very strange error loading my project

**URL:** <https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 20, 2022, 4:45pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524 "2022-07-20T16:45:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EgorMaksM](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/egormaksm/32/548054_2.png) [@EgorMaksM](https://forums.unrealengine.com/u/EgorMaksM)\
**Post date:** [July 20, 2022, 4:45pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524/1 "2022-07-20T16:45:48Z")

</div>

So, it’s not first time, but now solution from last time doesn’t work. When I try to start my project, UE4 crashes and gives me this sign:  
**Fatal error: [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 2618] UObject(const FObjectInitializer&) constructor called but it’s not the object that’s currently being constructed with NewObject. Maybe you are trying to construct it on the stack, which is not supported.**

**UE4Editor\_CoreUObject  
UE4Editor\_UMG  
UE4Editor\_MyProject!AMyCharacterCPP::AMyCharacterCPP() [C:\Users\keyni\Documents\Unreal Projects\MyProject\Source\MyProject\MyCharacterCPP.cpp:5]  
UE4Editor\_CoreUObject  
UE4Editor\_CoreUObject  
UE4Editor\_CoreUObject  
UE4Editor\_CoreUObject  
UE4Editor\_Core  
UE4Editor\_Core  
UE4Editor\_Projects  
UE4Editor\_Projects  
UE4Editor  
UE4Editor  
UE4Editor  
UE4Editor  
UE4Editor  
UE4Editor  
UE4Editor  
kernel32  
ntdll**

Here is my AMyCharacterCPP::AMyCharacterCPP() code:

```auto
AMyCharacterCPP::AMyCharacterCPP()
{
 	// 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;

	AutoPossessPlayer = EAutoReceiveInput::Player0;
	bUseControllerRotationYaw = false;
	CamComp = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));

	CamComp->AttachTo(RootComponent);
	CamComp->SetRelativeLocation(FVector(0, 0, 40));

}

```

Rebuilding project doesn’t help, idk what to do.

---

<div class="post-metadata">

**Author:** ![IrSoil](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IrSoil](https://forums.unrealengine.com/u/IrSoil)\
**Post date:** [July 20, 2022, 6:00pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524/2 "2022-07-20T18:00:39Z")

</div>

> [@EgorMaksM](#):
>
> Maybe you are trying to construct it on the stack, which is not supported.

Make sure you not trying to do this. You cant have on-stack uobjects inside of (in this particular case) your character, Make sure that your CamComp and other UObjects you may been defined in class definition in header are pointers (“UCameraComponent\*” and not just “UCameraComponent”).

---

<div class="post-metadata">

**Author:** ![EgorMaksM](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/egormaksm/32/548054_2.png) [@EgorMaksM](https://forums.unrealengine.com/u/EgorMaksM)\
**Post date:** [July 20, 2022, 6:21pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524/3 "2022-07-20T18:21:22Z")

</div>

> “UCameraComponent\*” and not just “UCameraComponent”  
> Yes, it is correct. What else can be incorrect?

---

<div class="post-metadata">

**Author:** ![IrSoil](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IrSoil](https://forums.unrealengine.com/u/IrSoil)\
**Post date:** [July 20, 2022, 6:49pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524/4 "2022-07-20T18:49:12Z")

</div>

Can you show the header? Right now i can only guess that you trying to create something from **UE4Editor\_UMG** inside of your character.

Btw you can install engine’s debug symbols and those stack traces will become a bit easier to read

---

<div class="post-metadata">

**Author:** ![EgorMaksM](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/egormaksm/32/548054_2.png) [@EgorMaksM](https://forums.unrealengine.com/u/EgorMaksM)\
**Post date:** [July 20, 2022, 6:59pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524/5 "2022-07-20T18:59:42Z")

</div>

> Can you show the header?

```auto
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Camera/CameraComponent.h"
#include "Components/InputComponent.h"
#include "Runtime/Engine/Classes/Engine/World.h"
#include "DrawDebugHelpers.h"
#include "GameFramework/Actor.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/EngineTypes.h"
#include "CustomUserWidget.h"
#include "Blueprint/WidgetTree.h"
#include "Blueprint/UserWidget.h"
#include "CollisionQueryParams.h"
#include "MyCharacterCPP.generated.h"

UCLASS()
class MYPROJECT_API AMyCharacterCPP : public ACharacter
{
	GENERATED_BODY()

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

	AActor* obj;
	bool IsTaking = false;
	FString MeshName;
	float movement_speed = 0.5;
	FHitResult LastHit;
	UWidgetTree WidgetTree;
	UCustomUserWidget BlackImg;
	TArray<FString> Doors = { TEXT("DoorWithHandles"), TEXT("DoorWithHandles90") };
	TArray<FString> ObjectsToUse = { TEXT("DoorWithHandles"), TEXT("DoorWithHandles90"), TEXT("Banker_Lamp_2") };
	TArray<FString> ObjectsToTake = { };

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

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

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

private:
	void MoveForward(float Amount);
	void MoveRight(float Amount);
	void MousePitch(float Amount);
	void MouseYaw(float Amount);

	void ToRun();
	void ToGo();
	
	void PutOrTake();
	void Use();
	void UpdateLookingPlace();

	int IsInArr(TArray<FString> arr, FString str);

	void RayCast();

	UPROPERTY(EditAnywhere, category = "Camera")
		UCameraComponent* CamComp;

	UPROPERTY(BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
		float stamina = 1.0;

private:
	UPROPERTY(BlueprintReadWrite, meta = (AllowPrivateAccess = "true"))
		int HUDMsgVal = 0; /*
						   0 -> Nothing
						   1 -> "Press E to use"
						   2 -> "Press 'Right_Mouse_Btn' to take/put"
						   */
};

```

---

<div class="post-metadata">

**Author:** ![IrSoil](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IrSoil](https://forums.unrealengine.com/u/IrSoil)\
**Post date:** [July 20, 2022, 7:08pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524/6 "2022-07-20T19:08:52Z")

</div>

Thanks. Just as i guessed, here they are:

> UWidgetTree WidgetTree;  
> UCustomUserWidget BlackImg;

Two uobjects created on a stack, while you supposed to define them as pointers and create them via `CreateDefaultSubobject`(in constructor) or `NewObject`(at runtime)

---

<div class="post-metadata">

**Author:** ![EgorMaksM](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/egormaksm/32/548054_2.png) [@EgorMaksM](https://forums.unrealengine.com/u/EgorMaksM)\
**Post date:** [July 20, 2022, 7:33pm UTC](https://forums.unrealengine.com/t/some-very-strange-error-loading-my-project/609524/7 "2022-07-20T19:33:51Z")

</div>

Omg, thank you very much!
