Suggestion: Object ID

This forum is currently in read-only mode.
  • I think that in some instances we will need to use a direct reference to an instance created (sprite or other objects).

    So far if you have 10 instances of an object and you want to issue a command to one instance, you have to assign a private variable to all of them, and use a "for each" and "compare" and then you can issue some commands to the specific object. But this is slow and if you need it a lot in your project can slow down the fps and is quite annoying to code so much each time.

    So my suggestion is this: another command in the system: system.create_obj_with_ID that can be used like this: "IDvar=system.create_obj_with_ID" to pass the unique ID to one of your vars at the time of creation. Then you can use a "obj(varID).do_stuff" to make the needed object to do what you want.

    Obj can mean a sprite or any other classes.

    The ID can be similar to a .com hwnd (unique and pretty large).

    Also the direct reference can be optional (to be used only if needed).

    An ID can also be used with a hash table or an array...

    Thank you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Each object has Unique ID. You can retrieve it using the Get UID expression or .UID suffix (ex. Sprite.UID).

  • Great.

    But when you can get this id? and how you can use the ID to tell the object to do stuff?

    Also, is this implemented in the action list or works only with a python script?

  • So far if you have 10 instances of an object and you want to issue a command to one instance, you have to assign a private variable to all of them, and use a "for each" and "compare" and then you can issue some commands to the specific object. But this is slow and if you need it a lot in your project can slow down the fps and is quite annoying to code so much each time.

    That's not accurate. You don't need to have a "for each" loop to do this. A simple "compare a private variable" condition will do. I replied to your previous help/tech post with a basic cap example.

  • To get the unique id or UID of the currently picked sprite , use "Sprite.UID" in the expression editor.

    No python needed.

  • Or, when in the dialog that wants you to enter expression, double-click the object to get a list of available expressions.

  • Thank you.

    Problem solved

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)