Create an unique ID

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

I am currently working on a Pokemon-like game. If you have played any of the Pokemon games, you will know that every mon you catch has a unique ID. I would like to replicate that in Godot but haven’t found any solutions yet.

For example:

There is an object “Slime monster”. In my level, I create three instances of them. My goal is that each one of them has a unique number (0001, 0002, 0003, etc.).

Is there a built-in method? Or do I have to code it myself?

Just make a new node that will be a parent(container) to those monsters and use it to count. Node id will be the ‘unique’ name for each of them like you want it to be under that node.

Primoz128 | 2019-04-08 09:07

1 Like
:bust_in_silhouette: Reply From: MuffinManKen

As far as I know there’s no built-in UUID function in GDScript, but it seems like for this all you really need is just a global counter that you increment for each new monster you spawn.

:bust_in_silhouette: Reply From: Ch.

Object.get_instance_id()?