How to do it...

  1. Create a new C++ class, like in the previous recipe. This time, select Game Mode Base as your base class:
  1. Once you have clicked Next, give the new class a name, such as UE4CookbookGameModeBase.

  1. Declare a function override in the .h file of your new GameModeBase class:
#pragma once#include "CoreMinimal.h"#include "GameFramework/GameModeBase.h"#include "UECookbookGameModeBase.generated.h"/** *  */UCLASS()class CHAPTER_04_API AUECookbookGameModeBase : public AGameModeBase{  GENERATED_BODY()public:  virtual void BeginPlay() override; };
  1. Implement the BeginPlay function in the .cpp file:
#include "UECookbookGameModeBase.h" ...

Get Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.