1 of 89

Section 1 - Character Movement

These are the slides that accompany the Unity RPG Series.

See us develop the slides as we write the course…

  • Right click or Insert > Comment to comment, especially if you see a typo.
  • The slides will update immediately as we change things.

Enjoy your stay!

Ben & Rick

GameDev.tv

Live Google Slides at http://bit.ly/rpgslides

2 of 89

Why You Should Buy This Course

Unity 5.5

z

3 of 89

In This Video…

  • What this course is all about
  • Why you would take this course
  • What you need to get started
  • What games you will build
  • What you will learn.

Live Google Slides at http://bit.ly/rpgslides

4 of 89

Welcome To The Course

Unity 5.5

z

5 of 89

In This Video…

  • Re-watch promo
  • About GameDev.tv
  • About resource links
  • Challenge: Find the donkey!

Live Google Slides at http://bit.ly/rpgslides

6 of 89

Find The Donkey!

  • Your first challenge slide, see the sword >
  • Look in the resource links for this lecture
  • Find the donkey
  • Bonus: Give them names as a reply.

Live Google Slides at http://bit.ly/rpgslides

7 of 89

About Character Movement

Unity 5.5

z

8 of 89

In This Video…

  • An overview of the section’s project

Live Google Slides at http://bit.ly/rpgslides

9 of 89

Start Designing Your RPG

Unity 5.5

z

10 of 89

In This Video…

  • Start designing your game
  • Your 1-Page GDD
  • Your top-down direction
  • Your bottom-up moment
  • Challenge: Create first section of 1-page GDD.

Live Google Slides at http://bit.ly/rpgslides

11 of 89

RPG Design Is A Battle...

Your epic imagination

Your realistic limitations

Skyrim

Live Google Slides at http://bit.ly/rpgslides

12 of 89

Think Big, Start Small

Start By Creating

A Gameplay Moment

Skyrim

Battleheart: Legacy

Live Google Slides at http://bit.ly/rpgslides

13 of 89

What’s Your Moment?

  • Start your 1-Page GDD
  • Define your high level direction
  • Define your core moment
  • Share in the discussions
  • Engage with others.

Live Google Slides at http://bit.ly/rpgslides

14 of 89

Set Up A Combat Sandbox

Unity 5.5

z

15 of 89

In This Video…

  • Quickly setup Unity project
  • World scale considerations
  • Import Ethan
  • Layout a simple arena
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

16 of 89

Layout & Share Your Sandbox

  • Layout a very simple sandbox
  • Share a screenshot with the community
  • Keep it simple, don’t worry about art.

Live Google Slides at http://bit.ly/rpgslides

17 of 89

A Simple DIY Follow Camera

Unity 5.5

z

18 of 89

In This Video…

  • Set up a camera arm
  • Position a fixed camera
  • Tag camera and player
  • Write a small script
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

19 of 89

Write CameraFollow.cs

  • Attached to Camera Arm
  • Keeps Camera Arm at Player’s position
  • Bonus: consider using LateUpdate()

Live Google Slides at http://bit.ly/rpgslides

20 of 89

Further Reading

  • Unity Docs - LateUpdate()

Live Google Slides at http://bit.ly/rpgslides

21 of 89

Pan And Tilt Camera Options

Unity 5.5

z

22 of 89

In This Video…

  • Investigate Unity’s standard cameras pack
  • Positioning the Free Look camera
  • Why we’re choosing a fixed camera
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

23 of 89

Explore Unity’s Cameras

  • Play with at least 2 camera prefabs
  • What do you like about them?
  • What would you improve?
  • Share your feelings in the discussions.

Live Google Slides at http://bit.ly/rpgslides

24 of 89

Prototyping With Placeholders

Unity 5.5

z

25 of 89

In This Video…

  • Prototyping requires pretending
  • Add placeholder blocks and enemies
  • Tighten movement and camera
  • Write down ideas and questions
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

26 of 89

Create A Simple Scenario

  • Add placeholders for world and enemies
  • Tweak your movement and camera
  • Share your ideas & questions in the discussions.

Live Google Slides at http://bit.ly/rpgslides

27 of 89

Raycasting And Layer Masks

Unity 5.5

z

28 of 89

In This Video…

  • A quick intro to raycasting in Unity
  • What a layer mask is
  • The bit shift operator << in C#
  • How to form a layer mask
  • How a layer mask helps Unity to filter hits.

Live Google Slides at http://bit.ly/rpgslides

29 of 89

Layer Masks AND The Bit Shift

int layerMask = 1 << (int)layer;

layer = 0, layerMask = 0000 … 0001

layer = 1, layerMask = 0000 … 0010

layer = 2, layerMask = 0000 … 0100

etc.

hitLayer & layerMask // hit in mask?

0010 & 0001 == false

0010 & 0010 == true

Live Google Slides at http://bit.ly/rpgslides

30 of 89

Further Reading

Live Google Slides at http://bit.ly/rpgslides

31 of 89

Using Raycasts To Query Click

Unity 5.5

z

32 of 89

In This Video…

  • Raycasting explained
  • Assign layers for raycasting
  • Import and review CameraRaycaster.cs
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

33 of 89

How We’re Using Raycasting

EndStop

Walkable

Enemy

Camera

Live Google Slides at http://bit.ly/rpgslides

34 of 89

Log The Layer Being Hit

  • Write Cursor.cs and attach to camera
  • Use CameraRaycaster.cs
  • Simply print layerHit each frame for now
  • Hint: this can be done 1-3 lines of code.

Live Google Slides at http://bit.ly/rpgslides

35 of 89

Click Mouse To Move

Unity 5.5

z

36 of 89

In This Video…

  • How the ThirdPersonCharacter moves
  • Import & review PlayerMovement.cs
  • CHALLENGE
  • Resolve any major movement bugs.

Live Google Slides at http://bit.ly/rpgslides

37 of 89

Get Click To Move Working

  • Implement click-to-move
  • Filter for clicks on Walkable layer only
  • Bonus: resolve bug if Ethan circles destination.

Live Google Slides at http://bit.ly/rpgslides

38 of 89

Work Breakdown Structure

Unity 5.5

z

39 of 89

In This Video…

  • Wearing many hats
  • What are we building?
  • Work Breakdown Structure
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

40 of 89

Wearing Many Hats

  • Project Manager
  • Designer
  • Developer
  • Artist
  • Quality Assurance
  • Marketer.

Live Google Slides at http://bit.ly/rpgslides

41 of 89

Typical Indie Pattern

Development

Design

Project Management

Content

Tuning

Feedback

Tuning

Feedback

Live Google Slides at http://bit.ly/rpgslides

42 of 89

What Are We Building?

  • Features
    • Eg. Combat
  • Mechanics
    • Eg. Spells are ranged attacks that damage enemies
  • Tuning
    • Eg. At level 1, Fireball attack does 6-10 damage.

Live Google Slides at http://bit.ly/rpgslides

43 of 89

What Are We Building?

  • Features - Work Breakdown Structure (WBS)
  • Mechanics - Game Design Document (GDD)
  • Tuning - Prototype, Spreadsheet

Live Google Slides at http://bit.ly/rpgslides

44 of 89

Create Your WBS

  • Find a game moment similar to yours
  • Categorize the high level features
  • Breakdown what you know you need
  • Bonus points: Share your top 3 priority features to the discussions.
  • https://www.mindmeister.com/820279464/project-dragon

Live Google Slides at http://bit.ly/rpgslides

45 of 89

Resources

  • WBS Mind Map

Live Google Slides at http://bit.ly/rpgslides

46 of 89

Instructor Hangout 1.1

Unity 5.5

z

47 of 89

Common Questions

  • Will we cover mobile?
  • Will the game get prettier later?
  • My camera’s misbehaving - see Q&A
  • Camera finding the player - different in S3
  • Raycasting lecture style - will use sparingly
  • Replacing TPC in S3

Live Google Slides at http://bit.ly/rpgslides

48 of 89

Organizing Project For Teamwork

Unity 5.5

z

49 of 89

In This Video…

  • Using GameObject > Clear Parent
  • Create separate Player and Enemy prefabs
  • Organise folders by game object type
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

50 of 89

Organise Your Project

  • End up with “just enough” folders
  • Have a 2nd scene, maybe “Level Sandbox”
  • All players, cameras and enemies prefab linked
  • Share a screenshot of you early work.

Live Google Slides at http://bit.ly/rpgslides

51 of 89

Using Cursor Affordances

Unity 5.5

z

52 of 89

In This Video…

  • How to rename a C# script in Unity 5
  • Why we need affordances
  • Import cursor artwork
  • Start writing CursorAffordance.cs
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

53 of 89

Further Reading

Live Google Slides at http://bit.ly/rpgslides

54 of 89

Finish The Script

  • Get all three cursors working
  • Don’t worry about art style yet.

Live Google Slides at http://bit.ly/rpgslides

55 of 89

Most Important Combat Feature

Unity 5.5

z

56 of 89

In This Video…

  • Where are we at with our moment?
  • What is next priority?
  • What are the design requirements?
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

57 of 89

Jot It Down

  • Write out your current implementation requirements.

Live Google Slides at http://bit.ly/rpgslides

58 of 89

Resources

  • WBS Mind Map

Live Google Slides at http://bit.ly/rpgslides

59 of 89

Gamepad Movement Mode

Unity 5.5

z

60 of 89

In This Video…

  • Simplify & debug current movement code
  • Optional: implement direct movement
  • CHALLENGE

Live Google Slides at http://bit.ly/rpgslides

61 of 89

Optional: Setup Controller

  • Setup controller movement
  • Ensure you can toggle modes
  • Share you thinking re controller.

Live Google Slides at http://bit.ly/rpgslides

62 of 89

Onion Design

Unity 5.5

z

63 of 89

In This Video…

  • What is Onion Design
  • Tighten our core
  • CHALLENGE

Live Google Slides at http://bit.ly/rpgslides

64 of 89

Tighten Your Core

  • Create enough sandbox elements �to test your movement and controls
  • Post a pic of your latest sandbox.

Live Google Slides at http://bit.ly/rpgslides

65 of 89

The Player Experience

Unity 5.5

z

66 of 89

In This Video…

  • Understanding your Player Experience
  • CHALLENGE

Live Google Slides at http://bit.ly/rpgslides

67 of 89

Define Your Player Experience

  • Define your Player Experience
  • Aim for 1 to 4 words
  • Post those words to the discussions.

Live Google Slides at http://bit.ly/rpgslides

68 of 89

TODOs And Bug Fixes

Unity 5.5

z

69 of 89

In This Video…

  • Review all the current TODO comments
  • Fix bug when changing back to indirect mode
  • Fix the slippery enemy bug!
  • Fix bug with cursor?
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

70 of 89

Tidy Your House

  • Fix or document any known bugs
  • Ensure all your TODO comments are done
  • Check for required components
  • Get your folder structure how you want it
  • Check your naming conventions.

Live Google Slides at http://bit.ly/rpgslides

71 of 89

The Observer Pattern

Unity 5.5

z

72 of 89

In This Video…

  • What the Observer pattern is
  • How data and execution flows
  • The benefits of the pattern
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

73 of 89

Observer Pattern

Subject

Observer 2

Observer 1

Observers register to listen to events on the subject, without the subject knowing or caring who is listening.

Live Google Slides at http://bit.ly/rpgslides

74 of 89

Old vs New

CameraRaycaster

CursorAffordance

PlayerMovement

Data Flow

cameraRaycaster.layerHit

OnLayerChange()

Execution Flow

Live Google Slides at http://bit.ly/rpgslides

75 of 89

Explain Why This Is Helpful

  • Pop over to the lecture discussions
  • Explain why this is helpful in your words
  • Be brave, if you’re not sure ask for help!

Live Google Slides at http://bit.ly/rpgslides

76 of 89

Further Reading

Live Google Slides at http://bit.ly/rpgslides

77 of 89

Using Delegates In C#

Unity 5.5

z

78 of 89

In This Video…

  • Declare a new delegate subject type
  • Instantiate a new delegate observer set
  • Write a compatible handling function
  • Add the handling function to the set of observers
  • Call the delegate
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

79 of 89

Old vs New

CameraRaycaster

CursorAffordance

PlayerMovement

Data Flow

cameraRaycaster.layerHit

OnLayerChange()

Execution Flow

Live Google Slides at http://bit.ly/rpgslides

80 of 89

Existing Data Flow

CameraRaycaster

CursorAffordance

Data Flow

OnLayerChange()

Execution Flow

Live Google Slides at http://bit.ly/rpgslides

81 of 89

Switch Cursor To Delegates

  • Stop setting your cursor every frame
  • Implement the observer pattern in your code
  • Share your feelings and understanding.

Live Google Slides at http://bit.ly/rpgslides

82 of 89

Further Reading

  • Unity Docs - Delegates

Live Google Slides at http://bit.ly/rpgslides

83 of 89

The event Keyword In C#

Unity 5.5

z

84 of 89

In This Video…

  • Why we need to protect our delegate set
  • Using the event keyword in C#
  • Adding a parameter to our delegate functions
  • CHALLENGE.

Live Google Slides at http://bit.ly/rpgslides

85 of 89

With Data Flow

CameraRaycaster

CursorAffordance

Data Flow

OnLayerChange(newLayer)

Execution Flow

Live Google Slides at http://bit.ly/rpgslides

86 of 89

Send newLayer Via Delegates

  • Protect your delegates with event
  • Send the newLayer as an argument
  • Stop reading cameraRaycaster.layerHit
  • Share your experiences with us.

Live Google Slides at http://bit.ly/rpgslides

87 of 89

Instructor Hangout 1.2

Unity 5.5

z

88 of 89

Section 1 Wrap Up

Unity 5.5

z

89 of 89

In This Video…

  • What we covered from a design perspective
  • What we covered from a dev perspective
  • Share your thoughts and work :-)

Live Google Slides at http://bit.ly/rpgslides