This works because the item data is technically the same, its simply referenced from two places, which can make it easier to pass data around and easier to compare item types, allowing you to stack inventory items when storing them. But, how is this any better than simply connecting the health bar directly to a health class on the player object in the scene? I dont know if its a good idea to show scriptable objects before explaining the importance of private variables for instances and getters/setters. Find with tag will return the first object that is found in the Scene with a matching tag. Or you could also access to the script which cointains the variable, assign it to a new script variable, and finally, use that variable: ScriptName targetScript = ObjWithScript.GetComponent (ScriptName); targetScript.variable = 0; koyima 9 yr. ago. Which can be used to allow an Inventory class to add an item of the same type to one of its item slots. Scriptable Objects work in a similar way to other Assets, such as Audio Clips. However, in a scriptable object, while some of these functions are still called, they may not work in the way you expect them to. However for the sake of keeping examples simple, in many tutorials and examples, you will often see a variable marked as public for the purpose of editing it in the Inspector. Then, if enough of the objectives have been completed, the quest raises the On Quest Completed action, passing in a reference to itself. I could really use some help with key parts of the code if you would be willing or point me to places to help get me started. If the public and private Access Modifiers are new to you then, put simply, public variables can be accessed by other scripts and are visible in the Inspector while private variables are not accessible by other scripts and wont show up in the Inspector. In practice, youre likely to combine object prefabs with scriptable objects, where objects of a similar type hold different instances of data. So which is the better option for getting a reference to component or script? For example, if you had a Timer script, with a public float variable called timeElapsed, you could access it like this: public Timer timer; Directly referencing a static health variable makes it impossible to reuse the script for anything else. While being able to store data beyond the life of a scene might be useful to you, there may also be times when youd like scriptable object data to reset with the scene in the same way that a regular script would. Normally, the main benefit of using a Scriptable Object is the reusable data structure, its just that Ryan Hipple demonstrated a way to do the same thing in a more granular way with individual variables. To mark a variable as static in Unity, simply add the static keyword when declaring it. For example, you might instantiate an enemy that needs to find the player. Its also possible for two different audio sources to reference the same audio clip without needing a reference to each other. All in a format that can be accessed from any class, on any object, in any scene. If other objects are accessing the component in the same way, reordering them could cause issues for other scripts that may rely on a certain object order.