Networking does not make sense to me

Even after more than half year of making multiplayer game, networking still does not make sense to me in many ways…

I expect “run on owning client” in player controller (Set color) can be fired only if server calls it, but:

  • Run on server - does not work - only event i expect that should work - not working… why?
  • Not replicated - working, this maybe make sense because wall is placed in level so server owns it, but why then “run on owning client” RPC in wall working for clients even if clients does not owning that wall?
  • Multicast - no idea why this is working, but its working correctly

(Whole script running well for my needs, im just only interested why this work and that not…?)

Very very useful

I read this 3-4x :frowning: its good but there is lack of examples…

BeginPlay is called on Clients and Server (if the wall is replicated).

First thing is, you should limit that call to Authority with “SwitchHasAuthority”.

Getting all Actors of Class PlayerController on the Client would result in 1 result anyway, as Clients only have their own.

Why aren’t you just calling a Multicast on BeginPlay, limited to Authority, in which you pass down the color, based on the tag?

Thanks a lot :slight_smile:

  1. Yes i know about this, but why authority? isnt better to switch this to remote only if this is cosmetics only? (players can “cheat” with colors but it won’t be very helpful to them)

  2. So you recommend, when players connects to game -> get game mode -> get array of PC -> switch color?
    First idea what i had was to make switching color to pawns, but in my project, i can possess multiple pawns so i decided to make it in PC, but what if someone reconnects? I was afraid of some bugs (because im only prototype-programmer) so i made it with “anti-bug” insurance :slight_smile: also im prototyping for now, so for testing needs im switching multiple times player “team” so i want to see if its working well

Well, then you can do it like this:

Created the DynamicMaterialInstance in the Construction Script.

Since the wall is replicated, the BeginPlay calls on all Clients and the Server.

So simply do:

BeginPlay->GetPlayerController(0)->GetTag(0) of PlayerController->If that Tag is equal the Walls GetTag(0), set the Color of the DynamicMaterialInstance.

No need to replicate anything.

Oh, this is pretty sweet :slight_smile: working excellent, now i understand that, so if i correctly understand, this won’t work if i spawn wall only on server (because i have some “walls” which are spawned only on server)

i finally understand this:
Calling it on the Listen-Server will return the Listen-Server’sPlayerController

Calling it on a Client will return the Client’s PlayerController

Calling it on a Dedicated Server will return the first Client’s PlayerController

I understood it that way like when i run “dedicated server” and i call "GetPC(0), on client3, i will get Client1 PC, oh my god, this was so big confusion for me for a long time, i read that 3 lines like 10x but now after your example i understand it. This was reason why i used “get all actors of class” for player controllers because i was afraid to use GetPC(0)

Thanks pretty much again, you’re really helpful to community :slight_smile: