Accessing Object Instances Index IDs

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I've been trying to find a way to access the order information of objects. Naturally, in which order they have been created, and have them carry their information in each instance. As in, this is the first instance, that has been created of this object, this one the second, the third, etc. ... .

    The only ways I could think of are too complicated, when I feel like there is surely an easy way.

    I would do it with a global variable, and that is what I don't like, to have something external like that. Since, if different Objects get plentysome, I'd end up with loads of global variables just for ordering the instances of each Object.

    I would basically do something like this:

    We have:

    + globalvar('IDCounter') = 0

    + SpriteObject

    + SpriteObjectVar('IndexID') = 0

    We do:

    + For Each SpriteObject (Ordered by SpriteObject.UID - Ascending)

    -> Add +1 to global('IDCounter')

    -> SpriteObject.SetValue('IndexID') = global('IDCounter')

    Thank You in advance.

  • It just so happens that for each goes through instances based on creation.

    So for each sprite set private variable "myid" to loopindex should suffice.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I love You. <img src="smileys/smiley1.gif" border="0" align="middle" />

    Yeah, I was reading about loop index earlier today, but didn't really think about this.

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