First-person shooter character

Unity lesson #1: make a first-person game

You are about to create your first FPS game with Unity.

Preparation

  1. Download, install and open Unity.and do our Unity setup and orientation tutorial.
  2. 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

new-project

  1. Create a new project by clicking NEW in the Unity Start Window shown above or by clicking File Menu / New Project.
  2. Click Create Project.
  3. 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.

  1. In the Project panel, click Create / Folder and name the folder Game.
  2. In the Game folder, click Create / Folder and name the folder Scenes.
  3. Click File Menu / Save Scene to save your first level of your game inside the Scenes folder and name it “level1”.
  4. 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

  1. In Hierarchy panel’s top left corner click Create / 3D Object / Cube.
  2. In the top toolbar click Resize, the fourth tool or hit the R hotkey.
  3. Drag the square resize handle gizmos out to make the cube wide and flat.
  4. While the object is selected, look in the Inspector panel Transform box to see the position, rotation and scale X, Y and Z numbers.
  5. Click in the Inspector panel on the Transform scale boxes and type to make X 10, Y 1, Z 10.
  6. Click in the name box at the top right Inspector where it says Cube to select the text.
  7. Type to name it Ground.

Place a first person character controller into the scene

  1. Click Assets Menu / Import Package / Characters.
  2. Click OK to import the package.
  3. Click in the Project panel / Assets / Characters / FirstPersonCharacter / Prefabs.
  4. Drag the FPSController blue cube into the Scene view or Hierarchy.
  5. In the top right Inspector panel, where it says Tag Untagged, click and change it to Player.
  6. In the top toolbar click Move, the first tool or hit the W hotkey.
  7. Drag the arrow move Y gizmo up above your Ground cube.

Test the game by playing it

  1. Click PLAY button top center.
  2. Your game is now running! Walk around by pressing W A S and D and look around with the mouse.
  3. Click PLAY button again to stop.
  4. Remember: NEVER edit playing or you’ll lose changes, always stop first.
  5. Click File Menu / Save Scene to save your first level of your game and name it “level1”.

Decorate your scene

  1. Make more cubes for the player to explore like walls, stairs, ramps and gaps for jumping across.
  2. Add point lights to make it look cool and more cubes to jump around on.
  3. 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.

Click to begin the next Tutorial: Triggers

Advertisements

One Comment Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s