Compile error?

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

    HUD->RemoveFromViewport();

if (bIsWinner)  
    {
        UUserWidget* WinScreen = CreateWidget(this, WinScreenClass);
        if (WinScreen != nullptr)
        {
 
            WinScreen->AddToViewport();
        }
    }
    else
    {
        UUserWidget* LoseScreen = CreateWidget(this, LoseScreenClass);
        if (LoseScreen != nullptr)
        {
 
            LoseScreen->AddToViewport();
        }
    }
    
    UE_LOG(LogTemp, Warning, TEXT("End"));
    GetWorldTimerManager().SetTimer(RestartTimer, this, &APlayerController::RestartLevel, RestartDelay);
}

[18/36] Compile [x64] ShooterPlayerController.cpp
D:\unreal\Unreal Projects\SimpleShooter\Source\SimpleShooter\ShooterPlayerController.cpp(24): warning C4996: ‘UUserWidget::RemoveFromViewport’: RemoveFromViewport is deprecated. Use RemoveFromParent instead. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.
[19/36] Compile [x64] BTTask_Shoot.gen.cpp

It’s a log

That is a very old change. It’s mentioned in the Unreal Engine 4.6 Release Notes.

Just change the call and you should be fine.

The fix is in the log.

What’s the difference between them?

RemoveFromViewport just called RemoveFromParent, it was pointless.

Privacy & Terms