Can not get game state inside of Game Mode "cannot convert argument 1 from 'From *' to 'UObject *'"

Please take a look at the GameMode.cpp AFPSGameState* GM line…
It does not compile and shows me the next errors:

Error messages screenshot:

1st:

2nd error:

GameMode.cpp file



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

#include "CPP_1GameMode.h"
#include "CPP_1HUD.h"
#include "CPP_1Character.h"
#include "kismet/GameplayStatics.h"
#include "UObject/ConstructorHelpers.h"
#include "Public/FPSGameState.h"
#include "Engine/World.h"

ACPP_1GameMode::ACPP_1GameMode()
: Super()
{
// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/Blueprints/BP_Player"));
DefaultPawnClass = PlayerPawnClassFinder.Class;

// use our custom HUD class
HUDClass = ACPP_1HUD::StaticClass();
// use our custom GameState class
GameStateClass = AFPSGameState::StaticClass();
}

void ACPP_1GameMode::MissionComplete(APawn* InstigatorPawn, bool bMissionSuccess)
{
    if (InstigatorPawn == nullptr) {
        UE_LOG(LogTemp, Warning, TEXT("InstigatorPawn is nullptr"));
        return;
    }
    if (SpectatingViewPointClass == nullptr) {
        UE_LOG(LogTemp, Warning, TEXT("SpectatingViewPointClass is nullptr, Please update GameMode class with valid class. Cannot change Spectating Viewtarget!"));
        return;
    }

    TArray<AActor*> ReturnedActors;
    UGameplayStatics::GetAllActorsOfClass(this, SpectatingViewPointClass, ReturnedActors);

    // Change view target if any actor found
    if (ReturnedActors.Num() > 0){
        AActor* NewViewTarget = ReturnedActors[0];

        APlayerController* PC = Cast<APlayerController>(InstigatorPawn->GetController());
        if (PC) {
            PC->SetViewTargetWithBlend(NewViewTarget, 0.5f, EViewTargetBlendFunction::VTBlend_Cubic);
        }
    }

***AFPSGameState* GM = GetGameState<AFPSGameState>(); // here is the line which produces errors***
***//**AShooterGameState* const MyGameState = GetWorld() != NULL ? GetWorld()->GetGameState<AShooterGameState>() : NULL; // this one is also not working in GameMode*

    //if (MyGameStae) {
    //    MyGameStae->MulticastOnMissionComplete(InstigatorPawn, bMissionSuccess);
    //}
    bOverallMissionSuccess = bMissionSuccess;
    OnMissionCompleted(InstigatorPawn, bMissionSuccess);
}

GameState.h file


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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "FPSGameState.generated.h"

/**
 *
 */
UCLASS()
class CPP_1_API AFPSGameState : public AGameModeBase
{
    GENERATED_BODY()

public:

    // NetMulticast  if this function is called from the server, it gets send to all clients.
    UFUNCTION(NetMulticast, Reliable)
    void MulticastOnMissionComplete(APawn* InstigatorPawn, bool bMissionSuccess);

};

GameState.cpp file



// Fill out your copyright notice in the Description page of Project Settings.
#include "Public/FPSGameState.h"
#include "GameFramework/Pawn.h"
#include "Engine/World.h"

void AFPSGameState::MulticastOnMissionComplete_Implementation(APawn* InstigatorPawn, bool bMissionSuccess)
{
    if (bMissionSuccess) {
**for (FConstPawnIterator it = GetWorld()->GetPawnIterator(); it; it++) { // is it okay for UE 4.23, or there's better one?**
            APawn* Pawn = it->Get();
            if (Pawn && Pawn->IsLocallyControlled()) {
                Pawn->DisableInput(nullptr);
            }
        }
    }
}



I would be glad to here any help!
Thank you in advance!

Your GameState inherits from AGameModeBase rather than AGameStateBase

:eek:

Huh, wow!
That is my huge fail(
Missclicked on class creation!
2 head are always better than one! Thank you for you attentiveness!

I am honored!