Actor with 2 separate components
Hello, Im new to ue4 and im working on a project. I created an actor with c++ class. I want my actor to have 2 separate components (not one attached to the other). If i declare the 2 components in the header file and then in the .cpp file i type: StaticMesh(the name of the first component) = CreateDefaultSubobject("StaticMeshComponent"); and after that i write the same for the other component(just the name is not the same), it attaches the second one to the first one! Soo my question is how to make them separatley not one attached to the other? Can you give me the code please! Sorry for my bad english!
I'm assuming you're doing something like this:
The problem here is that the first component you create will overwrite the "Default root" component. That's why you see the first mesh become the root component and the second mesh attaches to the first.
If you don't want either mesh to become the root component, you need to specifically create a component to be the root component.
Here is a code snippet:
And here's how the components will look in Blueprints:
answered Jun 04 '19 at 04:24 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here