Not sure if I understand you right, but I don’t create the Component in c++, so I don’t have a pointer.
The createDefaultSubObject was just for testing purpose. I create the Component in the blueprint derived from the actor.
Ok, then you should share nodes that actually are used to check them…
Ohh, that is something special ) Can you describe the hierarchy that is used?
Hi everyone,
I want to get an ActorComponent in my Actor, but it always returns nothing.
InvComp = CreateDefaultSubobject<UInventory>(TEXT("InventoryComponent"));
This works fine, so it shouldn’t be a problem of the UInventory Component. But this is not what I want. I create the InventoryComponent in a Blueprint derived from the Actor.
Here are a two test cases that don’t work:
InvComp = this->FindComponentByClass<UInventory>();
InvComp = Cast<UInventory>(FindComponentByClass(UInventory::StaticClass()));
This returns 0:
GetComponents(Components);
UE_LOG(LogTemp, Warning, TEXT("LengthComponents: %d"), Components.Num());
I’m calling everything from BeginPlay() which is called after the Components Initialise, so I really can’t find my mistake here. Hope anybody can help me.
Thanks in advance!
Hi! Why do you do it with FindComponentByClass? In class itself you can simply use pointer from Uproperty or getter function for example.
What kind of nodes? I’m using c++ only except giving the actor an actor component in bp.
While writing the hierarchy I noticed that i F-ed something up
So seems like it is working now, but still at some point my engine crashes. Will try to figure out why it crashes and if it is related to my problem here.
Will keep you updated, but thanks already.
Tried to reply yesterday twice but Epic didn’t let me.
While writing the hierarchy I noticed that I ■■■■■■ something up, now it’s working , so thanks for the idea
Have a nice day!