Every map needs three things in order to compile and play properly. They are:
We have already created a hollow cube, so we have the sealed-off world part covered. Now, we just need a player_start
entity and a light
entity. Both of these entities are point entities and are created with the Entity Tool. Grab your Entity Tool from the Maptools bar (the knob icon between the Camera Tool
and Block Tool).
In the 3D view, left-click on any two random spots on the floor. This will create two copies of the default point entity at those points. With the Selection Tool, double-click on (or select it and press Alt+Enter) one of the entities you have just created to access the Object Properties. In the Class field, type info_player_start
and hit the Apply button.
It might be pretty obvious, but the player will spawn at this location when the map starts. This map still needs a light. With the properties window still open, click on the other entity you have placed to bring up its properties. Turn this entity into a light by finding light in the dropdown, or by typing light
. Again, hit Apply to save your changes and then close the Object Properties window. Move the light about 128 units above the middle of the floor in order to adequately light the room. We have now finished creating everything that a map needs to run! Unfortunately, we can't just open the map in Half-Life2 and run around, it needs to be compiled first. Hit F9, or click the compile icon in the top toolbar in order to build the map and prepare it for in-game use.
If you have not already saved your map, Hammer will prompt you to enter a filename for the map and a disk location to save your map onto.
After saving (or if you have saved already), the compile window will appear. Let's just do a quick compile so Run BSP under Normal, and Run VIS and Run RAD under Fast. Disable HDR if it is enabled and check Don't run the game after compiling. It's easy to forget if you already have HL2.exe
running and you will get an error if you try to launch the game while it's already running. When you click on OK, a console window will appear and the build programs will display the current compilation progress.
Once the compile finishes, launch your game (Half-Life2: Episode 2 in my case) and open the command console with the tilde (~) key. Type in the command map mapname
and press Enter to run your map. If, for example, your map is called my_map
, type map my_map
and then press Enter.
Congratulations! You have built and played around your very first Source map! Six walls with a simple light source can get boring pretty fast, so let's see what else we can do.
If you would like to keep Half-Life 2 running while you develop, you need to at least exit your map. When you're ready to get back to mapping, type disconnect
into the console to exit the map without closing Half-Life 2. If you compile the map when it's still open in Half-Life 2, weird things will happen and you will likely need to restart the game to get things back to normal.
18.219.228.88