I am following the Core RPG course (which I am loving btw) and I have noticed that Sam uses GetComponent().anyFunction() directly and even sometimes its used in the main loop (Update).
I was curious if this gets refactored later on but by checking out the final code in the repository it seems that’s not the case.
This raised some questions and confusion in my head:
-
Is Sam wrong for doing so and it is just something overlooked or is there some reason behind this that i simply lack the knowledge to understand. If that’s the case please elaborate.
-
I’m I being unnecessarily cautious all this time about the performance issues that this might cause? Is it unnecessary to cache the components in variable on awake or start even when they are going to be used in the main loop?