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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Client Call an Event on an Unowned Actor

I'm trying to build a multiplayer game that allows players to open a door when they click on it. Here's my code.alt text

May not be the best for optimisation right now but that's an issue for another time.

Currently the door opens on both the server and the client, allowing both to walk through. But it only does this when the server clicks on it. The ActorOnClicked event is run when the client clicks on the door, but the ToggleDoor event it not.

My understanding is that this is because the client doesn't own the door actor, so can't call a function on it. I don't want to have to spawn every door for every individual client, partly because this makes level building difficult and because I think I'd be throwing any replication of the doors in the bin.

I'd appreciate any suggestions for solving this issue.

I'm still new to multiplayer programming and this is an attempt at learning some of the basics. I'd be very grateful for any assistance.

Product Version: UE 4.21
more ▼

asked Nov 11 '18 at 07:22 PM in Blueprint Scripting

avatar image

31 1 3

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

3 answers: sort voted first
more ▼

answered Nov 16 '18 at 12:01 PM

avatar image


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

To make a successful client-to-server RPC (execute on server node) happen it must be called from within the blueprint of a class that is part of the connection-owning hierarchy, such as a playercontroller. Doing it from a blueprint that is not will unfortunately silently fail.

So usually I will have playercontroller get the Game state and use that to call the event on Server. So it runs on the server's gamestate and from there it finds the door actor and tells it to move.

The trick is going to be finding the door actor from within the gamestate to tell the door to either multicast or set repnotify the door open boolean variable (either of those methods will cause the change on all clients). This is where it comes in handy to set Tags on your actors placed in the level because then the server rpc event can do a GetAllActorsWithTag using a string or Name fed into it from the event node (you can add parameter variables to those to send information through) and just Get index 0 from the array that GetAllActorsWithTag node returns.

As for telling your timeline to play AGAIN every frame, 60 times a second, I think there are better ways but the networking is the tricky part so I focused my answer on that.

more ▼

answered Nov 11 '18 at 08:01 PM

avatar image

3.8k 18 20 20

avatar image OneViGOR Nov 11 '18 at 08:13 PM

Thanks for that. I'll try and see if I can get it working through a game state. And yes, I agree that calling the timeline on a Tick event is a terrible way of doing it. I originally wanted the timeline to run at the end of the ToggleDoor function but for some reason it didn't allow the door to open on the client. It was just a quick fix, really.

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

Hello, RPC functions should only work on actor classes, maybe also on actor components not sure right now. Is your AnimationHelper also derived from the UObject class, I wouldn't know how that can actually work in networking. So simple solution just move your code over from the helper classes to the character and player controller class. If you want helper classes to outsource some functionality I would advice you to use components instead of uobjects anyways because that's how the framework is meant to be used, allows you to customize the components in blueprints for example. Usually a good approach in terms of networking is to give the clients as little control as possible and minimize network traffic, if you have client side hit detection run a server RPC on the character that the player hit something, the server then applies damage and calls a multicast RPC to let all clients know they need to apply damage locally as well to trigger the recoil animation. Also your RPC's are a little bit too universal in my opinion, I would rather have RPC's like ServerSwingSord and MulticastSwingSord, that way it is easier to avoid malitious data sent from clients and you reduce the data amount for every RPC quite a lot.

more ▼

answered Nov 14 '18 at 09:13 AM

avatar image


(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