Game Development Projects with Unreal Engine

Book description

Learn the tools and techniques of game design using a project-based approach with Unreal Engine 4 and C++

Key Features

  • Kickstart your career or dive into a new hobby by exploring game design with UE4 and C++
  • Learn the techniques needed to prototype and develop your own ideas
  • Reinforce your skills with project-based learning by building a series of games from scratch

Book Description

Game development can be both a creatively fulfilling hobby and a full-time career path. It's also an exciting way to improve your C++ skills and apply them in engaging and challenging projects.

Game Development Projects with Unreal Engine starts with the basic skills you'll need to get started as a game developer. The fundamentals of game design will be explained clearly and demonstrated practically with realistic exercises. You’ll then apply what you’ve learned with challenging activities.

The book starts with an introduction to the Unreal Editor and key concepts such as actors, blueprints, animations, inheritance, and player input. You'll then move on to the first of three projects: building a dodgeball game. In this project, you'll explore line traces, collisions, projectiles, user interface, and sound effects, combining these concepts to showcase your new skills.

You'll then move on to the second project; a side-scroller game, where you'll implement concepts including animation blending, enemy AI, spawning objects, and collectibles. The final project is an FPS game, where you will cover the key concepts behind creating a multiplayer environment.

By the end of this Unreal Engine 4 game development book, you'll have the confidence and knowledge to get started on your own creative UE4 projects and bring your ideas to life.

What you will learn

  • Create a fully-functional third-person character and enemies
  • Build navigation with keyboard, mouse, gamepad, and touch controls
  • Program logic and game mechanics with collision and particle effects
  • Explore AI for games with Blackboards and Behavior Trees
  • Build character animations with Animation Blueprints and Montages
  • Test your game for mobile devices using mobile preview
  • Add polish to your game with visual and sound effects
  • Master the fundamentals of game UI design using a heads-up display

Who this book is for

This book is suitable for anyone who wants to get started using UE4 for game development. It will also be useful for anyone who has used Unreal Engine before and wants to consolidate, improve and apply their skills. To grasp the concepts explained in this book better, you must have prior knowledge of the basics of C++ and understand variables, functions, classes, polymorphism, and pointers. For full compatibility with the IDE used in this book, a Windows system is recommended.

Table of contents

  1. Game Development Projects with Unreal Engine
  2. Preface
    1. About the Book
      1. About the Authors
      2. Audience
      3. About the Chapters
      4. Conventions
      5. Before You Begin
      6. Installing Visual Studio
      7. Epic Games Launcher
      8. Code Bundle
      9. Get in touch
      10. Please leave a review
  3. 1. Unreal Engine Introduction
    1. Introduction
      1. Exercise 1.01: Creating an Unreal Engine 4 Project
    2. Getting to Know Unreal
    3. Editor Windows
    4. Viewport Navigation
    5. Manipulating Actors
      1. Exercise 1.02: Adding and Removing Actors
    6. Blueprint Actors
      1. Exercise 1.03: Creating Blueprint Actors
    7. The Blueprint Editor
    8. Event Graph
      1. Exercise 1.04: Creating Blueprint Variables
      2. Exercise 1.05: Creating Blueprint Functions
    9. The Float Multiplication Node
    10. BeginPlay and Tick
      1. Exercise 1.06: Offsetting the TestActor Class on the Z Axis
    11. ThirdPersonCharacter Blueprint Class
    12. Meshes and Materials
      1. Meshes
      2. Materials
    13. Manipulating Materials in UE4
      1. Activity 1.01: Propelling TestActor on the Z Axis Indefinitely
    14. Summary
  4. 2. Working with Unreal Engine
    1. Introduction
    2. Creating and Setting Up a Blank C plus plus Project
      1. Exercise 2.01: Creating an Empty C plus plus Project
    3. Content Folder Structure in Unreal Engine
    4. Working with the Visual Studio Solution
      1. Solution Analysis
        1. The Engine Project
        2. Game Project
      2. Debugging Code in Visual Studio
      3. Exercise 2.02: Debugging the Third Person Template Code
    5. Importing the Required Assets
      1. Exercise 2.03: Importing a Character FBX File
    6. The Unreal Game Mode Class
      1. Game Mode Default Classes
      2. Gameplay Events
      3. Networking
      4. GameModeBase versus GameMode
    7. Levels
      1. The Unreal Pawn Class
        1. The Default Pawn
        2. The Spectator Pawn
      2. The Unreal Player Controller Class
      3. Exercise 2.04: Setting Up the Game Mode, Player Controller, and Pawn
    8. Animations
      1. Animation Blueprints
      2. Event Graph
      3. The Anim Graph
      4. State Machines
      5. Transition Rules
      6. Blend Spaces
      7. Exercise 2.05: Creating a Mannequin Animation
      8. Activity 2.01: Linking Animations to a Character
    9. Summary
  5. 3. Character Class Components and Blueprint Setup
    1. Introduction
    2. The Unreal Character Class
      1. Extending the Character Class
      2. Exercise 3.01: Creating and Setting Up a Third-Person Character C plus plus Class
    3. Extending the C plus plus Class with Blueprints
      1. Exercise 3.02: Extending C plus plus with Blueprints
      2. Activity 3.01: Extending the C plus plus Character Class with Blueprint in the Animation Project
    4. Summary
  6. 4. Player Input
    1. Introduction
    2. Input Actions and Axes
      1. Exercise 4.01: Creating the Jump Action and Movement Axes
    3. Processing Player Input
    4. DefaultInput.ini
      1. Exercise 4.02: Listening to Movement Actions and Axes
    5. Turning the camera around the character
      1. Mobile platforms
      2. Exercise 4.03: Previewing on Mobile
      3. Exercise 4.04: Adding Touchscreen Input
      4. Activity 4.01: Adding Walking Logic to Our Character
    6. Summary
  7. 5. Line Traces
    1. Introduction
    2. Collision
    3. Project Setup
      1. Exercise 5.01: Converting DodgeballCharacter to a Top-Down Perspective
    4. Line Traces
    5. Creating the EnemyCharacter C plus plus class
      1. Exercise 5.02: Creating the CanSeeActor Function, Which Executes Line Traces
    6. Visualizing the Line Trace
      1. Exercise 5.03: Creating the LookAtActor Function
    7. Creating the EnemyCharacter Blueprint Class
    8. Sweep Traces
      1. Exercise 5.04: Executing a Sweep Trace
      2. Changing the Visibility Trace Response
      3. Multi Line Traces
      4. The Camera Trace Channel
      5. Exercise 5.05: Creating a Custom EnemySight Trace Channel
      6. Activity 5.01: Creating the SightSource Property
    9. Summary
  8. 6. Collision Objects
    1. Introduction
    2. Object Collision in UE4
    3. Collision Components
    4. Collision Events
    5. Collision Channels
    6. Collision Properties
      1. Exercise 6.01: Creating the Dodgeball Class
    7. Physical Materials
      1. Exercise 6.02: Adding a Projectile Movement Component to DodgeballProjectile
    8. Timers
    9. Spawning Actors
      1. Exercise 6.03: Adding Projectile-Throwing Logic to the EnemyCharacter
    10. Walls
      1. Exercise 6.04: Creating Wall Classes
    11. Victory Box
      1. Exercise 6.05: Creating the VictoryBox class
      2. Exercise 6.06: Adding the ProjectileMovementComponent Getter Function in DodgeballProjectile
      3. Activity 6.01: Replacing the SpawnActor Function with SpawnActorDeferred in EnemyCharacter
    12. Summary
  9. 7. UE4 Utilities
    1. Introduction
    2. Blueprint Function Libraries
      1. Exercise 7.01: Moving the CanSeeActor Function to the Blueprint Function Library
    3. Actor Components
      1. Exercise 7.02: Creating the HealthComponent Actor Component
      2. Exercise 7.03: Integrating the HealthComponent Actor Component
    4. Interfaces
    5. Blueprint Native Events
      1. Exercise 7.04: Creating the HealthInterface Class
      2. Activity 7.01: Moving the LookAtActor Logic to an Actor Component
    6. Summary
  10. 8. User Interfaces
    1. Introduction
    2. Game UI
    3. UMG Basics
      1. Exercise 8.01: Creating a Widget Blueprint
    4. Anchors
      1. Exercise 8.02: Editing UMG Anchors
      2. Exercise 8.03: Creating the RestartWidget C plus plus Class
      3. Exercise 8.04: Creating the Logic for Adding the RestartWidget to the Screen
      4. Exercise 8.05: Setting up the DodgeballPlayerController Blueprint Class
    5. Progress Bars
      1. Exercise 8.06: Creating the Health Bar C plus plus Logic
      2. Activity 8.01: Improving the RestartWidget
    6. Summary
  11. 9. Audio-Visual Elements
    1. Introduction
    2. Audio in UE4
      1. Exercise 9.01: Importing an Audio File
      2. Exercise 9.02: Playing a Sound When the Dodgeball Bounces off a Surface
    3. Sound Attenuation
      1. Exercise 9.03: Turning the Bounce Sound into a 3D Sound
      2. Exercise 9.04: Adding Background Music to Our Game
    4. Particle Systems
      1. Exercise 9.05: Spawning a Particle System When the Dodgeball Hits the Player
      2. Activity 9.01: Playing a Sound When the Dodgeball Hits the Player
    5. Level Design
      1. Exercise 9.06: Building a Level Blockout
    6. Extra Features
    7. Summary
  12. 10. Creating a SuperSideScroller Game
    1. Introduction
    2. Project Breakdown
    3. The Player Character
      1. Exercise 10.01: Creating the Side-Scroller Project and Using the Character Movement Component
      2. Side Scroller versus 2D Side Scroller
      3. Activity 10.01: Making Our Character Jump Higher
    4. Features of Our Side-Scroller Game
      1. Enemy Character
      2. Power-Up
      3. Collectible
      4. HUD (Heads-Up Display)
    5. Steps in Animation
    6. Character Animation Pipeline
      1. The Concept Stage
      2. The 3D Modeling Stage
      3. The Rigging Stage
      4. Animation
      5. Asset Export and Import
      6. Exercise 10.02: Exploring the Persona Editor and Manipulating the Default Mannequin Skeleton Weights
      7. Activity 10.02: Skeletal Bone Manipulation and Animations
    7. Animations in Unreal Engine 4
      1. Skeletons
      2. Skeletal Meshes
      3. Animation Sequences
      4. Exercise 10.03: Importing and Setting Up the Character and Animation
      5. Activity 10.03: Importing More Custom Animations to Preview the Character Running
    8. Summary
  13. 11. Blend Spaces 1D, Key Bindings, and State Machines
    1. Introduction
    2. Blend Spaces
      1. 1D Blend Space vs Normal Blend Space
      2. Exercise 11.01: Creating the CharacterMovement 1D Blend Space
      3. Activity 11.01: Adding the Walking and Running Animations to the Blend Space
    3. Main Character Animation Blueprint
      1. Animation Blueprints
      2. Exercise 11.02: Adding the Blend Space to the Character Animation Blueprint
    4. Velocity Vectors
      1. Exercise 11.03: Adding the Blend Space to the Character Animation Blueprint
      2. Activity 11.02: Previewing the Running Animation In-Game
    5. Input Bindings
      1. Exercise 11.04: Adding Input for Sprinting and Throwing
      2. Exercise 11.05: Reparenting the Character Blueprint
      3. Exercise 11.06: Coding the Character Sprint Functionality
      4. Activity 11.03: Implementing the Throwing Input
    6. Animation State Machines
      1. Exercise 11.07: Player Character Movement and Jump State Machine
      2. Transition Rules
      3. Exercise 11.08: Adding States and Transition Rules to the State Machine
      4. Exercise 11.09: Time Remaining Ratio Function
      5. Activity 11.04: Finishing the Movement and Jumping State Machine
    7. Summary
  14. 12. Animation Blending and Montages
    1. Introduction
    2. Animation Blending, Anim Slots, and Animation Montages
      1. Exercise 12.01: Setting Up the Animation Montage
    3. Animation Montages
      1. Exercise 12.02: Adding the Throw Animation to the Montage
    4. Anim Slot Manager
      1. Exercise 12.03: Adding a New Anim Slot
    5. Save Cached Pose
      1. Exercise 12.04: Save Cached Pose of the Movement State Machine
    6. Layered blend per bone
      1. Exercise 12.05: Blending Animation with the Upper Body Anim Slot
    7. The Throw Animation
      1. Exercise 12.06: Previewing the Throw Animation
    8. The Super Side Scroller Game Enemy
      1. Exercise 12.07: Creating the Enemy Base C plus plus Class
      2. Exercise 12.08: Creating and Applying the Enemy Animation Blueprint
    9. Materials and Material Instances
      1. Exercise 12.09: Creating and Applying the Enemy Material Instance
      2. Activity 12.01: Updating Blend Weights
    10. Summary
  15. 13. Enemy Artificial Intelligence
    1. Introduction
    2. Enemy AI
    3. AI Controller
      1. Auto Possess AI
      2. Exercise 13.01: Implementing AI Controllers
    4. Navigation Mesh
      1. Exercise 13.02: Implementing a Nav Mesh Volume for the AI Enemy
    5. Recasting the Nav Mesh
      1. Exercise 13.03: Recasting Nav Mesh Volume Parameters
      2. Activity 13.01: Creating a New Level
    6. Behavior Trees and Blackboards
      1. Composites
      2. Tasks
      3. Decorators
      4. Services
      5. Exercise 13.04: Creating the AI Behavior Tree and Blackboard
      6. Exercise 13.05: Creating a New Behavior Tree Task
      7. Exercise 13.06: Creating the Behavior Tree Logic
      8. Activity 13.02: AI Moving to the Player Location
      9. Exercise 13.07: Creating the Enemy Patrol Locations
    7. Vector Transformation
      1. Exercise 13.08: Selecting a Random Point in an Array
      2. Exercise 13.09: Referencing the Patrol Point Actor
      3. Exercise 13.10: Updating BTTask_FindLocation
    8. Player Projectile
      1. Exercise 13.11: Creating the Player Projectile
      2. Exercise 13.12: Initializing Player Projectile Settings
      3. Activity 13.03: Creating the Player Projectile Blueprint
    9. Summary
  16. 14. Spawning the Player Projectile
    1. Introduction
    2. Anim Notifies and Anim Notify States
      1. Exercise 14.01: Creating a UAnim Notify Class
      2. Exercise 14.02: Adding the Notify to the Throw Montage
    3. Playing Animation Montages
      1. Playing Animation Montages in Blueprints
      2. Playing Animation Montages in C plus plus
      3. Exercise 14.03: Playing the Throw Animation in C plus plus
    4. Game World and Spawning Objects
      1. Exercise 14.04: Creating the Projectile Spawn Socket
      2. Exercise 14.05: Preparing the SpawnProjectile() Function
      3. Exercise 14.06: Updating the Anim_ProjectileNotify Class
    5. Destroying Actors
      1. Exercise 14.07: Creating the DestroyEnemy() Function
      2. Exercise 14.08: Destroying Projectiles
      3. Activity 14.01: Projectile Destroying Enemies
    6. Visual and Audio Effects
      1. Exercise 14.09: Adding Effects When the Enemy Is Destroyed
      2. Exercise 14.10: Adding Effects to the Player Projectile
      3. Exercise 14.11: Adding VFX and SFX Notifies
      4. Activity 14.02: Adding Effects for When the Projectile Is Destroyed
    7. Summary
  17. 15. Collectibles, Power-Ups, and Pickups
    1. Introduction
    2. URotatingMovementComponent
      1. Exercise 15.01: Creating the PickableActor_Base Class and Adding URotatingMovementComponent
      2. Activity 15.01: Player Overlap Detection and Spawning Effects in PickableActor_Base
      3. Exercise 15.02: Creating the PickableActor_Collectable Class
      4. Activity 15.02: Finalizing the PickableActor_Collectable Actor
    3. Logging Variables Using UE_LOG
      1. Exercise 15.03: Tracking the Number of Coins for the Player
    4. UMG
    5. Text Widget
      1. Anchors
      2. Text Formatting
      3. Exercise 15.04: Creating the Coin Counter UI HUD Element
    6. Adding and Creating UMG User Widgets
      1. Exercise 15.05: Adding the Coin Counter UI to the Player Screen
    7. Timers
      1. Exercise 15.06: Adding the Potion Power-Up Behavior to the Player
      2. Activity 15.03: Creating the Potion Power-Up Actor
      3. Exercise 15.07: Creating the Brick Class
      4. Exercise 15.08: Adding the Brick Class C plus plus Logic
    8. Summary
  18. 16. Multiplayer Basics
    1. Introduction
    2. Multiplayer Basics
    3. Servers
      1. Dedicated Server
      2. The Listen Server
    4. Clients
      1. Exercise 16.01: Testing the Third Person Template in Multiplayer
    5. The Packaged Version
    6. Connections and Ownership
    7. Roles
      1. Exercise 16.02: Implementing Ownership and Roles
      2. The Server Window
      3. Server Character
      4. Client 1 Character
      5. The OwnershipTest Actor
      6. The Client 1 Window
    8. Variable Replication
      1. Replicated Variables
      2. Exercise 16.03: Replicating Variables Using Replicated, RepNotify, DOREPLIFETIME, and DOREPLIFETIME_CONDITION
      3. The Server Window
      4. The Client 1 Window
    9. 2D Blend Spaces
      1. Exercise 16.04: Creating a Movement 2D Blend Space
    10. Transform (Modify) Bone
      1. Exercise 16.05: Creating a Character That Looks up and down
      2. Activity 16.01: Creating a Character for the Multiplayer FPS Project
    11. Summary
  19. 17. Remote Procedure Calls
    1. Introduction
    2. Remote Procedure Calls
      1. Server RPC
        1. Declaration
        2. Execution
        3. Valid Connection
      2. Multicast RPC
        1. Declaration
        2. Execution
      3. Client RPC
        1. Declaration
        2. Execution
      4. Important Considerations When Using RPCs
      5. Exercise 17.01: Using Remote Procedure Calls
    3. Enumerations
      1. TEnumAsByte
      2. UMETA
        1. DisplayName
        2. Hidden
      3. BlueprintType
        1. MAX
      4. Exercise 17.02: Using C plus plus Enumerations in the Unreal Engine 4 Editor
    4. Bi-Directional Circular Array Indexing
      1. Exercise 17.03: Using Bi-Directional Circular Array Indexing to Cycle between an Enumeration
      2. Activity 17.01: Adding Weapons and Ammo to the Multiplayer FPS Game
    5. Summary
  20. 18. Gameplay Framework Classes in Multiplayer
    1. Introduction
    2. Gameplay Framework Classes in Multiplayer
      1. Exercise 18.01: Displaying the Gameplay Framework Instance Values
      2. The Server Window
      3. Server Character
      4. Client 1 Character
      5. The Client 1 Window
      6. Client 1 Character
      7. Server Character
    3. Game Mode, Player State, and Game State
      1. Game Mode
        1. Constructor
      2. Player State
      3. Game State
      4. Useful Built-in Functionality
      5. Exercise 18.02: Making a Simple Multiplayer Pickup Game
      6. Activity 18.01: Adding Death, Respawn, Scoreboard, Kill Limit, and Pickups to the Multiplayer FPS Game
    4. Summary

Product information

  • Title: Game Development Projects with Unreal Engine
  • Author(s): Hammad Fozi, Gonçalo Marques, David Pereira, Devin Sherry
  • Release date: November 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781800209220