#multiplayer
1 messages · Page 181 of 1
sorry if i sound rude, but from my point of view you are not answering my main question
i am tho
and whats the link between your ID var and the collisions system
you'd use the ID to target which box you want to change collision instead of having to make a unique channel
okay, you change the collision on server or client ?
because both have issues
server :
client 0 and all other clients will have the same access to box 25 than client 1
client :
the issue i have rn
always have the server as the authority and the client should follow (but can also predict correctly to help out with lag compensation)
this would work if on a dedicated server scenario
listen is still the server tho
.
what's the issue?
if you run on server :
for the collider of id 25, disable collision
all clients can now go inside box 25
So if you just want a specific client to go inside of box 25 but not others then you just need to expand the system a little bit so that you have an ID for the client as well. Then you can make an access list something like:
Box 23 - None
Box 24 - None
Box 25 - Player 7
Box 26 - None
Box 27 - Player 4
you are not explaining the collision part
how do you deny/authorize a capsule to overlap within a box using those infos
That list would be replicated to all clients and would be used to determine IF the collision should change. So say there's a hidden box collider positioned just in front of the cell bars and OnBeginOverlap it calls some event "CheckCollision" with the box id and player id as arguments. Then you could check incoming data against the access list stored on GameState and adjust accordingly for the actor that triggered the event.
this wont work
if multiple players are inside/outisde and gets in/out this would fk up
no because you'd set it up to only change the collision on the actor that triggered the event if the box id and player id are valid according to the access list
if theres other players inside of the overlap area then they'd just fail the check silently and nothing would happen
yes exactly
if (GetMesh()->GetAnimInstance() && GetLocalRole() == ROLE_SimulatedProxy)
Why does it returns true for game server?
Under editor
Are not simulated proxies a client only thing?
I think it is a problem of Iris networking somehow
If it's advised to handle animations and sounds on the client, notify the server, then have the server play those same animations and sounds for the rest of the clients, how do we avoid playing an animation or sound twice on the client?
By filtering the local client from playing it again?
Right, but what does that look like in terms of implementation?
Depends on what you got so far
I typically just check if the role is autonomous
Yeah or IsLocallyControlled()
There is a PR out there that adds support to filtering RPCs
So you could skip some connections for an RPC
Which would be another way to solve this problem in some scenarios.
For filtering local client that shouldn't be tooooo complex
Yeah @magic helm did the work
I have been summoned?
Just talkin' about that RPC PR you did that is probably sittin' in limbo right meow
Ehhhh semi limbo... basically somebody at Epic is aware but its one of those "Anybody thats tasked with looking at it doesn't wanna do it because of how significant it is" since it impacts perf for BP across the board
I tried to make the most minimal change but I have two branches of it linked in the PR
https://github.com/EpicGames/UnrealEngine/pull/11578
Shoot I wasn't even aware of actor roles lol
But if I execute an event on the server by checking that it has authority or is the server, that just happens for everybody, right? So how do you actually filter the client that triggered the event out?
There are only ever 2 situations you'll be in:
- Client plays animation and then does a server RPC to tell everyone else to do the animation - for this, you'd just do what cedric and I said
- Server tells everyone to play an animation - the animation hasn't played anyway, so the client needs to play the animation.
So on the server it has an array of all the client connections. The filtering is done via the actor which has a pointer to its owning client connection. So its a simple "Is this connection the same as the actor's, no? Ok then thats simulated proxy. Yes? Then thats the owning client connection"
@sweet sage @thin stratus I do recommend upvoting this PR that does that, dont know if it helps anymore but just incase https://github.com/EpicGames/UnrealEngine/pull/11578
I appreciate the help. I don't really get how the filtering would happen, but I'm working with blueprints so maybe that's where my confusion lies. Maybe less granular control of how replication happens? I'm not sure.
So pretty much the thing(object) that handles UE's replication/RPC's is something called the Net Driver. Its like the brain of it all. And thats where we have all the connected clients(on the server). And each client is an object called a Net Connection(literally thats the name of the object without C++ syntax). Every actor has a variable for its Net Connection which is the owning client. That variable is only valid on the owning client and the server(because on the remote machine its a Net Connection to the server instead). The net driver just then is filtering the same way you would check through an array of actors by getting the actor's Net Connection variable, and then iterating through an array of Net Connections
Hopefully that makes sense?
i guys i want to create a loading screen to my host game button from the gamedevraw mp game tutorial and like this it doesn't host the game
and like this it doesn't show the loading screen
Yeah it does, thanks. But in terms of actual control flow, let's say I have an actor that does something requiring a sound to play. That actor plays the sound locally, then triggers a custom event that is set to run on server. In blueprints, that's all I get for control over that process as far as I know. I'm not aware of a way to iterate through the list of connections and handle the event for each client while making sure to exclude the original owning client.
Yeah thats something only the Net Driver is allowed to handle. I cant do that from an external object in C++ btw. The PR I made gives you more options basically because its not an easy change that can avoid blowing things up sort of thing because a lot of other network connection stuff needs to be done for security, data safety, performance, etc...
If you are working with Blueprints, you can use a RepNotify with Replication Condition SkipOwner/SimulatedOnly. Trigger the animation and/or sound inside or via the notify function on the client (locally), and also call the RepNotify function on the server using a Run on server RPC.
Then the notify will be called predicively on the owning client, and the server will run the function on all clients except the owner/autonomous proxy.
@magic helm can you help?
Yes but that can impact CPU performance because the server wastes CPU time iterating through each replicated property and comparing those properties and I've been on projects(including the current one) where our CPU performance on the server is at its limit and a lot of frametime is spent just checking replicated properties
Ah, that's a fair concern. I don't know any better ways to do it with Blueprints only though. Doesn't it depend on what you're doing with the notifies, or does it just cost a lot to compare the properties anyway?
It costs a lot just comparing the properties, the literal "Does this equal this" check
For smaller games, its not a problem. But depending on the game, it can hit you hard
Yeah, makes sense. I did some profiling, and the CPU for the replicated properties didn't really stand out to me.
I tend to link people this article to explain it easier
https://playvalorant.com/en-us/news/dev/how-we-got-to-the-best-performing-valorant-servers-since-launch/?linkId=100000192373791
It sounds like best practices for multiplayer replication are most easily doable via C++. I guess I should get around to figure out why VS doesn't recognize UE namespaces
Because you need Resharper
C++ in UE is unfortunately, very much, a pay-to-play type deal
Naw its just more tools in the toolbox, you can build a game with 90% BP for multiplayer and with all the game code being in BP. Its dependent on the game
Rider all the way
I feel like for a coop/sandboxy game, going the repnotify route might be fine. Latency/server performance won't be as critical as a pvp shooter like Valorant
If you're doing a dedicated server, it can. If nothing else, for cost alone.
I can tell you from experience, thats not true
Not saying it is a must - but it isn't as cut n' dry as "is this pvp or not".
This same paradigm was used by WatchDogs 2, its not a "This is a closed env FPS game" this is a "Its a online multiplayer game" paradigm
Cod Warzone is fighting the same issues, thats why their servers crash so much on launch
Hopefully Iris can help in this regard as well (not something you should be worrying about right now miles!)
What's a better way to replicate game critical animations if a RepNotify isn't optimized for CPU? Is the way GAS does it more optimized?
Oof. Okay
Thanks for the reassurance lol my biggest fear is getting too deep into the dev process implementing bad practices that I'll just give up instead of going back and fixing them
You make it data oriented(data assets) so you just replicate ID's(integers or tags usually) and locally resolve the animation to play. GAS does the same sort of thing
BTW the biggest CPU impact after you build it that way has always been animation lol
Sea of Thieves talked about that where they were bottlenecked by animation CPU time as well... haven't found a project that hasn't fought that bottleneck... physics objects ontop of that is a double layer cake of pain
So like, mapping small primitive data values to specific animations/sounds?
I guess I'll change my suggestion to just use GAS xP
What's GAS?
Something you put in your vehicle so it can go from A to B
BOOOOoooo
The TLDR is - think like RPGs/MOBAs abilities
Allows you to easily create that kind of stuff
And you can get quite general in what is an "ability"
Like, in Fortnite - shooting is an "ability"
Jumping is an "ability"
Stats and modifers as well
It was made for Paragon and then used in Fortnite. Its a great base framework don't need to use everything and it does not solve all your problems
But it has good paradigms
The best part of GAS really is the Gameplay Tag system. LOVE IT
And you don't even need GAS to use that
use gameplay tags everywhere
You can do this with GAS in a more optimized way I suppose. Just look into the gameplay abilities part of the plugin to begin with, they're basically replicated in a predictive manner for you.
Is anyone using Mover successfully with Iris? I noticed that as a client the state machine seems to be fucked and I get many warnings about network prediction proxy having descriptors generated
weirdly it works if you're the server or standalone
You can override that function and
Hey there so im having a issue im trying to call a function that i have to apply damage in my AI
so i run it from an anim notify which does run the function but it would only run on client i tried making a event and make it on server but it would just ignore it i even tried to run the event and the function after the multicast event that has the play montage but still the event gets ignored and the function would run on the client and would return damage as 0
does repnotify fire on beginplay or when that pawn is possessed automatically?
Repnotifies will fire when the value is received. Normally if a value is set that differs from the default, it'll be sent along with the actor that is replicating, and it will trigger the rep notify basically as soon as the actor starts (effectively on begin play, but not exactly)
Okay. I was just wondering if it would get fired twice since I'm repnotifying before I possess and new pawn and when I reenter the pawn. I knew it fired when actor spawns but wasnt sure if I would be firing twice
If you're doing it in blueprint, then setting the value could cause the server itself to fire that repnotify.
Yeah, I'm trying to figure out why attaching character to vehicle works the first time but not after exiting vehicle and trying to get back in still
even though the rep functions firing with correct values
so when i run the server apply damage event right after the play montage it would work fine but if i do it on the on notify begin it wont run
why is that ?
Does a RepNotify also automatically update the value for the clients or do you need to set the value in the OnRep function
its a replicated variable so setting on server would replicate to clients
thanks
Question: What's the best way to handle player indices in multiplayer (non-local)? Should I just add them into an array/map on postlogin in the gamemode? But then what about handling disconnection/reconnection? Basically I am asking if there's already a structure in place for handling/storing this information built in.
Edit: The reason I need this is because I'd like to spawn objects and assign them to player X at the beginning of the game, so I need some way of determining that you're player X.
I think you answered your own question
server seems replicate adding components before destroying components regardless of call order, is there any way around this to guarantee the intended call order?
Okay, I'm just making sure there isn't anything already in place or some standard procedure everyone else does. Just learning
i am calling this Run on server event which sets an OnRep variable inside a for each loop. The problem I am having is that the clients only call the onRep function after the for each loop is finished, so once. I would like the clients to call it each time after each set of the OnRep variable. How can I achieve this?
The client will call OnRep function whenever the variable in their machine changed in value.
There is no time you can measure , it depends on latency etc
how can I control this considering these facts and find a solution?
What are you trying to do?
for each loop this setup updates a trait of the character component with the customization items stored in the save game
Who's save game?
DT stands for data table
I have this handled, everything is working and replicated besides that the clients are not calling the OnRepNotify function directly after the server and instead after the for each loop ends
can't I force the server to wait with the next loop until the clients ran the OnRep too?
or call something to make them run it right after the server did
Loop happend in a single frame anyway
No and you probably wouldn’t want too 😂
imagine the server waiting for a client to do something CHAOS I SAY
Your appearance can be as simple as replicating the skeletal mesh comp.
Data loading is handled server side
In the server you will set the skeletal mesh comp (replicated) after loading from w.e data u want
Client will simply receive the updated skeletal mesh
For my case, I have my client sending info for it's custom. My game is listen server with no concern of cheating.
So client read its save file, send data to server.
Server load the data and set the skeletal mesh
I’m not sure if you own it, but universal character system does something very similar to what your trying and it’s replicated
Actually scrap that, that's not what I did
I replicate a struct
Loading is handled on client side
Now I’m changing some of this, but they have a map that lets you customize your character and store a string of info to a save game
yea that's how I do it too
At run tkme that string is pulled from save game and replicated
but I don't own it, no
Sounds like ya don’t need too if you already doing that haha
Now they are using a component to handle this that is replicated
That might be the difference not sure
Maybe you can wrap appearance dt and ID in a struct.
On the struct OnRep. Load your appearance data
the same setup inside the character blueprint does work. There it doesn't make weird things and actually calls the onrep for each client after the server runs it every time
but for this case i need it inside the player controller
and it does work for singular changes in the customization tab
but the for each loop is being weird
that wouldn't fix the issue probably of having them call it more frequently I guess
does the OnRepNotify fire even if the setted value is the same as it already is?
I believe repnotifies only call when the value changes
Not sure I understand this.
it does change but still the clients only run it after the for each loop ends
I would sync customisation data via a struct.
Struct changed -> load customisation data. Call it a day
This is weird way of looking at mp
Client don't care about the for loop what so ever. It just do something when the replicated value arrived
A string like they are doing is honestly probably better
Is this blueprints or cpp
Exspecially if they wanna back that up to a DB down the road
You should start testing your project with ping too
But I suppose different ways to do it
I am actually doing that
that's why I went with string
and it is working like a charm in every way whatsoever so far
Yep there ya go wondered if that was the throught process
Why do I need a struct for this?
Like I have said, the string is changing
Because u won't have race condition if you need both the DT and string
And u can handle the loading in one single function
Are you doing all of this in a single frame?
yea
Ok when I have issues with stuff like this I make timer loops
You need a short delay like 0.1 seconds
You need to allow time for the replicated variable sometimes to exist for a few frames
maybe i do that skip a tick node thingy I saw somewhere
Send them over a single love letter instead sending clients 2 letters with no order, each with the same instructions ( to load )
I’m glad I’m not the only one that throws a delay in to fix an issue 😂
Not delay. Timer loops
Welp I’m exposed
you mean, a map variable? Doesn't need to be a struct
How does delay gonna fix anything?
Wrap it in struct
by being lazy 🙈
Map is not replicated by default
what is the difference?
Delay stops code
yea that's why I split it into two
oh okay
You do BP or C++
Ugh, wrap it in a struct? Well it's up to you what you want to do down your road
right now bp. Gonna redo the heavy parts in c++. Not gonna do everything in c++ if many things are fast enough in bp too
don't need the headache xD
No stress I just wanna show either way
How can I do this work on every player? I cant find a way to get owners player index
If you ever do things with animations as well on replicated variables timers will save you
I do like 0.05 sec delay
That index is useful for local multiplayer (split screen)
I will try it with a struct
What are you trying to do anyway?
It returns the locally controlled player at index 0, for each machine that's the player
limiting view pitch of every player
in which bp is this
player
player character? Player controller? Player state?
player character
this I would say
do this once at the start and make the output of the cast as a parameter
then you can reuse it
so this is what should I do in other cases when I need to get player controller from owning actor
are too big values for walk speed an issue for character in multiplayer ?
thanks
with 3000 and an emulated network at 30ms ping and 1% packet loss, it is quite janky
This is my loop that scans and damages enemies if you just take the Time on the event in your loop and set the delay to like 0.1 or even 0.05 as it cycles through the loop it'll give it time to replicate
yea this gets the controller from the owner of this character (or so called pawn) . Cast it to your own player controller class, I used mine here that is called BP_BasePlayerController
Pretty sure you will need a Client RPC to execute the code in Client machine
Thank you
though normally, I would handled Camera locally, I have no context in what you are doing.
Well this is working without using any casting or replicating, but I generally dont know what to do when there is a player controller input in a node.
So that trick will help I guess
Clients only have access to their own Camera. So if you execute this code in the client, it will return the client camera manager
multiplayer
yea my bad, remembered the channel name xD
basically rule of thumb imo, don't use these " get " nodes with player index 0 if you want the code you are using it for to replicate or work for multiple players
I am not even sure I should handle camera shaking like this, but it works fine rn
Like what was I supposed to do here?
Its working but Im sure this isnt how I supposed to do it
@dark parcel now tried just this to have it loading only one variable and still same issue
so i don't think a struct would help here tbh
If this runs locally, you will get error with multiple players.
Because in client machine, they only have access to their own controller. Try to add players in Pie, then check to see if you have Accessed None
this is how I call this event btw, maybe it helps
Well that code is somehow working flawless
Why are you using delay?
I dont get how
this call happens in begin play but before it there is a "is local player controller" branch
Im not sure what you are tyring to do here at all
So what is the intented way I should handle this if I want to give camera shake to players?
If you need both the ID and DT, wrap them in a struct. Then Set the struct on server when you want to update the Struct.
Client will Receive the struct value on RepNotify, you can then break the struct in the rep notify and plug the DT and ID to load your customes.
you said putting it into one struct might make it work due to not having to load two "love letters"
Yes but it's not like you are doing it.
That's what I'm doing anyway and works for me.
where are you doing it, in character blueprint?
That's on you to decide where to handle it. But you can put it in your character blueprint
Got my clients to send it's customization data to server, then server replicate the change back to client.
inside the character blueprint it does work and I use that path in other places. For reasons that are too long to explain now, I need to handle it in the player controller too sometimes and here It's not working correctly and the clients only run the OnRepNotify at the end of the for each loop
scrap your delays and stop thingking about your loop.
Client will receive the data when ever the data arrived. Like mentioned, that will depend on latency
nevermind, need to hop off now. Gonna dive deep into this later on
i am not using a delay though
you shoulnd't have anything like that
because when you want to sync something, it should be called on rep notify
you update something when the value is updated
no you are misunderstanding this delay node. This is not having the reason what you think it does. It's not to test for when to call the on rep notify or whatever
like we talked a few mins ago with Uhr etc.
it's just also on the screenshot
i didn't yet try the timer method they mentioned
I won't do that either
why doesn't Unreal Engine like this branch? It works properly (prints username)
because your player controller is returning null
you use a diff node when you print the username
and looks like thats what you would want in the branch as well
though that branch is likely not necessary
Widget doesn't replicate btw, your RPC call is redundant here. If you need to make RPC call, route it to your controller or actor.
Anyway the code seems to be confusing. It's not like you can get other player's controller.
Client only have access to their own controller.
literally
and replication stuff just scratching the surface.
I use the default mannequin. I'm using an idle animation, instead of walk (the character is on a sort of vehicle). The lack of animation seems to add jankiness. How can I address that ?
its so daunting. I've been just trying to figure out how to display the usernames entered in by the players and i can't even get that.
It is certainly not for the faint of heart
Are you trying to swap animations using some kind of boolean or replicated value?
just remember that each client and server are like in separate dimension
GAS makes so much replication for me I love it
@proven pagoda nah, I just disabled the walk animation ABP_Manny this way:
Read the compendium multiple more times.
What you can do here anyway is to declare username in your Player State.
Each Pawn have it's own Player state, Iterate thru the player , for each player state -> Display the username
Have you tried motion matching yet? I made a whole setup with it
the animation might simply hide the jankiness
I guess I have to read through it enough to memorize it. I've considered hiring a tutor for fucks sake. I've watch enough youtube videos and read enough articles to burn me out on a lesser interest.
Most youtube videos for multiplayer are straight up wrong / won't cut it.
Most tutorials on anything are shit tbh
1st video I checked, someone spawn an actor thru multicast. It got thousands view and people are thanking him.
lol
What's the best way to learn then?
Read the compedium , practice. Fail, Repeat
^
it should be spawned on the server
depend on the context but for what the video show it just wrong.
there are times you want to spawn something on client only.
So
Eg projectiles
clients can spawn stuff yeah but if you want it to spawn for everyone server gotta do it
peer to peer
no, I mean. Let's say that a very motivated assholes decided to analyse the network traffic, and to make a custom client to connect to the server
Could it potentially spawn any actor anywhere ?
If your server lets it sure
the spawn on the client is client only ?
The network model in Unreal Engine is server to client
yes
If your server had a function that was like "Spawn whatever you want just give me an actor!"
then yeah....that can be abused x
yeah dont do that
xD
I just don't understand how clients and server interact and share info.
Like usernames. 1 widget displays your username and score, the other widget displays the opponents username and score.
If you have a blueprint that is replicated (ie it exists on the server and client) you can share information. For usernames playerstate is a good fit as its information related to the player. Each player has one, and has a copy on the server. the server ensures everyone stays in sync, and by "asking" the server you can get others playerstates and as a result, their usernames
Widgets are client only, they dont and cant replicate. But they can get classes that do and display this information
is there a way to debug why something doesnt attach?
I just don't understand how clients and server interact and share info.
The server shares its info with the client
every time a value is changed on a replicated actor, the value is sent to all clients by the server
client blindly trust the server
characterMovement nah ?
Well yeah but that is still checked server side too
CharacterMovement is a very special case of replication anyway
No need to think about that for a beginner
some things the client does have control over since the server doesnt need to dictate it (or shouldnt)
yes, you can have a local state
Or you mean stuff that is replicated with the client as authority ?
no i was talking about stuff like local effects being player
or something like turning your camera
oh yeah
if the server controlled all that the game would feel not responsive
almost there. for some reason, the clients name gets displayed for both players.
I thought that getting the Player Array from the GameState would be enough to get the variables saved in each playerState.
you should be grabbing playerstate and the username off that
gamestate is for game related variables
off your player array that you have there, you can do a getPlayerState
Get Player Name seems to get the different computer names.
but casting to a CustomPlayer State end up with both names being what that player typed.
yes, because if you dont use a subsystem this is what it defaults too
if you used something like steam, instead of the computer name it would be your steam name
However, now that you are starting to grasp the concept like that. If you do not want to use a subsystem, you can create your own replicated variable on the player state
set it, and retrieve that in your function
You don't need this.
think we past that, but yeah you could just use the nodes without the function
Whenever you're creating a widget that needs a reference to a playerstate, you feed it that reference. Within that widget you can cast, bind to and read from your custom playerstate to both know when the name changes and to read the current name set. The "GetPlayerName" function, as ShinyKey mentioned, isn't accessible to be changed in blueprint, so you must use a custom variable and handle it differently if you're stuck using blueprints which is what I was guiding you to do earlier.
i feed the reference within that widget and casted to the custom playerstate and i get the same result.
how are you setting the username?
Would you guys avoid having hundreds of instances of an actor, and instead use a single actor with an instanced mesh, and per-instance data? And handle replication within that?
Or, you could still use hundreds actors, but just use a separate object for the instanced mesh?
Really depends I guess? With a single actor it has no "culling" in that everything will replicate always given its size will be massive and you get no benefit there, it really depends on how important they are. Fornite abuses dormancy alot and just calls ForceNetUpdate when something changes to replicate it but then stay dormant (note it has a slight cost every forcenetupdate due to it re sending any data that differs from its default values)
Ok. obviously the instanced mesh is a benefit. I was concerned about the overhead of hundreds of actors. Assuming there could be multiple types too, e.g. 6 types, hundreds of each type.
For fortnite, are you saying they do that as a workaround to allow actors to be not relevant, but still update critical attributes of those actors on the clients?
i'm saving it into the GameInstance because the Place you type your username is in a different level than the level the game takes place in.
and it prints correctly for each?
Player on the left is "Bill", and the player on the Right is "Frank"
that test button just prints that player's name
its printing from the controller tho
yeah, thats not a very good test button is it.
Now it's working better
You have to RPC it to the server in order for other players to receive it.
Where do I put the RPC? in the PlayerState or the widget?
You always have to RPC on a replicated actor that is owned by the client.
So PlayerState would work, sure. You can have your widget call that RPC, that's fine too but it can't run on the widget.
I guess I don't understand how to make the RPC besides creating a custom event and setting the replication setting to Run on Server. That and calling it in the widget.
all of this delay and going all around with the pin seems to be derived from youtube practices.
saw 2 guys doing this already today.
That is how you create an RPC. The thing is, you can't call the RPC in the widget as it's not a replicated actor, so the server wouldn't receive it.
Your widget has a reference to the "owning player controller"
Player Controllers have a reference to their PlayerState.
So you'd create that RPC in your PlayerState, and from your widget, get the owning player controller which you can then get your PlayerState from, which you can then use to call your RPC that exists on your PlayerState.
do i need any logic in the PlayerState RPC?
Yes. You're trying to replicate the name. Replicating variables requires you to set them on the server.
You'll have to add an input to the RPC to pass the value through the RPC to the server.
This also won't work if you're trying to do it when you're also setting the name in the game instance assuming you're setting the name before the player is connected to the server.
Yup, set the name, then connect/ make session]
So then, you can't assume to send the RPC when you're setting the name.
You'll have to send it somepoint after they have joined.
An easy way to do so would be to use the Begin Play of the PlayerState.
Get the owner of the PlayerState and cast to PlayerController - this filters out other clients so they don't do the following.
Check if the PlayerController is locally controlled - this filters out the host if it isn't their PlayerState.
So now for sure, you're the client that owns this PlayerState. You can now retrieve your previously stored name in your GameInstance, send the RPC with the name, and then when running on the server, set the name in the replicated variable.
how do i get the owner of the playerstate in the playerstate?
GetOwner
do i just call the RPC from the true branch?
Begin Play > Cast GetOwner to Player Controller > IsLocalController (TRUE) > Cast GetGameInstance to custom GameInstance > Send RPC pass in Name from Game Instance.
RPC > Set Name.
like that?
Looks promising. Try it.
the second player didn't get his name saved
this is the closest I've ever gotten to it though.
Where do you set the name that lives in game instance?
In a widget that is in the level before entering this one.
show the code
Should I set the RPC to Run on owning client?
no
print string after the set text, make sure u see the print string for both of the window
also you might be doing some sort of race condition too
if the widget is created before the name value can be replicated to client
I set the RPC to be reliable and it worked, i dont fully understand how that is.
Reliable rpc are more guaranteed to arrive to the client where as Unreliable can be dropped.
Unreliable is more cheaper and lightweight, but you want to use reliable for important gameplay element.
I will try to test the game with some delay tho, just to make sure that your game still work when latency is introduced.
it gets dropped everytime when it's not set to reliable.
I gotta get to bed, but thank you @sinful tree and @dark parcel and @worthy oak for helping me understand this better.
Hey, i have a bit of an issue and am wondering if anyone can help,
As you may be able to see, when the client fires a lava bullet, on the other client its shown as a regular bullet. I may be hard to see but of the client firing the bullet, a regular bullet is fired along with the lava one,
Any ideas on what i could do/how it could be fixed?
You probably don't want to be spawning bullets on every single client like you are currently by multicasting the spawning logic. You probably want the server to spawn a replicated copy only.
newbie question.
I have a board game i am making and I am trying to understand what can and cant be replicable from the client to the server.
my goal right now is to be able for the server to see the client click and dragging pieces around the board.
currently, only the client can see when the server does it. no surprise
most of my events are replicable or server ran. but the actual dragging of pieces is a left mouse button press and release event.
here is a snapshot of the blueprint currently.
can I restructure this somehow where the client's actions will update live on the server's side?
hopefully this is informative. if I were to attach a video, the server would move a piece and both screens would show live movement, but switching ot the client, only the client's movement would show, not on the server's window.
replication is always from the server to the client, so nothing can be replicable from the client
if you want the client to change the server state you need to call a RPC
then it will be changed on the server and replicated to the clients
how would i go about doing that?
what creates the game state actor if game modes don't exist to do it for clients?
Sweet. This helps. I’ll need to change my plan a tad on how moves are updated visually.
if the player presses the bullet change button 1 is added to the variable until it reaches a max value and circles back around to 1
The game state is a replicated actor that is relevant to all clients. Server spawns it and once a new client joins it will eventually be replicated to the client 🙂
Hello folks.. Can I send MulticastRpc with an Actor right after it is being spawned?
like
MyNewActor = World->SpawnActor<AActor>(this)
NetMulticastNotifyActorSpawned(MyNewActor)?
I wonder whether its guarantee that actor will be replicated on clients before NetMulticastNotifyActorSpawned will be called
Use BeginPlay instead?
Like, you can tie a callback to BeginPlay fwiw
If the RPC is in a different actor, then the pointer might still be null locally
What are good methods to minimize the use of RPCs?
Mostly realizing that you are using them where you shouldn't.
In most cases ServerRPCs are only needed when the Client does something the Server doesn't know about. Like a KeyPress or UI Interaction.
Say i had a player, and i killed them, should the elimination event use rpcs?
ClientRPCs are only needed if you need a specific Player to do something.
Same with Multicast but for all Players. And most of the time you probably just work with Replicated Variables.
The Player would have a State, e.g. bIsDead. If that turns true, you can react to it locally via tying it to a RepNotify Function.
You don't use RPCs for States.
okay
it is like.. you pickup a weapon from loot(TSubclass<AWeapon>), spawn it into hand and select that weapon as a selected into character..
Weapon = SpawnActor<AWeapon)()
Character->MulticastSetActiveWeapon(Weapon)
i know I should use replication.. I just wonder about guarntee about spawning Actor, estabilish GUID, and receive RPC
Active Weapon is a State
Peeps you gotta really try to understand what State means if possible
You can't use RPCs for that
I am using a player state in my game, using the comprendium for information as well
yeah i know.. different example... you have a simulated proxies(other players). Player on server spawn weapon and instantly call Fire.. so SimulatedPlayer gets Fire(Weapon) but the given Weapon is what? is it guarantee that the weapon will be replicated atm?
UFUNCTION()
void OnRep_ActiveWeapon(AWeapon* PrevWeapon);
UPROPERTY(ReplicatedUsing = OnRep_ActiveWeapon)
AWeapon* ActorWeapon = nullptr;
void SetActiveWeapon(AWeapon* NewWeapon);
void ASomeClass::SetActiveWeapon(AWeapon* NewWeapon)
{
if (!HasAuthority())
{
return;
}
if (ActiveWeapon == NewWeapon)
{
return;
}
Weapon* PrevWeapon = ActiveWeapon;
ActiveWeapon = NewWeapon;
/// Optionally if needed on Server
OnRep_ActiveWeapon(PrevWeapon);
}
void ASomeClass::OnRep_ActiveWeapon(AWeapon* PrevWeapon)
{
if (IsValid(PrevWeapon))
{
/// Do stuff with Previous Active Weapon
}
if (IsValid(ActiveWeapon))
{
/// Do stuff with New Active Weapon
}
}
Player on server spawn weapon and instantly call Fire.. so SimulatedPlayer gets Fire(Weapon) but the given Weapon is what? is it guarantee that the weapon will be replicated atm?
Player can't call FireWeapon until the Weapon is replicated to them.
Or you just do:
UFUNCTION(Server, Reliable)
void Server_FireActiveWeapon();
void ASomeClass::Server_FireActiveWeapon()
{
if (!IsValid(ActiveWeapon))
{
return;
}
ActiveWeapon->Fire();
}
Cedric I got you 🙂 Take this as an example please.. It is about I have a code review where folk from my work use to call RPCs on just created actors and I dont like it so I am looking for a different opinions 🙂
Well I already said you should possibly tie your code to BeginPlay of that Actor or an OnRep of the Pointer of that Actor.
A reliable RPC on the Actor might make it, but then there is BeginPlay.
And an RPC in the spawning Actor/Class will possibly have a nullptr as param locally if the Actor hasn't replicated yet.
yep.. I completely agree.. thanks man
Right, sorry for going overboard with the answer. I never know how much a person actually knows.
Somewhere lurking will probably have learned something anyway.
nah, I am fine.. 🙂 thanks again for a clarification
In my player controller OnPossess I cast the pawn to my player and store it in a replicated variable. Then in beginplay if local player I call an Multicast RPC on to do additional setup. This seems unpredicatable, like for the 1st client it attempts to run begin play before possess so the player variable isn't set yet..
BeginPlay can totally call before possession replicated.
If you want to react to the Possess stuff, use OnControllerChangedEvent or whatever they called it
That calls for Server and Local Client.
Calling a Multicast on BeginPlay is kinda strange.
it very much can and does apparently.
cool let me try with that one
@thin stratus just for clarification.. I ve just recheck it within the UE and we're right.. when you call a RPC with just spawned Actor, clients receives nullptr and after that within Bunch processing the new actor being created
I don't see anything close to this kind of function in the BP overrides or c++
interesting thing that RPC and actor is received in same packet/same bunch.. but RPCs come first and then new actors are being spawned
They renamed it apparently
UFUNCTION(BlueprintImplementableEvent)
ENGINE_API void ReceiveControllerChanged(AController* OldController, AController* NewController);
Why is my array not replicating when I use it? I think I set it up correctly in the player state, but when I update it using a widget, only the client or server that does the change sees it and no one else does. Here is my player state code, what is wrong with it?
cpp
void AMainMenuPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const {
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMainMenuPlayerState, AllPartyID);
}
void AMainMenuPlayerState::CreatePartyID() {
AllPartyID.Add(UKismetMathLibrary::RandomIntegerInRange(1000000, 9999999));
}
void AMainMenuPlayerState::OnRep_AllPartyID() {
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Black, FString::FromInt(AllPartyID.Num()));
}
bool AMainMenuPlayerState::JoinParty(int AttemptedPartyID) {
if (AllPartyID.Contains(AttemptedPartyID) && !AllPartyID.Contains(0)) {
return true;
}
return false;
}
h
UCLASS()
class SPELLBOUNDSTUMBLE_API AMainMenuPlayerState : public APlayerState
{
GENERATED_BODY()
public:
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
void CreatePartyID();
UFUNCTION()
void OnRep_AllPartyID();
bool JoinParty(int AttemptedPartyID);
private:
UPROPERTY(ReplicatedUsing = OnRep_AllPartyID)
TArray<int> AllPartyID;
public:
FORCEINLINE TArray<int> GetAllPartyID() const { return AllPartyID; }
};
@round bobcat Who's calling the CreatePartyID?
I have an actor component attached to my pawn that calls the function
For the array to replicate, let the server set the value. Since this kind of stuff doesn't need prediction, just Run server rpc to CreatePartyID if Client calling it
Is this what you mean?
void AMainMenuPlayerState::CreatePartyID() {
ServerCreatePartyID();
}
void AMainMenuPlayerState::ServerCreatePartyID_Implementation() {
AllPartyID.Add(UKismetMathLibrary::RandomIntegerInRange(1000000, 9999999));
PartyID = AllPartyID.Last();
}
Test it
It doesn't replicate still and now, the client cannot create the PartyID. When I print out what PartyID the client creates, I get 0
can you show how you do this and when?
On your rep notify function, print the value
You mean the component class right? Here.
void UPartyInfoComponent::PollMenu() {
if (Menu == nullptr) {
TArray<UUserWidget*> WidgetsFound;
UWidgetBlueprintLibrary::GetAllWidgetsOfClass(GetWorld(), WidgetsFound, MenuClass);
if (WidgetsFound.Num() > 0) {
Menu = Cast<UMenu>(WidgetsFound[0]);
if (Menu) {
Menu->PartyCreated.AddDynamic(this, &UPartyInfoComponent::OnPartyCreated);
Menu->PartyCommitted.AddDynamic(this, &UPartyInfoComponent::OnPartyCommitted);
}
}
}
}
void UPartyInfoComponent::OnPartyCreated() {
if (MainMenuPlayerState) {
MainMenuPlayerState->ServerCreatePartyID();
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Blue, FString::FromInt(MainMenuPlayerState->GetPartyID()));
}
}
void UPartyInfoComponent::OnPartyCommitted() {
if (MainMenuPlayerState) {
FString PartyIDString = Menu->PartyIDTextbox->GetText().ToString();
AttemptedPartyID = UKismetStringLibrary::Conv_StringToInt(PartyIDString);
if (MainMenuPlayerState->GetAllPartyID().Num() > 0) {
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Green, FString::FromInt(MainMenuPlayerState->GetPartyID()));
}
else {
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Green, "0");
}
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Red, FString::FromInt(AttemptedPartyID));
if (MainMenuPlayerState->JoinParty(AttemptedPartyID)) {
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Yellow, "Party Created");
}
}
}
Menu is the widget and I'm using delegates to tell the component class when a button is clicked on Menu
void UPartyInfoComponent::OnPartyCreated() {
if (MainMenuPlayerState) {
MainMenuPlayerState->ServerCreatePartyID();
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Blue, FString::FromInt(MainMenuPlayerState->GetPartyID()));
}
}
I am beginner btw, so take it with a grain of salt but this is my 2 cent. I mean I can't visualize your project and how things flow
But assuming ServerCreatePartyID() is Server RPC, that piece of code will run on the server machine.
So Server will Create the Party ID, that Array will not replicate to client within the same frame anyway, there is latency it won't be physically possible.
You should test the value from OnRep, because that's when the client Array gets updated.
Also if it's a component, have you set it to replicate after creating the Sub-Object? that and ticking the component replicates in your BP version.
I'm a beginner too, so I don't know if I replicated it after creating the Sub-Object, but I do know I set the component replicates to on. Here is the updated player state code that took all your suggestions.
cpp
void AMainMenuPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const {
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMainMenuPlayerState, AllPartyID);
}
void AMainMenuPlayerState::CreatePartyID() {
ServerCreatePartyID();
}
void AMainMenuPlayerState::ServerCreatePartyID_Implementation() {
AllPartyID.Add(UKismetMathLibrary::RandomIntegerInRange(1000000, 9999999));
PartyID = AllPartyID.Last();
}
bool AMainMenuPlayerState::JoinParty(int AttemptedPartyID) {
if (AllPartyID.Contains(AttemptedPartyID) && !AllPartyID.Contains(0)) {
return true;
}
return false;
}
void AMainMenuPlayerState::OnRep_AllPartyID() {
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Blue, FString::FromInt(AllPartyID.Last()));
}
h
UCLASS()
class SPELLBOUNDSTUMBLE_API AMainMenuPlayerState : public APlayerState
{
GENERATED_BODY()
public:
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
void CreatePartyID();
UFUNCTION(Server, Reliable)
void ServerCreatePartyID();
bool JoinParty(int AttemptedPartyID);
UFUNCTION()
void OnRep_AllPartyID();
private:
UPROPERTY(ReplicatedUsing = OnRep_AllPartyID)
TArray<int> AllPartyID;
int PartyID;
public:
FORCEINLINE TArray<int> GetAllPartyID() const { return AllPartyID; }
FORCEINLINE int GetPartyID() const { return PartyID; }
};
@round bobcat ```cpp
RotatingComponent->SetIsReplicated(true);
make sure your component is set to replicate, otherwise I think RPC will get dropped
i tried unticking mine just now and the properties inside my component stop replicating
What is UPartyInfoComponent derived from?
Hmm nvm actually, the serverCreatePartyID lives in the player state
@round bobcat ```cpp
void AMainMenuPlayerState::OnRep_AllPartyID() {
GEngine->AddOnScreenDebugMessage(-1, 15.0F, FColor::Blue, FString::FromInt(AllPartyID.Last()));
}
This still giving you 0?
I have that checked, but It is still not replicating. UPartyInfoComponent is derived from actor component.
I will doodle something
No, it's not, but there is a delay between when I click the button and when it prints
So the Array in Client Player state get updated but with delay?
Yes, both the client and the server player state gets updated and the OnRep gets called, but with delay
Ok, so no issue with the *AllParty ID then? You are able to sync that now?
Chekc if you are emulating delay
PartyID is still not replicating to the clients or the server, but the OnRep is being called and it should be replicating
OnRep is called when the variable gets updated from the server
so I'm not quiet sure what you mean by AllPartyID not replicating
Your PartyID is never set to replicate btw, Are we talking about PartyID or AllPartyID?
UPROPERTY(ReplicatedUsing = OnRep_PartyID)
int32 PartyID;
if you want to replicate the PartyID
might not even need OnRep and just make it replicate. Depending on the context ofc.
PartyID is just the last element of the AllPartyID array and I just use it for simpler print strings. In these screenshots, the server just created a code that goes into the AllPartyID array and printed it in blue, and the client tries joining with the same code, shown in red, but the code they have is 0, the one in green because the server doesn't replicate the code to the client.
void AMainMenuPlayerState::ServerCreatePartyID_Implementation() {
AllPartyID.Add(UKismetMathLibrary::RandomIntegerInRange(1000000, 9999999));
PartyID = AllPartyID.Last();
}
``` okay but this code is only setting the Party ID in the server machine
not client
You can leave the code as it is.
But for client you can do
void AMainMenuPlayerState::OnRep_AllPartyID() {
PartyID = AllPartyID.Last();
}
this will set PartyID in the receiving client machine to the last element of the Updated Array (AllPartyID)
Didn't do anything and I think it is because PartyID is not the variable that needs to be updated. In the Join Party function
bool AMainMenuPlayerState::JoinParty(int AttemptedPartyID) {
if (AllPartyID.Contains(AttemptedPartyID) && !AllPartyID.Contains(0)) {
return true;
}
return false;
}
PartyID is not mentioned at all
Yo
Anybody struggled with UE5 physic objects in multiplayer?
When client hits object during sprint, that object is knoking in outer space. With server that not happens and all physics work normaly
I haven't read your other codes, I'm only trying to help you replicate the variable to the client.
void AMainMenuPlayerState::OnRep_AllPartyID() {
PartyID = AllPartyID.Last();
// Print PartyID here
}
Print and report the values, it shouldn't be 0
once you have the correct value, the rest is for you to work out how to use it in your System.
But the value is already not 0 and I already tried doing that, but the AllpartyID array just did not replicate
yet the RepNotify gets called? I'm confused what you mean by it did not replicate.
I mean that when the RepNotify gets called, it should replicate right? But when I try to access it from a client, the client never recieves the replicated AllPartyID array
RepNotify in C++ only gets called by the receiving client
it does not run for server
So if you have that function executed, that means you are receiving updates on your AllPartyID
Means the data arrived from server and the variable gets updated to the incoming data for the client
What you are saying is that it should be working right?
I feel like it has something to do with the widget input. I heard all widgets are local so I'm thinking you can't replicate variables.
You said so your self that the value is not 0 anymore
The variable lives in Player State which is a replicated Object
this got nothing to do with your widget. Your widget job simply just to read data that is available in the game instance it's in.
No I mean when I create the variable on the server, it is not 0, which it used to be, but the client still sees this variable as 0
#multiplayer message
Just tell me what this print
If you don't get 0, then I rest my case.
Screen shoot the OnRep Notify code then screen shoot the result
The rep notify is printing correcttly.
play with multiple players and print screen again
The server prints the PartyID in blue and when I join and type the code on the client shown in red, the green value, what should be the same as the blue value, is 0
Lets not jump to the join button, I am not certified to look at other people code
So it seems the AllPartyID is replicated since you get the same number
now you can work out what you do with the data.
When you make system like this, you have to think about when will the data be ready, what runs on server, what runs on client.
I don't get the same number though. the red text on the client is what I typed to match the blue text, the green text is the actual PartyID for the client.
I don't know how you print the other colors and where. You might print Party ID before the OnRep is called
anyway gonna sleep, maybe someone else can help.
Alright, thanks anyway
You can. No need for special handling.
worked like a charm. thanks!
i made an event for relocating the grabbed piece ( replaced that last node)
i made the event run on server and reliable
I then learned about scope because having grabbedPiece and newLocation within the server event errors out. instead simply passing them in from the original left mouse event into the new server event fixed it and it runs nicely!
thanks again
- When testing replication in a dedicated server setup, I only need to play as client in the editor?
- When not using RPCs run on owning client or so it's very likely that if replication is working for one client, it would work for other clients as well. Correct?
Of course, just regarding the replication in question 1. I know that the dedicated server itself would need testing
Thanks, that worked great. Decided to use the delegate directly instead of the blueprint implementable event.
Snippet for anyone searching this in the future.
in PostInitializeComponents of the player class:
ReceiveControllerChangedDelegate.AddDynamic(this, &APlayerBase::OnControllerChanged);
then the function with the same signature as the delegate
void APlayerBase::OnControllerChanged(APawn* Pawn, AController* OldController, AController* NewController) {... // do cool stuff, set up widgets etc
on begin overlap i would like to check some stuff on server then run a function on the instance where the event fired if the actor that triggered the begin overlap event is locally controlled.
but once im on server, i cannot go back to the specific client (only the owning client)
should i use a delegate or something ?
hey guys I have migrated my project from 5.3 to 5.4.1, and now I got a problem about replication I guess, the client gets kicked out after connecting, the error says Actor channel failed, in the server log "ReplicationDriverClass is null! Not using ReplicationDriver." "InitBase GameNetDriver (NetDriverDefinition GameNetDriver) using replication model Generic" then it registers network metrics listeners(I dont think before I had this registers)
Can't you pass both Actors and then call the ClientRPC on the one you want?
I have a function that enables and disables collision. My problem is that on client the collision is able to be enabled but not disabled even though the set collision is being called
I could that, but then this Player Actor will have to callback to the actor where the overlap began
Will work but i dont like splitting stuff like that
Is that other actor some random ass actor?
I basically have a "job location", on overlap im checking some conditions on server then updating a static mesh comp materials on the specific client who overlapped
Why can't you check the Conditions on the local Client too?
Because we dont trust the client ?
Idk what kind of conditions we are talking about
But most of the time you probably can do the tests on both ends
And let the client do the visual feedback
The condition check will change visuals stuff but also important stuff like collisions response to a specific channel
So i cant put all on client
Also only for that client?
The stuff that happens for all of them can be doen via OnRep
ServerOverlap -> CheckConditions -> Do State Changes
LocalClientOverlap -> CheckConditions -> Do Visual Feedback
When a new player joins he will have the correct channels response since its on the player capsule comp ?
I sont see the use of one rep
State -> OnRep
Its not really a state here.
If i change the size of a capsule comp for eg, since the capsule is replicated, it will have the correct size on join
Ill do that for now
Thanks
The Capsule does not replicate the size or collision :D
Oh wait i cant xD
Idk why you think that
The PDA is server side
I will have to replicated down a variable
That is contained in the PDA
You will need to replicate the State of the Capsule Comp via OnRep variables
Just marking it as replicated doesn't magically do that for you
bump 👆
I dont know where is the replication problem on my server, the previous unreal version was working fine
gamemode settings
Working with fast arrays, need an outside opinion
Fast Array with items
- with a soft object ptr & TArray<int>
- Soft Object Ptr & int
basically, would it better to have each item in the array to hold a soft object ptr and array of ints which would reduce the size of the overall array but would be harder to use with the update code. Or flatten the array so each item holds the int, which would increase the size of the overall array but I can update the UI on a per item basis
Personally I'm leaning towards option 2, especially since I'm working with fast arrays
@magic vessel I dont think youre in the right topic mate, here is for multiplayer
It's with the fast array serialiser which is very important for multiplayer, I was wondering about the broadwidth considerations though reading my post I forgot to ask about that
I'm spawning random buildings each playthrough, but players don't see the same buildings spawned. How do I go about replicating this?
Which class are you spawning them through?
And are the actor classes set to replicate?
Depending on the class, Begin Play will trigger on both server and client and if the actor classes are not set to replicate then the client won't see them
@dreamy gate try to create a custom event that runs in the server, in the game state class for example
if you want the player to call the event, then you have to create on the player controller
but with the option set to run on the server
okay so I have a game where I am using Steam, the Steam master pops but when i join on another computer/laptop won't let me; any advice?
make sure download regions are the same if your using the 480 appid
The parent class is Actor
@neon summit i am using custom and region are same on both computers
like i can open the connect way but doesn't find any 0/0 sessions
well anyways least i got its to pop on steam!
Thanks Heisen, I'll look into that
bump 👆 😵💫
I set up motion matching and then just finished replicating it. It's interesting to see the final product across clients and stuff. 3 person Listen Server
That's just the Lyra animations and this other starter pack that's in the free section
I can't wait until next month the 500 anims comes out
Spawn only on the server, not during a multicast. If the client changes what type of bullet they want to spawn, you also need to send that data to the server so that it can know what the player has selected and then the server can spawn the appropriate bullet based on the player's selection.
so what the different turning both( bInitServerOnClient= to false? Because when not false then the name on both don't change to the steam username, only the main
i turn them to false while hoping it'll bring up an value of 1 to join but only 0/0
I'm using this setup, it correctly plays the double jump animation on all clients. However, it plays it with a delay on the local client (which is expected, client->server->client to play animation). What is a recommended setup to play the animation immediately on the local client, and then have the server execute the event on all OTHER clients? so the local client doesn't double-play
Doing movement outside CharacterMovementComponent won't end well imo.
I'm only trying to update the animation on the clients, no movement should be happening there
I suspect I'm going about this the wrong way but I don't know what the right way would be (playing jump animation on all clients at the correct time)
the simple thing is to play it locally when the client locally controls that character, I don't see why the local client would need to wait for the server saying they can double jump here as the CMC kind of predicts that built in
if I hook up Event On Jumped directly to Jump to Node it'll play the animation correctly on the client that jumped and the server, but other clients won't see the animation. I'm not sure what the proper way to replicate that is, I figured Event On Jumped would be replicated
so I think I have to manually tell the clients to Jump to Node? But if I do that through the above method, it'll play the animation twice on the client that jumped
Question: Where, or how, would I begin implementing a multiplayer-account-system where the account stores the players data (IE: Weapons owned by the player, levels, stats, games played, etc)?
That's a very tall order. You'd either use something like PlayFab or roll your own. Either way, it's pretty complex.
There might be some UE / Playfab writeups around
would using something like steamworks or eos work as well?
Do you mind expanding on the methodology her?
So like, if I were to create one, then I would just have data stored on the account or connected to the account, then have a blueprint function retrive that data and show it on the game.
Is that a good method of approach?
It's way bigger than that. You'll need to do a lot of research. As long as the thing gets built it should all shake down to be some little blueprint function, but it's not just a little thing you add to a game.
In 'ListenServer' mode, I can move my clients. The client, which is the server, cannot move. I also tried removing "is local player.., result is the same.
why are you spawning this way?
i will have more than one base character and subcharacters. which way do you recommend?
override the spawn default pawn for in the gamemode
ingame, i'll have to change my character quickly
and event handle starting new player
When I used it this way in gamemode, the client that is the server problem also improved. But why didn't it work in PlayerController?
that is making the bullet spawn a little strangely, being a little further from the gun, also when firing straight down the client doing so can't see the explosion.
Any thoughts/solutions?
That's because it's never instant that you communicate with the server and there will always be some delay. You're now entering the realm of predicted projectiles which is a lot more difficult and beyond what I could help you with as I've not done it myself. The Unreal Tournament source code has the code required for doing it, albeit, it's in C++.
As far as seeing the explosions, I'm not sure why that would be happening, but that's likely because of your OnHit logic not being properly set up or not being detected on clients.
Pretty sure the Projectile spawns and explodes so fast it never makes it to the client
Ah yea XD
Thanks 👍🏻
But how does it go from an unresolved pointer on client side to a valid pointer all because of a simple replicated AGameStateBase*
it may have worked if you just did a is server check. Depending on your setup would determine the right way but usually overriding functions in the game mode is how you would handle this
also using spawn player at player start would be better
the problem was entirely related to "input mapping context". I solved the problem by adding DelayUntilNextTick to the begin play of the spawned pawn.
you should do that on possessed
on possess rather on controller would be better
why would you ever want a multicast for handling input context?
input is local to each player
good question ?
yes this makes more sense, thanks
But that only runs on Server, make sure to run Client RPC to tell the client machine to set their Input Mapping Context.
sorry im playing a game so distracted. it works for me as im doing other stuff. if you're just doing that just do a client rpc like he said
On Pawn (For any controls that relate specifically to the pawn): Receive Controller Changed > Check if "New Controller" is Local Controller > Set Mapping Context
On Controller (For any controls agnostic to the controlled pawn): Begin Play > Check if Is Local Controller > Set Mapping Contenxt
Can calling 'destroy session' when there is not a session in existence give me issues? Basically I have a single player level that opens before players search and join lobbies, when players first start the game they are not in a session. How I handle quitting the game (excepting alt+f4) is I teleport the quitting player to this original level and I call destroy session in begin play of the level blueprint. This all works fine but I get a yellow warning on the false destroy session I call when players first boot up the game. I'm just worried this could lead to problems in the packaged version. Or is it not an issue
I am testing multiplayer without checked run under one process but when one process is active on second one there are 3fps which causes a big net latency, how can I prevent this?
look for 'use less cpu when in background'
perfect, thanks
I have an AI task but it does not work on the client properly. Can anyone help?
The same way it does for all other actors, the game state is just a specialized actor in the end. On a high level Unreal keeps track of what actors need to be replicated to what clients and what properties are relevant to send over, as not all properties are wanted to be replicated over the network. Once that data is on the client it will spawn said actor and give it the data that was send along the network. There are some great resources about diving deeper if you want like this: https://www.youtube.com/watch?v=JOJP0CvpB8w - the network compendium from Cedric is also invaluable: #multiplayer message
But in general it comes down to Unreal doing a lot of the heavy lifting and network protocols etc.
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
I heard AI stuff is server only (as it should)
Your BT should only run on server
Not sure on unreal engine but not necessarily
it should more than likely be validated on server
In your case, your client doesn't need to know anything as well.
Hi guys, I hope there is someone who can help with my problem. I'm creating an online game with Steam multiplayer (I've already added the multiplayer itself and everything works correctly), it just so happens that my project is actually an online concert, so I have a lot of lights on the level, and they all work through the sequence, so who can help me with how to make sure that when I created a server, started the sequence, after that the player joined, and that HE STARTED the SAME sequence in the HIS game,
but from the place where he is already playing in my game. Here is how I have it implemented now, but now it works only when I start the sequence when the second player is already on the level, help pls
Server run the task, the A.I move towards the player. Movement is replicated .
Ofc, to player that has yet join the game, the code will not execute on them.
Multicast is like server telling all client to run this piece of event/code. But hey your player that have yet to join will miss it for obvious reason.
Also you will wanna avoid cross posting, but the answer you got in blueprint is the gist of it
Well, that's understandable, that's what I'm asking, how do you make sure they don't miss it? how do you make a request to the server at what point the sequence is playing and whether it works at all and how do you start it?
You define the rules and write it on paper with plain english
At what point do you want to play the sequence?
You said when the player join but how many player will join?
There is post login or something like that on game mode that detect when player joins.
You will need to store where in the sequence you are at in a replicated variable, when new clients join they “sync” these values
As you are finding, multicast is used for just telling everyone connected to do something
So for play sure that works great
about 20 minimum, I want to understand how to make the connecting player (each of the players individually by itself) take the information (current time) at which the sequence is in my game and run it as a separate sequence from the moment it was received
Game mode has a function on server that fire when a player join. Post login or something.
Define the rule there, eg making sure all player join. Only then you can tell everyone to play the sequence
So u want to play the sequence anyway? And when client join, they just jump to w.e server is at?
This is exactly what I don't like.
You are giving me different cases tho. Gotta be clear when you want to play the sequence and when do the client play sequence.
so it needs to take info from my game and start the sequence from the moment my sequence is in
By my game you mean the server?
You want client to play what ever server is at when they join? Is that accurate?
No, the server is my game, in which I run the sequence, you are the client, which after connecting should automatically play the sequence from the same place as I was at the time of your connection
But that's what I just said?
So server play the sequence and the elapsed time is 25 seconds when the first client join.
You want that client to play the sequence at 25 seconds. Are we on the same page soo far?
my game has the ability to create its own servers, but there will be live events from me personally that will be marked as official, so when I, for example, start a server sequence at 20:00 and you as a client join at 20:15, then you as a client should automatically start the sequence from the moment at which my sequence is on the server (in our case, from the fifteenth minute)
You will need to have a replicated variable that define the current time on server.
When player joins, it plays the sequence using the CurrentTime variable (which replicate from server)
If you want to be extra accurate. You can offset by round trip time
But honestly for something like this, is not neccesary
How can I prevent people from joining my game session if someone quits and number of players gets reduce? currently I just possess all the leavers pawns with an AI controller which seems to work ok but the session is still advertised :/ I dont really want to have to close the whole match if there is a leaver
they cant join if max players = num players but when someone leaves i would also like to decrement max players so session is not advertised
so after the play function in server , I must connect set current time variable(which replicate from server) and add this variable to settings for “create sequence player” and play it?
You can set current time to your sequence current time every tick
and it's all in the level blueprint? or in player controler?
If you are still using level blueprint, multiplayer is too early for you.
It has to live on an object that replicates.
Eg your character, controller, player state
I mean, I need to specify that it should start the sequencing only when it has already been started
@dark parcel please go to private messages
no ser, drop it here so other people may help you
Im having a issue with the version 5.4.1, the mapserver is not working how I was used, anyone had a problem like this before ? Actor channel failed ?
are character animations are replicated by defualt?
By my character animations are not replicating
you have to replicate the variables
those which are inside your statemachine
but I would reccomend to dont replicate directly those which are inside the state machine but those from player controller for example
because you start playing animation once the state machine changes the character state
yeah I've also tried replicated the variables I am using for state machines. Doesn't works Idk what I am missing
its because the animation blueprint doesnt exist on the server only in the client
that is why you have to update the variables from a class which exists on the server
I saw a yt video where he just setup his state machine and animation blend space and it automatically replicates his movement animations
Should it look like this?
or what?
I am using the velocity of character in state machine does that also needs to be replicated?
so now what can I do to make it start the sequence from the moment of this variable when connected?
@surreal fox you have to use the node "update animation" and maybe cast to different class to receive the replicated variables, casted from diferent class
for example player controller
bump
pls guys helpppp
gatt damitt that's all because of I was using get player character rather than use try get pawn owner for Casting
finally fixed that
Hey guys, I'm having issues with sub-levels.
What I'd like is for each client to be able to individually enter and exit sub-levels. Imagine one player going inside an interior level while another player stays outside...
Sadly what is happening is that it will load sub level for all clients regardless if they trigger the event or not
Is this even possible in Unreal?
yeah I've fixed that but on the client AI is jittering
when it is patrolling there isn't any problem but while playing montage it's jittering
that's the only problem for now
You cant have players on different maps in multiplayer.
You could use level streaming and teleport the player to another location.
Its been discussed here a few times - I vaguely remember there might be a plugin for it on marketplace, although not sure it does full replication for multiplayer.
Ok, so basically to create fake interior somewhere in the map and teleport the player over there. So only thing I need to do is to exclude external light somehow
that's the simplest option that I know of, yes. But I'm not an expert, so feel free to keep looking around to be sure.
Ok 👌 thank you
bump
hi plz help i need a sequence that starts when f1 is pressed on the server while it is running in parallel with the client game i am using steam multiplayer and i want everyone who has already joined the server to get the sequence at the same time but also those who joined already after starting the sequence, they could join and see the sequence from the same place where the server sees it when the client joins (ie if I started the sequence at 20 00 and the client joined at 20 15, then for the client to see please wait 15 minutes at this point) see what I did please tell me what's wrong and why the sequence doesn't start at all if you join from the main menu but if you start from the level it should work sequence, then it starts itself, and only on the server(first two photos from game mode third from character)
I am falling through collision in sub-level 😄 😄
@ someone helppp pleaseee
You'll have to use repnotify I believe or set the new players sequence when logging in
what you mean by new players sequence?
This might be the worse naming of anything I've seen yet, but the game mode doesn't replicate for a start
Editor or shipping?
both
I'm not far in on AI yet. Currently in tutorial hell for mp that actually cover A.I.
Gonna give 2 cent when I actually have A.I on my own. Maybe someone else have idea, my only experience of montage jittering is from using listen server
Gl maybe someone else knows
spectator pawn DO NOT exist on the server, right?
You have to play it in the actual client.
So pass in the new player
Might want to consider a scenario where client load faster than server as well prob.
Still people glimpsing over the game mode part
Game mode don't replicate but it exist on server right? Can't it call a client rpc in the pawn using the new player? New player -> cast to my player -> do something (client rpc)
It exists on the server, but RPCs are being used there. I doubt this works at all
this is always fun in a multiplayer context too
Ye he needs to plugin the actual joining player (new player)
needs to rework the entire thing tbh
Rpc would be redundant in game mode
Everything is basically already run on server
But i think it should be able to call client rpc in pawn
StartSequenceAtTime isn't an RPC
Yeah he needs to wrap that function in the character
though when I've done something similar in the past, we used a level sequence player actor that existed on the level rather than creating one at runtime
Didn't look carefully, I see now
kind of surprised the server doesn't complain about this Player->GetWInventory()->UpdateSlotAtIndex(_index, SlotReference); it's the widget part of my on equip which is in a replicated inventory component on the player.
It works without a local controller check so does the server just ignore anything having to do with widgets?
did anyone already packed a mapserver in unreal engine 5.4.1 and manage to make it work ?
my mapservers are not working
I have recorded a video for demonstration
👆
Im about to downgrade to 5.3 because of that
I was compiling the whole engine from 0 again to be sure, and the problem is still there
seems people having the same issue
I'm asking just to be sure, is the way I'm using these values correct? When testing character movements on a dedicated server, I feel a slight stutter. Is there another solution to fix this?
Increasing bandwidth isnt going to fix stuttering CMC.
You are likely seeing stutter because you are doing something to the Character that is fighting the prediction system and getting constantly corrected.
When I simulate packet loss, I feel like I'm getting similar results, but I'm still not entirely sure if that's exactly the issue
How much packet loss are you simulating?
20
then it's not related with packet loss
Correct
Packet loss is typically either constant or non existant.
Constant meaning the connection is basically shot due to environmental factors outside of your control
Packet loss simulation should only really be relied upon to ensure that your game can recover to an acceptable state after its gone.
Understood, what would you recommend for me to pinpoint the actual issue?
Test against a brand new Character with no modifications.
If that doesnt stutter, then your issue is with what you are doing to your Character.
perfect , thank you so much
So I'm having a problem where I get the error LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_Miner_C_0. Function RPC Receive Damage will not be processed. when I try to call an RPC from a BP_Miner class to another BP_Miner(hitting one another with melee weapons). I can detect the hit and replicate it just fine, but I can't actually send damage. Nothing I have tried has worked even after extensive googling. Here are the two BP's, BP_Miner(https://blueprintue.com/blueprint/ozvuoo4x/) and BP_ThirdPersonCharacter(https://blueprintue.com/blueprint/m7i08o07/) (BP_Miner's parent is BP_ThirdPersonCharacter). Any ideas?
Only Actors with a NetOwningConnection (an Owner chain that goes back to a PlayerController) can send RPCs
You are likely trying to send an RPC from an Actor that is not owned by a Player.
Hmmm what do you mean owned by a player? I have full control of the actor and have two windows pulled up and it set to client mode when I click play.
(In BP_Miner)
Not within the weapon itself or anything, directly in a function of BP_Miner's event graph. Everything else except sending damage is syncing properly, even some other RPCs that have to do with animation montage blending etc.
if you call a Server_Interact_Implementation from an input, that function then calls say a PickUpItem function, is the second one always going to run on the server only? 🤔
@fossil spoke do you know about this problem "LogNet: Actor channel failed: [UActorChannel] Actor: BP_TopDownCharacter_C " after client connects to the mapserver, the client gets disconnected
remote mapserver
Thing is, the server knows the damage is happen but won't replicate it to the rest of the clients
UI/Widgets don't replicate themselves, but so long as the server/host is spawning the actor and the actor is marked as replicated, then it should still replicate to everyone. If you need to replicate the reference to that actor, then you'd need to pass the reference through some other replicated actor that is available to everyone, such as the gamestate.
Making a variable set to RepNotify makes it so that when the variable replicates and a new value is received, it triggers the connected function to it. So if you needed to have something done when a value changes, a RepNotify is the way to do it otherwise it won't necessarily be synchronized if you changed a replicated value and then sent an RPC. It's also helpful in that the state is saved and those that end up receiving it later, say like joining players, they too will fire the OnRep functions if the value is different from the default when the actors they belong to begin play.
RPCs are when you need to send a one-off message or trigger that doesn't matter if the state is saved. RPCs are the only way to communicate anything from a client to the server and can only be done on a client owned actor. The server can communicate to specific clients using any actors they are owner of too, but it can also communicate using replicated variables (with repnotify or not) and multicasts.
I tried with the default third-person character as you suggested, and there were no stuttering at all; it works smoothly and properly. However, there are many things I've modified on my character that could potentially cause issues. Do you have any suggestions about where the issue might be?
Anything to do with movement obviously.
There are so many things that could be causing this, you have provided no context. How do you expect people to help you when you give the bare minimum?
Post logs
What have you tried?
What are you trying to do?
What have you changed?
Provide as much info/context as you can.
Thank you again.
Client's can't send RPCs through the Gamestate as clients do not own the gamestate.
How can I stop level streaming from replicating? I want the level to be loaded only on the server and chosen client, but it is loaded on everyone when server loads
Send the RPC on a replicated actor that the client owns. Their PlayerController, PlayerState, Controlled Pawn or any replicated components of these will work, or any other actors that are replicated that you've assigned that client ownership of.
do repnotifies work when that pawn isnt currently possessed?
RepNotifies have nothing to do with possession.
When you mark a variable as rep notify, all you're signalling is that you want the generated function to be called when a new value is received from the server.
alright
eg. You can have a rep notify on the gamestate, and whenever that value is changed on the gamestate by the server, teh repnotify would fire on clients.
Why it may not be working for you:
- The actor isn't replicated.
- The property isn't set to use Rep W/ Notify
- The property isn't being set by the server. (Replication only happens from Server -> Clients)
- The property has some additional replication conditions set on it (like Owner Only)
- The actor is marked as replicated but you're spawning separate actors on all clients (ie. multicasting a spawn) , thus, it's not actually being replicated.
- The actor isn't relevant to the client at the time the RepNotify fires for everyone else.
it fires just doesnt attach actor to component the second time I try but I see it firing.
I've run out of ideas or why this doesnt work. I'm just lost
What are you setting to have the rep notify trigger?
Only thing not working is the attachment. It will work the first time I get in the vehicle but when I get out and get back in it will keep the character at position he enters at
This is a bit of a problem as you can't guarantee the order or timing of receiving these properties if they are both required together.
That said, I'm not sure why you would need to replicate the driver seat.
This here, though it's cut off looks like it probably shouldn't be an RPC.
that changes a variable that determines what hud is used
Why do you need to send an RPC to do that? You have a variable already that indicates they're entering a vehicle.
i probbly dont need a rpc tho prob right
thats not what its for
we're getting off topic
Seems very similar to me.
And yeah, not a game breaker for what you're trying to do right now 😛
that variable is for the animation
i call switch hud afterward to determine which hud is used
and that variable determines the animation
And....? Could it not also be used then to control whether or not the HUD displays what it needs to when the character is in a vehicle? You don't want a seperate variable for every possible thing that could happen as you want to try and replicate the least amount of data.
true true
Ok so back to these guys...
anyway i noticed if i take out the rep_attachtoseat in the exiting code he will attach the next time.
but not at the location of the driver seat
I don't think Detach From Component is the right thing to call here as that would have the component detach from whatever component it is attached to.
probably
Or at least, you wouldn't want to call it on the seat.
And to make matters worse, if you've removed the reference, you don't have a proper way of detaching.
As you'd need to detach the driver's root component
wouldnt that detach the character from all its components?
No.
when you're attaching actor to component, you're attaching the root component to the other component.
So you need to detach the root component from whatever it is attached to (which would be the seat!)
so target would be the character not the driver seat for detach from component?
Yea. So you'd need something like this in the client side logic of the character.
I'd use the capsule compoent insteaf of default scene root in my situation?
Yea it's whatever is the root component.
You can literally do "get root component" to be sure.
I just happend to grab the default scene root in the actor I had opened XD
didn't make a difference so far
it attached but not at the location of the driver seat but I gotta the is valid
it didnt seem to attach using self but attached using the rep driver property
should I just use a bool instead of a ref to character for the repnotify?
thanks datura. I think I just read the description wrong or misunderstood it of the detach from component node
If I have a struct with a custom net serialize function I know it will only send over whatever I serialize inside of that function but my question is what happens to variables marked as NOT replicated?
Does that flag stop shadow states and stop the rep system from comparing them to know if something has changed but thats it? Like I could still manually replicate it if I wanted to with the FArchive but it wont know that something has changed and replicate if I mark it as NotReplicated, is that correct?
how to fix "all clients are Client 0" error for 5.4?
i find this topic about this error, looks like there is a solution, but i dont know, how to use it
help please
https://forums.unrealengine.com/t/multiplayer-all-clients-are-client-0/1689143/6
Show the bits of your code where you're getting that error
Reading the article they changed the type to a struct
Can't fix it in blueprint
everywhere
so, what i need to do then?
Use c++
can u pls give me a more detailed instuctions?
It's written in the article. Anytime you want to print string the GPlayInEditorId. You have to cast it to int32
is there a way to fix it once and for all for the project, instead of every time?
Editing engine code, responsible for the print string
where this code is located?
Kismet library :: print string something like that
UKismetSystemLibrary::PrintString
What is the actual problem?
Engine bug 5.2 5.3
How does this affect your game code?
They changed GPlayInEditorId to become a struct
So the issue now all client print client 0
Despite the existence of multiple clients when doing print string
is this bug affects something more, than just a visual representation of client's name?
do i really need to modify this, or its just a wrong name in string?
Well knowing which client print is extremely important
It kinda defeat the purpose of debugging if we can't ID the caller
It won't break your game code, but will be a pain debugging the game.
can i use client's index or something like that, to identify clients?
No
so, i need to change code in UKismetSystemLibrary::PrintString
?
I would say so, no other way if u want to use print string
It's broken in your end, if you want it to work you gotta fix it
Waiting for Epic to fix it and updating engine could be an option
i'm sorry, i dont see anything like this string here
and i dont find other UKismetSystemLibrary
I even recorded a video about it and post here
.
For a start you want to download IDE (visual studio 2022). Install all the pre requisite as shown in Epic docs. Then convert your current project to cpp project.
You should install VS anyway because you will need that to package your game.
nope
i hate this bloatware
Well you should get it if you want to make games using unreal.
You can't package without having visual studio.
Meaning you can't package your game for others to play.
i use jet brains rider
Me too but still need visual studio to package the game afaik
And if you have rider anyway, then why arnt you using it? Open your project using rider and go edit the print string
bcz when project is converted, it immedeatly get +1.5 gb for nothing
I have no idea, but it's kinda pointless with the nit picking
If you want to seriously work on your game, you do what you have to do
Or just don't do it. The choice is yours
the 1.5gb is why Rider works and VS doesn't
probably all the indexing etc
You still need VisualStudio installed. Even if you use Rider as your IDE. It doesn't need to be open. But Rider still uses stuff from VS to compile.
And it's not for nothing. They're generated files which exist for differing reasons. It's not like it just creates a random file that sucks up 1.5gigs. Unreal generates a lot of code for you from their macros, and a lot of that size is to allow debugging and whatnot.
hey guys, i have problem with UE5.3 dedicated server connection. I am using basic thirdPersonTemplate, and I built it as a windows server. When I am trying to connect to it from second client, map is not loaded on it. What could be the issue? https://www.youtube.com/watch?v=YHc28Qnrpsg
when second player connects to the level, map is not loaded on it's client
check logs from the client?
anyone use smoothsync?
Lol. Professional Epic. Just wonderfully done.
"Here's a PUBLIC guide to use Iris"
https://dev.epicgames.com/community/learning/tutorials/z08b/unreal-engine-iris-faq
"And in that PUBLIC guide, here's a link to how you use Iris on our super expensive developer network that is NOT PUBLIC without your credit card number!"
More information on getting started with Iris can be found here, including how to configure Iris: https://udn.unrealengine.com/s/article/Experimental-Getting-Started-With-Iris
can you even "buy" udn access?
AFAIK it's a licensee thing. So, not directly. But sure.
Enterprise can, but it's with custom licensing for games
so you're not even paying for it with a credit card number
also that UDN is article is practically identical to this one https://dev.epicgames.com/community/learning/tutorials/Xexv/unreal-engine-experimental-getting-started-with-iris
my mapservers on 5.4.1 are not even working, I tried with my own project and with a new project to test and is not working at all, maybe because of iris replication, gives error "Actor channel failure"
Unless you opted into Iris you won't be using it
btw, if i open this server from thirdpersonmap with console command 'open <ipaddress>', all clients work fine. this ocurs when i open thirdperson server map from menu map
If you set an actor component to replicate what about it gets replicated? Any variable you put into it or what?
Any variable that is also replicated
Is there a better way to store permanent player IDs than storing the ID of each client in their game instance?
if your using steam/eos - you can get the respective steam/eos ID of the client and store that
Why I variable I have set as replicated is different on the server than the one I have on the client?
Client might have set it locally.
Hello, I'm looking for some general advice on replicated timelines from anyone who may know. 👋
I was working on an enemy that rotates on a repeating timeline. The timeline fires SetActorRotation() on update. This looks choppy on the client so I was about to start tackling that when I spied the Replicated button in the timeline settings. I've never used this feature before and I thought since the rotation of the actor is already replicated, replicating the timeline would only cause problems.
However, on enabling Replicated in the timeline, I see that the rotation on the client is now nice and smooth. 🙂
This seems too good to be true so I'm here to ask if there is a gotcha here I need to look out for. Are replicated timelines expensive? I'm wary.
Any advice would be appreciated.
Cheers.
When I start the game for two players in the editor, I can see the other character moving without any stuttering. However, when I test the same on the server, I see the other player stuttering while moving, although my own controlled character does not have this issue. I changed the animation blueprint to make sure it wasn't the problem, but it didn't help. However, I noticed that when I use the default third-person character blueprint, everything works fine without any issues. I have changed many things in my own character blueprint. What would you recommend I check first to resolve this problem?
I mean, are you modifying the CMC or movement in general in your BP code?
a boolean repNotify will do something when the variable is set to true only? Or will it do something when marked as false also?
Whenever it changes, or every time if you set it to that in C++
If you flip it to true and then back to false before it gets considered for replication, nothing might happen
i did some of them, do you think this cause server movement stuttering ?
Only if you modify them runtime
oh but on the on rep function i could use a branch to see if the variable is true or not, right?
i only modify for sprinting and walking at runtime
What exactly are you doing for that?
Cause Blueprints will always have corrections when changing values runtime
Yes
Are you setting the MaxSpeed anywhere else?
Cause just there would not be enough, even for BP standards
Sprinting is also a State, so you use an OnRep not a ClientRPC to send the data back
And without prediction you will always have a small lag before you start spriting and a small correction
But that's not solvable in BPs anyway
No thats all
but i did not get any lag with default thirdperson character
You are also not sprinting there, are you
Either way, modifying movement variables in BPs might always cause corrections. At least small ones when changing the value. If you do it wrong it might go async and keep jittering
So i need to use prediction right ?
In theory, if you want proper multiplayer movement, you are required to use C++ and modify the CMC (or in the future hop onto Mover 2.0)
should I set the Bp of the door as replicated in order for the clients to see it move?
Idk why when I replicate it, it spawns 2 of them instead of only one ( 2 for the client and 1 for the server :(( )
It spawns 2 cause you are spawning one locally
Replicated Actors have to be spawned on the Server only
thank you
they are spawned via begin play
Yeah and?
isn`t begin play only for the server only?
ah ok, so I spawned them, but I canno`t see the static meshes that I add them only on the server, any ideea? I can see the actors spawned tho but not the static meshes
Is the StaticMesh added runtime somehow?
what does runtime mean?
While you are playing