x

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"

Cant pass Widget reference from server to client

So after beating my head against this and checking literally everything to see who has a reference to what variable I finally came to find out that the widget ref I was passing from the server to the client never gets sent even when replicated and/or reliable

ok so here is the scenario I have a left and right hand they are a component widget of my players UI they are a custom widget that I added to the UI manually not in code and I want to switch between them I set this to the Tab key in my inputs and fire the event in my player controller as well I create and set a reference to the UI in my player controller and in my pawn I set the left and right hand and the currently active hand to references now with all that

in my player controller off of the tab pressed I fire run on server which then says if active hand ref is the right hand ref then set left hand as the active hand and vice versa then pass the active hand through a run on owning client event for the highlight function in the UI

only the problem is the active hand ref never gets sent to the client its always null if I check the clients version of active hand its auto set to the right hand that prints out correct if I check the server side before and after everything comes out correct only after I pass it through the run on owning client does it come out null

I tried looking it up and I cant seam to find anyone else with this particulate problem and I dont have any screen shots as I have changed this from sending the active hand to sending an integer then just saying if its 0 then its the right hand if its 1 then its the left the problem with this is that down the road I wanted to put items in inventory slots and having all the inventory slots represented hypothetically by numbers makes it really hard to figure out what everything is supposed to be a reference to

So if anyone has any ideas as to why you cant send widget ref variables from server to client I would like to know or maybe a better work around then sending integers all over the place

oh also the custom widget is just a button with an image in it made it easier to use that instead of making a ton of on clicked events for each slot in the players UI

Product Version: UE 4.16
Tags:
more ▼

asked Jul 08 '17 at 05:09 AM in Blueprint Scripting

avatar image

Valcare
18 4 6 9

avatar image MatzeOGH Jul 08 '17 at 11:12 AM

A sever generally doesn't implement any kind of U. You have to do the replication in your pawn or player controller and adapt your UI accordingly on the clients side.

avatar image Valcare Jul 08 '17 at 11:59 AM

Ok so this is were my widget gets created in my player controller alt text

This is my hands getting referenced and set in my pawn alt text

This is the swap hands code the ActiveHandNum used to be just active hand inventory widget ref which is the custom widget component alt text

And this is the function for the swapping of the hands alt text

now I tried passing the active hand variable from the client side to the server side switching it and passing it back didn't work tried implementing swap hands on both side so the server could be updated with the the current hand of the player but nope something else would brake either the client or the server could no longer switch hands I guess the only thing I haven't tried is doing a switch has authority but I cant see why even if the server didn't have the players UI which if I can print what hand they have and get the right variable it should but what ever why can I not just pass a variable around and change what its supposed to be then send it back I dont get it

widget.png (326.3 kB)
hands.png (348.9 kB)
swap.png (433.3 kB)
function.png (345.4 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Your Slot refferences dont exist on the Server. Server will never Create any UI. In your Swap Function they will always be null. Think of your UI as read only. Here a nice refference that can explain it better than I can =)

http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf

more ▼

answered Jul 08 '17 at 09:47 PM

avatar image

Nachtmahr
7k 143 28 172

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

That document was very helpful thank you very much ok so if I can't pass wiget variables around then any suggestions on how to get what one was clicked I saw in that compendium him passing a click event in but I need to know exactly which one was clicked and update its image variable from the item and depending on which one was clicked I'm storing the item server side in a variable on that pawn each variable named for each slot

more ▼

answered Jul 09 '17 at 06:49 PM

avatar image

Valcare
18 4 6 9

avatar image slaas Sep 20 '18 at 03:23 PM

(How) Did you manage to solve this?

avatar image Nachtmahr Sep 20 '18 at 03:53 PM

I give you a Example.

Imagine you have a Inventory on your Character filled with Items. You create a Widget localy to display them and interact. If you click a Item you notify your Character what you clicked and your Character in turn can tell the Server what he clicked. The Server was not involved in any UI buisness.

If you think of something like a Trade window between two Players you have a local UI for "each" Player and not a single one both interact with. So P1 Drags a Item into Trade via his local UI, P1 Character would tell the Server that he added ItemX to trade, Server would forward it to P2, when P2 recives the message he tells his local UI to display ItemX. Then both hit the confirm Button that again will go trough their Characters to the Server who in turn makes the actual exchange of Trade goods and send a message to both Players afterwards so they know when they can remove their no longer needed local UI.

Hope you can See on this Example that the Server never knew or interacted with the UI or the Trading Players never tried to access the others UI.

Good luck and have Fun =)

avatar image DK Buzzin Mar 17 '19 at 09:13 PM

What are the nodes required for the server to be able to distinguish which clients are trying to trade and properly exhange the information between the two player characters involved?

(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