Engine folder not added to VS when creating new code from UE4?

So this is weird…

Looks like I need to have a folder called Engine with the UE4 main file in it. I’m not sure what you call it, the root, executable?

Anyway, for some reason this folder is only added to my new VS project, if VS is already open with the Base UE4 project while I create a new project with the UE4 startup wizard.

When this UE4 Engine folder is in my new VS project, I am able to compile without errors.

When the UE4 Engine folder is missing, I get a compile error.

I’ve run in to a couple tutorials now, where you start the code from within UE4. When it opens in VS, the UE4 Engine folder is missing, so when I compile, I get an error.

What is that folder about, and how do you add it to the project?


1>------ Build started: Project: FPSProject, Configuration: Development_Editor x64 ------
1> FPSGameMode.cpp
1>C:\Users\gabe\Documents\GitHub\UnrealEngine\Games\FPSProject\Source\FPSProject\FPSGameMode.cpp(12): error C2601: ‘AFPSGameMode::BeginPlay’ : local function definitions are illegal
1> C:\Users\gabe\Documents\GitHub\UnrealEngine\Games\FPSProject\Source\FPSProject\FPSGameMode.cpp(9): this line contains a ‘{’ which has not yet been matched
1> -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: C:\Users\gabe\Documents\GitHub\UnrealEngine\Games\FPSProject\Binaries\Win64\UE4Editor-FPSProject.dll
1> Cumulative action seconds (3 processors): 0.00 building projects, 28.17 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.00 linking, 0.00 other
1> UBT execution time: 33.19 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ““C:\Program Files\Unreal Engine\4.0\Engine\Build\BatchFiles\Build.bat” FPSProjectEditor Win64 Development “C:\Users\gabe\Documents\GitHub\UnrealEngine\Games\FPSProject\FPSProject.uproject” -rocket” exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Why don’t you fix the error?

C:\Users\gabe\Documents\GitHub\UnrealEngine\Games\ FPSProject\Source\FPSProject\FPSGameMode.cpp(9): this line contains a ‘{’ which has not yet been matched

I can’t, because I don’t see the mistake and I’m new to coding.

The error takes me to the bracket just under this line. : Super(PCIP)



//.cpp
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#include "FPSProject.h"
#include "FPSGameMode.h"


AFPSGameMode::AFPSGameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

	void AFPSGameMode::BeginPlay()
	{
		Super::BeginPlay();

		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
		}
	}

}







//.h

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "GameFramework/GameMode.h"
#include "FPSGameMode.generated.h"

/**
 * 
 */
UCLASS()
class AFPSGameMode : public AGameMode
{
	GENERATED_UCLASS_BODY()

	virtual void BeginPlay() OVERRIDE;

	
};



For the error, it just looks like you have your BeginPlay function



void AFPSGameMode::BeginPlay()
{
    Super::BeginPlay();

    if (GEngine)
    {
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
    }
}

inside of your constructor:



AFPSGameMode::AFPSGameMode(const class FPostConstructInitializeProperties& PCIP)
    : Super(PCIP)
{

}


If you set it up like this, with one after the other, does it still give a compile error?



AFPSGameMode::AFPSGameMode(const class FPostConstructInitializeProperties& PCIP)
    : Super(PCIP)
{

}

void AFPSGameMode::BeginPlay()
{
    Super::BeginPlay();

    if (GEngine)
    {
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("HELLO WORLD"));
    }
}

Yes! thank you, it worked now.