Custom UActorComponent is null

intronaut
Sat, 09 Dec 2017 15:58:32 +0000
Community & Industry Discussion

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.

4 posts - 2 participants