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:
UPROPERTY() class USpell* SpaceSpell;
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.