Let's start with an empty scene. Go to File > New Scene, or press Ctrl + N to create a new scene.
New scenes in Unity come with a Camera and a Directional Light. We won't need the Camera, so you can delete it. We will work with very basic geometry for now. Create a plane by going to GameObject > 3D Object > Plane.
Make sure the plane is centered in the scene by resetting its Transform component in the Inspector panel.
We'll take a moment to review the components our plane came with.
3D models in Unity use the Mesh Renderer component, that comes with a Mesh Filter, to manage some rendering settings, like the materials (a.k.a. textures) and shadows. Next you'll see a Mesh Collider. This type of component takes care of the physics collisions of this object. If our plane didn't have this type of Collider component every other object would just fall through it. Specifically, a Mesh Collider is a collider that will have the exact same shape of the model containing it.
In the top part of the Inspector panel, you'll see two dropdown fields that are independent of any component: Tag and Layer. You need to set the Layer of the plane to "14: WorldColliders". The purpose of setting layers is to determine which objects can collide what objects. The player, projectiles, enemies and other physics objects will treat "WorldColliders" as the main world geometry (floors, walls, etc). Every object that conforms the environment of your map should be on Layer "14: WorldColliders", otherwise the game will not function properly.
Right after changing the Layer, check the Static checkbox. As soon as you do that, you'll note that the Unity Editor will start working on something.
What's happening is that Unity is "baking" the lightmap of your scene. This is a default behavior that can get a bit annoying. We will cover what "baking" a lightmap means later in this guide. For now, I'll teach you how to disable it so your computer isn't constantly working at full throttle everytime you change something in your level. Open up the Lighting panel. If you don't see a tab that says "Lighting" to the right of the Inspector panel, you can bring it to view by going to Window > Rendering > Lighting Settings.
In the Lighting panel, all the way down, check off the "Auto Generate" option.
In the Lighting panel, all the way down, check off the "Auto Generate" option. The lighting in your scene might look weird, or too dark. If this bothers you, you can delete the partially baked lightmap by clicking the down arrow to the right of "Generate Lighting" and selecting Clear Baked Data. You'll only need to do this step once per scene, and it's not necessary, but it will improve the performance of the Unity Editor.
We need almost every GameObject that's part of the environment to be marked as Static. Objects marked this way will be used not only for the lightmaps, but most importantly for the AI pathfinding.
Okay! We can go back to working on our level. Right now, we succeeded at creating the absolute minimum environment for the player to move around. We need a Player spawner now. You can find a [PlayerSpawn] prefab in the Project panel, inside the Prefabs folder. In there, you'll see more prefabs that I prepared for you. Grab the [PlayerSpawn] prefab and drop it in the Hierarchy.
If you do that, you'll see an icon appear in the Scene viewport, right in the middle of the plane.
If you do that, you'll see an icon appear in the Scene viewport, right in the middle of the plane. Take a look at the Inspector with the [PlayerSpawn] selected. You'll see a field named "Equipment". Here you can establish what weapons and items the player will begin the level with.
Right click anywhere in the Project panel and select Create > Game Stats > Equiped Weapons.
This will create an object named EquipedWeapons by default. Rename it to whatever you want. I'll call mine TutorialEquipment. When you select it, you'll see this in the Inspector:
For this example, let's make the player spawn with a Dart Gun and with a Generic D.I.L.D.0. Type 1 in the Size field under Starting Weapons. This will open some options.
Weapon Type determines the weapon. By default, we'll get Unarmed. If you open that dropdown, you'll see the current player weapons in the game. Starting Ammo Primary defines how much ammo the weapon starts with. Starting Ammo Secondary defines the secondary ammo amount, which only applies for weapons that have secondary ammo, like the SMG. Starting Weapon On Hand makes the player have that weapon equiped on hand when the level starts. Only one weapon should have this option marked.
We need 2 weapons. One will be Unarmed, and the second will be the Dart Gun. We'll also add one Starting Item. Some items require ammo, but the Dildo doesn't, so we can leave its ammo at 0.
Next, we'll give the [PlayerSpawn] this list of weapons we created. Just drag and drop it.
We need one more thing before we can test our map. Place a [LevelManager] prefab in the Hierarchy panel. All levels need this object to be present.
You are ready to test the level in the game and see if you we everything right so far. It's better to test your map constantly. If something goes wrong,you'll have a better idea of what could be the cause. You can check the previous page for more details on how to build your map. Don't forget to save your progress!
That is what you should see. Just an empty platform with nothing going on, but you should be able to move, shoot, switch weapons, and exit the level normally without anything strange happening. You might note that your plane is no longer showing as white. This is what happens when you don't have lightmapping data in your level. Don't worry, we'll fix this later on.