Multiplayer events fired on selected clients


I have simple question: How to run some events only on exact client? Is is possible to do this only in player controller?

Im trying to call run on owning client rpc from player controllers to actor components (invisibility logic) and i want to pass from allies 0,5 opacity but from enemies 1… But its not working (i think because all players does not own that component?), so is there another way how to deal with this kind of multiplayer problems? Or i have to move all invisibility logic from actor component to player controller?

Little more context. Are you making an in world object half opacity or umg element?

I set in my game on possess of player a reference variable to playercref and playertstateref in order to have a way for server to be able to cast to the items easier inside the pawn.

First you need some method to give them unique IDs, Unreal has that build in, but it is not easy to correctly setup (well it is easy but hard to guess, so read on it first). For eg cedric exi multiplayer docs (google it).
When you have that working correctly, you just broadcast event to all clients with array of id you want to trigger. Then clients check if their id is in array and execute it or ignore. I know it is not optimal because you broadcasting that event to all clients. However after this works, you may move that logic to server side.

Server side version:

  • make logic that sends event only to required clients,
  • trigger your event in server copy of player controller
  • replicate that triggered event, so it goes from server player controller to client side player controller
  • from client player controller trigger event in level umg or whatever you need on client side

This setup is probably not optimal, and it is easy to cheat because event is executed from client.

ps, thing that was very confusing for me about multiplayer: same blueprint on client and on server are in fact 2 different actors in 2 different games. It is kind of hard to grasp at first. So if you make switch on authority you have 2 different sets of variables. Because that is confusing i always separated both sides of code as far as i could. For eg server side logic was in player pawn, but all client side i moved to player controller, and used only replicated events. Or when i used game state as server brain, i avoided doing client side code in game state,

I tried to set character in world half or fully invisible :slight_smile: making invisible UMG was much easier

Guys thank you, i had very little stupid mistake in my BP and that was reason why it wasnt able to work :smiley: so its WORKING, i afraid its hackable but anyway im making prototype for now so its ok.

Nawrot’s server side version make me thinking twice so i found potential bug and that was it… Im attaching my BP if you want to check it guys, maybe its not good so if you have any advices how to correct it, ill be glad.