Getting Player Controller in Multiplayer

So I’m working on a 3D side-scrolling platformer, wherin the character shoots at things in the environment. The aiming done by where the mouse is. Here’s the blueprint:


This works perfectly on the Server, or 1 person. However, If I play with two players, the second player (client) does not aim correctly, or at all. If I choose dedicated server, it also doesn’t work.

I realize this is probably because the player controller is set to 0. However, when I set the player controller to 1, 2 or any other number, this setup does not work at all.

Why isn’t it working for player 2?

Hey what class is this in? The pawn? Or a UMG widget? If its the pawn then use get pawn controller, or if a widget, get owning controller.

Yes, this is in the pawn class. I tried typing in ‘get pawn controller’ and all I could find was ‘Get Controller’ which is incompatible with ‘Get Viewport Size’ and ‘Get Mouse Position’

Thanks for the reply

Ah thats probably because its returning a controller class and not its subclassed playercontroller… Or the other way round. Ill mess about in the editor tonight and see if i can figure it out, im sure ive done something similar before

Silly me, the problem was that the player controller doesn’t exist on the server, so the instance of the character pawn that exists on the server would check its controller’s mouse position, and it would always be zero. Basically you need to make a remote procedure call (RPC) (a custom event) that is triggered on the client, and sends the info to the server. Its confusing because there are more than one copy (instance) of the same object.


This should work, I tried to copy your blueprint as best I could for a quick test, I used a print string to make sure the client was successfully sending off its data every tick, and both the client and the server pawns are registering mouse input.

So basically every tick (you could trigger the info sending however you want, custom event or calling the function or something), the local instance of the pawn, and only the local instance because of that “is locally controlled” branch check, does all the computing you had before, and just sends off its result via a custom event. The custom event is set to “run on server” with reliable checked. It also has a parameter of type float, that sends the data along, delivering it to the instance on your pawn on the server.

If that scene component still doesn’t move it may be because that component is not set to replicate, this could be solved with another RPC I believe.

Sorry if its a bit confusing, hope it helps a bit

You can cast the Controller returned by Get Controller to PlayerController - then it should work.


Thank you! :smiley:

It works! Fantastic!

mpie - I tried what you recommended, but it didn’t seem to work.

How do I use to logic to make a character move to a click’s location on multiplayer?


Thank you so much Zuriel.

Hi. I have a similar problem and I don’t understand how create RPCI event :frowning: