How does C++ constructors relate to SpawnActor?

After some reading at AnswerHub I’m left with the impression that it is better to have a special Init function in the class and use it after SpawnActor.

But I see that constructors are still present and there’s functionality added to them like


PrimaryActorTick.bCanEverTick = false;

So it seems that they are used. But can I use overloaded constructors and how?

You can use overloaded constructors but SpawnActor() does not provide a way to pass parameters to them. This is the reason that an “init” method is recommended.

The downside to this is that certain things are only allowed in the constructor, like ConstructorHelpers, etc. So, you will have to do certain things in the constructor and certain things in init(). The design is not ideal but I haven’t found anything, yet, that can’t be accomplished with the two separate methods.

There are also some good examples in the wiki that show you how to get around using ConstructorHelpers. I would recommend doing that only if it’s really necessary, because it has some tricky side effects.

Thank you, .

This answers my question entirely.