Skip to content

A simple First Person game to learn level building, lighting, Unreal Editor, C++ game logic, basic Blueprint and more.

License

Notifications You must be signed in to change notification settings

TLIsolator/03_BuildingEscape

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Intro, Notes & Section 3 Assets

  • Welcome to our first Unreal editor section.
  • You’ll learn simple level building.
  • We’ll be using meshes and materials.
  • C++ events accessed from Blueprint.
  • Calling C++ code from Blueprint.
  • And much more.

S03 Game Design Document (GDD)

The Concept, Rules and Requirements of our simple game.

Version Control 101

  • The what and why of Version Control Systems
  • Choosing your Version Control System (VCS)
  • What files to include / exclude
  • Commit = save a local snapshot
  • Reset = roll-back to a previous state
  • Branch, Push and Large File Support later.

Ignoring Unreal Derived Files

  • Derived files can be easily rebuilt
  • Other files (code, assets, level layout etc) can’t
  • Ignore most derived files for version control
  • Which folders to ignore in version control
  • Our starting .gitignore file for Unreal.

Your First .gitignore for Unreal

  • Understand Unreal creates VS projects for us
  • How to re-generate VS project files
  • Writing our first .gitignore file
  • “Committing” our project for the first time.

Getting to Know Unreal’s Editor

  • Why changes to the starter scene aren’t tracked
  • Arranging a simple set of windows
  • Moving around in the 3D Viewport
  • Setting our start map, and committing

A Pointers Primer

  • You’re about to meet pointers for the first time
  • The clue is when you see a * next to a type
  • Pointers are simply memory addresses
  • You have to “follow” the pointer to the object
  • Benefit: saves you from moving things in memory
  • Disadvantage: you can lose control of data.

Unreal’s Class System

  • Introducing the idea of inheritance
  • Unreal’s scarily powerful class system
  • Exploring using the Class Viewer
  • Inheritance for “is a” relationships
  • Components for “has a” relationships.

Runtime Messages for Feedback

  • Using UE_LOG to print to the Output Console
  • Printing to the game screen

Useful Links

Accessing Object Names

  • Use GetOwner() to find the component’s owner
  • *AActor is a pointer to an actor, a new concept
  • Use -> to access methods through pointers
  • Use GetName() to find the object’s name
  • Use %s as a format operator for strings
  • Use * to “dereference” pointers.

Getting Transforms in C++

  • Introducing FVector
  • Mixing . and -> to access methods
  • Using multiple format operators
  • Finishing our PositionReport component.

Moving Objects With C++

  • A little more about the editor & temporary actors
  • How to eject yourself from the possessed pawn
  • Snapping objects to the floor (END key)
  • Using the FRotator struct to represent rotation
  • Use SetActorRotation() to rotate objects.

Laying Out Geometry

  • A brief intro of BSP “vs” Static Meshes
  • Use Q, W, E keys to translate, rotate, scale
  • Make good use of grid snapping and quad view
  • Hold ALT + drag translate to duplicate an object
  • Hold L and double-click for temporary work Light
  • This is fiddly, try letting go of L and trying again.

Applying Materials

  • A material is comprised of texture(s) and shader(s)
  • Textures are image files, shaders are GPU code
  • Unreal ships with some impressive examples
  • Unreal has powerful material editing tools
  • Applying materials to our room interior.

Macros Starting with UPROPERTY

  • A macro is a programmed cut-and-paste
  • This happens before the code is compiled
  • Can unlock powerful functionality
  • We don’t get code complete as standard
  • Can also create really weird build errors
  • Expose ATriggerVolume* to the Details window

Using Trigger Volumes

  • A trigger volume is a very versatile tool
  • A 3D volume that detects things entering / leaving
  • We’re going to use one as a pressure plate
  • How we’re going to specify what can open doors
  • Use IsOverlappingActor() on ATriggerVolume
  • Polling vs using events.

Unreal’s PlayerController

  • We’ve used GetOwner() to search “bottom-up”
  • Now let’s use GetWorld() to search “top-down”
  • Game Mode specifies the Default Pawn Class
  • The Default Pawn is your “body”, is transient
  • The Player Controller is your “mind”, persist
  • PlayerController class has GetPawn()

Using Collision Volumes

  • Collisions volumes are also known as colliders
  • These tell the physics engine what hits what
  • A trigger volume just triggers code
  • A collider actually has physics simulated
  • Exploring how to add collision volumes
  • Prevent players from passing through the door!

Using GetTimeSeconds()

  • Using GetWord()->GetTimeSeconds()
  • Making our game highly “play tunable”
  • Re-factoring our code for simplicity
  • Using a spotlight to provide “affordance”
  • Play-testing to ensure the game is annoying!

Grabbing System Overview

  • We want to be able to lift the chair next
  • We’ll add a Grabber.cpp component to the player
  • The player is a temporary actor, appears on play
  • The Game Mode sets which Default Pawn to use
  • Create Default Pawn & Game Mode Blueprints
  • Specify our modified Default Pawn.

Modifying the Default Pawn Actor

  • Why Blueprint is helpful in this case
  • How to make a Blueprint from the Default Pawn
  • Note this Blueprint class inherits, an “is a” relation
  • A Blueprint is like a template
  • You make an “instance” in the scene
  • Explore “instantiating” from Blueprint & modifying.

Inherit Game Mode Blueprint

  • “Hard coding” means assets written into code
  • The DefaultPawn_BP is an asset
  • We want to be able to track changes to its name
  • It is convenient to use Blueprint for this purpose
  • Extending our C++ Game Mode with Blueprint
  • Selecting the new DefaultPawn_BP

Getting Player Viewpoint

  • Know where the player is looking
  • Out-parameters can be confusing
  • A way of marking-up out parameters
  • Continuously logging player viewpoint.

Using DrawDebugLine

  • How to add vectors
  • Calculating our line trace end point
  • Using debug functions for visualisation in Unreal
  • Use DrawDebugLine() to visualise the vectors.

Line Tracing AKA Ray-Casting

  • Line tracing (AKA ray casting) is a very useful tool
  • Imagine we shine a virtual laser into the world
  • We can use different view modes to visualise
  • Simulating physics sets the object channel.

LineTraceSingleByObjectType()

  • Meet references for the first time
  • LineTraceSingle may be deprecated
  • Build params inc. FCollisionQueryParams

REFERENCES & POINTERS

  • How references and pointers compare
  • How to perform common operations in both
  • What the & and * symbols means in context
  • Challenge: Repoint and Rewrite
  • When to use references over pointers?

Resetting Your Unreal Project

  • What to do if your Unreal solution keeps crashing
  • How to delete all temporary files
  • The order in which to reset things

Using FindComponentByClass()

  • What FindComponentByClass() does
  • How to use it to find attached components
  • Introducing angle brackets <> for generics
  • Use nullptr to initialise your pointers
  • Log a useful error if the component isn’t attached.

Introducing Input Binding

  • Settings > Project Settings > Engine > Input
  • Action mappings are used for on / off actions
  • Axis mappings are used for analog values
  • You can give players a way or re-mapping
  • Many keys can bind to one action
  • How to call a function on a key press or release

Accessors & Memory Layout

  • How the arrow, dot and :: accessors work
  • Introducing virtual memory
  • Introducing permanent storage, stack & heap
  • Heap is also known as free store
  • How accessor operators relate to memory
  • Bind another input action

Reducing Code in “Hot Loops”

  • A “hot loop” is code that get called often
  • TickComponent is a good example, every frame
  • Beware of code that you know will be called a lot
  • Make it clear what happens every tick
  • Refactor our code for speed...
  • ...and make it ready for for the physics handle.

Using Physics Handles

  • Unreal provides a Physics Handle that’s ideal here
  • The Physics Handle component docs are scant*
  • Find an example of its use in the engine
  • Get the physics handle working.

Useful Links

Refactoring Rules

  • Using multiple getters for multiple return values
  • Less lines of clear code is better (143 at start)
  • Naming is really important, take the time
  • Comment the “why”, don’t assume it’s obvious
  • The “what” should be obvious...
  • … but it can be helpful to add clarification

Introducing Unreal’s TArray

  • A TArray is Unreal’s go-to container class
  • Use to contain many elements of same type
  • We’ll use to contain all actors on pressure plate
  • Give our Default Pawn an eye-height and mass
  • Making our pressure-plate based on total mass.

Iterating over TArray with for

  • Using auto& as an auto reference type
  • Automatically iterating over a TArray
  • Pattern: for (const auto* Iterator : Array)
  • How to find an actor’s mass
  • Tweaking and testing our mass values.

Debugging Game Issues

  • Are you using source control? If not start now
  • You can “binary search” commits quite fast
  • For example 1024 commits takes max 10 tries!
  • Think “what changed” and “possible side-effects”
  • Remember you can eject with F8 during play.

Managing Texture Tiling

  • You may want to re-size objects (e.g. panels)
  • Doing so will stretch the texture
  • You can re-scale a few ways
  • One way is in the material blueprint
  • UV mapping because we ran out of letters!
  • Using the TexCoord node in the material editor.

Pointer Protection Process

  • Horrible crashes when we follow a nullptr
  • We must always check pointers before use
  • When declaring always initialise to nullptr
  • Look for * in your .h files to help find pointers
  • Also check before every use and handle nullptr
  • Sometimes we may chose not to, e.g. Owner.

Exposing Events to Blueprint

  • Sometimes Blueprint’s the better choice
  • For example defining our door swing as a curve
  • We can create an event called OnOpenRequest
  • Using UPROPERTY (BlueprintAssignable)

Using Blueprint Timeline

  • The Timeline node in Blueprint has a curve editor
  • This is ideal for defining our door movement
  • How to use Timeline curves in Blueprint
  • Setting rotation from a Timeline.

Everything in its Place

  • Using Blueprint has superseded some code
  • It’s important there’s only 1 place per parameter
  • Creating a 2nd event: OnClose

Using Variables in Blueprint

  • Not all doors have the same absolute rotation
  • We want to store the door’s rotation at the start
  • … then use this value to make a relative rotation
  • We can use Blueprint variables for this
  • Making doors that face any direction work.

SFX & Audio Clips

  • We’re going to trigger a simple sound in Blueprint
  • Later in the course we’ll use C++ too
  • However we’ll always reference our assets via BP
  • How to trigger a 3D sound.

Section 3 Wrap-Up

  • Congratulations on another complete section
  • You’ve learnt so much, look at the lecture titles
  • Please carry-on a little on your own and share
  • Attached are useful resources
  • Start the next section as soon as you’re finished.

About

A simple First Person game to learn level building, lighting, Unreal Editor, C++ game logic, basic Blueprint and more.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 81.8%
  • C# 17.2%
  • C 1.0%