Widget Appears On Other Player In Multiplayer

Need help with this: When player 1 interacts with an object in the game, a widget appears just like it should. When testing on a multiplayer dedicated server when player 2 joins in and interacts with objects, the widget still appears on player 1 screen. If player 1 gets killed and leaves the game, then an interaction widget appears on the player 2 screen. How to fix this?

You probably use GetPlayerControler for the widget, and it gets controller 0, which is player 1. Can you show your blueprint?

1 Like

Yes, that could be the case. But how do I get the right player?
Here’s the code in lootbox:

And player controller

Do you have to process interaction on the server?
I’d suggest managing all UI stuff locally, this way there will be no mix-up with controllers.
And only send the necessary interaction data to the server when needed.
I don’t know your setup, so it’s hard to be more specific.

When doing it locally nothing even shows up when interacting, works in standalone, but not in server

What do you mean by “not in server”?
Usually, the server itself doesn’t need any widgets. It’s the clients who want to see widgets

I mean, you still press an interaction key/button on the client, it looks to me that you’re doing a lot of unnecessary things back and forth between the client and the server.

Plus, if you’re using listen server, your function works for player 1, because it’s the server and the client all in one, but it doesn’t work for player 2, because for clients Player Controller exists in two parts, one part on the server, and the other on the client. If you call the Looted function like this for Player 2, it won’t work, since you’re calling it for the server part of the controller, and UI can not exist on server. You have to additionally call a Client function on this controller.

I mean when testing it on dedicated server without changing blueprint

and what’s the easiest way to do it?

The client presses the interaction key/button, you check all the parameters on the client side, and if everything is fine, you create the widget. And you call a server function with the interacted actor as a parameter to tell the server what actor is interacted with, and then you do what you need with it on the server side.

Guess Has Authority api will help for you, you can control which is happened on server or client for one blueprint but exists in both

If you are using collision detection, then you need to get its controller from OtherActor when collision calls BeginOverlap, so that you can create the correct interactive UI in the corresponding player window.