Knowledgebase / Using Instance Properties to customize the behavior of game objects
To customize how scripted game objects behave, you can edit the instance properties of an individual game object. For example, you might want to have multiple coins you can collect, but some of them might give you more points.
You can also create your own instance properties on a script by making that script’s variables public.
1. Using Existing Instance Properties
To edit the properties of a scripted game object, right-click on the game object and choose Edit Instance Properties.
From the instance properties window you can set values for those public variables. This makes it really easy for you to change how a scripted game object works without having to change the script for each object.
In the example above, this character can have its own message and health without those being predefined in the script – this means the Character script can be reused on other characters, and those characters can have different messages and health.
2. Creating your own Instance Properties
To create editable instance properties, you need to first make sure your script has Public Variables. You can set variables to public by opening the Script Properties window inside the Script Editor.
The Script Properties window is accessible by clicking on the 3 lines icon in the menu bar of the script editor. In the Script Properies window, you can name and describe your script, see all the variables that the script uses, and set whether or not your variables will be public. You can also set what those variables should have as default values.
Ticking public will make that variable available from the game object’s instance properties – this makes it really easy to have individually customized game objects. For example, you could have a “Collectable Coin” script attached to three different coins, and each coin gives you a different amount of points.