Project will not load when trying to use SetNetDormancy()

Every single time I compile my project it will successfully compile with no errors, but when I’m loading my project it gets to 75% before crashing out. The error log only points to the last line of the constructor that the SetNetDormancy() function is in, so I had to comment each line of code out until I landed on SetNetDormancy. I’ve ran into this issue before, but just instead set it in blueprint as a temporary work around for it, but now want to fix this issue, as I want to set the default value for my actor for this particular property.

Any help on this would be fantastic.

Thanks,
.

That’s probably the ClassDefaultObject (CDO) of your class being created. Looks like SetNetDormancy uses GEngine without checking against nullptr, also the World will be nullptr for a CDO. I guess the NetDormancy member can be set directly in your constructor without going through SetNetDormancy. The AActor and ABandwidthTestActor classes do this as well.

Ah ok thanks it works perfectly now, I was always confused why there were setter functions for some properties even though you can set those properties directly. That clears things up a bit.

Yeah SetNetDormancy and SetReplicates shouldn’t be called in the Constructor, you should set them directly. The output log will give you warnings about using SetReplicates() now.

Ah ok, I assume I should be doing this with other functions like SetOwnerNoSee, SetHiddenInGame, etc and just set them directly as I noticed they can also just be set directly.

Thanks a lot.