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)

Creating your first level in UE4

Creating levels in UE4 is easy and facilitated by a great all-around UI. In this recipe, we'll outline basic editor usage and describe how to construct your first level once you have your first project launched.

Getting ready

Complete the previous recipe, Creating your first project in UE4. Once you have a project constructed, we can proceed with creating a level.

How to do it...

  1. The default level that gets set up when you start a new project will contain some default geometry and scenery if the starter content was included when creating the project:
The MinimalDefault level and interface of Unreal Engine 4

You don't need to start with this starter stuff, however. If you don't want to build from it, you can delete it, or create a new level.

  1. To create a new level, click File | New Level...:

From here, you can select to create a level with a background sky (Default), or without a background sky (Empty Level).

If you choose to create a level without a background sky, keep in mind that you must add a light to it to see the geometry you add to it.
  1. If you loaded the Starter Content on your project's creation (or some other content), then you can use the Content Browser to pull content into your level. Simply drag and drop instances of your content from the Content Browser into the level and save it, and then play the game by hitting the Play button.
  2. Add some geometry to your level using the Modes panel (Window | Modes). Be sure to click on the left-most button with the picture of a light bulb and cube on it to access the placeable geometry:

By default, the Basic option is selected, which contains general geometry and other common features that are needed in Unreal. You can also add lights via the Modes tab by clicking on the Lights subtab on the left-hand side of the Modes tab. These can be added to a level by dragging and dropping as well.

The Modes panel contains two useful items for level construction: some sample geometry to add (cubes and spheres and the like), as well as a panel full of lights. Try these out and experiment to begin laying out your level.
If you are interested in learning more about building levels inside Unreal Engine, check out https://docs.unrealengine.com/en-us/Engine/QuickStart