I have Actors with 3D widgets as WidgetComponents on them but I need to distinguish who interacted with that Widget/Actor.
The game is a Multiplayer game and the Actors and WidgetComponents are Replicated and the Game is in Mouse & UI mode to Interact with the Widgets.
I tried using the InteractionComponent on the player controller but this didn’t help me with the problem.
Another thing I tried is to check who is the owning pc and check if the local player is the same but local player is apparently something completely different despite the confusing name imo.
The last thing I tried was with linetrace to the actor and that worked sort of but I need the interaction on the widget and check where the user clicked and that’s not possible with that as far as I know.
But the problem remains even if I get the OwningPlayerPawn, that is replicated as far as I know and looked up in your wiki, in the widget that was clicked on I still don’t know who interacted with that widget.
That means in my mind if player 1 clicks on player 2 actor with the widget component the widget knows that it is owned by player 2 but not who clicked on it (In this example player 1). That is the problem I am facing.
Certainly you are much deeper into the topic than me but I don’t see a solution.
The only thing I could imagine is that the server knows who did the RPC that you mentioned and compares that with the owning player from that, in my case the actor of the widget component.
It would be really nice if you could help me further, I am going a bit insane about this problem…
and btw really nice wiki I found it already earlier and it helped me with some other problems. Thank you
Like you said is right about the OwningPlayerPawn. I would like to ask some questions.
Lets get the info correctly first in the player after that we know we want to send a RPC to the Server.
Can you explain me how is you world widget working? Is a button? The player should enter in a location and press an input? Do you game has multiple local characters or is just a player for client?
To cut it short the game is going to be an card game.
That means every player has only one local player that is under his control.
Each card is an replicated actor with an world UI widget on it, because obviously both players need to see the UI of the card.
The card has buttons to interact with it, one big one that covers all of the card and is used for the selection and hover over. In this button should go the logic for interaction, at least that is what I am trying to do.
Interaction to the card is only via mouse at the moment. (Interactions with mouse while pressing on the keyboard is no priority and can be achieved with the InteractionComponent I think)
Each card actor has the corresponding player controller reference as its owner and passes it down to the widget on creation. The cards are created after player join in the game mode.
The easy way to do this is get the local character once the interaction is triggered.
GetPlayerCharacter(0) → Will get the local character from the world you are interacting.
Remember to avoid using PlayerController to anything related with networking. The Player 2 can’t see the Player1 controller.
Ok I tried it and it seems to work. But I need to say this solution is a bit janky if I think about it. I don’t know why Unreal isn’t improving on their widget handling in general.
For the people reading this after the solution here is how I did it.
I made a reference in the widget for the parent actor. When the button is pressed it triggers a event/function in the parent actor and passes the local character as described here
GetPlayerCharacter(0) → Will get the local character from the world you are interacting.
This actor has a reference for the owning pawn. These two can be compared and there you go the owning distinction is implemented.
Again thank you @JonathanBengoa for the help and look at his suggestion for this wiki its really helpful