Is there a way to get variables from widget and run on server?

Before I do replication mechanic for multiplayer, I placed a lot of variable things inside widget. Now I want those variables can also run to server(as replication for client)
but it seems not to work.

Widgets only gets spawned locally and can’t replicate.

You will need a replicated Actor or Component to handle the replication of variables.

Then how do I suppose to do if you customize your character through inventory or customization character widget?

You separate the replicated data from the UI by moving it to an Actor or Component.

The replicated Actor handles the data changes while the UI receives these updates and handles player Input.

This is similar to your normal Character Widget showing for example the health of the Characters by getting the health from the Character Actor instead of having the health variable within the Widget itself.

There is a list of classes which are excluded on Dedicated Servers in Project Settings, maybe can remove widgets from there and then load them

I would not work as Widgets are not meant to be spawned on a server so even if you force it by modifying the engine then a lot of things would start to break down and you would end up with a lot more trouble than it’s worth.

Why, you should be able to get a CDO for Widget since it’s UObject

You are right it is a UObject but it is not an Actor and to be fair I haven’t tried this experiment myself so it might work to some extent on a listen-server but I highly doubt that it would work on a dedicated server and it would most likely create some unintended behavior.

Note that the “Create Widget” node is “Cosmetic only” meaning it would have to be remade into a Server Authority node as well.

So even if it is possible to Replicate a widget it seems more logical and extensible to just create a replicated Actor and separate data from the widget to begin with.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.