How to create level based game ?

I started to work on level based game and i have a few questions:

  • What is the best solution for save levels at level based games?
  • Should i create a scene for every level or i have to save in XML file?

If i have to save in XML file:

  • Should i have to save in one XML file each level or i have to save it all levels in one XML file?

Honestly, all of that is up to you. There’s nothing in Unity, or from game design principles, that directs how you implement your level saving.

(Personally I’d save each level in its own GRFON file, but that’s just me.)

From performance point i think if i save in files is better. Am i right ?

Not necessarily. When you switch levels, you’re going to have to tear down and recreate most of the objects in the scene anyway, which is the same thing Unity does when you Application.LoadLevel.

As soon as you ask “how do I build this?” you’ve moved into scripting forum territory. Seriously, those guys will be all over this question.

Over in game design we are more esoteric. Game design does questions like “Should I have levels?” “What length should my levels be?” “How do I balance the difficulty of my levels?”

2 Likes

Easing the process of creating the files by hand is nice, but JSON already has assets on the store to process it.

https://www.assetstore.unity3d.com/en/#!/content/11347

Though if you were to make an asset for processing GRFON files…

1 Like

My favourite format to save levels in is actually an image. It works brilliantly for 2D games or anything that can be reduced to 2D data (such as terrain).

The key advantage of image is that they can be readily created by pretty much anyone. Simply give them a key with what each channel or value means and let them at it.

I’m currently designing levels for my new game in paint.

1 Like

It’s on my to-do list. :slight_smile: Obviously I already have such code, and it’s been working like a champ in several projects, but that final clean-up & documentation needed to put it in the Asset Store has so far failed to happen!

So yeah, if I were in anybody else’s shoes at this point, I’d go with JSON or XML. Or an image, as @Kiwasi suggests, if that’s appropriate for your level structure.

There is a LitJson library available for free and open source.

1 Like