Error when calling "virtual void StartPlay() override;"

I have a problem when trying to use C++ in UE4. Whenever I call this function: “virtual void StartPlay() override;” I get a long message of errors in Visual Studio. I’ve tried different solutions for this, but I have not been able to figure out what’s wrong with it. I’ve also tried googling this without any luck, or find anything on these forums.

in my ExpGameMode.h it looks like this:

virtual void StartPlay() override;

I have also tried without the public and with private and so on. But without any luck. I just can’t get it to work. Can someone please help me with this?


1>------ Build started: Project: Explorare, Configuration: Development_RocketGame x64 ------
1> Parsing headers for Explorare
1> Reflection code generated for Explorare
1> Performing 3 actions (4 in parallel)
1> ExpGameMode.cpp
1> Explorare.generated.cpp
1> [3/3] Link Explorare.exe
1> Creating library C:\Code\Games\UE4\Explorare\Binaries\Win64\Explorare.lib and object C:\Code\Games\UE4\Explorare\Binaries\Win64\Explorare.exp
1>ExpGameMode.cpp.obj : error LNK2001: unresolved external symbol “public: virtual void __cdecl AExpGameMode::StartPlay(void)” (?StartPlay@AExpGameMode@@UEAAXXZ)
1>C:\Code\Games\UE4\Explorare\Binaries\Win64\Explorare.exe : fatal error LNK1120: 1 unresolved externals
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Code\Games\UE4\Explorare\Binaries\Win64\Explorare.exe
1> Cumulative action seconds (8 processors): 0,00 building projects, 0,43 compiling, 0,00 creating app bundles, 0,00 generating debug info, 4,24 linking, 0,00 other
1> UBT execution time: 12,85 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command “C:\Game_Engines\Unreal_Engine_4\4.5\Engine\Build\BatchFiles\Build.bat Explorare Win64 Development “C:\Code\Games\UE4\Explorare\Explorare.uproject” -rocket” exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Do you actually implement that function? Or do you only define it? If its the latter, that’s the error.

I’ve done all the first steps until it says I should compile in this tutorial:

And it still does not work. :frowning:

i did not know they changed it to startplay i have been using beginplay without problem tho?

This problem is caused by having the StartPlay on the class AExpGameMode but not implement the method.

You should have this on the AExpGameMode.cpp file:

void AExpGameMode::StartPlay() { }

Ah, thanks. And I should remember my c++ tutorials. Was such a long time ago, been doing c# the last five years so need to read up on this again. Thanks again.