Jump to content
Sign in to follow this  
  • entry
    1
  • comments
    0
  • views
    507

Unity Getting started with your Third Person Game

Vinicius Marques

860 views

Getting started with your Third Person Game

Difficulty: Beginner

Link to original content

clip_image002.png

Introduction

The indie game development is a trend nowadays. Recently, we can notice some of the top triple-A developers leaving their jobs, where they use to lead huge projects, to start their own game studios. Or even new talents, from best-selling indie games studios, are refusing to move to major publishers, sticking to their origins to focus on expanding and improving their indie games franchises that made them popular.

With the indie games market in such evidence, game developers have more and more tools to develop its own games nowadays. The game engines itself, responsible for making the task of game creation faster and simpler, are even more accessible, without the need of major investments. One of them in special, the Unity game engine, with triple-A quality features, offers affordable conditions for small studios, and even a free personal version. This is a perfect fit for the indie market, following its tendency to grow more and more.

The Unity creators also provide a great marketplace, the Asset Store, where it is possible to acquire several professional level packages with fair prices. Such assets can be considered one of the best allies of the indie studios, saving a lot of time and money. There are even top quality, completely free packages to consider, that leaves nothing to be desired in comparison to paid alternatives.

What we will build

In this tutorial, we will learn how to start creating a 3rd person game, using a free starter kit that we can acquire in the Asset Store. The 3rd Person Controller + Fly Mode asset is one of the most popular in the Asset Store, and was chosen by the editors as a must have asset , an essential one for those who are getting started with Unity and the store itself.

When we have completed this tutorial, we will have a fully functional third-person walking simulation, that can walk, jump strafe, aim, and even fly over the environment.

Prefer video format?

If you prefer an alternative (and more objective) version of this tutorial in video form, please click here.

Getting started

To complete this tutorial, you need to have the latest version of Unity, and at least a personal free account. If you don’t have one yet, please click here to proceed to the Unity website and follow the steps to choose a plan and download the game engine.

  • When ready, open the Unity IDE, and create a new project.

Inside the project, the first thing we need is to add an environment to navigate in. If you have any custom scenario, you can import it right now and place it into the scene. To keep it simple, we will just setup a plane as our ground, using one of Unity’s basic 3D objects.

  • On the editor menu, go to GameObject > 3D Object > Plane.

clip_image004.jpg

  • Select the Plane GameObject, under the Hierarchy.
  • On the Inspector tab, scale it to 2, 0.01, 2.
  • Ensure the position and rotation values for it are all 0.
  • Check the Convex option under the Mesh Collider section.
  • Check the Static option on the upper right side.

clip_image006.jpg

Before proceeding, we will reduce the light intensity for better scene view.

  • Select the Directional Light GameObject, under the Hierarchy.
  • Change the Intensity value to 0.3.

clip_image008.jpg

 

Downloading the assets

If you have not yet downloaded the asset package, please click above to get it:

notrack
  • On the asset page, click to download it and open in Unity . This may redirect you to the Unity Editor.
  • Back to the Unity Editor, the Asset Store tab will appear. Scroll down until you find the Import button, and click on it.
  • If prompted to confirm that you are importing a complete project, click on Import.

The Import Unity Package window will appear. Since we are using just the essential assets of this package to create our own game, we don’t need to import the entire package.

  • Click on the None button to deselect all.
  • Check the entire Animations folder.
  • Check the Animator folder.
  • Under Materials, check the Character physic material.

clip_image010.jpg

  • Inside Scripts > LevelScripts, select the ThirdPersonOrbitCamBasic script.
  • Check the entire PlayerScripts folder.

clip_image012.jpg

  • Scroll down until the ProjectSettings folder, and check the InputManager asset.
  • Click on Import.

clip_image014.jpg

Configuring the player avatar

Now we can proceed to setup the player avatar. If you have any custom model, you can import it right now and place it into the scene. Note that it has to be a Mecanim humanoid compatible model. For this tutorial, we will simplify and use on of Unity’s standard assets, Ethan.

  • On the menu, go to Assets > Import Package > Characters.
  • On the Import Unity Package window, click on None.
  • Scroll down until you find the Ethan.fbx model, and select it.
  • Click on Import.

clip_image016.jpg

  • Under the Assets folder, go to Standard Assets > Characters > ThirdPersonCharacter > Models.
  • Drag the Ethan model to the scene.
  • Under the Inspector, set the position to 0, 0, 0.
  • Open the Tag selection, and choose Player.

clip_image018.jpg

Before adding the player actions, we need to setup some components on the avatar.

  • On the Animator, select the Controller parameter and choose CharacterController.

 

clip_image020.jpg

Now we need to setup the player physics components.

  • Click on Add Component > Physics > Capsule Collider.

clip_image022.jpg

Next, we need to setup the collider so it fits the player. The following values are for the Ethan avatar.

  • Select, for the Material parameter, the Character physic material.
  • Set the center of the collider to 0, 0.79, 0.
  • Set the radius to 0.26.
  • Set the Height to 1.6.

clip_image024.jpg

When configuring the Capsule Collider on your own character avatar, you must avoid the following situation:

clip_image026.png

If the collider end is positioned above the mesh end, the character will get stuck when trying to move. Do not let the avatar mesh surpass the collider! The correct position is set when the bottom of the collider is at the same level or under the mesh end:

clip_image028.png

As a reference, to centralize the collider correctly, check the mesh size and use its height as the collider Height parameter. For the Center position, you may use half of the collider height minus 0.01, as the Y value of the parameter. After setting it, remember to check if the situation described above does not occur.

Now we need to add the RigidBody component to the player.

  • Click on Add Component > Physics > RigidBody.

clip_image030.jpg

  • Set the player Mass. We will use 70 for Ethan.
  • Under the Constraints section, check the Freeze Rotation options for the X, Y, Z axes.

clip_image032.jpg

Setting the player actions

Now it’s time to setup the player actions. The player actions are defined by behaviours, each one implemented in completely independent scripts. All behaviours are controlled by a behaviour manager, that defines who is the active player action. The manager also contains common features for all behaviours. This design opens the possibility to enable or disable player actions even during runtime.

  • With Ethan selected, click on Add Component > Scripts > Basic Behaviour.
  • On the Player Camera parameter of the script, drag the Main Camera.

clip_image034.jpg

This is the script responsible for managing the player behaviours. It contains some common variables that you can play with, if you desire. Now we can start adding the custom behaviours. The first one is the Move Behaviour, responsible for player actions like walk, run, sprint, and jump. It is usually the default player behaviour.

  • Click on Add Component > Scripts > Move Behaviour.

clip_image036.jpg

You can play with the parameters of this script if you desire. Check the README file that comes with the package for more details about each one of them. We’ll leave the default values for this tutorial. Now we will add the behaviour responsible for the strafe movement and the aiming mode.

  • Click on Add Component > Scripts > Aim Behaviour Basic.
  • Click on the Crosshair parameter, and select DropdownArrow (or any other custom texture you want to use).
  • On the Aim Pivot Offset parameter, change the Y value to 1.

clip_image038.jpg

Depending on your player’s height, you may have to adjust the Aim Pivot Offset and Aim Cam Offset parameters. Remember to check the README for more information about specific parameters. Finally, we can add a custom extra behaviour, responsible for making the player avatar fly over the environment.

  • Click on Add Component > Scripts > Fly Behaviour.

clip_image040.jpg

We’ll leave the parameters as is, but you can always check the README file for more information on changing this values.

Setting the 3rd person camera

The last setup we need is to set our camera as a 3rd person point of view, which will orbit around the player and follow him during his movements.

  • On the Hierarchy, click on the Main Camera.
  • Click on Add Component > Scripts > Third Person Orbit Cam Basic script.
  • On the Player parameter, drag Ethan GameObject (or any other custom avatar you have chosen).

clip_image042.jpg

Now that we have everything ready, we can play the scene and test it. Now is a good time to save the project and the scene.

  • Use the mouse to move the camera.
  • Press the directional or w,a,s,d keys to move.
  • You can control the movement speed using the mouse scroll.

camera.gif walk.gif run.gif

  • Hold the left shift while moving to sprint, and press space bar to jump.
  • Hold the right mouse button to aim. While aiming, press the middle mouse button to switch shoulders.
  • Press key f to toggle the fly mode.

sprint_jump.gif walk.gif fly.gif

This asset features a keyboard + mouse setup input, and also comes with full Xbox One Controller support. For the complete controls scheme, you can run the demo scene that comes with the asset. Since you will need to import all the files from the package, we recommend that you start a new project and import the full asset into it. Once loaded, play the demo scene and press F2 to see the keyboard + mouse scheme, or the Xbox One Controller Menu button  to view the gamepad scheme.

Conclusion and next steps

Now that you have basics to start with, you can try to design you own custom player actions. What about making the player swim? Or even a melee combat system?

The 3rd Person Controller + Fly Mode asset was built to make easy the task of adding new player behaviours in a completely independent manner. You can enable and disable actions during runtime, temporarily overwrite the active behaviour, and more. Take a look at the commented methods of the Basic Behaviour class, the README file, and start coding your own player behaviours right now!

If you enjoyed this package and want to know more about other custom player actions that can buy you some time and speedup the game creation process, we have a hint for you. We invite you to take a look at the Cover + Shooting System - Third Person Shooter asset, a complete starter kit for any third-person shooter game:

icon

It comes with 2 extra behaviours, besides the basic locomotions: the cover system, with environment interactions, and a complete shooting system, with fully interactive weapons, particles and hittable targets. A time and money saver!

And that's the conclusion for our 3rd person walking simulation game setup tutorial. We want to thank you for getting in this journey with us!

About the author

clip_image044.jpg

Graduated in Computer Science, and with a master degree in Artificial Intelligence & High-Performance Computing, Vinicius Marques has started working with state of the art concepts and technologies, like Machine Learning and Parallel & Distributed Computing. These areas, in particular, later defined some actual IT trends: Big Data and Data Science.

Even working with state of the art tech, the passion for the games was never abandoned, taking an important role in his academic and personal lives. Having worked with Data Science/Big Data until recently, he defined that it was time to follow his passion and dedicate himself to what really gives him day by day motivation: creating games. Since then, he has dedicated his professional life to projects in many game related areas, such as Virtual Reality, Augmented Reality, Artificial Intelligence and gameplay mechanics.

 

Click here to visit the author’s page.



0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By trapazza
      I'm trying to add some details like grass, rocks, trees, etc. to my little procedurally-generated planet. The meshes for the terrain are created from a spherified cube which is split in chunks (chunked LOD).
      To do this I've wrote a geometry shader that takes a mesh as input and uses its vertex positions as locations where the patches of grass will be placed (as textured quads).
      For an infinite flat world (not spherical) I'd use the terrain mesh as input to the geometry shader, but I've found that this won't work well on a sphere, since the vertex density is not homogeneous across the surface.
      So the main question would be: How to create a point cloud for each terrain chunk whose points were equally distributed across the chunk?
      Note: I've seen some examples where these points are calculated from intersecting a massive rain of totally random perpendicular rays from above... but I found this solution overkill, to say the least.
      Another related question would be: Is there something better/faster than the geometry shader approach, maybe using compute shaders and instancing?
    • By FedGuard
      Hello all,
       
      I would like to start off with thanking you all for this community. Without fora like these to assist people the already hard journey to making an own game would be exponentially more difficult. Next I would like to apologize for the long post, in advance...
      I am contemplating making a game. There, now that's out of the way, maybe some further details might be handy.
      I am not some youngster (no offence) with dreams of breaking into the industry, I am 38, have a full-time job, a wife, kid and dog so I think I am not even considered indie? However I recently found myself with additional time on my hands and decided I would try my hand at making a game.Why? Well mostly because I would like to contribute something, also because I think I have a project worth making (and of course some extra income wouldn't hurt either to be honest). The first thing I realized was, I have absolutely no relevant skill or experience. Hmm; ok, never mind, we can overcome that, right?
      I have spent a few months "researching",meaning looking at YouTube channels, reading articles and fora. Needless to say, I am more confused now than when I started. I also bought some courses (Blender, Unity, C#) and set out to make my ideas more concrete.
      I quickly discovered, I am definitely not an artist... So I decided, though I do plan to continue learning the art side eventually, I would focus on the design and development phase first. The idea being, if it takes me a year or more solely learning stuff and taking courses without actually working on my game, I would become demoralized and the risk of quitting would increase.
      So I thought I would:
      1: Keep following the courses Unity and C# while starting on the actual game development as the courses and my knowledge progress.
      2: Acquire some artwork to help me get a connection with the game and main character, and have something to helm keep me motivated. (I already did some contacting and realized this will not be cheap...). Also try to have the main character model so I can use it to start testing the initial character and game mechanics. For this I have my first concrete question. I already learned that outsourcing this will easily run up in the high hundreds or thousands of dollars... (lowest offer so far being 220 USD) I am therefore playing with the idea of purchasing https://assetstore.unity.com/packages/3d/animations/medieval-animations-mega-pack-12141 with the intention of then have an artist alter and/or add to the animations (it is for a Roman character so some shield animations are not going to work the same way.). This way I could start  with the basic character mechanics. Is this a good idea, waste of money,...? Any suggestions? I then have a related but separate question. Is it a good idea to buy Playmaker (or some other similar software I haven't yet heard of like RPGAIO), and using this for initial build, then changing/adding code as the need arises?
      3.Get a playable initial level ready as a rough demo and then starting to look for artist for level design and character/prop creation.
      ...
       
      I would really appreciate some input from more experienced people, and especially answers to my questions. Of course any advice is extremely welcome.
    • By GameTop
      Dirt Bike Extreme - another game made with Unity. Took about 2 months to complete.
      Take part in extreme motorcycle races across the dangerous and challenging tracks. Dirt Bike Extreme is easy to pick up but hard to master. Race, jump and crash your way and other mad rivals through the amazing tracks as you master the skills and physics of motocross in this high-speed racing adventure. Conquer challenging routes on 23 different runs, discover new bikes and become the best of the best! Over 257K downloads already!
      Windows Version:
      https://www.gametop.com/download-free-games/dirt-bike-extreme/

      Mac Version:
      https://www.macstop.com/games/dirt-bike-extreme/
       

       


    • By Sergio Ronchetti
      Continuing to work on “Eldest Souls” (first article here!), I’ve begun familiarising myself with the workflow between Fmod and Unity, and the integration system. I know much of this will be pretty obvious to most, but I thought I’d share my thoughts as a complete beginner learning the ropes of sound designing. 
      The library of sounds that Fmod provides has been very useful, at least as reference points. I’ve still kept to my ethos of producing the sounds myself as much as possible. Having said that, Fmod gives you 50 free sounds with your download, and I’ve used a wooden crate smash, a drawbridge and electricity sound you can hear in the foley video below.
       
       
      The thing i found most useful was witnessing changes i made in Fmod being realised instantly in Unity. If a volume needed changing, or the timing of one of my effects was off, i can literally switch to Fmod and then back to Unity and immediately see the result of my alterations. It also seems apparent that using middleware such as this (or i've heard Wwise is also equally intuitive) grants the developer, and myself included, a great deal more flexibility and opportunity to edit sounds without going all the way back to a DAW, and bouncing down again. Needless to say, my workflow is so much faster because of it.
      I've also loved the randomised feature of Fmod, whereby any sound can be made to sound slightly different each time it is heard. Taking a footstep recording i made for example, I was able to add further authenticity of uneven footsteps by randomising the pitch and volume of each playback. 
       

       
      I used this technique when creating footsteps for the first major boss in the game called "The Guardian". A big, over-encumbered husk of a monster. I also had fun rummaging through the garage for old tools and metal components for the “Guardian” (the first boss) footsteps. See below!
       
       
      I also created a sword attack for our player, trying to sound different from the generic “woosh” I see in so many video games. I used a very “sharp” and abrasive sound to differentiate him from any enemies.
       
       
      On another note, I recently upgraded my microphone to a Rode NTG2 shotgun, which has been phenomenal. I haven’t had to worry about noise interfering with the clarity of my objects, whereas before with the sm58 I had to be clever with my EQ and noise reduction plugins.
      Important to note again that this still a “cheap” mic in comparison to most other products on the market, and all in all my entire setup is still very simple and affordable which I’m quite proud of. I’ve seen many musicians spend heaps of money on gear they don’t necessarily need. I much prefer being resourceful with less equipment, than to have more than I can understand or remember how to use.
      It’s forced me to understand every aspect and capability of my tools, which I believe is a principal that can be applied to any discipline.
       
      I have more fun little sound effect videos on my Instagram for those interested, where I post regular updates. Thanks for reading! (if you’ve made it this far)
       
      www.sergioronchetti.com
      INSTAGRAM
      fallenflagstudio.com
    • By Sergio Ronchetti
      BASICS IN SOUND DESIGNING FOR VIDEO GAMES
       
      Recently I joined the talented team at Fallen Flag Studio as the composer for their latest release "Eldest Souls" which consequently lead me into a field I have always dreamt of trying - sound design!
      Having no prior experience, I began watching a few online tutorials (if you want to learn from anyone make it Akash Thakkar from "Hyper Light Drifter"... what a guy!) and basically just testing stuff out i found around the house. Luckily my dad has a garage FULL of random crap to use.
      Before i continue, it's important to note that i DO NOT have fancy equipment, meaning anyone can try this. (my equipment is an sm58, focusrite scarlett interface and Logic Pro X plugins... that's it!)
      I started basic with some footsteps, which weren't all too difficult. Then I moved on to projectiles and a spear attack one of the bosses has. Below are a couple super short videos on my resulting attempts.
       
       
      Amazing how great a banjo sounds for that typical "woosh" sound! And if you're wondering, the paper was added to give some texture to the jab.
      I could be finding a lot of these sounds in libraries online (like the built-in ones that come with Fmod and Unity) but I've chosen not to, in order to produce authenticity and hopefully a more unique gameplay experience for players when the final product is put together.
       
      P.S. if you'd like to try the game and hear my hard work we'll be at EGX and several other conventions later this year, soon to be announced! Thanks for reading!
      www.sergioronchetti.com
      fallenflagstudio.com
       
      To those interested, there's an Alpha trailer of the game in question below.
       
       
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!