Get the client player controller from a server player controller?

I’m not actually sure how to word this one, But what I’m trying to do is grab the clients version of a player controller from a specific server player controller.

For an example lets just say we have Player 1 and Player 2

Player 1 has these two controllers:

Player 2 has these two controllers:

The clients can of course only see the client controllers, and the server the server controllers.

Now the controllers for each respective player have to be connected in someway, I’m trying to find out how to get for example, ClientPlayerController2 from ServerPlayerController2

It’s a bit confusing I know, but the main reason I need it, is because the method for attaching armor in my game to players, does not seem to be replicating to the client as it should.

I tried two difference methods but both had the same result.

I tried a “Run on Server” Replication event which ran into a “Multicast” Replication event which equipped the armor, and it worked to a degree. The server could see the armor attached on the client(s) and itself. But the client could only see armor attached to itself, the server and other clients armor would simply fall off.

I tried having a “RepNotify” variable which was a reference to the armor actor I equipped. And of course when I changed the value of that variable it ran the equip armor code. But the thing was I got the exact same result, which was that Client could see only themselves with armor on, whilst the server could see everybodies armor.

This is due to the code trying to attach the armor to ServerPlayerController instead of the clients controller. I assumed multicast would work as it’s running on all the clients controllers as well, but it still seemed to only grab the servers controller.

Now I’m thinking that if there’s a way to just grab the ClientsPlayerController from a servers one, I could just attach it to that, so when I do a multicast, the code will only ever attach to the ClientsPlayerControllers. That way it’s guaranteed the clients can see the armor on each other.

If this doesn’t make any sense, Lemme know and I will try and clear it up. Maybe it’s not even possible, but this is the only way I can think of doing it.

Any and all help is appreciated

It is something quite weird. It is easier than you think, but complex to understand.

I suppose you are using BluePrint, not C++
It is same code which is running on server and client, so to differentiate where you are, you can use the has authority.
So on your client, playercontroller[0] is your player. You use has authority remote pin to work on your controller on client side. For know, if you want to apply action on this player controller, on server side, you will create a custom event, run on server. The best is that the event is defined on playercontroller blueprint. in this way, player controller client and server are directly connected, without give any reference or id.
Or you can put a “in parameter” a player controller reference. It will automatically converted to one side or the other.

If action is on server side, for example, you detect a collision on your pawn, from which you can retrieve the player controller which possessed it. But you have to test before has authority with authority pin. After that, you can create a custom event, running on owner side (client), or broadcast to all user. Best is that this event is on plyercontroller blueprint…

I ve tried to summarize some information on my blog, if it can help you:

From my understanding, I should be doing everything correctly. I’m really not sure where the problem lies. I am using authority switches and custom events like “Run On Server”

I made an image album to showcase the blueprints and an example of the problem in-game.

You can see in the in-game example, On the client side the servers helmet doesn’t attach because it’s getting the server controller not the client controller

Authority is the server. In fact, all objects are managed by server, it is the authority. and remote is client.
So you have to invert your pin :stuck_out_tongue:

Yea I know but that isn’t the problem, It’s simply not attaching to the other clients on a given clients screen. When I inverted the pins the armor didn’t show up on anybody.

I’ve tried almost every setup for custom events and switch on authorities, but the farthest I can get is the example in the album above. There doesn’t seem to be a way to keep the actor attached to the other clients on the server on a given clients screen. It keeps trying to grab the servers player controller instead of the clients one, even when multi casting.

Alright I got it! Turns out the functions I had worked perfectly, The problem was I was doing all of this in my player controller.

I took the same code (I modified the parent of the attach only) and shoved it into my actual player character blueprint.
Then I redirected the interface message to go to the character instead, and now it works perfectly.