Is uuid better than a global counter to give each object an unique ID?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamemap

I want to give each object an unique id (like for example in Minecraft).

Should I use the uuid system (Godot Asset Library) or an global counter for this?

What are the advantages and disadvantages?

:bust_in_silhouette: Reply From: spaceyjase

Yes, if you wish to guarantee uniqueness. I think the only really glaring disadvantage is sorting.

A global counter may be fine for you application if you can guarantee thread safety (i.e. they’re handed out atomically and nobody else can get the same ID; some kind of ID manager, perhaps) and also that the type doesn’t overflow.