Blueprint RPC for non owner

I’m trying to have my player be able to open a door that is spawned by the server. The problem is I can’t use a “Run on Server” event because the player pawn doesn’t own the door. When I run the game with two clients the server window can open and it will replicate, but the Client 1 cannot open the door because EV_OpenCloseDoorFull (below) will only fire if the server calls it.

Excerpt from unreal tutorial on blueprint networking.

“Server RPCs can only be called by a
client who owns the actor executing
the event graph. For example, a
PlayerPawn is owned by the client who
controls it - only that client can
send Server RPCs on that pawn. The
pawn also may own weapons, abilities,
inventory items, etc (this is game
specific). This can be a hard concept
to communicate directly in blueprints.
It is something we will work to
improve as time goes on.”

How do I ask the server to change the state of the door so it will open and replicate to all clients?

11179-openclosedoorevent.png

If you create a custom event, you can create a node that triggers it. So if the client opens the door, you plug in that specific node of your “EV_OpenCloseDoorFull” Event.
After that, the server will execute it for the client. I show you a picture of my blueprint for destroying an item as client.

So let me explain what you need from this picture. Ignore the “Find usable actor” “branch” and “pickupitem” nodes.

The red “Destroy Item” Event is the one you have as “EV_OpenCloseDoorFull” ok?
So you can create the blue “Destroy Item” Event by rightclicking and searching for it after you created the red one.
If someone now presses the Input on the left side of my graph, he will trigger the blue event. That will trigger the red event on the server and finally let the Server destroy the object.

You can specify inputs if you click on the red event (bottom left where all input/outputs are definied). This will add inputs to the blue event and outputs to the red one.
So at my example this script is launched on the character, so the server doesn’t know what item the player is really looking at. So the player gives the server the item with an input in the red node.

If you don’t understand something, please ask. (:

http://puu.sh/arDvJ/a7495b654a.jpg

I should have been a little clearer. My code is running inside a blueprint that contains the door, not my player character. I’m using an interface to send a message from the player character to the door. I would rather not have to code every interaction inside my character. Unless I’m mistaken what you’re showing is all happening within your character blueprint.

Below you can see the chain of events:

Player presses use → Raycast to find actor it hit → Sends message to door (using interface)

Door receives message via interface function and tried to execute EV_OpenCloseDoorFull on BP_SmallDoor which is owned by server. Again, this works from the server window, but not the client window.

11238-int_onuse.png

I would absolutely love to hear what others have to say on the matter. I’ve been trying so many different ways to get a door working in multiplayer and never quite succeeded.

Sorry, but i don’t know how to use the Custom Event inside your door graph, but if you put them behind your Branch in your Character Event Graph and let the Red Custom event call the function of your item it should work.

You also need an Input in the Red Node so you can give the Server the Hit Actor. Without that he can’t know which door the client meant.

And in your Door Graph you just call the print if you want and after that the “FOpenCloseDoorFull” function.

That should definitly work. Remember to set the door to replicate!

Ah. I understand now what you were trying to show me. I need to have the replicated event be on my character, and not in the door blueprint. Once the replicated event (that is set to Execute on Server) happens on my character it can call the function on the door (via the interface event). I had it backwards and had the interface event the one that was set to run on the server which did not work because the door isn’t owned by my character!

For anyone else looking this up this is what works for me now:

  1. Character presses “Use” key.
  2. Line trace to see if we hit an actor
  3. Test actor to see if it implements “On Use” interface
  4. If it does call a replicated event (run on server) on character that has an input of Actor (pass it the actor we hit with the raycast)

  1. Have the replicated event send the message to the door via the interface which will now happen on the server!

11248-int_onuse.png