can please someone explain me the differences from instance variable and object variables ?
If I create an object in run time I usually use object variable but if I drag an object on edit screen I can use instance variables. In events, I can’t find Instance variable; object and instance variables are the same thing ?
In the object list you have the all objects in your current scene.
Object variables are variables added by edition of your object in this list.
(right click on an object then “Edit object variables”)
On the scene you drag and drop one object, one object on scene is called instance.
An instance is one or many duplication of your original object.
If you have one object “Player” in object list, and two “Player” on scene, so you have two instances of “Player”.
Then when you click on an instance you can edit the values of the selected instance, position, width,
At the bottom you see the “Instance variables” section.
If you have setup an object variable on your object the variable and the value will be shown in this section.
This variable object can be override, if you edit the value of the variable in this section, the value go to italic, this mean you have write over the object variable, and this value is now effective only on the instance selected.
If you click on a second instance, you will see the object variable, but not the value edited on the other instance
Hello, I’ve created an global objet variable in a scene and modify it with an event, in that scene. I’d like this modification to be applied on the instances of that object in another scene.
Could you help me ?
I’m not sure what you mean by Global Object Variable: do you mean an object variable of a global object? As per the wiki: Variables [GDevelop wiki] there are 3 kinds of variables: global, scene, and object. An instance variable is an object variable that only applies to one particular object in a scene.
If you want to assign a global variable to an object variable of all instances of an object, you could try an event like: “For Each” condition (targetting the object) with an action “Set object.Variable(instance_variable) to GlobalVariable(set_by_events)”
There’s probably other ways to do it but maybe this will work?
When you create the object, add another action straight after it - click on Add action select the object from the left panel, select Value of an object variable on the middle panel, and enter the details in the right-side panel :