This recipe will reuse the GameMode from the previous recipe, Instantiating an Actor using SpawnActor, so you should complete that recipe first.
Destroying an Actor using Destroy and a Timer
How to do it...
- Make the following changes to the GameMode declaration:
UCLASS()
class CHAPTER_04_API AUECookbookGameModeBase : public AGameModeBase
{
GENERATED_BODY()
public:
virtual void BeginPlay() override;
UPROPERTY()
AMyFirstActor* SpawnedActor;
UFUNCTION()
void DestroyActorFunction();
};
- Add #include "MyFirstActor.h" to the implementation file's include statements. Remember, we need to place it above the .generated file:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase...