xiaozongpeng 发表于 2022-8-26 10:46

Unreal Mixing AGameState with AGameModeBase is not ...

Gameplay用起来很巴适,但是有时候就会折腾一下,然后就遇到一些不注意的东西!
Mixing AGameState with AGameModeBase is not compatible. Change AGameModeBase subclass (bp_BaseGameMode_C) to derive from AGameMode, or make both derive from Base因为项目中并没有使用AGameMode,使用的是AGameModeBase,在AGameModeBase的代码中
/** GameState is used to replicate game state relevant properties to all clients. */
    UPROPERTY(Transient)
    TObjectPtr<AGameStateBase> GameState;
而AGameMode中的是
void AGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
    Super::InitGame(MapName, Options, ErrorMessage);
    SetMatchState(MatchState::EnteringMap);

    if (GameStateClass == nullptr)
    {
      UE_LOG(LogGameMode, Error, TEXT("GameStateClass is not set, falling back to AGameState."));
      GameStateClass = AGameState::StaticClass();
    }
    else if (!GameStateClass->IsChildOf<AGameState>())
    {
      UE_LOG(LogGameMode, Error, TEXT("Mixing AGameStateBase with AGameMode is not compatible. Change AGameStateBase subclass (%s) to derive from AGameState, or make both derive from Base"), *GameStateClass->GetName());
    }
    ...
}
https://ai-gaminglife.hatenablog.com/entry/2018/07/23/115923


所以要求是项目的MyGameMode继承的是哪个Mode,就是用对应的GameState!
页: [1]
查看完整版本: Unreal Mixing AGameState with AGameModeBase is not ...