In this section we create a First Person Shooter with a zombie theme. We cover raycasting for shooting and the core mechanics you'd expect in an FPS. This repo is part of our Complete Unity C# Developer 3D course (http://gdev.tv/cu2github). (Ref: ZR_CU2)
This is the Complete Unity Developer 3D - one of the most successful e-learning courses on the internet! Completely re-worked from scratch with brand-new projects and our latest teaching techniques. You will benefit from the fact we have already taught half a million students game development, many shipping commercial games as a result.
You're welcome to download, fork or do whatever else legal with all the files! The real value is in our huge, high-quality online tutorials that accompany this repo. You can check out the course here: Complete Unity Developer 3D
In this section we create a First Person Shooter with a zombie theme. We cover raycasting for shooting and the core mechanics you'd expect in an FPS. This repo is part of our Complete Unity C# Developer 3D course (http://gdev.tv/cu2github). (Ref: ZR_CU2)
Here are the lectures of the course for this section.
In this video (objectives)...
- Overview of this section.
- Demo of the game prototype.
After watching (learning outcomes)...
Ready and raring to start this section.
In this video (objectives)...
- Discussion of the game overview screen and core features.
- Reminder that we're using Unity 2019.1.
After watching (learning outcomes)...
Super clear on the game we are making and the feature priorities.
In this video (objectives)...
- Download Unity Standard Assets.
- Implement the First Person Controller with RigidBody.
After watching (learning outcomes)...
Get and add the First Person Controller to our scene.
In this video (objectives)...
- Use Unity's simple prototyping geometry to make a simple level.
- Make sure there are different obstacles to test the expected functionality in the game.
After watching (learning outcomes)...
Create a simple sandbox level for prototyping.
In this video (objectives)...
- Add a placeholder enemy with NavMeshAgent component.
- Bake our NavMesh.
- Create EnemyAI.cs and add logic to move the enemy towards the player.
After watching (learning outcomes)...
Use the NavMeshAgent component to drive the enemy towards the player.
In this video (objectives)...
- Fix jitter by removing head bob.
- Stop player getting stuck on walls by adding a physics material.
After watching (learning outcomes)...
Fix some issues with our first person controller.
In this video (objectives)...
- Make the enemy and player more obvious in their positions.
- Create logic that tells the enemy to move to the target if the target is within the chase range.
After watching (learning outcomes)...
Move the enemy to the target if the target is within range.
In this video (objectives)...
- Use the Unity docs to figure out how to draw a gizmo which shows the chase range of our enemies.
After watching (learning outcomes)...
Use gizmos to visualise chase range.
In this video (objectives)...
- Structure our EnemyAI class so we have logic for the enemy being provoked.
- Use the nav mesh stopping distance as part of our conditions for attacking or not.
After watching (learning outcomes)...
Add to our enemy AI, causing it to attack if provoked.
In this video (objectives)...
- Import a weapon and attach it to the player.
- Add a reticle the the UI canvas.
After watching (learning outcomes)...
Give the player a weapon asset.
In this video (objectives)...
- Overview of how Raycasting works.
- Add a ray that is cast when the player clicks their shoots (clicks their mouse button).
- Print to the console the thing that we hit.
After watching (learning outcomes)...
Implement raycasting so we can shoot an invisible laser beam.
In this video (objectives)...
- Create a public method that reduces enemy's health.
- Call that method from our weapon and pass in the weapon's specific damage amount.
After watching (learning outcomes)...
Lay some smack down on an enemy (well, decrease its hit points).
In this video (objectives)...
- Create simple code to play our muzzle flash.
- Create a particle system that looks somewhat like a muzzle flash.
After watching (learning outcomes)...
Create a muzzle flash particle effect and play it when the player shoots.
In this video (objectives)...
- Twiddle with one of the standard assets particle effects to get something we like.
- Instantiate the hit impact at the point the raycast hits.
After watching (learning outcomes)...
Instantiate a hit effect when we shoot something.
In this video (objectives)...
- Discuss animation states.
- Set up a simple flow from Idle to Move to Attack.
After watching (learning outcomes)...
Understand the basics of how Animator Controllers work.
In this video (objectives)...
- Create a new animation that we add to idle state.
- Understand that we can animate properties such as the transform of an object.
After watching (learning outcomes)...
Understand how to add simple animations to our animator controller states.
In this video (objectives)...
- Set up a trigger and a bool parameter.
- Cycle through our states by trigging our transition conditions.
After watching (learning outcomes)...
Understand how to trigger different states based upon parameter conditions being met.
In this video (objectives)...
- Add code to trigger move state.
- Implement attack state bool to set to true or false depending upon enemy AI logic.
After watching (learning outcomes)...
Understand how to use code to trigger animation state changes.
In this video (objectives)...
- Create EnemyAttack.cs and create a public method that can be called as an animation event.
- Create simple animation for attack and add an animation event which calls our attack code.
After watching (learning outcomes)...
Use animation events to create precise attack moments.
In this video (objectives)...
- Nifty challenge where you get to chose your difficulty level.
- Have the enemy damage the player.
After watching (learning outcomes)...
Complete our loop where the enemy can hit and damage the player.
In this video (objectives)...
- Discuss briefly how Vectors work.
- Rotate the enemy to face the player by using Quaternion.Slerp().
After watching (learning outcomes)...
Be clear on how to rotate an object so that it is facing another moving object.
In this video (objectives)...
- Create a Game Over canvas with buttons to reload game and quit.
- Create a class which contains the methods with the functionality for our buttons.
After watching (learning outcomes)...
Create a simple game over menu to ensure we can restart the game when the player dies.
In this video (objectives)...
- Disable and enable our game over menu screen.
- Give the cursor back to the player.
- Stop the game so that we aren't seeing weird cursor fighting issues.
After watching (learning outcomes)...
Elegantly handle displaying and using the Game Over menu when the player dies.
In this video (objectives)...
- Our goal is to have the enemy provoked when shot.
- We look at a couple of ways to do this, one of which being BroadcastMessage().
After watching (learning outcomes)...
Use BroadcastMessage() to call any methods of a particular name on our Game Object.
In this video (objectives)...
- Tidy up our sandbox and make a bit of level flow.
- Tune our Player and enemies so that the game feels the way we want.
After watching (learning outcomes)...
Make the game feel like a game with the limited feature set we have at the moment.
In this video (objectives)...
- Examine Rick's prototype to look at how the weapon switching, ammo system and ammo pickups relate to one another.
After watching (learning outcomes)...
Be clear on what we are about to undertake with our weapon system.
In this video (objectives)...
- Figure out what would give us a zoomed in effect.
- Create a connection to our camera and variables for zoomed in and out FOV.
- Create logic that toggles between zoomed in and zoomed out.
After watching (learning outcomes)...
Clear on how to use a camera's field of view to zoom in and out.
In this video (objectives)...
- Create Ammo.cs and add 2 public methods to allow our weapon to communicate with our ammo.
- Create logic so we can only shoot if we have more than 0 ammo and to decrease ammo each time we shoot.
After watching (learning outcomes)...
Add basic ammo functionality where we decrease our ammo when shooting and can only shoot if we have enough ammo.
In this video (objectives)...
- Create a delay between shots for our weapon.
- Tune the damage, range, scope and shot delay for our three weapons.
After watching (learning outcomes)...
Understand how to create a shooting delay and how to differentiate our 3 weapons.
In this video (objectives)...
- Create a foreach loop which loops through our weapons and sets them active or inactive.
- Create the framework for the player to be able to select their weapon.
After watching (learning outcomes)...
Create the framework for setting weapons active or inactive.
In this video (objectives)...
- Create a way for the player to change weapons by pushing the keyboard numbers.
- Create a way for players to change weapons by using the scroll wheel.
After watching (learning outcomes)...
Give the player multiple ways to change weapons.
In this video (objectives)...
- Tidy up a couple of bugs.
- Create AmmoType public enum.
- Create AmmoSlot private class.
After watching (learning outcomes)...
Have experimented with a public enum and private class.
In this video (objectives)...
- Assign our weapon to be a particular ammo type.
- Hook everything up so our weapons decrease ammo from a specific ammo slot.
After watching (learning outcomes)...
Have specific weapons use specific types of ammo.
In this video (objectives)...
- Identify why our weapon is staying zoomed.
- Challenge to fix the issue.
After watching (learning outcomes)...
Practice finding and fixing bugs.
In this video (objectives)...
- Create a game object which is triggered when the player runs through it and destroyed, printing a witty message to the console in the process.
After watching (learning outcomes)...
Create a simple pickup framework that can only be triggered by the player.
In this video (objectives)...
- Set the value and type of the pickup.
- Create a public method to increase ammo amount.
- Create prefab variants for each pickup type.
After watching (learning outcomes)...
Increase specific types of ammo when we collect that an ammo pickup of that type.
In this video (objectives)...
- Import enemy character asset.
- Hook up new animations to our animator.
- Add code to trigger enemy death and stop weird death-related behaviours.
After watching (learning outcomes)...
Make your game 5 times more awesome by having an enemy who actually looks like an enemy.
In this video (objectives)...
- Figure out why our zombie is not hurting us.
- Implement a fix to this problem.
After watching (learning outcomes)...
Practice hunting down an issue and implementing a solution.
In this video (objectives)...
- Create a new scene that will be a more organised level.
- Sketch out a level design and import that into the scene to use as a reference diagram.
After watching (learning outcomes)...
Create a level design diagram to use as a reference for the level creation.
In this video (objectives)...
- Add terrain and sculpt it, being sure to add elevation changes.
- Add trees.
- Add grass texture and mesh.
After watching (learning outcomes)...
Make our forest look interesting by adding terrain and trees.
In this video (objectives)...
- Instal ProBuilder.
- Use ProBuilder to make shotgun shells.
- Use ProBuilder to make bullets.
After watching (learning outcomes)...
Get comfortable with ProBuilder by making props.
In this video (objectives)...
- Install ProGrids.
- Create the shell for our first room.
- Create a separate game object that is the roof.
After watching (learning outcomes)...
Comfortable using ProBuilder to make rooms.
In this video (objectives)...
- Use ProBuilder's Poly Shape Tool to trace around our entire level sketch.
- Flip the normals of our level so we can see the walls on the inside.
- Add elevation and link everything up.
After watching (learning outcomes)...
Comfortable using ProBuilder to make levels.
In this video (objectives)...
- Import some textures.
- Use ProBuilder's Material Editor to add textures.
- Use ProBuilder's UV Editor to tweak the look of the textures.
After watching (learning outcomes)...
Comfortable using ProBuilder to add textures and materials.
In this video (objectives)...
- Create a light with an emissive material.
- Place lights in our scene.
After watching (learning outcomes)...
Able to place emissive lights in your scene.
In this video (objectives)...
- Create a flashlight that is attached to the player.
- Decay the flashlight angle and intensity over time.
After watching (learning outcomes)...
Create a decaying flashlight.
In this video (objectives)...
- Create 2 public methods on our flashlight which increase angle and intensity.
- Create a battery pickup which calls the 2 public methods.
After watching (learning outcomes)...
Create a battery pickup which restores the functionality of our flashlight.
In this video (objectives)...
- Tidy up, add enemies, rebake navmesh.
- Add code and UI to display the player's ammo for each weapon cycled through.
After watching (learning outcomes)...
Display the ammo for the currently wielded weapon.
In this video (objectives)...
- Add some cool effect for when the player takes damage.
- Trigger the UI effect by turning on and off the canvas.
After watching (learning outcomes)...
Provide the player visual feedback for when they receive damage.
In this video (objectives)...
- Download and add props to your game, being sure to use them to make a story.
- A challenge for you to make a 5 minute experience that is wow.
After watching (learning outcomes)...
Add props and polish your game to make a 5 minute wow.