Widget variables in multiplayer

Hi There! I’m trying to do this: there is a multiplayer game, the user can choose one character from a list of 3 (i.e. mouse, cat, dog) in the lobby( when an user chooses one of them the others can’t choose the same), so inside the player controller there is a variable( texture 2d type called Picture) and when the match starts the player controller assigns a specific and different “picture” to the owning player ( a picture of a cheese if it is a mouse, of a bone if it is the dog, of a ball of wool if it is the cat); well, for now no troubles, but for the next step i can’t found a way, in the level there is an actor (a door) with a trigger volume, in the door’s blueprint, when one character overlaps it, the doorBP gets the instigator controller and casts to the player controller and calls a custom event; in player controller the event enables input and when inputAction Leftmouse is pressed the character opens the door and set his Picture variable on another variable (called Marked) when inputAction RightMouse is pressed it creates a widget where the texture 2d of the variable Marked will be bind on an Image and add to viewport: the result will be that when the dog is in the trigger box he can press leftmouse to open the door and if he does it he marks it ( Marked variable will contain his Bone picture) if then the dog press the rightmouse he sees his Bone picture in the widget…and after if the cat enter in the trigger box and if the cat press rightmouse the cat( and only him) will be able to see the Bone pictures trought the widget’s image binding by Marked variable… but i think or better i’m sure that player controller isn’t the right and only place to do all these things…that’ is the reason why i tried to do that using Player State, Game State etc in different ways but without succes…and now i’m very fused and confused and i need your help!!! How can i get the Marked variable from player controller and bind it in widget’s image?

The explanation is a bit confusing, is the widget that is being marked on the door itself or is it on the players screen

Hi! :slight_smile: the widget is on the player screen ( created in player controller) and only on the screen of the player that press rightmouse

Ok, I understand now. What you can do is when you first create the widget in the playercontroller, save it as a variable so that when you press right click later you can set the marked variable from the widget reference. Then in the widget, you bind the image to your variable. Hope this is right!

Save as var

250774-1.png

Set marked

250775-2.png

Bind image in widget to marked

250776-3.png

uhm I think that it’s a little more complicated, probably I don’t explain well the problem. Try to see the problem in this point of view: the left clik has 2 effects the first is that it opens the door the second is that it marks like a fingerprint the door; the right click instead will allow to see trought the widget the fingerprint, so if the dog marks with his fingerprint the door by clicking leftmouse then if another character or the dog himself return in the trigger box of the door and only click the rightmuose the widget will show, to the character that press rightmouse, the printfinger of the last time that leftclik was press

In my opinion, since widgets are client side only, theres no way someone other than who created the widget can access the data, so I would suggest maybe a database actor in the level somewhere that stores the image that is supposed to be on the widget so when someone left clicks they set the marked variable inside the widget and also inside the databse actor, and when someone right clicks, they get the marked variable from inside the database actor

I try to do this:

  • in the doorBP, when triggerbox is overlap, it calls the player controller
  • in player controller on leftmouse click it calls (a replicated to all ) function in doorBP where opens the door
  • in player controller on leftmouse click it calls (a run on server) function that get the “fingerprint” and casting it to gamemode, set a game mode variable “fingerprintGM”
  • the widget bind the image trought the get brush which takes fingerprintGM from the gamemode, make slate brush and return node
  • in player controller on rightmouse click it calls (a run on server) function that creates the widget and add to viewport
    ( if i try to change the replication of this function to multicast or run on owning client the widget doesn’t appear)

if I play the result is that on the Host-Player it works well, on the client when i click right mouse the fingerprint in the widget is right but it creates the widget in the Host-Player viewport ( if i get a self reference to the create widget node it doesn’t appear)