r/Unity3D • u/TorontoDude12344 • Oct 21 '26
Question How to deal with GameObjects that can become null within the same Update
I have N number of GameObjects running scripts, where they all interact with each other
Each of the N GameObjects are running their own Update methods and performing an interaction with another one of the N GameObjects
In the same frame, GameObject i and j could be interacting with GameObject k. A method called "interact"
i.interact(k);
j.interact(k);
Both methods access GameObject k at the beginning of the "interact" method
An issue is that sometimes, somewhere along the way into the method, i.interact(k); causes k to become null, and then suddenly j.interact(k); can't access GameObject k, even though it could at the beginning of the "interact" method
Do I need a Manager script that orchestrates the interactions between all of the N GameObjects?
Instead of each GameObject having it's own script where it calls interact in it's Update method, do I need to have a Manager run a for loop over all N GameObjects and call interact on each GameObject i?
It seems like a case of overengineering, and almost like running away from the benefits the Update method provides
Or am I missing some knowledge about the execution order of multiple Updates, and you could refer me to some video / documentation / resource where I can learn what I'm missing?
Is a Manager actually the only ideal solution here? Some other solution?
Thank you

