Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Unlock item by entering key-code

Discussion in 'Scripting' started by nikolasjklein, Feb 18, 2018.

  1. nikolasjklein

    nikolasjklein

    Joined:
    May 17, 2017
    Posts:
    8
    Hey!
    I plan on implementing a feature that people can get a key (like physically printed on paper) that they can enter in my game to unlock a certain weapon.
    Each code should only be useable once and then be ‚blocked‘.

    Do you have any idea of how to accomplish something like this? o_O

    Thanks in advance! :)
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    If it's all on the client, you could store a list of keys and whether they're unlocked or not. I guess that is kind of obvious.
    If there's a server involved, then the same idea, but stored there?

    Please clarify if I missed something in your question. :)
     
  3. nikolasjklein

    nikolasjklein

    Joined:
    May 17, 2017
    Posts:
    8
    Thank you for your answer!
    So basically, this check if a key is used should be constant.. so that 2 people cannot use the same key.. I think a server that stores the keys and stores if they have already been used is needed then right? Or wrong? :mad:
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Well, for sure.. otherwise how would you work it out? :)
     
  5. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    In addition to that, note that anything that's deployed with your application can be reverse-engineered... no matter whether it's a trivial comparison with hardcoded values or some smart and flexible algorithm that only accepts a subset of keys out of all permutations.

    All of that can be read out and can be "cracked" when it's part of a client application. So if you're serious about proper key management, you'll definitely need some server-driven validation and even that is sometimes not as easy.
     
    Ryiah likes this.