Hello everyone!
I am trying to look for methods / ways in how i can make an unique identifier / key to each Item created in my game, i want it to be an RPG style game with trading and i want to make it so each item has an unique ID so i can also make it so each item can behave differently from eachother.
I still don’t know what exactly to do and i am creating this post so you guys can maybe give your ideas and thoughts on how i could accomplish something like this, since it is my first time diving into this sort of stuff.
I have looked at some methods like Asymmetric Encryption and Symmetric Encryption but i don’t know if those are what i am looking for, and encryption methods like the Caesar Cipher.
Now if i were to choose any method to make this sort of system how would i go about it?
Would there be a Seed Variable? In which it would increment by 1 every time a new Item would be created?
Please let me know what i can do to achieve this, thanks for all the help and for reading.
Here, Easiest way to make Unique Identifier for a start would be something along these lines, OwnerName + ItemName + Date when created + the time in seconds that has elapsed since the current game instance started running.
Have you thought of using a GUID for this? Basically you take the output of the function, remove the characters that don’t matter (the - between segments) and then convert it from hexadecimal to bytes. It should take 16 bytes to be stored or 128 bits. For context this is roughly 0.0004% of space in a datastore key.
Alternatively you could use a combination of Player User Id + Item Id + Quantized Timestamp
I’ve never heard of a GUID but from what i have seem from the GUID Page It seems to be exactly what im looking for, since it creates an unique string and at random and basically always unique, even though it isn’t fully unique i think it fits what im trying to do and i’m pretty sure i can use it and something else to make it fully unique, like a timestamp for example.
Basically instead of storing time down to the millisecond, you first divide it to a larger “chunk” (for example how many times of 20 seconds), convert that chunk to an integer, and save it as unsigned to the datastore. That way the resulting integer is much smaller. Although if a user gets the same item in that small interval you will have to compensate, for example by increasing the quantized value manually (as if they got the item slightly in the future). So to tune the quantization you need to figure out how likely players are to receive duplicate items in short intervals.