Book Image

Learning C++ by creating games with UE4

By : William Sherif
Book Image

Learning C++ by creating games with UE4

By: William Sherif

Overview of this book

Table of Contents (19 chapters)
Learning C++ by Creating Games with UE4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Variables and Memory
Index

Writing C++ code that controls the game's character


When you launch your UE4 game, you might notice that the camera is a default, free-flying camera. What we will do now is make the starting character an instance of our Avatar class and control our character using the keyboard.

Making the player an instance of the Avatar class

In the Unreal Editor, create a subclass of Game Mode by navigating to File | Add Code To Project... and selecting Game Mode. I named mine GameModeGoldenEgg.

The UE4 GameMode contains the rules of the game and describes how the game is played to the engine. We will work more with our GameMode class later. For now, we need to subclass it.

Recompile your project from Visual Studio, so you can create a GameModeGoldenEgg blueprint. Create the GameMode blueprint by going to the Blueprints icon in the menu bar at the top, clicking on GameMode, and then selecting + Create | GameModeGoldenEgg (or whatever you named your GameMode subclass in step 1).

  1. Name your blueprint; I called...