When I create a session the ui is all fine but when a client joins the session his ui is also replicated on the server wich I dont want to happen. I currently set the ui in the event BeginPlay, I also tried custom events with owing client only but that doesnt work.
If you know what I am doing wrong please let me know. Thank you
SwitchHasAuthority (Authority - runs on server only, Remote runs on client only)
IsLocalPlayerController - this will be true only if controller is owned by a real player (server and client). So it’s useful for spawning UI, as it will be spawned in the same way for server and client, but it won’t be spawned for replicated controllers.
I think if you use Branch with IsLocalPlayerController before spawning UI, this should solve your issue.
Hey there @DonJuan1232! Sitiana is correct, just adding some extra resources for other visual learners. The video doesn’t into extreme detail on all the factors you’ll need however.
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.
Thank you this helps @Sitiana, But for the guns in the game They are “pawns” if I say that correctly (a component I attach to the player)
I add the ui from that the same way as the health I showed.
Is there a way i can use IsLocallyControlled then some how to get the player the gun is attached to and see if that is locally controlled. Or should I pass on the result from IsLocallyControlled from the player to the gun.
If Guns are pawns then you can get their controllers and check it the same way (make sure to validate controllers, as other players’ guns on clients won’t have their controllers).
But general rule is that controllers should be responsible for player UI. If you have different UIs per gun, you could send UI class to the controller and create it there. It’s easier to manage.