Object variables | scene variables

What’s the difference between: object variable and scene variable and global variable ?

Object is related to an specific Object and all changes are going to affect that Object.
Scene variables, are related to the Scene that is running.

For instance: an Object variable could be
Player obj_var_hp = 100 this will be the Player Object healing points.

Scene Variable: gs_var_score = 0 The current Scene score.

1 Like

To further on @UlisesFreitas’s explanation:

Object variables (aka instance variables) only exist for the lifetime of the object and are referenced via the object. Each object can have a different values for the same named variable (for example, a variable holding the enemy’s health). When an object is deleted, the variable for that object is deleted too.

Scene Variables only exist while the scene exists, and are accessible by anything in that scene. They cannot be accessed by another scene. Change scenes, and the scene variable is gone.

Global variables exist while the game is playing, and can be accessed by any scene. Changing scenes or deleting objects won’t cause a global variable to disappear. Exiting the game will.