Hi there guys, i’m trying to make a power up system, in wich the character can attach a component of certain type.
UFUNCTION(BlueprintCallable, Category = "Vertex Character", meta=(Tooltip="Absorb the given essence into the character"))
virtual void AbsorbEssence(TSubclassOf<class UEssenceComponent> EssenceClass);
This is made so any blueprint powerup can call the AbsorbEssence with the type of the EssenceComponent that i want
The problem is that i given this TSubclassOf Object (UClass) i can’t attach the component or create it.
I tried doing:
essenceComponent = EssenceClass->GetDefaultObject<UEssenceComponent>();
essenceComponent->RegisterComponent();
But the engine crashes because something something about the world of the actor not existing. (its a ensure that RegisterComponent does that my component fails).
I’m banging my head here, any idea how can i dinamycally add these components to my actor given the UClass?