Hi!
I have fore quite a while been trying to make it possible for two clients to pickup the very same actor/object (in this case a sphere) and then replicate the movment of that sphere to the same movment as the client that last picked up the object… however… no matter what I do, the server always seams to be “king”…
I have managed to replicate the movment from a listened server to a client… however… the other way around (from the client to the listen server) I have not managed…
Basically what I have now is a simple script for moving the sphere… and checked the actor to replicate and replicate movment…
Is there anyway to tell the server to use one of the clients for the replication and then simply just switch between the client currently “owning” the replication?
what I did for people carrying things in an online game, is create a physics handle and have the server multicast it so that everyone saw the client pick something up. that worked out pretty well for me.
if this is not what you wanted, just let me know.
the problem is in that branch where it says “authority or remote”. you have the remote branch goes into that move self node, which will only activate if the server activates it. it’s a paradox essentially. what you want to do, is add a custom event to the remote , that asks the server to run your move self event. that should fix that part, but then you have a smaller problem. you do not want to call the event on the server every tick. instead, have the is picked up variable trigger picking something up on the server when it’s activated, and then drop the item when deactivated. that way they sync up twice instead of every frame. that would make your game lag in the long run.
Ok thanks for the guidens… however I must be missing something very essential as far as networking goes…
This is my current blueprint:
So… this is what I expect to happen…
- The remote(client) gets the mouse input and interpret it to a point in the worldspace.
- The client then calls the server to move the actor based on the points calculated in step 1.
However… when debugging this… the server never seams to fire the Move Self event… its just stuck just after the switch has authority node…
I was assuming that the Move Self event would be fired once the client calls the event… have I got this wrong? If so… how do you trigger an event from the client thats supposed to be executed on the server? Any ideas?
ok, but I guess the part I still dont quite get is… how would I go about creating an event thats triggered by the client/remote but then fired on the server?..
No matter what I do it appears as the client cant communicate with the server…but only the server to the client.
Would it be possible for you to provide me with a very simple screen shot of such a setup?.. would be very much appreciated!
Thanks in advance!
Sure, I don’t mind at all. You need 4 custom events in total. Two that tell the server you picked up and dropped something, and two that do the work on the server. then on tick, you check that variable and move it if it has authority. this will cause the server to move the object, and if the object is set to replicate, everyone will automatically see this.
Thanks for sharing!
I made the changes… but the client still seams to have problem to communicate with the server (or sending the values to the server)
This is my current blueprint:
The thing is that the ActorOnClicked I assume is only executed on the client/remote… which then I guess makes Ask Server to carry something also to only execute on the remote… however… Ask Server to Carry something is not fired on the server (at least not when playing and checking the debugger and setting the debugger to debug the server… basically the only thing thats triggered on the server is the Event Tick and it gets stopped at the first branch since carrying something by default is false).
Another thing I dont quite get is that to calculate the new position this has to be done driven by the mouse input (and I guess that inputs are not sent from the client to the server… so basically the server has no idea of the mouselocation for a specific client… however… I guess if I managed to get the Start Carry Object server event to fire from the remotes-request I could sort of pass-along the location value as well.)
I know this is alot to ask… but if I upload my project to git (its only 100mb)… if it doesnt take you more than a few minutes… could you help me get this going? Just so I have something to elaborate with and so I can get the basic hang of it…
FYI:
I have marked the two parts in my screen shot that I guess is only executed on the client (1 and 2)
I might have figured out why this isnt working… but please correct me if Im wrong…
The replication of Custom events (for instance Execute On Server) can not be used if the event is part of an actor-blueprint? (Basically my entire script is a part of an actor)…Could this be the reason to why I can’t get the events to fire?..
I just tried by createing a very simple custom event and set it to replicate and to run on server… and then simply called on that event once I press the A-key… and placed this script in my PlayerControllerBP instead of the actors BP… and then the event did fire…
I don’t mind looking at your project. it would give me a break from my usual work. also, I forgot to mention in my example, that you have to calculate the location on the client when it first starts, send that across, and have the server keep things updated. if you use get player controller on the server, it will return the host location, or if a dedicated server, it won’t return anything. that’s why what we have now isn’t working. if you upload a project for me to look at, I’d be happy to look at it and get it working.
Think I actually just managed to get it all working… now its just to implement this bad boy into the HTC Vive and do some cool stuff :D.
Here is what I ended up with:
https://bitbucket.org/Inx51/replicationlab-open-sample
Please feel free to come with improvments if something comes in mind.
MPUS - Multiplayer Pickup System in Blueprints - UE Marketplace This Should Help You Out !