- Home /
Online level database
Hi! I'm working on my Android game and I have already finished all of the game mechanics. Now it's time to create some new levels. I want to let users create their own levels and send them to me, or put them in online levels database accessible for all players. It would be quite easy to make a level creator, but I have no idea how to send completed scenes to me, because I have never done anything similar. Can you help me?
Answer by Bodrp · Apr 13, 2017 at 02:53 PM
First thing is to make your level "web-service-friendly". You can do so by using Unity's JSON serializer: You can first serialize the level to JSON: https://docs.unity3d.com/Manual/JSONSerialization.html
This will take an object (like level specific data) and create text out of it. This JSON can then be POSTed to your server and stored there.
Anyone requesting a level made by another player can then GET it and deserialize it to overwrite an existing level object in their game. All explained in this same link: https://docs.unity3d.com/Manual/JSONSerialization.html
Now the hard part is about setting up your backend. You may try Flask or Google Drive API. I haven't tried those (I personaly use Django) but they look fairly simple and may suit your need.
Answer by Kishotta · Apr 12, 2017 at 06:38 PM
Not sure how complex your levels are, but I'd try to find a way to represent the levels as a list of values: say, as a model index number, position, and rotation. From there, you'll need a script/scene that can generate any level from a list of these values.
When the user creates a level, they only send you the values. similarly, when they request a level from the database, the client recreates the level from the values.
Hope that helps some.