To create UActorComponent you need AActor
To create AActor you need UWorld
UWorld is created by UGameInstance
UGameInstance is created by UEngine
This clearly implies who owns and who is responsible for the lifetime of the object.
If you need to share a given resource then you use shared_ptr
,
If it is exclusive to a given object then unique_ptr
.
If you are just observing (without transferring ownership) then weak_ptr
. And only weak_ptr really needs to be checked for null.
GC completely ruins this logical, widely used approach.
And more. This leads to four different pointer types inside one project:
- “pure” → user defined types, FSomething, etc. (new/delete)
- smart → ex. Slate (TSharedPtr/TWeakPtr)
- managed → UObject derivatives, (requires reflection macros)
- engine-owned → AActor and UActorCompontent derivatives
And worst of all, three of them are identical = type*
.