Book Image

Unreal Engine Game Development Cookbook

By : John P. Doran
Book Image

Unreal Engine Game Development Cookbook

By: John P. Doran

Overview of this book

Table of Contents (18 chapters)
Unreal Engine Game Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Saving or loading games and keyboard input with C++


As games get more and more complex and longer and longer, players will often need to play a game within multiple sessions. However, by default, players will need to start over from scratch. In this recipe, we will be going over how to save a variable and load it at runtime.

Getting ready

Before we start working on this, we need to have a project created and set up. Follow the Setting up your development environment recipe all the way to completion.

How to do it…

To give you an idea of how it works, let's do a simple example of saving a player's position and rotation, which we can return to using keyboard input:

  1. Navigate to File | New C++ Class, and you should see the Choose Parent Class window pop up. Check the Show All Classes option, select SaveGame, and click on Next.

  2. Next, it'll ask you for the name of your save class. In this instance, I'm going to leave it as MySaveGame and click on Create Class and wait for it to finish compiling.

  3. In the...