Different way of referencing?

Hi. Since Rick said that using findobjectoftype is not recommended to put inside the update method, what referencing method would you recommend to use? I saw this way of referencing a script from a different gameobject from the internet. would this way of doing it be acceptable?

Hi Jacob,

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Hope this helps :slight_smile:


See also;

I see. Thank you very much for the advice!

Hi Jacob,

I think the concern Rick raised was with with where you put FindObjectOfType call, not the call itself.
Placing a single call to FindObjectOfType in the Start method is totally fine. It’s placing it in Update that’s the problem – cos Update is called every frame.

I hope this helps answer your question.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms