Hello, I have searched on this subject already and I can’t seem to find a definite answer that works. I’m trying to remove the skeletal mesh component that is inherited from the base Character class, how would I do this in the constructor for a class that inherits from Character?
1 Like
So I tried destroying the component and then setting active to false. Then after saving all, recompiling the Blueprint class that derived from the C++ class worked!
My code in the cpp’s constructor:
GetMesh()->DestroyComponent();
GetMesh()->SetActive(false);
Make sure to just recompile the Blueprint(you can just place a node then delete it) and you should be set!
1 Like
Thank you so much for this solution!
Just for the record, you can destroy any left component of the actor by writing in its constructor:
UActorComponent* spr = GetComponentByClass(USpringArmComponent::StaticClass());
if (spr != nullptr) {
spr->DestroyComponent();
spr->SetActive(false);
}
Don’t forget to include USpringArmComponent header.
EDIT:
It seems that the component returns when you remove these lines of code from constructor…
I think I will have to try this solution:
1 Like