How can Server control the item that a Client has?

I’m trying to figure out how the server can change the skin of an item the client has.


Certainly, server can change it when the server has the item.


But, server can’t change it when the client has the item.

It sounds stupid, but server must change it, not the Client.


I added ‘Static Component’ named item and, as you see, the item is attached to it.


I feel like no matter how powerful server is, the server can’t control it when the item is occupied by others.

How can server change the skin?

Haven’t looked at the rest of the code yet, but this logic makes no sense :

image

HasAuthority is essentially equivalent to being the server in 99% of cases. You are replicating to server when you are the server, which is either redundant or simply wrong (depending on what you want to do).

Adding a HasAuthority check behind InputAction only makes sense if that InputAction should only work for the host player.

I’m not sure if I understand what you’re trying to do, so maybe that’s your intent. Only the host is allowed to perform actions to change picture? If that’s the case, then your approach is semi-correct, but :

  • Replicating to server after HasAuthority is useless because you’re already the server

  • Input is only forwarded to the controlled pawn. This means when host presses NextPicture it executes on his own pawn, which doesn’t have the item (and hasn’t bound the events).

If you want host to be able to control the item regardless of who owns it, you need to know how to reach the item from the host character BP. Since the host character BP may not be the one who overlaps the item, you can’t rely on that event to do that link.

If you plan on having several items in the level, which one should be modified when host presses NextPicture?

If you always have only one item in the level, you could simply rely on “GetActorOfClass” to find it. A simple, unoptimized, example, in character BP : InputAction NextPicture → HasAuthority → GetActorOfClass (BP_Cap1) → KeyNextPic

Try this,
In your Character BP Event Graph,
Remove nodes that check authority (Switch Has Authority).

The client don’t have a authority so when the client has the Cap the authority check can’t be passed.

How about move these autority check node to
Event ‘KeyNexPic’ and ‘KeyPrePic’ in ‘BP_Cap1’ ?

Because some changes are really happened in there.

Oh my godness…
When I put the node ‘GetActorOfClass’ with some doubts, I couldn’t help myself saying ‘WTF…’
How simple it is!
Since I kept failing it, I thougth that it must’ve been rocket science. I was going to try to touch even BP_Gamemode! Thank you so much! You are my savior!