RegisterComponent breaks the component

I have a simple custom component that derives from UStaticMeshComponent.

I assigned it as the root of a Pawn in the editor.

When calling RegisterComponent in its constructor, several things break:

  • A CameraArm I attached to the CustomComponent doesn’t work anymore; it’s always at the center regardless what length or offset it’s set to.

  • When placed in the world it falls (normal physics), but when assigned as the player pawn it’s frozen in the air where placed. SimulatePhysics has been enabled for the component inside the editor.

What does RegisterComponent do that breaks the component? Is RegisterComponent supposed to be called at all?

Context here: How to implement physics substep logic? - C++ - Epic Developer Community Forums

I’d also love to know the answer to this question.

I do not have the specific answer for this but the documentation clearly states “Register this component, creating any rendering/physics state”, so what could happen is it re-initialize the physic somewhat, making some other stuff break. This is pure theory, but this is a bad use of the function.

RegisterComponent() does not need to be called in the constructor since the constructor is basically the “default properties” of your class, the component will register to it’s owner (the actor) correctly by default.

RegisterComponent() needs to be called when you spawn the component at runtime either in the construction script or elsewhere during play.