I’ve searched everywhere multiple times and I can’t seem to find any information at all on how to send data from the client to the server.
I had been developing a multiplayer project in Unity using playmaker and Photon, and from what I recall I just had to add a function to send data from the client to the server, but I can’t seem to find any node for that in blueprints, and the only search results I find are people discussing RPC’s but that won’t work for me. I want people to be able to setup their characters appearance/profile and then join a friend via IP to play the game, there is no way to achieve this with replicating custom events from the server, as they wouldn’t even be connected at the time. (I’ve also followed the Unreal multiplayer blueprint tutorial series and there was nothing regarding this in that either).
Does anyone know what method is meant to be used to send data from the client to the server, I’d greatly appreciate some help with this.
Did you watch the networked third person game tutorial videos on Youtube (or the video collection)?
They describe how all of this works. Start here:
Thanks for the link but as mentioned in my post I have watched that series (and followed through with/made the resulting networked blueprint project successfully), it only describes replicating events/functions to the server. It does describe replicating variables-but all the variables are being replicated from the server to the client, not the other way around. I haven’t been able to work out how to send any variable that is set on the client, to the server.
Hi SwiftIllusion.
One option would be to just continue to use Photon. It is not limited to Unity3D, but also available to Unreal Engine 4 as well.
For more information please see Fusion Introduction | Photon Engine.
You can download a Photon UE 4 demo package at https://dl.dropboxusercontent.com/u/4296291/PhotonDemoParticle-UE44.zip.
I appreciate the link however I only used it in Unity because it was the best available solution in that engine and it was integrated with playmaker which allowed me to use it via visual programming (I’m unable to do actual programming), however Unreal Engine’s core built-in multiplayer is far more flexible and offers a lot more freedom. I’m more than happy with the multiplayer built into Unreal Engine and I’ve been excited to continue using it after I completed the tutorial series and saw all of the benefits. I just wish someone could let me know how I send data from the client to the server as without that knowledge I’m unable to move forward with a lot of the early systems of my project I’d like to get working.
What do you mean by “send data” then? You can send whatever events or functions you want, at whatever time you want, to the server. How does this not let you send data to the server?
Btw: In general, sending data (rather than just UI/events) to the server greatly increases the attack surface for cheaters/hackers. There may be cases where that’s OK, but I’d be very careful about this in any game put up on the internet.
It’s not exactly clear what you want. Do you want to send things via RPC to the server? That’s in the tutorial.
For replicated variables, the server has authority. So for the client to dictate anything you’re pretty much limited (rightfully so) to RPC.
You really need to be more clear what you’re trying to accomplish with this client-server relationship. The answer to this question is dependent on this.
its very clear what the op wants to do, send data from the client…
this is a brick wall i came up against with udk, there was no way for a client to say to the server for example, i want character number 1 at game start.
sorry i cant help, will be interested to see if its the same with ue4.
CustomEvent called Send Character Request
Replicated:
- Server
- Reliable
Input: - PlayerState called RequestingPlayer
- Integer called CharacterNumber
<some sequence for querying the client’s character selection> -> Returned Integer -> Send Character Request.
(now this will only happen on the server)
Send Character Request -> take the requested CharacterNumber, find the character object corresponding to that number, and then set the RequestingPlayer player state to that number. If this is a character selection screen, like in a fighter, then you could have a replicated array of PlayerStates on each object that represents a selectable character. Every client will see then all the PlayerStates for that character, and could render their name on it maybe or their player index.
Whatever you think isn’t doable likely is doable.
Thank you very much for the responses however none of them solve my problem.
As tegleg said, I’m trying to send data from the client, to the server, not call a custom event on the server-I have already completed the blueprint multiplayer tutorial made by Unreal on youtube and I already know all of that.
To try and simplify/clarify my example in the first post-
What I want is to have variables that are set on my client by the player,
for example an INT (what clothing options the character has chosen), a linear color (what hair color the character has chosen), a string (what name the character has chosen),
and have them sent to the server.
A Replicated event will not accomplish the above for me, as the players will have set up their profile before they are even connected to a server (their profile is saved locally).
I haven’t been able to find anywhere how you are meant to do this via blueprint.
Okay, I understand what you’re saying now. What I don’t understand is why you can’t have the player connect to the server and then send this info? If it’s saved locally, you have access to that data from any level, even if you saved it in another. So once you begin play on the server, you call a server RPC whose parameters are INT, LinearColor, and String. If you want to do this more cleanly, you’d probably have to move to C++, but honestly it should be more than adequate.
Even if I were to connect to the server first, it doesn’t matter when I haven’t been able to find out how I can send data from the client to the server, which is why I’ve posted this question and am asking for help. Calling a server RPC won’t get me the variables saved on the client. Even if I set variables on the playerstate on the client, a replicated event on the server will just find the variables on the servers playerstate-which haven’t been changed, and even if I make it so people have to be connected before they can customize their profile-they won’t be able to save that data to their computer and just load it back later, because the server they have connected to won’t know that information, because I have yet to find out how to send that information to the server.
I’m wishing to know how I can send a parameter from a client to a server, I’ve done it previously in Unity without any issue, it doesn’t matter what level the players are in or at what point in the game the client has this information or where it is saved, etc, I’m just asking for someone to please tell me how to do this in Unreal Engine with blueprints so I can accomplish my desired result and move forward with my project.
The Client calls the RPC and passes the parameters…
EDIT:
There are 3 RPC types.
Client
Server
and NetMulticast.
Two of those are Server-to-Client. One is Client-To-Server. You are asking for Client-To-Server. I am giving it to you. UE4 gives it to you in the tooltip for each one.
I’m aware of those three RPC types and how to use them and I have completed the blueprint networking tutorial series.
While all of those allow you to call events from the client to the server, it doesn’t allow you to pass parameters from the client to the server-but it uses the parameters held on the server object.
For example if I set the value of an INT to 10 on a clients characterstate, then call a replicated custom event to activate on the server which adds that INT to another INT variable of 0, the result will just be 0-because the characterstate on the server still has an INT value of 0.
I’m trying to find out how I can send the value of a variable from the client to the server, I already know how to call events to the server.
Yes the int would be 0 on the server because you haven’t told it what the int should be. That’s why you have the rpc with your int parameter tell the server what the int needs to be. You then have the server set the corresponding value and now your server’s character state matches that of the client. If you want everyone to see the state, then you ALSO make the variable replicated - that way when the server sets the data that the client told it to set, everyone will also get that data.
Sorry I think I’m still being misunderstood here.
I believe I understand what your saying however that is not what I’m asking for.
Yes you can have it so that the client is connected to the server, and each time for example you change the hair left/right instead of having the event activate on the client, have the event activate on the server via a replicated event, which will accomplish a result.
But that is not what I want for this situation.
I want players to be able to create a profile and save that on their computer, then when they want to join a friend online to play the game with they can load their profile and send that information to the server immediately. I don’t want them to have to connect to the server first and customize their character every time so that the server can know what appearance/name they’ve chosen.
The reasoning behind all this is, you set your character info offline (before you’ve entered the server). Once you enter the server, you inform the server of your character info. Once the server is informed of your character info, it can do whatever it wants with it, like tell everyone about it or maybe spawn you a Character with that given info and have your controller possess it (how I would approach client character creation).
Thank you very very very very much!! Just tested that and it works perfectly :D.
I had no idea that adding inputs in the custom event would allow you to get data from the clients event to the servers event, because I thought that was only relevant to what the function may be doing on the server as I didn’t find any information to suggest otherwise, which led to my confusion when people just mentioned the RPC (I thought sending specific data must have been a different blueprint node I couldn’t find).
Again seriously thank you so much, especially thank you for taking the time to create that setup and take a screenshot of it, I can now finally keep moving forward with my projects gameplay development now that I understand this :)!
I’m very very very glad you figured it out and that you can keep moving forward
Hi guys. Finally I found an ally :D. Actually I’m a beginner and I want to know how to send data to a server and display it to my website. How can I do that? So far from your conversation, I can’t find any info on how to connect a project to a server. Thank you