Reader small image

You're reading from  Unreal Engine 5 Game Development with C++ Scripting

Product typeBook
Published inAug 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781804613931
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
ZHENYU GEORGE LI
ZHENYU GEORGE LI
author image
ZHENYU GEORGE LI

Zhenyu George Li is a passionate video game developer with 20+ years of experience. He has contributed significantly to many games and serves as a senior development consultant at Unity. His early immersion in technologies like C/C++, DirectX, OpenGL, and Windows GUI laid the foundation for his success. Notable titles in his portfolio include Magic Arena, Halo Infinity, Stela, Dead Rising 2, and The Bigs 2. He has gained extensive knowledge in programming, graphics, animation, gameplay, AI, multiplayer, and UI using Unreal and Unity engines. Additionally, he has taught UE at Vancouver Film School and has college teaching experience at College of Interactive Arts and Hefei Union University.
Read more about ZHENYU GEORGE LI

Right arrow

Preface

Welcome, and thank you for choosing to pick up the Unreal Engine 5 Game Development with C++ Scripting book! This comprehensive book is designed to assist game developers and students in advancing their professional skills in C++ programming for Unreal Engine game development.

Unreal Engine is a powerful and versatile game engine widely used in both the gaming and movie-making industries. Possessing advanced and professional Unreal Engine development skills enables individuals to adapt more effectively to the demands of a career in game development, opening a multitude of opportunities for them.

When developing with Unreal Engine, you have the option to use either one or both of two available programming tools:

  • Blueprint provides a user-friendly interface suitable for non-programmer developers
  • C++ is predominantly employed by software engineers, providing a more robust and flexible approach to game development

As an Unreal Engine developer, you may have a genuine interest in understanding C++ and how it integrates with the engine, even if you don’t identify as a software engineer or aspire to become one.

This book is designed to assist you in expanding your knowledge and skills by guiding you through the necessary steps to create a fully fledged game, covering essential aspects of game development. It aims to smoothen the learning curve, allowing for a more seamless and efficient grasp of the concepts presented. The carefully organized topics eliminate the need for random searching and prevent wasted time on unrelated readings, enabling you to focus on the relevant information. Moreover, this book serves as a valuable reference manual, offering a comprehensive resource that can be revisited and utilized for further study.

Who this book is for

It is important to note that this book does not serve as a beginner’s guide to using Unreal Engine. Prior to exploring its contents, you should already possess a basic understanding of, and practical experience with, Unreal Engine and Blueprint. This prerequisite ensures that you have a solid foundation of knowledge to fully leverage the material covered in this book, maximizing your learning experience.

This book caters to a diverse range of readers:

  • Non-engineer game developers, such as game designers and artists who aspire to learn and comprehend C++ in the context of Unreal Engine development
  • Software engineers who may lack prior experience in Unreal Engine C++ programming but wish to quickly acquire the necessary skills for their next project or job
  • Students who are interested in learning and digging into Unreal C++ programming for their study or personal projects
  • Individuals with a keen interest in game development using Unreal Engine will benefit from the comprehensive knowledge presented within these pages

What this book covers

Chapter 1, Creating Your First Unreal C++ Game, guides you quickly through creating a new C++ game project based on the Shooter template in Unreal. This chapter also introduces how to convert an existing Blueprint game project into a C++ game project.

Chapter 2, Editing C++ Code in Visual Studio, provides basic information on how to use the powerful integrated development environment Microsoft Visual Studio to edit C++ code. This chapter not only presents the editing skills needed but also demonstrates how to create a calculator application in C++.

Chapter 3, Learning C++ and Object-Oriented Programming, goes deeper into C++ programming based on the previous chapter’s calculator project. This chapter covers the fundamental C++ syntax, data types, flow control, and so on. C++ object-oriented programming is also introduced in this chapter.

Chapter 4, Investigating the Shooter Game’s Generated Project and C++ Code, explores the details of the generated shooter game project, including the project files’ structure and the source files. In this chapter, the C++ code lines are briefly explained, so that you gain an overall understanding of how C++ code works.

Chapter 5, Learning How to Use the UE Gameplay Framework Base Classes, instructs you on how to create our new top-down game project, Pangaea. You will be guided on how to create the game actors, DefenseTower, for instance, and the game character, PlayerAvatar classes, for instance, as well as defining actor properties and functions in C++.

Chapter 6, Creating Game Actors, provides steps to write code and set up the main character for the Pangaea game. It includes setting up the character, creating the animation instance, defining the state machine, and synchronizing the animations.

Chapter 7, Controlling Characters, provides methods of controlling game characters. This includes configuring the input map, handling player input, and effectively processing the reactions of the player character. Additionally, you will be introduced to the AI controller and the navigation system for controlling non-player characters.

Chapter 8, Handling Collisions, discusses the engine’s collision system and its configurations for game interactions. To handle collision events – attack hits and projectile hits, for example – you will learn how to configure actor colliders and triggers. Using ray casts to check whether a projectile hits the target is also introduced in this chapter.

Chapter 9, Improving C++ Code Quality, presents how to employ software engineering practices during code refactoring and refinement. This chapter implements class generalization, caching, and pooling methods to improve the game code’s quality and performance.

Chapter 10, Making Pangaea a Network Multiplayer Game, starts by introducing the fundamental concepts related to multiplayer games, including servers, clients, and multiplayer modes. You will be guided step by step through converting the single-player Pangaea game into a multiplayer game.

Chapter 11, Controlling the Game Flow, intends to make Pangaea a complete multiplayer game, which has a main menu as the lobby, so that players can decide whether they want to start a host or join a game session. C++ and Blueprint scripting skills for user interface operations are also revealed in this chapter.

Chapter 12, Polishing and Packaging the Game, provides resources, methods, and suggestions on how to polish games from both visual experience and product quality aspects. This chapter also provides steps for configuring and packaging the Pangaea project to be an executable standalone game for distribution.

To get the most out of this book

You will need to have knowledge and experience in using Unreal Engine. Basic Blueprint scripting knowledge is also required prior to reading this book.

Software/hardware covered in the book

Operating system requirements

Unreal Engine 5.0 and up

Microsoft Windows 10 and up

Microsoft Visual Studio 2002 with the C++ compiler

If you conduct experiments with the samples on systems other than Microsoft Windows, such as macOS, please keep in mind that there may be user interface and configuration differences that may not be addressed in this book.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Unreal-Engine-5-Game-Development-with-C-Scripting. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The AProjectile class can be inherited as child classes for creating various fireable objects, such as AFireBall, AMissile, ABomb, and so on."

A block of code is set as follows:

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DefenseTower.generated.h

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

void APangaeaCharacter::BeginPlay()
{
…
_AnimInstance = Cast<UPangaeaAnimInstance>(
GetMesh()->GetAnimInstance());
…
}

Any command-line input or output is written as follows:

$ mkdir css
$ cd css

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: "In the Unreal Project Browser window, choose the GAMES tab on the left side. Then select the First Person template."

Tips or important notes

Appear like this.

Additionally, the C++ sample code provided in this book adheres primarily to Unreal Engine’s coding standard, ensuring consistency and minimizing confusion for readers. For detailed information, you can visit the official Code Standard website here: https://docs.unrealengine.com/5.0/en-US/epic-cplusplus-coding-standard-for-unreal-engine/.

Exceptions may occur when using compact expressions that are clear and easily understood, allowing the text to fit within the constraints of the page printing layout without compromising reader comprehension. For example, the following line of code follows the code standard by explicitly declaring the type of the assigned GameInst variable:

UPlayerAvatarAnimationInstance* GameInst = Cast   <UPlayerAvatarAnimationInstance>(GetMesh()->GetAnimInstance())

The following modified version is used instead:

auto GameInst = Cast<UPlayerAvatarAnimationInstance>(
  GetMesh()->GetAnimInstance())

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Unreal Engine 5 Game Development with C++ Scripting, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below

https://packt.link/free-ebook/9781804613931

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Unreal Engine 5 Game Development with C++ Scripting
Published in: Aug 2023Publisher: PacktISBN-13: 9781804613931
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime

Author (1)

author image
ZHENYU GEORGE LI

Zhenyu George Li is a passionate video game developer with 20+ years of experience. He has contributed significantly to many games and serves as a senior development consultant at Unity. His early immersion in technologies like C/C++, DirectX, OpenGL, and Windows GUI laid the foundation for his success. Notable titles in his portfolio include Magic Arena, Halo Infinity, Stela, Dead Rising 2, and The Bigs 2. He has gained extensive knowledge in programming, graphics, animation, gameplay, AI, multiplayer, and UI using Unreal and Unity engines. Additionally, he has taught UE at Vancouver Film School and has college teaching experience at College of Interactive Arts and Hefei Union University.
Read more about ZHENYU GEORGE LI