Custom UActorComponent is null

Hi Guys,
I’ve encountered a weird problem:
I have an ACharacter and I’ve added several UActorComponents to this ACharacter. Now when I try to access one of the Components, it’s null.

The weird thing is that not all of them return null, some of them work just fine, but they’re exactly the same and all derive from the same custom UActorComponent class. I tried adding them during runtime via NewObject() but that doesn’t work either, it’s still null.

I also tried calling RegisterComponent() or AddOwnedComponent().
Yes, they are being replicated correctly.

Here’s an example:
.h

	UPROPERTY()
		class USpell* SpaceSpell;  

.cpp

    SpaceSpell = CreateDefaultSubobject<class UPyromancerHaste>(TEXT("Haste"));
	SpaceSpell->SetIsReplicated(true);  

I add several Components this way, but only one of them returns null.

Is there a limit on how many UActorComponents can be added to ACharacter or something? It is always the third one I’m adding/changing. Haven’t tried a fourth one yet.
Am I doing something fundamentally wrong?
I have another project where I add a UActorComponent this way and it works just fine.

Thanks for your time and help guys.

Removing UPROPERTY() seems to be a workaround.
Found here.

2 Likes

Thans a lot~

I wasted my lot of time to deal with this annoying problem, I found If custom UActorComponent is null, the detail panel is initial incorrect, become blank, and check the outline ,I found the nullptr Actorcomponet whitout any infomation, Of course ,I Removing UPROPERTY(), and hot reload ,it works fine !!! Oh My GOD ,What happend ? Which Step I made mistake? It so huge cost to find a so baseless and so stupid issue !