I wrote only 2 classes, and already got a fetal crush, as the title say, whenever i open my project in the editor, the editor crushs. the classes are as follows:
###APlayerPawn.h:####
#include "BodyShapeComponent.h"
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "PlayerPawn.generated.h"
UCLASS()
class SHAPETOSS2_API APlayerPawn : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
APlayerPawn();
UPROPERTY(VisibleAnywhere, Category = "Mesh")
UBodyShapeComponent* shape;
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;
};
###APlayerPawn.cpp:###
#include "PlayerPawn.h"
// Sets default values
APlayerPawn::APlayerPawn()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
shape = new UBodyShapeComponent("Sphere");
}
// Called when the game starts or when spawned
void APlayerPawn::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APlayerPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void APlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
###BodyShapeComponent.h:###
#include "CoreMinimal.h"
#include "Components/StaticMeshComponent.h"
#include "BodyShapeComponent.generated.h"
UCLASS()
class SHAPETOSS2_API UBodyShapeComponent : public UStaticMeshComponent
{
GENERATED_BODY()
public:
/** Default Constructor - create a sphere */
UBodyShapeComponent();
/** Constructor - name is the meshe's file name */
UBodyShapeComponent(const FName name);
protected:
// The Folder in which all the mesh files are located. Duh.
const FName MESHES_PATH = "/Game/Meshes/";
};
###BodyChapeComponent.cpp:###
#include "BodyShapeComponent.h"
UBodyShapeComponent::UBodyShapeComponent(const FName name) :Super()
{
FString path = MESHES_PATH.ToString() + name.ToString();
UStaticMesh* tmpMesh = LoadObject<UStaticMesh>(nullptr, *path);
SetStaticMesh(tmpMesh);
}
UBodyShapeComponent::UBodyShapeComponent() {
UBodyShapeComponent("Sphere");
}
Whenever I try to open my project in the Unreal Editor, it crushes with the following error:
Fatal error: [File:D:\Build\++UE4+Release-4.16+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2450]
UObject(const FObjectInitializer&) constructor called but it's not the object that's currently being constructed with NewObject. Maybe you trying to construct it on the stack which is not supported.
UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:349]
UE4Editor_CoreUObject!UObject::UObject() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2451]
UE4Editor_Engine!UActorComponent::UActorComponent() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\engine\private\components\actorcomponent.cpp:146]
UE4Editor_Engine!USceneComponent::USceneComponent() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\engine\private\components\scenecomponent.cpp:68]
UE4Editor_Engine!UPrimitiveComponent::UPrimitiveComponent() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\engine\private\components\primitivecomponent.cpp:156]
UE4Editor_Engine!UMeshComponent::UMeshComponent() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\engine\private\components\meshcomponent.cpp:14]
UE4Editor_Engine!UStaticMeshComponent::UStaticMeshComponent() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\engine\private\components\staticmeshcomponent.cpp:172]
UE4Editor_ShapeToss2_124!UBodyShapeComponent::UBodyShapeComponent() [c:\users\paz\documents\unreal projects\shapetoss2\source\shapetoss2\bodyshapecomponent.cpp:5]
UE4Editor_ShapeToss2_124!UBodyShapeComponent::UBodyShapeComponent() [c:\users\paz\documents\unreal projects\shapetoss2\source\shapetoss2\bodyshapecomponent.cpp:14]
UE4Editor_CoreUObject!UClass::CreateDefaultObject() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\coreuobject\private\uobject\class.cpp:2687]
UE4Editor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:816]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:894]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:1027]
UE4Editor_Core!TBaseMulticastDelegate<void>::Broadcast() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:937]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\core\private\modules\modulemanager.cpp:479]
UE4Editor_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\projects\private\moduledescriptor.cpp:421]
UE4Editor_Projects!FProjectManager::LoadModulesForProject() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\projects\private\projectmanager.cpp:60]
UE4Editor!FEngineLoop::LoadStartupModules() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2470]
UE4Editor!FEngineLoop::PreInit() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:1896]
UE4Editor!GuardedMain() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\launch\private\launch.cpp:127]
UE4Editor!GuardedMainWrapper() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
UE4Editor!WinMain() [d:\build\++ue4+release-4.16+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:210]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253]
kernel32
ntdll
I have no idea what has gone wrong (i didn’t even know the editor itself could crash because of bad code) and didn’t find anything of that sort online. Any help would will appreciated.