&APlayerController Error

Hey there,
I’m trying to follow along to get the level restart timer working, but am running into an issue where I cannot compile the SetTimer, as the APlayerController reference doesn’t seem to work?

My ShooterPlayerController.cpp:

#include "ShooterPlayerController.h"
#include "TimerManager.h"


void AShooterPlayerController::GameHasEnded(class AActor* EndGameFocus, bool bIsWinner) 
{
    Super::GameHasEnded(EndGameFocus, bIsWinner);

    UE_LOG(LogTemp, Warning, TEXT("Game has ended!"));

    GetWorldTimerManager().SetTimer(RestartTimer, this, &APlayerController::RestartLevel(), RestartDelay);
}

&APlayerController gets red squiggles, and when hovered over it says “expression must be an lvalue or a function designator”

The compile error in UE4:

   K:\MiscUnrealProjects\SimpleShooter\Source\SimpleShooter\ShooterPlayerController.cpp(15) : error C2664: 'void FTimerManager::SetTimer<AShooterPlayerController>(FTimerHandle &,UserClass *,void (__cdecl AShooterPlayerController::* )(void),float,bool,float)': cannot convert argument 3 from 'void *' to 'void (__cdecl AShooterPlayerController::* )(void)'

Thanks for any help!

&APlayerController::RestartLevel()

That is trying to take the address of what that function returns as the () calls the function. You need the address of the function itself

&APlayerController::RestartLevel

Oh lord… yep, that makes sense!
Thank-you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms