In this article: Programming with C++ in Unreal Engine | Unreal Engine 5.1 Documentation I’ve read that any UObject instance without any reference(ue4 container containing the object or UPROPERTY pointer pointing to it) are garbage collected.
But in the First person shooter template project, I noticed something strange to me:
`// spawn the projectile at the muzzle
World->SpawnActor<AMyProjectProjectile>(ProjectileClass, SpawnLocation, SpawnRotation, ActorSpawnParams);`
This line creates a projectile each time we press the left mouse button. But we can see that no pointers are taking the function’s return value. But still, the Actor (an UObject child) is not garbage collected…
So I want to ask what is really going on here. I would guess that the world instance has a TArray, and the Actor is put in it when spawned, is it correct?
Thank you for your attention.