Section 4 - The toughest, and most rewarding section of the course. Here you learn to finish strong, with clean code, few bugs, and great features. This is real game dev right here.
The full Unity RPG course is part of a Kickstarter campaign which was over 200% funded. You will benefit from the fact we have already taught over 360,336 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! Please note that some sections contain assets with commercial use restrictions. The real value is in our huge, high-quality online tutorials that accompany this repo. You can check out the course here: Unity RPG
This is a Unity project. If you're familiar with source control, then "clone this repo". Otherwise download the contents, and navigate to Assets > Levels
then open any .unity
file.
This branch is the course branch, each commit corresponds to a lecture in the course. The current state is our latest progress.
Here are the lectures of the course for this section...
- What we're going to cover in this section.
- Why this material is SO important.
- Ben will start, Rick will finish.
- A few new features but a LOT of polish.
- Don't Repeat Yourself (DRY) Principle.
- Inheritance can help us centralise.
- It's often easy to change an interface to inheritance.
- Create the new parent class, then delete the interface.
- Getting code running again may require
abstract
andoverride
.
- Move all
PlayParticleEffect()
code to parent class. - Use "down-casting" with caution for configs.
- Setup prefab based idiom for world vs local particle space.
- Move special ability audio to
AbilityBehaviour.cs
. - Use the
PlayOneShot()
method to play clips at the same time. - Import Rick's special ability sound effects.
- Move
AttachComponentTo()
method to parent class. - Refactor to simplify code as practice.
- Creating what's effectively nested prefabs!
- How to use
[ExecuteInEditMode]
annotation. - Detecting play mode with
Application.isPlaying
- Trigger a sound effect when weapon is collected.
- Destroy previous weapon by keeping member variable.
- The
Player
class is becoming a "god object" (see Resource links). - Change runtime animation on weapon swap.
- Remove Unity's
AICharacterControl.cs
class. - Make
PlayerMovement
more generalCharacterMovement
. - Overall reduce our code base by 68 lines.
- Remove jump and crouch arguments.
- Remove all un-necessary methods.
- Remove un-used member variables.
- Upgrade our project to Unity 2017.
- Fix anything that isn't working.
- Overview the new features in Unity 2017.
- About the
OnAnimatorMove()
callback. - Using this to adjust root motion speed.
- How call-backs can catch you out in refactors.
- Refactor our code in place to get an understanding.
- Bring Unity's code in line with our code standards.
- Move all code from
ThirdPersonCharacter
toCharacterMovement
.
- With special abilities we turned an interface into inheritance.
- Now we turn the
IDamageable
interface into a component. - Extract all damage, healing and health bar code.
- Don't be distracted when not compiling.
- Just solve the errors, get running & commit.
- Complete extraction of
HealthSystem
.
- Drawing a comparison with Health System.
- Using the "Pomodoro Technique" for 20-min chunks.
- Make energy and special abilities self contained.
- How to write an alternative getter format in C#.
- Remove the
AbilityUseParams
struct. - Eliminate the
IDamageable
interface.
- Review our code to ensure we "own" it.
- Get special abilities working again.
- Use an optional parameter in C#.
- Setup an out of energy SFX.
- Using the
[SelectionBase]
attribute. - Making characters add their own component on
Awake()
.
- Finish the work we started in the last lecture as a challenge.
- Both
PlayerControl
andEnemyAI
set world space destinations. - This will work for mouse, but would need to be modified for gamepad.
- Take all input listening out of the character.
- Start to really focus
PlayerControl
on it's sole function.
- Review how the character part of the player works.
- Create a dedicated animator override controller per enemy.
- Build a character from scratch as the basis of an enemy.
- Demonstrate our architecture by possessing as player.
- Extract a few member variables at a time.
- Keep your code close to compilation.
- Provide new getter methods as needed.
- Know when to stop and commit your work!
- Beeminder is a useful tool for accountability.
- When you're tired you can still move forward.
- How to recover Scriptable Objects that you can't inspect.
- A strategy for handling
todo
tags in code.
- What makes an enemy an enemy?
- Remove member variables relating to
WeaponSystem
. - Use
RequireComponent
appropriately. - Make enemy attack radius depend on weapon.
- Is
GetComponent()
slow? OK to call inUpdate()
?
- Outline our required enemy behaviour in pseudocode.
- Use an
enum
to track the enemy's state - Use co-routines to patrol, attack, chase, etc.
- Use the inspector debug mode to see it working.
- A simple scheme for defining patrol paths.
- A new
WaypointContainer
class. - Setup a couple of test paths.
- How
yield break;
works - Care of infinite loops with
while (true)
- Pseudocode to help you keep a consistent level of abstraction.
- How to use
Debug.Break()
to pause on error. - Using a co-routine for repeat attacks.
- Our target could die at any time.
- We will test for deadness, and out of range every frame.
- Using
StopAllCoroutines()
to do just that!
- How to trigger an animation for each special ability.
- Setup move and attack.
- Setup move and power attack.
- Fix the enemy UI.
- Fix coroutine logic to stop attacking
- Review our
// todo
items.
- Challenge to fix the weapon pickup (see resources)
- Create a ranged character
- Delete
Projectile.cs
- Resolve all
todo
items in the entire project! - Fix bug where level doesn't re-load on player death.
- Explanation of our polish audit process.
- Creation of our polish list, phases and priorities.
- Creation of polish database.
- Execution - Intention
- Intention - Execution
- Imitation - Execution
- Updates of our spreadsheet
- Base damage and weapon damage approach
- Checklist for building a new enemy
- Our current goals for our prototype level.
- Types of ways that we can surprise and delight our players.
- The surprise and delight we will be using for our game.
- How to decide what to do first.
- Fixing the continuous attacking bug.
- Identify nature of bug - enemy not attacking in certain states.
- Map out the enemy state machine options.
- Add variables to more clearly show what distance the player is to the enemy.
- High level story for your level.
- Key story beats.
- Step-by-step level flow with script.
- Record placeholder dialogue.
- Record final dialogue.
- Create a new NPC character.
- Add new NPC_None weapon which does no damage.
- Change the NPC's chase radius, turn off canvas, set layer to ignore raycast.
- Create your character's waypoints.
- Understand and alter the character's max forward setting for animation blendtree.
- Tuning so that NPC stops and looks at player.
- Identify why the player's weapon is not visible.
- Create a grip scaler, place on dominant hand then place dominant hand script onto grip scaler.
- Identify the problem - enemies are difficult to click on.
- Create the solution - expand the enemy's capsule colliders.
- Oh, we upgraded to Unity 2017.1.1 by the way.
- Review Rick's off-screen changes.
- Fix the player canvas UI and re-link.
- Allow for no energy bars.
- Fix an animation event error.
- Fix attack timings once and for all.
- "Cherry-pick" some changes in git.
- Identify cross-talk bug.
- How
gameObject
is global state. - Change
AudioTrigger
paradigm.
- Identify problem - death audio not triggering.
- Change order of audio triggering for death of characters.
- Let's add some music to our game.
- Playing with volume and pitch of audio track.
- Placing ambient triggered effects.
- Changing your overall scene lighting to be softer and more interesting.
- Adding point lights to highlight certain areas of interest.
- Combining lighting with particles effects.
- Reviewing all of the amazing development you've done on your project to date.
- Ideas for expanding on core combat to personalise it to your game.
- Well done for finishing this course.
- Keep working on and improving your game.
- Schedule for upcoming content.