Download

Help needed with custom components.

Hello.

Let’s say I have a component and a set functions and variables that fulfill a specific task.

I would like to be able to pack them all into a single component so that I can attach them easily to any blueprint (I want that package to be self-contained so that there is no need to add anything else to make it work).
I can do it with functions and variables without a problem, but I can’t have a component inside a component.
I also can’t spawn a component from inside of another one.

I thought the solution would be to create a custom component that is a child of an already existing component - but this can only be done in some situations. I can for example create a custom component that is a child of an instanced static mesh, but not one that is a child of a normal static mesh.

TL DR:
So here is my question:
Can I create a component that will have all the functionality of an already existing component + anything else that i want to add (or simply create a child of an already existing component)?
I need to do that with a custom mesh component.

Thanks for help.

Like a virtual function in OOP ?

I think it’s this: https://forums.unrealengine.com/showthread.php?4089-Are-there-plans-to-add-the-ability-to-override-virtual-functions-in-Blueprint&p=286060&viewfull=1#post286060

I don’t think this is it.
1)I don’t want to override a function, I want to add one (and variables).
2)I can’t create a child of the component so I can’t even get that far.

Since 4.7 there has been blueprint components which are different to the components inside the actor blueprint. You can create an “actor blueprint” or a “scene blueprint” you can then just add these straight onto your blueprints in the level or to a static mesh actor that you put into the level without converting it to a blueprint. An example 1 is the rotating actor component which you can just drop onto any static mesh and it will spin around based on some of your parameters

You may just be better off using actor blueprints for now if you are wanting to nest your components. Then you can always just child actors. It will be more efficient thought if you can make it work using simple components. Is there any particular reason you need components IN components rather than just adding all the components to the same base blueprint?

Child actors cannot be configured in the editor for some reason (their class defaults can not be edited). They must be configured in the construction script which is a real pain ATM.