Replicate 3d widget navigation

I have a cannon that receives input from an actor with a widget component (3d widget).

If player A presses charge the cannon, it creates a progress bar that fills up then opens a new widget allowing you to fire the cannon. The issue is only player a can fire the cannon, player B still sees the charge button, and vice versa. I want either of them to be able to charge then fire the cannon.

What is the best method to go about this :slight_smile:

Here is some psuedo code to show my methodology and the order of events for ease of understanding

Since widgets in Unreal Engine do not have replication, you need to write logic for handling clicks on widgets in Blueprint.

You must notify the server that a button on the widget has been clicked.

After changing the value of the variable ON THE SERVER, the RepNotify function will be called on the server and all clients, which will allow you to change the appearance of the Widget for everyone.

Using RepNotify will also allow clients who joined after another client clicked the widget to see the latest information.

In order for the client to call RPC Events on the server, the player controller that will press the button must own Blueprint.
For an EXAMPLE, I did this on Begin Play. In this case, only one player (Client 1) will be able to interact with the widget.

Also, do not forget to set the Replicates flag in the Class Default of the blueprint.
Otherwise, RPC Events will not work properly.

1 Like

Made an example scene that shows how to accomplish replicated cannon with ui.

There are actually a couple of extra steps to get it working with the widget interaction component.

Ah I didn’t understand why you were going back to the actor bp to do many things but I missed the first line, that makes so much sense why I couldn’t get rep notify to work in the widget then! :cry:

I feel like you’ve answered my post, after I get it working I will mark it as solved

I’m confused about the beginplay line in your screenshot, can you elaborate the purpose for that? And it is in the blueprint correct?

In order for an Server RPC Event to be called by a client, the client’s player controller must (ultimately) own the actor in which the Server RPC Event is to be called.
Otherwise the event will not be called with the following warning:

Initially, the client only owns its player controller, then the controller becomes the owner of the pawn, allowing RPC events to be called within it without any problems.
But other actors in the level do not initially have an owner, so RPC events in them will not initially work as expected.

1 Like

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