So i have this part of code to create widget on screen, but it only works on server and prints this error if i am trying to call this from client:
PIE: Error: Only Local Player Controllers can be assigned to widgets. BP_IgoraPlayerControllerBase_C_2 is not a Local Player Controller.
If i am checking for IsLocalPlayerController() it just does not work on client. (Excpected)
Is there a fix or it just wont work until i launch it as exe and connect as game expects? I just want to fix this so it wont be needed to be launched as exe each time
if (WidgetToApply != nullptr)
{
AIgoraCharacter* Character = Cast<AIgoraCharacter>(GetCharacter());
if (!Character)
return false;
//Set mouse visibility and click events according to params
this->bShowMouseCursor = bShowMouseCursor;
this->bEnableClickEvents = EnableClickEvents;
//Create the widget
CurrentWidget = CreateWidget<UUserWidget>(this, WidgetToApply);
if (CurrentWidget != nullptr)
{
CurrentWidget->AddToViewport();
return true;
}
else return false;
}
else return false;