Book Image

Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition

By : John P. Doran, William Sherif, Stephen Whittle
Book Image

Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition

By: John P. Doran, William Sherif, Stephen Whittle

Overview of this book

Unreal Engine 4 (UE4) is a popular and award-winning game engine that powers some of the most popular games. A truly powerful tool for game development, there has never been a better time to use it for both commercial and independent projects. With more than 100 recipes, this book shows how to unleash the power of C++ while developing games with Unreal Engine. This book takes you on a journey to jumpstart your C++ and UE4 development skills. You will start off by setting up UE4 for C++ development and learn how to work with Visual Studio, a popular code editor. You will learn how to create C++ classes and structs the Unreal way. This will be followed by exploring memory management, smart pointers, and debugging your code. You will then learn how to make your own Actors and Components through code and how to handle input and collision events. You will also get exposure to many elements of game development including creating user interfaces, artificial intelligence, and writing code with networked play in mind. You will also learn how to add on to the Unreal Editor itself. With a range of task-oriented recipes, this book provides actionable information about writing code for games with UE4 using C++. By the end of the book, you will be empowered to become a top-notch developer with UE4 using C++ as your scripting language!
Table of Contents (16 chapters)

Installing Visual Studio

Visual Studio is an essential package for code editing when editing the C++ code for your UE4 game.

Getting ready

We're going to set up a C++ coding environment to build our UE4 applications. We'll download Visual Studio 2017, install it, and set it up for UE4 C++ coding.

How to do it...

  1. Begin by visiting https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx. Click on Download VS Community 2017. This downloads the ~1,250 KB loader/installer:
You can compare editions of Visual Studio at https://visualstudio.microsoft.com/vs/compare/. The Community Edition of Visual Studio is fully adequate for UE4 development purposes in this book, that is, as long as you're an individual developer, doing academic research, or have fewer than six people on your team.
  1. Launch the installer, and continue through the installer until you get to the window where you select the components of Visual Studio 2017 that you want to add to your PC. Keep in mind that the more features you select, the larger your installation will be.
  1. Support for C++ is now an optional part of Visual Studio and isn't installed by default, so we have to select that we want it installed. Under the Workloads section, scroll down to the Mobile and Gaming heading and check the Game development with C++ option:
It is possible to download the Unreal Engine installer at this point as well by selecting it under the Optional section in the Installation details menu, but we will be getting the latest version of the Epic Games launcher and Unreal Engine directly from Epic Games in a separate recipe later on in this chapter.
  1. After you have selected the tools you'd like to add on to Visual Studio, click the Install button. The installer tool will download the required components and continue setup. After finishing installation, the installer may ask you to restart your computer. Go ahead and do so.
  2. After you download and install Visual Studio 2017, launch it. You will be presented with a Sign in dialog box:

You can Sign in with your Microsoft account (the one you use to sign into Windows 10) or Sign up for a new account. After you've signed in or signed up, you will be able to sign into Visual Studio itself. It may seem odd to sign into a desktop code editing program, but your sign-in will be used for source control commits to your repositories. On first signing into Visual Studio, you can select (one time only) a unique URL for your source code repositories, as hosted on Visualstudio.com (https://visualstudio.microsoft.com/).

How it works...