TWeakObjectPtr questions

Good practice would be to use AActor* or TObjectPtr (or subclasses). Use them as-is for passing around in functions. For storing them in memory, wrap them with UPROPERTY in an UCLASS-decorated object instance, such as another actor or a world subsystem.

TWeakObjectPtr is kinda for advanced use, if you need to store an actor in memory outside of an UCLASS, for example in a static variable. It has more purpose with UObject types (not AActor) as you get to reference the object without preventing its garbage collection, while still benefitting from being able to check its validity post-destruction.

1 Like