Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by saikrishna-dasari · Dec 04, 2016 at 12:25 PM · unity 5multiplayerplayerprefsdatabase

How the games are storing Bulk data of players and how they are processing?

Hi friends, I would like to know more about storing of bulk data of players.Bulk means not a bulk but storing of too many values like (player level,health,speed,coins,how many games played,won games,lost games,gems,trophies ....etc). simply an example game is COC. In that game how they are saving each and every level,stats,trophies...etc every thing.And how they are making Multiple device play. I have seen playerprefs, saving in xml and one more saving in database(I think But in this case if 10K players are playing at a time 10K requests are gone to Database. At that time database can't handle thus much of request or some unknown Error we can face). And how they are serialize this data in multiplayer, how to create a multiple device play game. Generally in games what they are doing for this type of data storing ? Any Suggestions please. If already this question is there sorry , But I have not find any answer about this type of question. Sorry for my English. Thanks in advance for clearing of my doubt's.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image UnityCoach · Dec 04, 2016 at 01:26 PM 0
Share

I'd say you want to make the difference between local data and server data. PlayerPrefs is local, serialising to xml or json can be local or distant. There's also Game Centers API for leaderboards.

avatar image saikrishna-dasari · Dec 04, 2016 at 05:47 PM 0
Share

@jikkou Thanks for clearing some doubt. Right now iam not developing any game.But i have an lots of doubts about this one.clearing of some doubts thank you. can you give some useful links about this one may be helpful to others also.

avatar image AurimasBlazulionis saikrishna-dasari · Dec 04, 2016 at 05:54 PM 0
Share

Always reply to a comment by a comment.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by AurimasBlazulionis · Dec 04, 2016 at 05:37 PM

If you know exactly how longs is the data (even if you do not, it is still possible), you can write manual byte serializer. It is much faster and uses much less space, but it requires to be handwritten and it is pretty hard to do. You will have to a lot of debugging if you need to store more complex structures like arrays in them.

Basically you put all values into a byte array. If all the data you store is in floats and ints, then for each value you will have to use 4 bytes.

Once you have created an array of the exact size you need, also create a temporary byte array with the length of 4. For each value do something like tempArray = System.BitConverter.GetBytes (theValue). Now you have to put all these values to the array you will store somewhere else. Now there is a catch. Platforms have some type of endiannes. It is basically how the values are stored in the RAM. Most systems are little endian, but you should still write the code for the big endian machines. For little endian machines we write all the data to the array in normal order, but if the machine is big endian, read values from temporary array reversed. There is some code from my project:

 if (System.BitConverter.IsLittleEndian) {
     bytes [i + 1] = flVal [0];
     bytes [i + 2] = flVal [1];
     bytes [i + 3] = flVal [2];
     bytes [i + 4] = flVal [3];
 } else {
     bytes [i + 1] = flVal [3];
     bytes [i + 2] = flVal [2];
     bytes [i + 3] = flVal [1];
     bytes [i + 4] = flVal [0];
 }

The i is there, because I did serialize arrays and the code is from for loop. Now you are done with writing.

To read it back you will have to do the reverse.

There are 2 helper functions for you to use, which take endianness into account:

 public static float ToSingle (byte[] bytes, int index) {
     if (System.BitConverter.IsLittleEndian) {
         return System.BitConverter.ToSingle(bytes, index);
     }
     else
     {
         return System.BitConverter.ToSingle(Reverse(bytes), bytes.Length - sizeof(float) - index);
     }
 }
 
 public static int ToInt32 (byte[] bytes, int index) {
     if (System.BitConverter.IsLittleEndian) {
         return System.BitConverter.ToInt32(bytes, index);
     }
     else
     {
         return System.BitConverter.ToInt32(Reverse(bytes), bytes.Length - sizeof(float) - index);
     }
 }

Also, the reverse function:

 public static T[] Reverse<T> (T[] array) {
     T[] ret = new T[array.Length];
     for (int i = 0; i < array.Length; i++) {
         ret [array.Length - 1 - i] = array [i];
     }
     return ret;
 }

Put them somewhere in your code to access them. To read the value, set it to the function. Put the byte array as the first argument and the index of the first element as the second.

This should achieve what are your needs. If you deal with arrays, then it is going to be more difficult since they are variable sized. You will need to use one element of the byte array to store length of the array, assuming your arrays are not longer than 256 elements. And then, you will have to offset with that length all elements going after the array, the one example line of code from my project looks like this:

 bytes [bytes [0] * 2 + bytes [bytes [0] * 2 + 1] * 5 + 1 + 29] = lW [0];

Also, you can try storing values as shorts and not ints to save even more space.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by saikrishna-dasari · Dec 05, 2016 at 06:25 AM

Hi, I found Some more useful information about this topic related in this Link. I think It may be useful for some fellows, who have same doubt about it. Thank you.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiplayer Health Bar 1 Answer

it is Playerprefs can use in saving highscore and both PC having this can same see data in Highscores? 0 Answers

Hosted Database for Mobile Game 0 Answers

Connection between menu and scene 2 Answers

Player interaction in multiplayer. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges