Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.19
more ▼

asked Aug 16 '18 at 11:03 PM in Blueprint Scripting

avatar image

1 1 1

avatar image TheApplePieGod Aug 17 '18 at 01:52 AM

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

avatar image michele84 Aug 17 '18 at 10:52 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

alt text

Set marked

alt text

Bind image in widget to marked

alt text alt text

1.png (30.0 kB)
2.png (41.5 kB)
3.png (29.8 kB)
4.png (53.1 kB)
more ▼

answered Aug 17 '18 at 02:18 PM

avatar image

26 2 1 3

avatar image michele84 Aug 18 '18 at 09:40 AM

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

avatar image TheApplePieGod Aug 18 '18 at 12:47 PM

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

avatar image michele84 Aug 18 '18 at 02:32 PM

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)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question