So our game has a few different types of actors that have health state. To implement the health bar, we currently are using MaterialBillboardComponent. Now to avoid putting the same MaterialBillboardComponent and its corresponding logic into every blueprint class that has health state, I want to create a health bar component for all of them. This health bar component can ideally be added to an actor in the its blueprint by [+AddComponent] button, same as a static mesh component or skeletal mesh component. And then it can be updated easily by its owner actor in the actor’s event tick by passing in a value between 0.0 and 1.0.
The first thing I did was create a HealthBarComponent based on the SceneComponent. However I cannot create or construct a MaterialBillboardComponent in HealthBarComponent’s blueprint, nor can I directly create the HealthBarComponent based on MaterialBillboardComponent (it didn’t appear in the base class list for a new blueprint class).
I could create the MaterialBillboardComponent in the actor (a character for instance), and create a HealthBarComponent in the same actor as well. Pass the MaterialBillboardComponent into the HealthBarComponent to initialize it. However if the implementation of the HealthBarComponent is changed (from using MaterialBillboardComponent to a Mesh), I will have to go through all the actors that use it and modify the initialization. That would be a lot of pain.
I could also use a child actor, but that can’t be directly observed in the actor’s components window and might be a little bit expensive.
Is it by design that components other than actor component and scene component can’t be inherited? Or is there any reason preventing AddComponent in a non-actor blueprint context even though I can pass in a proper actor ? (I noticed an AddComponent blueprint function, which didn’t appear in a scene component blueprint context. I couldn’t use it even thought I could pass in an actor by GetOwner()). Will it be available in a future build?
What would be the best approach for now to create such a component that is used by different types of actors, especially considering the implementation of it could be changed in the future?
Thanks in advance.
bump, any news on this. Having the same issue here