if I have to access it outside the object that created it I would add prefix object_name.instance_id.variable?You never add object_name. Instance_id is unique to each instance no matter what object they are. So instance_id.variable will work. object_name usually returns the oldest existing instance, so object_name.instance_id.variable would be like id.someotherid.variable, which is pretty much undefined.
Can you maybe post an example? I just tried adding instances to lists and changing them and it works fine for me.
Try this: https://www.dropbox.com/s/oaiuuppj2htmvnw/unit_test.gmk
I only used this in draw event for obj_text before the modification I made in the attached file. It would only show 0's for defined variable with un.x
. Prefixing un
with the object_name
fixed that. Objects are not global.
I tried to modify old code to make it work with out object_name.id.variable.
Thanks TheExDeus for that example. I have attach an example for you. I have modified it using controller object to create instances of obj_unit, like you have in your example. Now I can see the userdefined values of the last instance with draw event instead of zero. I still have the same problem, that only value for max_moves is coming from last instance created.
I the example arrow keys move units, pageup and pagedown key cycle threw units, and space bar resets moves back to zero.