Coocys
Coocys

Reputation: 61

How to determine the interacting player in an unreal world space widget

Main Problem

I try to make an multiplayer game where I want to interact with widget components in an actor that is set to world space that all users can interact with it. The game is in UI mode most of the time and controlled with the mouse

For the game it is important to know who clicked on the mentioned widget to check if it is owned by him or do some other checks.

I tried to use the OnComponentClick for the widget component but you lose the ability to know what the user clicked on the widget. And in my case it is necessary to know that. Another method is the InteractionComponent that is placed on the player controller, maybe I am not knowledgably enough to use it but it didn't help me with this problem. The last thing I tried is to use the owner(pc) of the widget and compare it with the local player PC but this didn't work too.

My question now, is there any way to retain the interaction of the widget and still check for the owning property of that widget/actor to determine if he is allowed to interact with it.

Any help would be gladly appreciated

Side note

I looked up if other game engines have the same issue like unreal and I found that it is possible in Unity to change the default behavior of the clicks to take more arguments. I looked it up for Unreal but I think my abilities aren't sufficient to implement anything like this. But maybe it could be a solution

Related Unrealengine forum thread

https://forums.unrealengine.com/t/who-interacted-with-the-3d-widget/2355115

Upvotes: 1

Views: 25

Answers (1)

Coocys
Coocys

Reputation: 61

Solution

This is the solution from the unreal forum thread. Read the tread to see the full solution. https://forums.unrealengine.com/t/who-interacted-with-the-3d-widget/2355115

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 https://cedric-neukirchen.net/docs/category/multiplayer-network-compendium/

Upvotes: 0

Related Questions