I’m attempting to move some of the functionality from my Primary Pawn class into several ActorComponents, however I am not sure if the way I am attempting to construct the ActorComponents is correct.
When I create an ActorComponent (TestActorComponent) within the TestPawns constructor and attempt to register that ActorComponent in the constructor the program compiles fine, however when I try and register that ActorComponent in the constructor I get StaticFailDebug within UE4Editor-Core.dll, on the following line of the TestPawn constructor. (Example below)
At what point is the ActorComponent registration available to the pawn prior to game start? This is probably an easy question, but I haven’t traced the pawn function call stack far enough to figure it out just yet.
Ideally, the code I need to implement would occur after all of the components are registered (Pawn::PostRegisterAllComponents), however i’m not entirely sure where the proper location to register the components at the Pawn level is.
Thanks,
Mike C.
Header File
#include "TestActorComponent.h"
UCLASS(config=Game)
class ATestPawn : public APawn
{
public:
GENERATED_UCLASS_BODY()
UTestActorComponent* TestActorComponent;
protected:
virtual UTestActorComponent* CreateTestActorComponent();
virtual void DestroyTestActorComponent();
bool bTest;
}
CPP File
TestPawn::TestPawn(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP)
{
TestActorComponent = CreateTestActorComponent();
if (TestActorComponent)
{
TestActorComponent->RegisterComponent();
}
bTest = false;
}