Hi, I understand why we dafactored the 2 methods GetControlledTank and GetPlayerTank. What I don’t get (and Ben says he’ll explain why, but he doesn’t until the end of the video) is why assigning them to local variables every Tick.
I created 2 instance variables in tank.h and I assign them the values just once, in BeginPlay(), and it works correctly for me. Is there something I’m not getting?
Thanks! So, I suggest Ben to explain this if he gets the chance to work on this lesson again, or maybe people could think that the AI tank “loses” this information every single frame
No, that’s not the reason. Once you get a reference to an object, it’s still the same even if the object changes the value of its properties (i.e., position). So it’s theoretically enough to get the reference once, and use it everytime you need it. The only possible reasons for getting it every frame are the ones in the comments above