Search Unity

Question I want to Make a Clicker Game

Discussion in '2D' started by apollo_wayne, Apr 11, 2021.

  1. apollo_wayne

    apollo_wayne

    Joined:
    Dec 26, 2020
    Posts:
    27
    Hi! I'm a beginner in unity... but I have a big goal :)

    I want to make a clicker game like Clicker Heroes or Cookie Clicker with a saving system, or an online saving system.

    The saving system and the online one kills me.

    Do you have any tips or tutorials?
     
  2. DevTn

    DevTn

    Joined:
    Apr 11, 2021
    Posts:
    4
    You could make a save file by making one large text program that lists all the data in it and compressing it into a different extension.
     
  3. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    if you want to do online stuff you will have to buy a server and do network and database coding i advise you not to try this if you are new
     
  4. apollo_wayne

    apollo_wayne

    Joined:
    Dec 26, 2020
    Posts:
    27
    Hi! Where can I learn all that? I really want to do this project
     
  5. TheNightglow

    TheNightglow

    Joined:
    Oct 1, 2018
    Posts:
    201
    why do you want to make an online saving system, is there any benefit for your application to have its saves online instead of on the computer of the user?

    most browsergames (pretty sure including cookie clicker) just save in the persistent data path of the users device....

    you may want to take a look at I/O classes like StreamWriter and StreamReader that allow you to easily read and write textfiles

    you could just write a serializeable save class that has variables for all the values you want to save, serialize it to json
    JsonUtility.ToJson(myObject);
    and than write the json text into some text file using streamWriter
    the path where you write it to could be
    Application.persistentDataPath
    that path will work on most operation systems and is generally where smaller games store their saves

    to load you would then simply load from the persistent data path using the StreamReader and then convert the json back to an object of your save class, so you can read out the saved properties
    myObject = JsonUtility.FromJson<MyClass>(json);

    this will work as long as all your save data is trivial serializable
    tho as soon as you have to save more heavier data types than just text and numbers, you will need to write your own Serialze and Deserialize functions for your save data, where you convert text and numbers somehow to the data type you need and back (like for instance using refernce ids, or slowly filling the datatype using raw data (which works for images))

    to convert this to an online format, instead of saving it to the persistent data path, you would have to send a message to a server, and have on that server a script running that listens for packages that arrive and is able to read them out, as in general networking

    and that server than also would have to be able to listen to load requests and then send the data back to the client

    all of this networking is generally a pain to implement

    --------------------------------------

    another way to save data would be the playerprefs
    https://docs.unity3d.com/ScriptReference/PlayerPrefs.html

    they make it incredibly easy to save small amounts of data in a few lines

    like with
    PlayerPrefs.SetInt(KeyName, Value);
    you can simply save an integer and with
    PlayerPrefs.GetInt(KeyName, Value);
    you can read it back out

    for a clicker game you could easily save all your data like that, though this cant be saved online (as in, you cannot use PlayerPrefs as an external save data, they are internally in your application, you can not just send them around and exchange them)
     
    Last edited: Apr 21, 2021
    DavidTeo likes this.
  6. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    trust me dont try to do online stuff, you will need 5 years to learn it
     
  7. apollo_wayne

    apollo_wayne

    Joined:
    Dec 26, 2020
    Posts:
    27
    Thanks for your reply TheNightGlow!

    I want to make sure players won't cheat, that's why I really want to make sure the data is checked twice, from the client and from the server

    That's why I want to have something like an online database where I store all the player data like buildings and credits
     
  8. apollo_wayne

    apollo_wayne

    Joined:
    Dec 26, 2020
    Posts:
    27
    I want to make sure people won't cheat because I want this game to give rewards to players

    Something like: You hit level 50... here's 5 bucks (the money will be sent manually if I can't find a way to automate it)
     
  9. TheNightglow

    TheNightglow

    Joined:
    Oct 1, 2018
    Posts:
    201
    Well... If you need to be automaticly informed when a player reaches a specific level, you wont get around writing some networking in the first place....
    so at that point you might aswell do an online saving system....

    uuhh... here is an unity networking tutorial series, tho i wanna say, I havent fully watched it myself, not etirely sure if it teaches you everything you need, it should be a start tho



    tho just a heads up:
    networking can be a pain to develop, hard to debug, and expensive to maintain
    (like renting 24/7 server wont be cheap, and you might have trouble debugging your networking code at home depending on your router settings (if I understood it correctly you might have trouble using your own private computer as a server, if your router doesnt like portforwarding), though I am a networking noob, not entirely sure how true that is^^)

    I just know someone who is struggling with making a matchmaking server for a while now^^
     
    Last edited: Apr 22, 2021
  10. apollo_wayne

    apollo_wayne

    Joined:
    Dec 26, 2020
    Posts:
    27
    Thank you so much!