I’m trying to build a super basic chat system to learn a little about the networking in UE4 but am struggling to understand just how the replication works.
Looking at the following link makes me believe that that I should be able to do this all in the Character Controller
Here’s what I have for my blueprint:
This works to some extent but it completely freezes all input from whatever client didn’t send the message.
Here’s a look at how the receiving client ends up after the messages show up on him:
Here’s what the client that sent the message looks like – this is pretty much identical to how the other one looked before receiving the message:
What about how I have it set up causes whatever client didn’t send it to freeze? Is there a better way to go about doing something like this?
how i would build Chat
as replicated actor, which exist on server and on all clients
it contain array strings, which is not replicated
1.when player send message, it goes to server and save into array
2.there are looping timeline running on server, which get all items in this array and based on some frequency call Multicast Event which transfer those strings into all other clients, than clear array.
3.Multicast event, when trigger, add all messages into current player HUD.
done.
so try to make it, if you are not cappable here i made it for you =)
free for commercial bla bla bla
around one hour spent
im not gonna develop this further, 2-3 more hours and this would be the same as marketplace one, i feel kinda guilty even now =)
I put a couple of debug messages in to see what happens and to better understand what you are doing:
LogBlueprintUserMessages: [ChatSystem_C_7] Taking control with: Player 278
LogBlueprintUserMessages: [ChatSystem_C_7] Getting game hud for:Player 278
LogBlueprintUserMessages: [ChatSystem_C_8] Taking control with: Player 1105
LogBlueprintUserMessages: [ChatSystem_C_8] Getting game hud for:Player 1105
LogBlueprintUserMessages: [ChatSystem_C_9] Taking control with: Player 664
LogBlueprintUserMessages: [ChatSystem_C_9] Getting game hud for:Player 664
Looking through your setup brings a couple of questions up:
It appears that you use GetPlayerController[0] twice in the begin play of the ChatSystem. Is it safe to assume that this is always the local player? That’s what it appears to be doing.
It doesn’t appear that the Switch Has Authority is ever called for the remote user.
What is the purpose of setting the Owner? Is Ownership client side or server side?
It appears that there is a new ChatSystem actor for every player? ChatSystem_C_# for example. Is this the replicated one that is on each client?
As a follow-up to the previous question, when exactly does the level blueprint run? Is that run on the server at start and on every player loading the level? Is it correct to believe that only the server has authority in the level blueprint?
Edit: I’m trying to go step by step through what you have done. First I am simply trying to recreate a very stupid send/receive message thing using an actor as you have done. My current issue is that it ONLY works for player 1. Player 2 and Player 3 get the following message:
Any ideas on what is incorrect to be causing that?
player 0 its always local player with ID 0, in case of split screen there are might be more than one.
switch has authority called everywhere, but it split executables for remote and authority
its more of the programmer ideahow the stuff get replicated over network than actual place
chat system actor is “only one”, spawned by level blueprint triggered with authority, which means on server. But actor is set replicated for all clients connected to the session, so it exist everywhere, but all remote one is the copy of main, so created and saved chat widget, is not replicated variable and since they trigger on every client (begin play) they all have different values representing different widgets.
yes.
its kinda cheezy initialization, but as example is ok.
also there are was a bug, related to multicast happening on dedicated server as well, which cause log spam, so you can add the branch for it or download updated link in the original post.
also i fixed enter
Whatever you did on that latest one, Edge decided it’s not safe anymore. I did notice your server trying to do things on a None variable, I’m going to assume that’s what you fixed.
To be honest, I don’t know why I’m struggling so hard with this. It’s really not that overly difficult of a system to figure out the basics of.
Here is a picture with my understood flow (for the most part not completely everything). Where you see the // across the path is where my system stops working. It’s almost like the owner of my chat system actor isn’t being replicated to the clients? Can you help me figure out where I’m going wrong with that?
for what i can see, i would guess, you are adding message directly from a widget to the chat actor, but instead you should use a controller event run on server as redirector from a local widget to the server chat actor.
Lets try this one for the picture and see if that’s better.
I am actually calling the Run on Server event in the Player Controller. I will attach the project that I am working in to try and get it to show up. It attempts to send the event when you hit enter in the viewport. Nothing fancy.
here -> http://puu.sh/l4Efi.png
as i said, REDIRECTION
from a local space of your inputs and controller to the server side of your controller
not replicated objects(widget, press enter happens only local too) cannot cannot call function on “another side” of a different object, i guess its has something to do with how the event replication and casting works, im not a programmer so i dont know how those build, i just know how to use them.
also, idk is project editor settings is your main one or those which just a default for share project, but i recommend you to turn off open assets in new window (matter of taste) turn on favorites and arrows
favorites on rightclick, to add/remove function click on star before function name, add custom event is most useful one
btw, how you build those graph, is there any tool, or just paint?
I built the graph using draw.io, there are some other ones out there, but this one lets me keep it super simple without any extra goodies. https://www.draw.io/
So, it sounds like my problem is that:
You can only call the same side you are currently on, unless you switch your side in the current object.
That is going to take some work getting used to. Thanks for all your help!
As for the settings, thanks for the suggestions, I come from Unity and didn’t realize that there was so many options. Some of these are super cool.