Attach a SkeletalMeshComponet to SceneComponent at Construction
First of all, I try to attach a USkeletalMeshComponent to a custom USceneComponent at the construction of the custom USceneComponent. I read a lot of answers some of them say use SetupAttachment(), others say to attach the component in OnComponentCreated(). But none of them works correctly for me. My current Constructor looks like this.
But the results are always the same, even if I restart the editor.
Sure I can assign a skeletal mesh to it, but should it not look like this?
asked Jan 08 '19 at 08:56 PM in C++ Programming
What "correct" looks like depends on what you determine works best for your purposes.
But, as far as your constructor goes, I'm pretty sure that calling
If you look at other actor constructors, you'll commonly see that the first component is set to be the root component, and subsequent components are frequently attached to that (new) root component — and so forth. Here's an excerpt from the ACharacter class constructor:
That creates a capsule component (for collision) and makes it the root component. Then, just a bit further down...
...the character's skeletal mesh component is created, and attached to the CapsuleComponent (by calling
How you set up your component hierarchy is up to you, but just remember that the transforms of parent components, by default, affect the position/rotation/scale of child components.
I hope that helps clear things up!
answered Jan 09 '19 at 10:07 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here