Discussion about this post

User's avatar
Ari Arnbjörnsson's avatar

A good reason why you you should always, and especially with With World Partition maps, pair any initialization code from BeginPlay with cleanup in EndPlay is because WP maps turn off s.ForceGCAfterLevelStreamedOut, meaning that levels can be made invisible (all actors call EndPlay) and then made visible again (all actors call BeginPlay) multiple times before actors actually get garbage collected and OnDestroyed gets called.

That means that actor lifecycles are:

Construction -> BeginPlay -> EndPlay -> N * (BeginPlay -> EndPlay ) -> OnDestroyed.

A call to BeginPlay will always be paired with an EndPlay call. Construction and Destruction only happen once each.

Expand full comment
2 more comments...

No posts