Calling Multicast Function from PlayerController Problem

Hello,
I’ve run into a problem while trying to call a multicast function on my PlayerController. When I call it like:
PlayerController->ServerFunction(insidePlayerController)->MulticastFunction(insidePlayerController)
it executes only on Server and the client who called this function. Result in the game:

250500-playercontrollermulticast.png


The issue doesn’t occure when I do it like this:
PlayerController->ServerFunction(insideControlledPAWN)->MulticastFunction(insideControlledPAWN)
it works as intended:


Am I missing anything? I know of some limitations about PlayerController replication - is it related?
Thanks for help!

1 Like

Yep.

I am not sure what your expectations are but I’ll explain what happens as much as I can.

Multicast functions are executed on all instances of the containing object across all clients.By “instance” I mean instance of an object. (not of a class)

In your case every client has an instance of the Pawn. (assuming it is part of the relevant set of Actors for that client) This is why when a multicast function is called in the Pawn, every client executes it on its own instance of the same Pawn.

Things are very different for the Player Controller. The server has references to all Player Controllers, however the clients only have their own controller and do not “see” any other controllers.

When a multicast function is called on all instances of the Player Controller - only the server and the owning client have instances of this particular Player Controller. Other clients have their own Player Controller and have no object to execute the function on.

I hope that makes sense.

3 Likes

I was afraid it was thought like this… Would you suggest a cleaner solution maybe (than PlayerController->Pawn)? I’d rather avoid small chunks of code inside Pawn, when it should affect the controller only. Maybe interfaces? I don’t have a clue what shall I do to make it elegant

Player-to-player communication is intentionally restricted within the engine architecture.

However, player-server-player communication is entirely possible. You can send messages to (call functions in) your Game State and it can redirect them to the player controller you need. This is usually the way you keep score or check for end game conditions.

Keep in mind that I have no idea what you re trying to achieve and it still might be more appropriate to use the pawn.

Oh I’m sorry, I wasn’t clear with what I want to achieve. It is about changing character’s capsule size (ie while crouching), so I think GameState wouldn’t be what I’m looking for in this case

Yea you are right. It seems to me that it is completely logical to be part of the character code.

It depends entirely on internal character values - what the animation speed is, how high is the model is (while crouching), is the character in the air or swimming.

Moreover you can change the character of that player and this particular character might burrow underground instead of crouching which will entirely defeat the purpose of having the logic inside the player controller.

Your wisdom flows like a river.