- Home /
Is there any overhead when using Update functions for making object references?
Basically, I use Update for making object references during runtime for lots of stuff that only appears sporadically, since I can't really do it at the start. But once these references have been stored by the Update, because Update happens every frame, does it keep searching for the objects it has found, or does it just stop executing while the reference exists? And if so, does it bog down performance?
Answer by Casiell · Dec 14, 2018 at 11:03 AM
You have to do it manually. Create global variable, assign it in Update and before the assignment check if the variable is null. Update doesn't cache things, it would be illogical as things can chage over time and it's not guaranteed that you will get the same object back from whatever "Find" you use. And yes, it's not really advised to search for the same thing in each update, cache your results instead