User Created Levels, for others to play

Hello, I’m making a simple level builder game like Little Big Planet or Happy Wheels where the user creates levels and other players can play and rate that level. The level editor is going well, but how do I save and upload the level to some server so others can play it?

1 Like

That’s simple.
Save it a as a txt / data file ( with all data regarding your level ). Then you can use WWW class to load this in the unity from the server where you uploaded it.

What kind of server do I need mySQL? And How do I store the data in a txt file?

You could create a database with all the info ( url to the file on the server, uploaded by, time of the upload), so mySQL would do it. This is harder to do.

You would need a server for storing levels that players have made. Or you could let them upload on some third location and then let them to input the URL to the level.

Saving data to txt file should not be that difficult, there are plenty tutorials online about this topic.

Put your level data in a class instance, and serialize it to a string using JsonUtility. See Manual: JSON Serialization. Then use StreamWriter to save it to a text file. See How to: Write Text to a File.

Sharing is more complicated. As a first pass, you could just let players pass the files around, host them as downloads on their websites, or whatever. Provide a way to load a level from a local text file.

How to I retrieve a file from a server?

Start with using WWW GET and POST, which is probably the simplest way to get started. This UnityAnswer contains example code.

Hmm, do I need to serialize it to a string using JsonUtility If all I’m saving are the object positions? They can be converted to a string easily. Or do I serialize it to a string using JsonUtility for other reasons?

No, you don’t need to use JsonUtility, but if all your data is in an object (that is, an instance of a class) already, it’s probably easier to use it than convert it to a string yourself.