I have this code:
#include "CustomComponent.h"
ASomeActor::ASomeActor(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
class UCustomComponent* customComp;
customComp = ObjectInitializer.CreateDefaultSubobject<UCustomComponent>(this, TEXT("CustomComponent"));
}
And it’s crashing every time I try to open up the blueprint actor that inherits from this custom actor class. When I run this in a Debugging Editor, it breaks at the line that is commented // THIS LINE of the StaticAllocateObject function in UObjectGlobals.cpp:
else
{
// See if object already exists.
Obj = StaticFindObjectFastInternal( /Class=/ NULL, InOuter, InName, true );
// Temporary: If the object we found is of a different class, allow the object to be allocated.
// This breaks new UObject assumptions and these need to be fixed.
if (Obj && !Obj->GetClass()->IsChildOf(InClass))
{
UE_LOG(LogUObjectGlobals, Fatal,
TEXT("Objects have the same fully qualified name but different paths.\n")
TEXT("\tNew Object: %s %s.%s\n")
TEXT("\tExisting Object: %s"),
*InClass->GetName(), InOuter ? *InOuter->GetPathName() : TEXT(""), *InName.ToString(),
*Obj->GetFullName()); // THIS LINE
}
}
What is the proper way of initializing a custom component that has inherited from AActorComponent ?