3
\$\begingroup\$

I've been asking this question over the years many a time, but I still haven't found an answer when i search for one. Now I have slightly more knowledge of how programming is done and want to start making some full games.

I want to start with a side scrolling shooter (space style like R-Type/Gradius). I have many ideas in my head for good levels, and i even have some basic 3d skills in Maya/Blender to make the assets, but I do not know how best to formulate the levels. Lets say the space shooter has 30 levels. Each level might have about 10-15 enemy types and a boss on some levels. How best to store the location of all the enemies? (Same scenario for all the background objects,obstacles, powerup locations etc.)

Is there a better way than manually building the whole level in a Unity Scene editor view? Another way I have tried is to set spawn positions for every single object as a Vector2 or similar in XML or JSON, but how i did it that seemed even harder to make the levels than just inside the editor (not even accounting for having to write the functionality to get the data from the textfile).

\$\endgroup\$
6
  • \$\begingroup\$ Are you trying to save the location of each object in the scene? \$\endgroup\$ Commented Jun 21, 2019 at 13:24
  • \$\begingroup\$ well im not sure. Im wondering if there is any better way than manually building entire levels all inside the scene view of Unity. As i say I tried setting position values from text data files but i found that more cumbersome than it was worth... I was perhaps doing it wrong lol \$\endgroup\$ Commented Jun 21, 2019 at 13:25
  • \$\begingroup\$ i will be making all my assets in tiles, they are 3d but will conform to certain sizes so that they can be tiled. But i can't decide/understand whether there is some function i could make that will create things such as passageways through the space (if you are familiar with R-Type you'll know what im describing). All the old games I used to play seemed to have a mathematical feeling about the placement of the objects if that makes sense \$\endgroup\$ Commented Jun 21, 2019 at 13:29
  • \$\begingroup\$ That will be really tricky if you are doing it in 3d. I know that you can create sprites and place down tiles from a tilesheet, kinda like drag and drop. I believe the best way to go with the style of your game is create some sort of random level generator class. It could randomly generate from all of the enemies in the game or specific ones. When you are spawning in the edges you could have a check where it deletes a random portion of the wall to allow entry into the next area. That will be a cool concept of a RNG based shooter. I'll see if I can find any resources on that if you want me to. \$\endgroup\$ Commented Jun 21, 2019 at 13:35
  • 1
    \$\begingroup\$ Here is an article that goes over the mechanics in simple terms. This would be a good starting point. johnnycode.com/2016/11/08/procedural-generation-101-for-games \$\endgroup\$ Commented Jun 21, 2019 at 13:39

2 Answers 2

3
\$\begingroup\$

The reason you might not find any good literature about this subject is because the best solution always depends on the game, its architecture, its scope and your team's preferred workflow.

Possible options are:

  • Hardcode your levels. Crude and hard to maintain, but a simple and effective solution for small games or proofs of concept.
  • Create it in Unity using the Unity scene editor
  • Create it in Unity, but use editor scripting to add some functionality to the Unity editor which helps you with building levels. This ranges from custom inspectors to editor-only behaviours to completely new editor UIs running in their own windows.
  • Create your level in Unity as a Timeline asset. Levels in scrolling SHMUPs are usually just a series of chronological events, so you might be able to represent a level as timeline. (Disclaimer: I never tried this, but it sounds like it could be a good idea in theory)
  • Make up a file format which might or might not be based on a markup language like JSON or XML and:
    • Edit it with a text editor
    • Create a visual level editor as a stand-alone executable
    • Create a visual level editor as part of your game.
  • Make use of procedural generation. Only define a few basic parameters for each level and create the actual content of the level with an algorithm.
\$\endgroup\$
2
\$\begingroup\$

Currently I know only of two ways.

pre-defined

If your levels are limited and should always (basically) be the same then you are good to go to create the levels with as Unity scene. 30 levels, 30 scenes. If you don't use Unity scenes and store pre-defined levels in a different format they are still pre-defined.

procedural

If you are looking for some infinite runner type you will need to create the objects dynamically/procedural using scripts or code. Here you can define patterns (e.g. enemy formations) as prefabs and instantiate them from your script.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .