Do UIDs get recycled?

Discussion and feedback on Construct 2

Post » Sun Jan 01, 2017 9:12 am

I'm creating two test maps (coming from TMX) and implemented a 'room transfer', where I can move between maps. I do this by deleting the tile instances (and other bits related to it).

Now, I finding something curious: the UIDs of the tiles I'm generating and destroying just keep on going up and not being 'recycled'. My question is, does it matter? Is there an upper limit of UIDs? Or they get recycled after reaching a limit?

By the way, yes, I have checked the debugger, and my objects and instances are not increasing in number. They are indeed being deleted.

Thanks!
B
33
S
11
G
1
Posts: 62
Reputation: 2,641

Post » Sun Jan 01, 2017 1:02 pm

uid's are the order of objects or the number of object that is created, for example, you got 100 different objects created then you destroy them , the next object will have the uid 101 and not 1 ...

for the object order to recycle you need to use IID which is the order spawned for each object of same type...

while uid is the order of any object, all objects created no matter the type of them.

if that doesnt cut it, you can make a localvariable on tile objects, and for each tile seed assign the count based on a loop.

ex : for each tile slot add to variableid 1+loopindex if you want to start the counting from 1 and not from 0.
B
70
S
20
G
67
Posts: 1,314
Reputation: 42,301

Post » Sun Jan 01, 2017 8:25 pm

@gamescorpstudio, thanks for your reply. You are probably referring to me picking instances consistently? I'm not actually picking instances nor need to refer to them, but rather simply generating instances for a map and deleting it to clear the map for in indefinite number of times.

However, your first sentence confirms it enough for me, thanks. :-) I was just wondering if, internally, in the game engine, there was some significance to ever-increasing UIDs...
B
33
S
11
G
1
Posts: 62
Reputation: 2,641

Post » Mon Jan 02, 2017 2:09 pm

In the editor, it does actually recycle UIDs, to keep them low-ish. (Otherwise if you deleted all your objects and added a new one, it would have a high UID - this way it goes back to being low.) However at runtime UIDs keep incrementing by 1 for every new object, they are never re-used. The limit is the integer limit of Javascript's double-precision floating point numbers, which is 9,007,199,254,740,992 (9 quadrillion I think that's called?). Hopefully high enough :P
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,228

Post » Wed Jan 04, 2017 10:03 pm

@Ashley, I believe, yes, that's a fairly reasonable upper limit. :- ) Thank you for the reassurance.
B
33
S
11
G
1
Posts: 62
Reputation: 2,641


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests