![]() ![]() Keep in mind that GameObject.Find functions will return null if nothing is found. You will find that some are better for finding the specific game object, while others are more useful when trying to grab a reference to a component on the game object. You can ideally use any of them to set up your reference prior to accessing the game object containing your health. There are a couple of useful functions for finding game objects, in Unity. Using GameObject.Find to find a game object in your scene Note that these methods work for all component types, but I will be using Texture2D as an example. You could use GameObject.Find to find the game object in your new scene, or you could simply use DontDestroyOnLoad() to retain the original reference from the previous scene on a 'controller' script. ![]() There are a couple of ways you could obtain/retain reference to a game object between scenes.
0 Comments
Leave a Reply. |