Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Newbie Incremental Game Help

Discussion in 'Editor & General Support' started by crawniik, May 6, 2018.

  1. crawniik

    crawniik

    Joined:
    May 6, 2018
    Posts:
    2
    Disclaimer: I'm new here, I don't know if I'm even posting this in the right place. If there is an admin that could move this thread to the right place, I would be happy.


    Hi there, folks. I'm very new to development with Unity, and I was creating an incremental tap game. I've got most of the basic code written and working, but I've noticed that once I reach a certain number, it will switch my numbers to negative and completely mess the game up. I was wondering if anyone has had this problem, and if so, is there a way to fix it? I would really like to use Unity to make this game but if the engine can't handle large numbers then I don't know what to do.

    I found out that by using number conversions (1,000 to 1k and so on) that it lets me go a little further, but I still hit a limit. I would like to be able to count much higher. If you want an example of a game that counts really high, check out "Will It Crush" or "Knife Flipper" or "Idle Balls" all published by Voodoo. I know that I can submit my game directly to them, but I kind of want to develop this game on my own.

    Any help would be greatly appreciated.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    If you're storing the value as an int or a float, those have a limit. Ints, for example, go up to a little over 2 billion. If you keep adding to an int after this point, it will "overflow" to about negative 2 billion.

    For incremental games, you quickly pass the "billions", and deal with massive numbers. You'll need a different way to store the values. One approach is BigInteger:

    https://msdn.microsoft.com/en-us/library/system.numerics.biginteger(v=vs.110).aspx
     
    jlpaivar likes this.
  3. crawniik

    crawniik

    Joined:
    May 6, 2018
    Posts:
    2
    Thank you SO much. If you want, I can put your name in the credits.