I want to center mouse cursor. Here how I do it.
But here is a problem - when I change active window with alt + tab, cursor still in the center all the time. Can I check somehow that game window is focusable?
I want to center mouse cursor. Here how I do it.
But here is a problem - when I change active window with alt + tab, cursor still in the center all the time. Can I check somehow that game window is focusable?
You can call IsForegroundWindow() on your LocalPlayer’s ViewportClient->Viewport.
Something like:
ULocalPlayer* LocPlayer = Cast<ULocalPlayer>(Player);
if (!LocPlayer->ViewportClient->Viewport || !LocPlayer->ViewportClient->Viewport->IsForegroundWindow())
{
// viewport is either not present or not in the foreground.
}
…should work for you. Player lives within the PlayerController, so the above code will work if called from within a playerController, or can be called somewhere else by grabbing the Player from the local playerController.