0
\$\begingroup\$

I am following GameDev.tv's unreal C++ course, but I am getting an error that is causing my compiler to fail. I'm coding a player controller, and I think I followed all the steps right but when I call the GameHasEnded() function from Super in the playercontroller.cpp, It gets an error saying: anything followed by '::' must be followed by a class or namespace.

Here is my .h file which has no known compiler errors.

    #pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "ShooterPlayerController.generated.h"

/**
 * 
 */
UCLASS()
class SIMPLESHOOTER_API AShooterPlayerController : public APlayerController
{
    GENERATED_BODY()
public:
    virtual void GameHasEnded(class AActor *EndGameFocus = nullptr, bool bIsWinner = false) override;
};

Here is my .cpp file with the problem.

// Fill out your copyright notice in the Description page of Project Settings.


#include "ShooterPlayerController.h"


void GameHasEnded(class AActor *EndGameFocus, bool bIsWinner)  
{
    //this is the problem super
    Super::GameHasEnded(EndGameFocus, bIsWinner);
}

I have a lot of other scripts, but I don't think they're related to the problem. I'm using Unreal 4.26, and Visual Studio 2019. I have no idea why this is getting an error, the code is exactly the same as the instructor’s code.

\$\endgroup\$
0

1 Answer 1

0
\$\begingroup\$

Since I didn't have much work done on this class, I decided to delete it and start over. This done, I added the same code and got no errors. My guess is that Unreal had a bug and didn't generate some code Super needs to work. Hopefully this will help someone.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .