Creating a save game file

As noted at the top of this section, our actual game and the state of all our dynamic actors is done in three major steps:

  1. Add an interface to all actors that need to save. This involves a few changes to our moving platform, which we'll try to keep straightforward.
  2. Serialize all our actors' desired variables to an FArchive by tagging our UPROPERTIES.
  3. Write this to a file we can then serialize everything back out from.

For very simple saving (such as player stats and the current level), be sure to check out the USaveGame document link in the Further reading section at the end of the chapter. Now, on to our relatively complex version.

First we need an interface that we'll add to all of our actors that we care about ...

Get Mastering Game Development with Unreal Engine 4 - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.