I’m currently working on a 2d horror game, and was planning on letting the player can create their own custom levels to share. However, I’m stuck with trying to figure out save the data so that it can be shared. I imagine I could easily create an XML or text file, but how would I go about creating something that is encrypted, or that can only be read by my game so that others cannot modify it?
I guess ultimately I just need a glorified .txt file that can’t easily be opened, but this is completely outside of my area of expertise.
I wouldn’t put too much time into it. There are a lot of different approaches you can take from simple encryption to creating your own binary format to use. If you’re super worried about it I would go the binary format approach and some simple encryption. One thing to keep in mind… in order to encrypt the data you’ll need to use some kind of encryption key. That key will be in your code and anyone who wants to get at it will be able to if they’re a bit savvy and determined enough. Encrypting your save really only deters the casual folks from fiddling with it. Your best bet is to use a binary format and when you load the save file back in, do some bounds checking on your values to at least make sure someone isn’t modifying them outside of what you’d expect. For instance, if you have a “PlayerHealth” property and the max is only ever “100”, when you load, make sure someone hasn’t changed it to, say “1000”.
You could also do some goal checking… so if a player can only have a specific ability after they’ve accomplished some goal, make sure that goal has been accomplished if it’s been set within your save file.
I don’t think you should worry so much about not allowing others to modify the save. If its a single player game and they cheat they’re only cheating themselves out of the experience, not hurting anyone else.
Yeah, I’m only looking to stop people from easily abusing other files. I realize there’ll be a work-around to pretty much whatever I do. It’s more about saving custom-built levels, and less about a player cheating. I want others to share their custom created content without being able to rip eachother off. I’ve got a lot of Unity experience, but don’t know much about encryption.