I understand that the course is introducing things step by step, but this was the first time in the course when I was really uncomfortable following along, because my engineering background was raising all kinds of red flags.
How close is this implementation to a real life scenario? More specifically, how exactly the engine will manage memory in this case?
The way I see this, the thank has a pointer to the health component, which has a pointer to the game mode, which has a pointer to the tank. This creates a “reference loop” which in languages that I’m more familiar with than C++ (like Swift, for example) is a big NO-NO, because it will create a memory leak. The same with the tank having a pointer to the player controller which internally has a pointer to the controlled pawn (which is the tank).
Are reference loops a problem in UE, or the garbage collector can still figure out what is not used anymore and free the memory?
Intuitively I was using TWeakObjectPtr<> everywhere I could, but I don’t know if this is the right approach here.