Identifying my character in online mode

I created a game which has to work on a dedicated server. My main character is replicated, and he has an energy bar linked to the viewport by this code:



if (HealthBarClass)
		{
			if (!HealthBar)
			{
				HealthBar = CreateWidget<UHealthBar>(GetWorld(), HealthBarClass);

				if (HealthBar)
				{
					HealthBar->AddToViewport();
				}
			}
		}


The problem is that when other players log on, my character progress bar gets covered by other players’ one. I want like my character progress bar to be visualized. So I think I need to identify my character so that I can insert a condition in the method in order to add the progress bar to viewport.
How can I do this?
Thanks a lot.

In my experience checking that the Player Controller that you pass in as owner for the Widget IsLocalPlayerController()
Can`t see you passing in one in the code above.

Also a tip, creating the widgets from the HUD class/ BP i have found to be the less painfull.

Try replacing this:


HealthBar = CreateWidget<UHealthBar>(GetWorld(), HealthBarClass);

with this:


HealthBar = CreateWidget<UHealthBar>(UGameplayStatics::GetPlayerController(GetWorld(), 0), HealthBarClass);