Unity lesson #1: make a first-person game
You are about to create your first FPS game with Unity.
- Download, install and open Unity.and do our Unity setup and orientation tutorial.
- Unity Personal Edition is free, but it will ask you to create an account and verify your email by clicking on the special link in an email they send you.
Create a Unity project
- Create a new project by clicking NEW in the Unity Start Window or Unity Hub shown above or by clicking File Menu / New Project.
- Click Create Project or CREATE.
- Wait for Unity to finish making the project for you.
Organize your project into folders and save your scene
Keep your files organized in a single Game folder with sub-folders for each file type.
- In the Project panel, click Create / Folder and name the folder Game.
- In the Game folder, click Create / Folder and name the folder Scenes.
- Click File Menu / Save Scene to save your first level of your game inside the Scenes folder and name it “level1”.
- For best organization, click Project / Create / Folder to make additional subfolders of Game with the following names: Scripts, Prefabs, Models, Materials, Texture, Audio, Terrain and Animations.
Turn a cube into the ground
- In Hierarchy panel’s top left corner click Create / 3D Object / Cube.
- In the top toolbar click Resize, the fourth tool or hit the R hotkey.
- Drag the square resize handle gizmos out to make the cube wide and flat.
- While the object is selected, look in the Inspector panel Transform box to see the position, rotation and scale X, Y and Z numbers.
- Click in the Inspector panel on the Transform scale boxes and type to make X 10, Y 1, Z 10.
- Click in the name box at the top right Inspector where it says Cube to select the text.
- Type to name it Ground.
Place a first person character controller into the scene
- Click Assets Menu / Import Package / Characters or download the FPS Controller Package from here and double click it.
- Click OK to import the package.
- Click in the Project panel / Assets / Standard Assets / Characters / FirstPersonCharacter / Prefabs.
- Drag the FPSController blue cube into the Scene view or Hierarchy.
- In the top right Inspector panel, where it says Tag Untagged, click and change it to Player.
- In the top toolbar click Move, the first tool or hit the W hotkey.
- Drag the arrow move Y gizmo up above your Ground cube.
Test the game by playing it
- Click PLAY button top center.
- Your game is now running! Walk around by pressing W A S and D and look around with the mouse.
- You can hit the ESCAPE key to unlock the mouse from looking around.
- Click the PLAY button again to stop.
- Remember: NEVER edit while the game is playing or you’ll lose changes when you stop. Always stop first before making any changes you want to keep.
- Click File Menu / Save Scene to save your first level of your game and name it “level1”.
Decorate your scene
- Make more cubes for the player to explore like walls, stairs, ramps and gaps for jumping across.
- Add point lights to make it look cool and more cubes to jump around on.
- Create a Material in Project / Create button, assign it a different color, and drag it onto some of your ground cubes to make them more distinctive.
It can’t be turtles all the way down
Have you noticed that if you fall off the edge of your ground cube, you fall forever?
- You could make wider ground and put more bigger cubes below to catch you, but players will always find a way to go where they shouldn’t.
- Next, we’ll add a trigger script to stop players from falling infinitely off the edge.