Deproject Screen Position to World not working

Hi y’all, I’m trying to draw a debug square in the top-left corner of my screen. De-projecting screen to world works in blueprint but not in c++. Why is that?

Pink is BP, red is C++:

Here’s my Blueprint (had to wait some time for viewport to be ready)

And here is the equivalent C++:

void ABreakoutGameModeBase::BeginPlay()
{
  Super::BeginPlay();
  UWorld *World = GetWorld();
  Controller = Cast<ABreakoutController>(World->GetFirstPlayerController());

  World->GetTimerManager().SetTimer(CheckViewportHandle, this, &ABreakoutGameModeBase::TrySpawnBlocks, 0.1f, false, 0.2f);
}

void ABreakoutGameModeBase::TrySpawnBlocks()
{
  UWorld *World = GetWorld();
  FVector OutSpawnPosition, OutSpawnDirection;
  Controller->DeprojectScreenPositionToWorld(0, 0, OutSpawnPosition, OutSpawnDirection);

  DrawDebugPoint(World, OutSpawnPosition, 100.f, FColor::Red, false, 10.f);
}

I’m just trying to spawn some actors relative to where the camera is looking. What am I doing wrong here?

ABreakoutGameModeBase::ABreakoutGameModeBase()
{
PlayerControllerClass = ABreakoutController::StaticClass();
}

I’ve already set that up.

Well, for me the C++ code works correctly.

Are you possessing a different pawn or somehow otherwise changing the view, or have you tried to make sure that the changes to the code have been properly applied (by closing the editor, building the project and re-opening the editor)?

I have a different pawn that just has a top-down camera and that is set on the “Default Pawn Class” in a game mode blueprint that is derived from the cpp game mode. I wonder if that might cause the problem.