As soon as you have something that should be replicated you need to call a funktion from client to server.
So a custom function “run on server” with the input you want to change. If your client wants to change something you need to call the event and give the event your variable as input. The red custom event gets this variable and sets it for everyone.
Why would you replicate that? The mouse position is something only the clients need. You only replicate something that everyone needs to know. Like the health if you want to display it for everyone. Have you seen the network tutorials from unreal on youtube?
Yeah you’re right in the sense that I don’t want everybody to know. For the mouse position part, the server needs to know where the client is trying to target in space to be able to tell where I’m trying to shoot for example.
So you want the “mouse” position for the server to check if the player hit or not?
Hm, you could make the line trace client side and give the server the hit output or you can give the server the position of the start and the end of the line trace and let the server do it. So that the server actually checks if the player hits something (because he knows where everyone is. HE is the one, who has the 100% legal map and player positions).
It sounds a bit too much checking over the net, but nowaday we got good inet connection, so it doesnt matter if this little information is send.
You only send 2 Vectors from the player to the server.
Everything else is done on the server. He checks if the player was hit and deals the damage (maybe give the server the weapon you used, to calculate the damage). Than he replicates the new health to everyone. Thats how i understood it. (:
Except that my problem isn’t really about what to send or how to interpret my data but HOW to send it using the blueprint scripting. Because basically it’s like a replicated variable like the player velocity except that it’s a vector I want to send aswell but not be replicated to all the other clients.
Like this? (Ignore the OnBeginPlay, just needed something)
You call the function that is “RunOnServer” and give him two Variables.
One that is Replicated (So you set it to a the provided Value)
And one that is not replicated but send to the server to use it.
If i still don’t understand your problem, than sorry ): Doing my best to figure out what is causing the trouble.
Well I think I’ve found the right way to do it on the Unreal Engine Wiki. I actually have to use a replicated function that isn’t considered reliable. Otherwise it would cause problem since I’m sending a lot of these.
I’ve used the same thing as what you did for my firing event except that I’m not using a variable for it.
What I actually need to do is send an unreliable replicated function with my data to the server that set a variable on the server that isn’t replicated.
I got confused because I though those replication function was supposed to be used only a few times based on the tutorial I’ve seen.
I thumb you up since it was the right answer even though I knew that but I wasn’t sure it was optimal when you are doing it very often.
I really appreciated that you spent that much time to try to help me, thank you for that!