I show a widget when the controller of a user is disconnected. To ensure keyboard focus i use the method setuserfocus. The funny thing is that the method setuserfocus uses the connected controller index, which at that time is of course disconnected… and returns -1, which will eventually lead to an incorrect array index. The fact that the code comments says its a hack triggered me that this is not really nice
UWidget::SetUserFocus(APlayerController* PlayerController)
{
.....
// HACK: We use the controller Id as the local player index for focusing widgets in Slate.
int32 UserIndex = LocalPlayer->GetControllerId();
....
}
Due to the InUserIndex being equal to -1 when no controller is connected. In my case i am playing on PC with an xbox controller connected that i pull out of the usb port and right at that instant the controller id is temporarily -1 which crashes the game if i also set focus to some widget at that time.
I am marking this topic as resolved for tracking purposes, as we have not heard from you in a few days. If this issue persists, feel free to respond to this thread. For any new issues, please create a new Answerhub topic.