#multiplayer
1 messages ยท Page 224 of 1
Its what Im doing but I need the building to be in complete isolation
For lighting and post processing purposes
Hence the separate world
I will be very surprised if that actually works outside the editor then
But just not sure what the correct way of sending the texture is
Because AFAIK, the only environment where you can have multiple active UWorld's at a time is inside the editor, given all the special case handling that exists for that case.
Does 5.4 have some sort of forced emulation for networking or something? I'm testing stuff in PIE, Listenserver. Good framerate. no emulation turned on, but it's acting like I have about 150 latency.
What happens if you clamp FPS to 60 or so?
If you're using CMC and run at a high enough framerate, you can cause throttling
My FPS already is clamped there. ๐ In this case it's a simple boolean replication. Sets from a button checkbox press. Updated from tick atm.
nothing springs to mind, other than possibly a low net update frequency on the object?
Maybe. Does that effect even with no other networking going on?
I dunno why I always thought of that as a priority system instead of a timing thing.
Oh, right no that was net priority. Getting my wires crossed.
But yes. ๐คฆโโ๏ธ That was it. I keep forgetting that Playerstate has such a low frequency by default.
You could keep it low and call ForceNetUpdate when you change something too, just resets the timer
True. But we do a lot of stuff out of the playerstate atm, or out of it's components more so. So I just upped it for now. But I'll keep that in mind for sure if it becomes an issue.
hmmm is ~30kb/s the fastest i can squeeze out of a UChannel?
i send the snapshots as a custom struct at a fixed rate using an unreliable RPC
i havent had to increase any bandwidth limits.. actually my system uses way less bandwidth than CMC and mover
the client buffers the snapshot and then lerps through them, client doesn't start processing the buffer until theres atleast 1 extra snapshot in the buffer. It gets a little jumpy at high pings but i can just increase the amount of extrasnapshots the client waits for before it starts processing them
I am doing a replicated projectile with client prediction of the projectile
does anyone know how to replicate the projectile and sound?
in a way that the client firing it will see the projectile and sound first, but not hear the sound from multicast nor seeing the projectile spawn on server
At the start of the multicast, check if the local role is an autonomous proxy. If it is, return.
Otherwise, do the stuff
Hey all, I'm encountering issues with an OnRepNotify function and I wonder if it's because I'm doing something that isn't allowed or something. It's a simple function but if anyone can tell me if this should work, I'll start looking elsewhere for why it's not workign as intended:
As for the projectile - you can link them up by name. I forget how though.
Some other people also use an "initiator" param.
(For the exclusion on local client)
Might be overall easier to do to be honest.
Just annoying
thanks!
Would be nice if Epic would look at the PR earlier this year that implements this functionality though
There are also people who have gotten an "Is Local Controller" check to work as well
Here is an old post from Cedric that kind of walks the flow https://forums.unrealengine.com/t/i-need-help-with-server-multicast-functions-i-am-not-sure-if-i-am-doing-this-correctly/86820/2?u=duroxxigar
If a replicated variable is changed on the dedicated server is the OnRep called on server and the clients? or do you need to invoke it on the server after the variable change
There is next to no information you're giving. Best to provide as much info as possible rather than as little as possible. People don't often like poking for quesitons. Just saying "it doesn't work" isn't helpful. WHAT isn't working?
c++
you have to manually call it on the server
This is where setter functions come in handy
Thank you!
it'll obviously be called on clients when it replicates and the value differs (unless set to always notify)
Just wanted to clarify, having to deal witrh some replication and its been awhile
My mistake. Well this OnRepNotify is for keypad the player presses. It's recording the number of keypresses so that when the max character limit is reached (6) it should call this event dispatcher so that the keycode gets sent to the corrisponding actor it's intended to activate. Right now, it doesn't seem like the even dispatcher is firing on the target actor and I just wondered if that is because I put the variable conditions in the OnRepNotify I posted above.
Having a condition in the onrep doesn't affect if it fires or not, no. Something else is afoot.
Roger that. I thought as much but I wanted a sanity check from you guys.
Slap a debugger on the actual broadcast. If it never hits, at least you now know that the true condition is never firing.
Thanks
I'm looking up the different Mover BaseMovement modes
and I struggle to understand .. when does it make sense to use things like TrySafeMoveUpdatedComponent and when should we just use MoverCompenent->MoveComponent()
My guess is that, when there is no collision to watchout for .. MoveComponent does the job .. but I wanna make sure I'm right about it.
When using a dedicated server in PIE is there away to route the server logs to the output log?
still one of the worst design choices in the entire engine, I still forget it works this way all the time
well that's easy enough to remember
I am just used to it being automatically called on the server too from using BP for like 8 years before I touched C++ itโs burned into my brain
So, solved the last issue but I'm noticing something weird on my player character. I have a flashlight which toggles on and off using an OnRepNotify bool value. That all works great. The thing I noticed is that the flashlight angle doesn't change pitch as the player looks up or down. It is a component of player character and parented to the camera and it yaws correctly but when the payer looks up or down, even though the AimOffset is replicating correctly, the flashlight doesn't tilt up or down with the player's head/camera. Also, this is only true of the client player. I can see the client player's flashlight behaving as intended, from the server character, but not the other way around. The component is set to replicate as well as the spring arm component that the "flashlight" is attached to.
I disagree. I think that the engine's forward is X+ but the animation tools are done as if Y+ is forward is worse.
if we were so fortunate to have something like C# properties
Yeah that one too is awful, but is it as bad as rotators in BP being RPY but in C++ being PYR
uuuggghhh - why'd you remind me

Or well...rotators existing at all
I doubt C++ lovers would ever want something that nice. Because "ohh - scary. It is doing magic behind the scenes"
BM pre-emptively hates this
Do I have to manually set the pitch value on the server? And if so, why don't I have to manually set the yaw? Is that because it's a component of the actor which is replicated and replicating movement?
Anything c# is better

I guess camera impacts Yaw of character which is replicated, though camera do nothing to Pitch.
Pitch (w/e one is up and down dang it) is replicated due to GetBaseAimRotation
Was a common issue/complaint way back in the day. So Epic replicates it now.
My spring arm is using pitch and yaw so unfortunately that's not it.
I'm not sure why mine isn't working. Here's the PlayerCharacter heierarchy as well:
I mean spring is local thing isn't it? try to read Pitch on server in a different way than from character
ok. hmmm. so would I bew reading the pitch of the flashlight then feeding it back to the flashlight? or the spring arm?
first of all verify that server receives Pitch from clients in some way. I guess that's what Duroxxigar meant by suggesting GetBaseAimRotation, log/print it on server/client
i remember only yaw getting replicated
I can never remember what actually gets replicated. But it is what is generally used for up & down replication of the camera stuff.
@quasi tide Alright I'm trying GetBaseAimRotation to see if that helps.
Locally - you want to use your own stuff, but the remote clients should be using what gets returned from the GetBaseAimRotation.
That seemed to do the trick
If that's not the right way, please let me know. But thanks guys!
reduce update frequency of the actor/component to 5-10 times per sec and check how it looks when you move lights(pitch). I'm not sure AimRotation supports interpolation(smooth anim) like movement component.
though high frequency may be a way to go for "indie/Single A" project 
well according to you algorithm (setting rotation from RPC) it will not be smooth as movement component
I had sprint but i disabled it to try and diagnose the problem, im pretty certain its just the base movement im having issues with. The issues are only happening in a built project, standalone works fine
huh, I didn't know aim rotation was replicated
you're a life saver thank you
It looks smooth and doesn't seem to affect performance, though I haven't run the profiler to check yet.
I reduced it to 5 times a second and it still looks very smooth.
ah, frequency about properties, but you are using RPC
which might be not optimal depending on frequency of Look InputAction node
I'll read through that doc you sent and figure out if I need to adjust this.
I do have another question though, a rather noobish one. If I want to set a variable on an actor that the player interacts with so it is persistent, shouldn't calling a server RPC from the player to the actor, via an interface, allow that replicated variable on the other actor to be switched on the server? I haven't provided BP's or details because, depending on the answer to the above general question, I want to do some reworking before I bother anyone again.
- Client sends a server RPC saying it wants to interact with X
- Do the logic on the server (flip the variable or w/e)
- OnRep gets triggered and everyone is happy
- Cry because lag
yeah I would inform server about "Player's actions" i.e. interacted with object, instead of "instruct server what props to modify directly".
Could you clarify what you mean? Do you mean call a function on the actor from a server RPC?
@quasi tide 's approach
@quasi tide so rather than having a function in the interaction actor that changes the variables, I should reference that actor when I interact and then set those vars directly in the player character actor, with a server RPC?
No
Refrain from having one object directly alter the state of another object. Interact with them through functions.
Makes it much easier to manage the state of an object.
So let objects manage their own state
It depends on how you do interaction - but, you would just ask the server to interact with X object. The server would then do validation checks (if you care) and then call the interact function ON THE SERVER
Then the server version of the object mutates its own state and replicates it back down to clients
Ok cool. That's essentially my flow.
Player Interact Input > Interact Sphere Trace > Interact BPI Function is called on the interactive object > A different BPI function is called on the Interacting Player which carries data from the interactive object > Server RPC is called based on the interactible type which does the stuff.
But it's such a crazy way to do things, my brain hurts. lol.
I'm a visual/hands on learner so reading documentation isn't super effective for me. Practical examples are what lock things in for me. Problem is, all these youtube tutorials on "replicated doors" aren't doing it correctly because they just call a multicast rpc which works while players are connected but any reconnecting players see the door in their default state. So I'm trying to wrap my brain around it.
Networking sucks. But you want to play with your friends. So deal with the suck.
Yup. I'm trying to gut through it. It's just such a huge shift in methodology that it's fuckin me up.
Basic door is just an open/closed state, literally a boolean
A little more advanced would be open w/direction or closed
More advanced or overkill would be replicating the timestamp at which the movement started so you can keep the door's position in sync with other clients
lol - screw that. Just laugh with your friends in discord when their door is 40 degrees and your door is 110 degrees.
Yeah I'm just trying to figure out on the door bp itself, how the bool would drive the door animations and position.
Rep notify -> start moving door
I keep forgetting that the clients will get the updated repnotify values when they connect so that makes sense.
But now if I want to play a sound at location that still has to be routed through my player right? Or will that work correctly because of the server RPC driven repnotify bool?
You can play the sound in the rep notify
You do your logic in the onrep function
Roger. No timelines then.
ok that's what I was doing. Sorry. When you say do your logic in the onrep function I thought you meant it had to be self contained.
Nope
All it is, is a function that gets ran on the machine when the variable changes.
Thanks for your patience today.
This seems to work pretty well for a door. Audio can be played using event tracks on the timeline itself. Since the Timeline is replicated, anyone within relevancy range should hear & see the door. The OnRep is used only to ensure that clients can see the state of the door when late joining or if the door was out of relevancy range when it completed the move. Any clients who have the door relevant or the door enters relevancy while it is playing will see the door in the appropriate position. Only thing that may need some tweaking is audio playing while the door is moving, which could probably be handled in the Update event.
This is pretty much exactly what I'm doing and it's working well.
Hi! I need some help understanding how Unreal networking does events. Basically, let's say a client player presses the jump button and it needs to communicate that with the server. I understand that I need to send an RPC from the event trigger in the client to the server (and then to multiplex as well to spread to all other clients). But lets say there are a bunch of specific variables with conditions set inside of the jump function which needs to be true for the jump to pass through- should I have my RPC call from the client route to the start of this chain of checks, or does it need to be at the end of it where only the actual jumping node is for it to work?
If you're using the Character Movement Component, the Jump functionality is already built in with client predicted movement & replication. All you need to do is press an input and call the Jump function and it'll end up replicating to others. If you're wanting to change the logic of when that Jump is allowed to execute, to do it properly, you'd have to modify the CMC within C++ to ensure that the server knows when a client should be allowed to jump or not correctly with client prediction otherwise you run into a situation where a client could potentially cheat and jump whenever they want and the server won't really be able to compensate for it, or if you enforce a server authority on the jump function being triggered, the client prediction of movement will fail and cause corrections on the client's end making the movement look jittery.
If you're making your own movement component then you can basically do whatever you like. Technically you should have the client perform the checks themselves too just so you're not sending an RPC if it's not necessary, and then having the server validate it as well before calling the jump function, however, this again will have poor response time on the client as it requires the server to perform the move and replicate the result before the client receives any feedback that they pressed the button.
I got tired of debugging multiplayer so I added this little tool for myself ๐ค together with a macro UE_MULTIPLAYER_DEBUG_BREAK(ContextObject) I can break on either client, or, server, or none, without recompiling. I found debugging across multiple clients pretty annoying, are there any secret tools that people know of?
It would be neat if you could easily filter logs by server/clientX also ๐ค
Useful tips and tricks for working on UE content in Visual Studio
The Immediate Window tips in here are handy to know.
I remember seeing this years ago, you are right, this is pretty useful. Sadly doesn't seem to work for rider
I'll ask internally if this is something we can do
Having a version of the "Tips" for Rider would be nice.
Seems you can use these in Rider with different syntax, {,,UnrealEditor-Engine.dll}::GPlayInEditorContextString
a doc for Unreal + Rider would certainly be useful, I'll ask one of our technical writers if that's in the cards. But no promises
Damn, I thought you could make promises ๐
for some reason the server's shots seldom get replicated to the client?
shot a lot of times but only a few times the client saw the shot
is this spawning a replicated actor for the bullet?
this should be, does spawning actor on server and ticking replicated not make the actor replicated?
It does, I'm just wondering why everyone is spawing a replicated bullet here in a multicast
simuled proxies spawning a replicated actor seems uninteded
Multicast = "Everyone do this"
If the actor that the multicast is called on exists on a client, the client will execute whatever is contained in the multicast execution path. In your case, when clients receive that multicast, they'll spawn a local copy of that actor while also receiving a replicated version that the server spawns.
What's also probably happening here is that because you're spawning the replicated actor on the server call, and then also calling the multicast afterwards, the server can end up spawning 2 copies of the projectile since the server also executes the multicast, so then they could end up colliding and destroying one another before the clients can actually see anything.
huh I'll check that
Alright. I'm heading to bed but I wanted to post this in case someone might be able to spot my mistake while I'm away.
I'm working on a keypad system that lets the player enter a code, this code is sent out along with an int ID to find a matching receiver actor. If the ID matches, it checks the code that was sent to see if it was correct then does stuff. This works on the server but not on the client and I'm hoping someone can look at this very crazy code flow and tell me what dumb mistake(s) I'm making:
Why don't you just pass the actual actor reference? Why do you want to use ID to grab an actor in another machine?
Also what is up with the use of interface here?
At what point during initial PIE / game spawn should a client's Player state be valid? I've been trying to run some logic on the playe controller BeginPlay/RestartPlayer but the playerstate doesn't seem to be valid on the spawned clients if there's no delay
Is there a certain function I can override where when it gets called I know the player state should be valid? Right now I'm trying to use ACharacter::SetupPlayerInputComponent() but that doesn't seem to work
APlayerController has OnRep_Playerstate() you can use which should be called when it becomes valid.
My worry with onRep_PlayerState was that it wouldn't fire for the client hosting/running on the server, would that be true?
yes, you can just call it manually though
Try it and see, but you're probably right.... In that case, you should just be able to check on Begin Play of the PlayerController for the server.
C++ onreps are only called by unreal when replication happens. The simple thing is to just call the onrep when the value is changed on authority as well
Yea but that's not something typically modified by someone trying to augment the class... It's internally assigned.
They'd have to override any place where the PlayerState gets assigned in order to then call the function.
Even better...
Nevermind... What I was thinking only exists in APawn.
a note here: you may be calling this inside of the packet that also sets the playerstate being written
don't use a delay set to some arbitrary time...
I would try to make a timer for next tick that does some checks to consider if
- the game objects you need replicated are set
- the game objects have each other set (the player state->controller actually point to one another)
If they aren't there yet, set the delay for the next tick again to check until it shows up
replication is fuzzy... even more so with multiple objects
Pawns know when their playerstate is set at least
I've been trying to copy Lyra's implementation for the most part, but this is the first main part where I haven't been able to replicate their logic
They do delay a tick on ALyraGameMode::InitGame() before restarting all players, but then they delay for all assets to be loaded which I think covers up the liminal time I'm hitting where the client spawns but their player state isn't valid
Lyra also uses the IGameFrameworkInitStateInterface for their necessary components which probably helps out with this a lot as well, but it was a lot of overhead for something that was more supposed to be a proof of concept for me so I haven't implemented that
IGameFrameworkInitStateInterface is literally just some if statements that check for if some objects are present in current contexts
what exactly is the overhead caused by this?
Sorry overhead as in the implementation overhead lol, they also use the pawn extension component to facilitate the init checks and it just seemed like a lot
what does implementation overhead mean?
It may be the functional answer though so I may consider it, I just have only ever seen it used there and figured it was overkill
I guess it does appear complicated but the main gist of it is that it's just multiple places calling CheckDefaultInitialization
each one of them can advance how ready the object thinks it is by... some if statements
It's maybe pointless to be an entire new type of thing if you only need it for this one thing, but the exact way it works is pretty simple besides the gameplay tag array
the idea there was probably to split up the idea of "okay, the playerstate is here but their assets aren't loaded yet" or something
But yeah... definitely be keenly aware of calling stuff from onreps that could be expecting things that happen RIGHT AFTER the onrep in the same frame
especially if you are changing the netcode to iris etc, it might surprise you
Yeah I took some time to try to figure it out to assess if it was necessary or not and you're right it's not that complicated, I just figured it was an overly robust solution to something which could reasonably be done another way (also considering I'd never seen any tutorial/example use it either)
Maybe I was just hoping that the replication part would work relatively painlessly, which seems like isn't usually how it works out lol
There is basically nothing that gaurantees replication of separate properties will show up together

Lol
so... yeah you get to make spaghetti like this
Okay that makes me feel a bit better, I felt like doing some repeated tick-delay like you mentioned was more non-deterministic than it needed to be, but it sounds like that is kind of just the accepted reality of initializing things with replication
The playercontroller is sort of the head-honcho of the connection so that one you can safely assume will always be around in a multiplayer context on the local client (just for you)
also the default send rate of the playercontroller is pretty damn low, you might not want that
Makes sense, that's helpful thank you!
Maybe I will set up the game framework init state interface
you can just have your own simple function, you don't really need their interface etc
I temporaily disabled the multicast function, changed the collision setting but client still can't see the bullets from server (/other clients)
the simple thing here is to determine if the actors ever beginplay on the other clients
and also make sure you make these always spawn if you want to
Say I want to have a Trigger Volume only operate on the server. Sure I can add authority checks on things like the overlap event, but could I also just not have the Trigger Volume be replicated in the first place to the clients' instances, having it only exist on the server, so that I don't even have to bother with that? Or is that not the UE way of thinking of this kind of gating?
bNetLoadOnClient woops, typo
Yep! I did see that one, I was mostly curious if using that vs HasAuthority is considered idiomatic (or good practice) or if either way is common?
I think it just kind of depends
It might arguably be kind of wasteful to load the actors and then instantly nuke them...
If you want you can go nuts with data layers/sublevels that have different sets of actors but that can be a headache
You might find that the actor doesn't have anything interesting to do on the client but it might be useful to have as a marker for visual things, etc
It's true.
I think I found the problem
the actor did run beginplay on client
so I checked the on hit event, in case the actor hit the shooter and disappeared
and found out client run hit event right when the actor spawned, when server's run normally
it seems that the actor pointer is different for different machines
currently I used an actor param and != to prevent bullet from hitting yourself
Hello everyone, I'm considering developing my first game using Photon so I that I can concentrate on game development rather than the client/server rabbit hole for a small multiplayer game - has anyone got experience in it here?
Photon is probably largely used by Unity Developers. For Unreal it's somewhat nonsense to use that over the built in system.
So I doubt there are many or any users here who touched that
Pretty sure it also costs?
Well I noticed they have the Unreal offering in there circle at the moment with public realease upcoming.
I mean you can use it if you want. I personally would not and just use the existing logic in UE. Makes a lot more sense to me. Small multiplayer games can be done with ease and I doubt photon will take away the pain
I'm surprised it's even a thing
Even with photon you'll still need to setup property replication, handle smoothing, prediction, etc
Yeah it's odd one I'm looking to develop a Empire of Ants style game but very much humanoid PvP with tanks and bases etc - I'd come across photon have noticed some games with rather a lot of players (Albion online for example) that use Photon and wanted to figure out if it was worth it.
Why waste your time trying to beat the native networking model lol
With UE you can at least use the character and get that for free
Well a lot of players is not a small game
Because it's serverless and if by some weird chance I end up creating game that gets loads of players(it'll be hyrid PC/Mobile) then I don't want a billing surprise trying to upscale servers on AWS.
It's totally the opposite
The only reason I'd ever consider Photon is if I'm making a memey "cross-engine" multiplayer game
Clash of clans is a small game, but has millions of players.
With EOS you can also just have the clients be hosts Crossplatform
If you reach clash of clans levels of players I don't think money is going to be an issue
The infrastructure behind that is huge
The server hosting is what will be your problem, not the UE part
And server less or listen server is gonna be the wrong approach if you want to have pvp
Hmm OK - you see I'm work in AWS/Devops so server orchestration/scaling is the easy bit for me - but I was wondering about Photon, however it seems the consensus is don't bother ๐
You always need to host the dedicated servers away from the players otherwise the cheat both the gameplay and the progress of their accounts
Don't bother isn't true
I have a data based Anticheat, also collectables/deployables are controlled via API rather than on the game server.
If you need more than 100 players in one session, UEs default system will fight you
Otherwise if it's just, idk a max of 100 or way less, using UEs system that powers games like fortnite sounds a lot better
Yeah gotcha, so this would be mostly matchmaking based so yeah it wouldn't go over 100 in a session.
Yeah then UE would probably make more sense
Pretty sure you'd need to write movement prediction etc from scratch for photon
Here you could use the character class fwiw
A lot of the UE systems also have built in multiplayer solutions which I would assume would all become useless. You might even add work by using photon
And you can probably forget asking for help here cause almost no one uses this
You are the first to ask in months or years
My opinion though. Take multiple and form your own I guess
The UE5 offering they've got coming out seems to extend/wrap the base classes - until I can see the source it's obviously hard to tell and I'm not joining their circle just to see it.
Do they provide a custom engine for that?
If so that's also a pretty shitty requirement in the long run
If they fail or shut down you'll have a very shitty time ahead of you
Heh yeah thats very true you'd have to go through and unpick everything.
A bit of a chicken-egg problem but it's surprising how few projects use photon seeing as how they have a lockstep determinism setup that handles animation/navmesh as well
Idk I just don't see the gain if UE already offers everything you need
"you" specifically
Multiplayer is a first-party feature of the engine, literally no benefit to using anything else IMO
Just making life harder
It's just not really the best idea for most studios to buy into a third party solution if UE has something that works for them
Pretty sure a bunch of projects use it
Most of them probably never made it to the public
I wouldn't be shocked if many of them use it out of ignorance of UE's native networking
UE does not do what quantum does (no, network prediction does not count...) but the fusion thing seems completely pointless to use with ue
Especially if they came from Unity in the past
Unity also has its own system by now iirc
they seem to have a matchmaking service as well which I have no clue about... I don't know anything about that stuff
Even Godot has its own haha
This is what I came across that made me think about it: https://www.youtube.com/watch?v=6DdR9U0czBk
Live-coding with Quantum for Unreal Engine 5:
- Deterministic game state properties added to Actors and ActorComponents
- Predict-rollback logic using DeterministicTick()
- Quantum Unreal native physics engine built-in components
- Input, events, settings, late-joins and other topics.
Besides the above, general questions related to Quantum or ...
โ
I would say lol to that... unless they provide a lot of tooling for rolling back sounds/vfx
also I will say with this you would basically need to turn unreal into a rendering api
I am doing something similar to this (their SEO must be pretty awful for me to miss it for this long lol)
Thanks everyone, so I guess it's Ue5 native and Kubernetes then, I guess that'll be quicker anyway, I just wanted to see what other people thought of Photon ๐
And they provide 0 reflection support out of the box. So scripting integrations such as BP/Angelscript/U# won't work with it unless a programmer exposes it.
I think photon has like 6 distinct products here... The only one that appears directly unique over unreal's offerings is quantum and the matchmaking/chatting stuff I don't know
god save us they add another reflection macro on top just for their stuff
which frankly is probably needed to segregate the deterministic sim from unreal doing random shit
โWe did not do any direct integration... ( for BP) But it is easy for any C++ programmer to expose functions to BP to handle either view polling (we use this all the time for animation, etc), or for gameplay.
But I would NOT recommend using BPโ
This is a direct quote from one of the devs, it was brought up in a discussion over on unrealsharp's discord
So I don't think those properties are viewable from the editor
not sure if based or insane
I would say it's probably not reasonable to just hand over a bp api for this that isn't SUPER locked down and basically crashes when you call RandRange without a seed
They would need to do a lot of extra work to make a "designer friendly" + foolproof api
they miss out on a lot of customers to not integrate it with unreal's reflection
They kind of just... can't let that happen though
like I don't think you understand that deterministic means they must control the state COMPLETELY
it appears that you can do that yourself if you need to, they have serialization etc already done for you
Sure, but if it comes to the cost of cutting out a big part of the engine's feature set
is it really worth it
yes, which is just the way it is
they made their own physics/AI etc to be deterministic I guess
you can't just randomly add a dash of non-deterministic state... this must basically be anything that effecst the game must be made and tested by them for state hashing etc
visual things that just represent or interpolate between frames can do whatever
Imagine if they sold this to people and someone made a ticket like "uhm, I tried to turn on chaos physics and the state hashing broke?"
they more or less need to make it insanely hard to leave their walled garden here
I don't disagree. Just they make it out to be so integrated, when a whole lot the engine won't work with this out-of-the-box
of course I'm sure in the C++ api you could explode it in one call to rand() but it's more about the principle of the thing and having a sort of "other context" of code
yeah it's definitely a bit scuffed to present this as ~integrated~ depending on how little they do on their end
I think to make this reasonable for them to make and reasonable to use they probably would need to have users get a separate "scene viewer" application thing
as I doubt they are putting in the effort to make their collision meshes visible in the editor (I still debug draw lines for my meshes from Jolt like a dingus but I spent a bit making a custom/unique wireframe draw at least)
Take what I say here with a grain of salt because I haven't used their product... this is more speaking as someone who does waste their time basically hollowing out the engine for no reason to make it all stuff I like (fixed ticking with Jolt physics, everything done in an ECS because I like it)
Yeah fair point, at the moment I'm putting together a demo and am currently thinking about platforms, if I decide it's playable on mobile I might even just remove physics completely, at which point Photon did seem like an easy(ish) drop in.
There have a been a few indie launches recently which have tanked in their steam reviews because they didn't properly plan for scaling they servers, so one publication posted a review, a few thousand extra people logged in and their game was unplayable.
That being said I can just use AWS/Lambda/Kubernetes to manage this kinda thing quite easily, knowing nothing about photon really though I thought it was worth checking.
Plus I do have some cool destructable stuff in mind that would need physics so classic networking is probably going to be better.
Thanks everyone!
Deterministic math library: FP (Fixed Point) type (Q48.16) to replace floats/doubles, FPVector2, FPVector3, FPMatrix, FPQuaternion, RNGSession, FPBounds2, and all extra math utils including safe casts, and parsers from native types.
Interesting... I haven't seen fixed point used in the wild before
that completely removes the need to reckon with floating point indeterminism (platforms don't all agree on how floating points work)
Yeah I think a few of the comments here around Photon might not be quite doing it justice, when you watch them go through the live programming on youtube it looks like a pretty solid, well thought out product.
I am more concerned with how it actually works I guess... I think this looks awesome but the Unreal parts look pretty early on
Also very scary to have so few real-life examples of this being used besides some unity projects
That lead programmer guy on there is very approachable by the way, you can just contact them - Albion online supported 350,000 concurrent players earlier this year on the previous version of Photon(unity) - thats the only one I found at any scale.
tbf, there aren't that many use cases for full determinism really
If you can pull it off and make up for some of the strange drawbacks
it can remove some complexity from having one holy code path
but MAN it is difficult and basically forces clients to be able to simulate an entire frame 10 times as fast as normal (and they can't skip simulating much either)
regular client server desyncs basically every frame... but if you fuck up and desync in a lockstep deterministic game you have no choice but to either drop the connection or basically send the entire game state with little compression
I think it's an awesome choice for games without floating point state that are willing to make the tooling required... it has a lot of fun properties
for example: replays are cheap as shit
The downsides are massive though:
- you must make a balancing act choice between delaying input locally vs forcing more rollbacks/popping each frame the less delay you add
- anything that pushes frametime for the game beyond msPerFrame/8 (the number of frames behind by ping etc) will basically hardlock the simulation and force a variety of bad situations to happen depending on what you promised to the other simulating clients
- rollbacking things like sounds/visuals is... yeah.... Imagine accidentally playing a loud gunshot and rolling back, then playing it again
tbh, just for the kind of stuff I work on and being so long in the tooth with UE multiplayer, I've just grown used to it
yeah frankly I think it's a testament to simplicity in some ways with how many games kind of Just Work with the chaos that is unreal property replication multiplayer
There are a LOT of scuffed things that can be fought off but my general impression is moving towards something in the middle for most games
Basically life is easier if you can kind of make tiny atomic expressions of game state over the network
for example: If the height of something is controlled by a separate property, and you also send the state
you are basically risking those being sent on different frames, resulting in some funny situations
Yeah, but that's kind of what I mean - I've grown used to dealing with/working around that sort of thing. Though it is still a tripping point even for experienced UE devs
I find shit just works having a dumb "rep struct" that basically expresses the state of the object on its own... Anything that involves timing frame-by-frame is not reasonable to do over property replication without some fairly decent efforts into timestamping things
It also partly comes down to finding different ways to represent that state with as few variables as possible, not just for bandwidth reasons but also to avoid conflicts
For example... something like an animation that plays that needs to do something for a quick moment... you do not send that "moment" as a replicated property
you are basically praying it will show up with the same timing as the animation... Always just send the "start doing this at this point" and follow through on the sim proxy if it must be timed well...
yes, it's definitely more about compressing complexity than fighting for bits 100%
It's honestly strange we can't make it easier to bundle properties to be replicated as tuples
that would save a LOT of fucked up situations where things show up in odd orders
how to store an actor pointer from client that point to the server machine self?
or as an alternative get their replicated actor on server machine and store it as pointer
replcated actors already do this for you assuming you spawned them on the authority with replication enabled
I want the keypad actors to be able to activate a number of different things so they are independent from the actor that they activate. There may be several different keypads and receivers in a level so I use the ID to connect them
the keypad probably should have a reference to those that it want to activate
I see no reason to use int to tag things that needs to be activated
oh well, I don't really know your use case
if it work for you then good
Well it's not working for the client so if that's the reason, I'm open to any suggestions. I'm not sure how I'd go about getting a reference to them though, other than giving the keypad actor an array of actors and exposing that var so I can "eyedropper" select them in the editor
activation should be done on server
the server can then send signal to client that things has been activated.
can be done by listening to variable change (rep notify)
Right. I'm trying to do that now but perhaps I'm doing it incorrectly. The keypad interface is fired from the server and alters a couple of variables which have onrep. Hmmm.
activation on client doesn't necessarily have to mean anything. Your job is to just sync the world, you don't need to any unnecessary data.
For example when opening a door, for client. The door being "activated" or not is irrelevant, only the the state in the server matters.
Server can handle opening or closing
while client only receive information in a form of the door's position
https://dev.epicgames.com/documentation/en-us/unreal-engine/replicated-object-execution-order-in-unreal-engine at least devs made some docs about it 
Right. I think I understand that. That's what I'm trying to convert all my systems to. Listening for states which the server sets and then doing stuff in response
@glad escarp I think in a nutshell you have to think what information the client need to give illusion that the world are in sync between different machine.
Illusion driven development 
And you just summed up network game design. ๐
handle the activation on server side, set variables which fires on Rep on client to sync the change.
The client doesn't do "OnActivation" or any of the sort
if you get what I mean
Indeed. I think I get what you mean and I think that is what I'm doing but I'm new to this so my implementation might be off.
I think I have the perfect example for this for the door mechanics. We're just replicating the door's open/close state and the server time of the last state change. Client's are moving/rotating the door locally according to that data. So if a door that opened ages ago gets relevant freshly on a client, it's being shown directly as open instead of playing the opening animation
Weird to say this but I love using timestamps for this kind of stuff
As Client : Server RPC -> Enter Code
On Server-> Checks code, if true, set lock color variable to green
Client On Rep -> Set Color
Or like using the server end time of the skills cooldown as the replicated variable instead of a bool
hmmmm
Probably hard to tell from the spaghetti code image I posted above but that's essentially what I'm doing. I send the code to the various receiver actors, using a server RPC but I'm relaying on the ID var being set to fire a server RPC. I'm gonna try getting a ref to the actors like you suggested so I can bypass the ID thing and just change the door open bool which has an OnRepNotify to open the door (which is used flawlessly with the regular interact interface)
I think my brain is finaly adapting to this whole OnRepNotify methodology
Got it working. I was doing some unnecesary stuff server side. Now all my functionality is on the client. And passing a direct reference instead of using an ID is much cleaner. Thank you.
I find it easier to divide the roles. Knowing what server should do and what client should do.
should make sense in paper first before implementing
I can see why that is the better method. A few others have also tried to explain that to me on here but it clicked today so collectively I appreciate it.
Now I get the super fun task of revamping all the systems I've incorrectly created to this point. ๐
But it's nice to know that something is working as it should rather than just that I happened to hack a solution that may or may not work depending on circumstances.
takes a while for things to click for me too
it's like eye opener when the basic stuff clicked
Yeah and my problem is that I'm a very hands-on/visual learner. So reading documentation doesn't work for me as a learning tool. Documentation reinforces practical stuff I've learned and explains to me why it works but it just goes over my head until I've seen an implementation.
Which unfortunately annoys alot of coders when I ask questions because I think they think I'm just bing lazy and want the work done for me.
If you ask for examples to understand something no one should get annoyed. Asking for your actual code problem to be written out is a different thing though. Haven't scrolled up and read anything, so only really reacting to your last sentence
This wasn't one of those times. It's just happened in the past. It's just certain personalities I think who don't even like when people ask for examples. For the most part people here have been super patient and helpful.
I only witnessed this in cases where the user refused to follow the provided information and repeatedly asked for having their actual problem being solved for them.
Haha well that's just obvious laziness
As in actually code the solution. But not when asking for generic examples, fwiw in pseudo code
Unless you go around on StackOverflow
There you probably need to know the solution to your question
Yeah. That's the dark place. We don't go there now.
How to setup Multiplayer for VR
Hey devs
I am new to Unreal and multiplayer in Unreal, but am experienced in Unity, C#, and C++. I am creating a multiplayer game for VR, and I am confused about whether to use a dedicated server or a third-party app like the Photon server.
I want to make a drag and drop app for users where one user creates the room and other join with the name and password, I have experience using photon with Unity and wanted to use that but after finding that it only has realtime SDK for Unreal, which is responsible for Session creation, joining and not much replication, where we need to do replication on our own, I step back, and when was researching I found approx everyone are using Unreal's default multiplayer mechanism, but to setup that with C++ so I can implement custom logic, it is giving me hard time bcz I am using null subsystem right now for local testing, but could not make it work as there is no player id there and my command returns when it could not find that.
So I am again back to wandering which sdk or server to use, that are easy to setup, scalable and less pricy. and has documentation to follow through. Can you please suggest me some good methods that I can do and docs to learn
Thanks
source parameter seem to be missing on the on hit events when run on
and the multicast event seemed to can't read the parameter replicated
Hey does anyone know how to not have Replicate Movement force the client position?
turn it off
I think client movement is already replicated anyways?
it doesnt seem like movement isnt replicated without it :7
In a multiplayer game, if a player is killed due to Kill Z when falling out the world, how do I respawn them?
Does anyone know why my Add Movement Input doesn't move the player on the server but does client side?
(I have verified that the Move Right Axis Value gets sent correctly and that the direction is correct as well)
Only servers can call multicast RPCs
The client needs to tell the server to tell everyone to move
so like this?
Add Movement Input is normally called on the client side. If your class is based off of Character, all you should need to do is call Add Movement Input from the input you're using, pass in the vector calculation you have, and feed in the scale value from the input event.
Ohh I see
The reason I'm trying to do it like this is because I'm having horrible rubberbanding on my clients, as the server tries to force them into their "correct" position whenever they try to move
That's probably because you're fighting against the Character Movement Component with other movements you may be doing. The CMC has built in client-prediction and server correction, so your client gets quick responses when they move, but if they move in a way that the server isn't expecting, you get a correction that adjusts the position of the character -- the rubberbanding you are seeing. So any movements outside of what the CMC is doing can cause a correction, whether on the client or on the server.
If you're using the CMC and only performing moves on the server, then you can't really use the "Add Movement Input" node. You'd have to RPC the values from the client to the server (like the world direction & scale), and then the server would need to calculate and set the desired new location of the actor based on those values. The problem with this is that players would have to wait the round trip time of their ping in order to get any response from their controls... So even someone with 100 ping to the server will feel more like 200ms before they get any response, and it only gets worse with higher ping.
Ah that makes sense! Thanks so much for your explanation!
Since my game is a 2D platformer, its very important that ping is very low for the clients. Although, in my game clients wont really interact with each other at all, so is it possible to perhaps skip this correction from the CMC completely and give the clients full authorization over their movement? (Basically making the clients free from the servers control in regards to movement)
You can, there is a setting on the CMC for ignoring corrections and another for client authoritative movement. The risk with this is that someone with a little bit of know-how could then potentially make their character teleport anywhere in the map. If it's not a competitive game, then it may not be that big of a deal.
That said, what's the point in having your game multiplayer if the players can't interact? Is there a specific type of game that you're trying to mimic for a multiplayer system? There may be a better solution than Unreal's built-in networking for such a game.
My game is primarily a single player game but there's an option to invite friends to play through the story cooperatively. The player uses a gun to shoot things (so bullets will need to be synced between clients) but players wont be able to shoot each other, since its not a competitive game at all. The method for playing together I'm going for is similar to dark souls where you can summon a player which joins "your world", i.e. you only make progress on the host's session and not on the client players'.
Ah ok, so that kind of game would probably be good with Unreal's networking. So then it's just a matter if you're willing to allow client authoritative movement or not. Technically speaking, the host would always be able to teleport around as they are the host, so having a client have authority over their movement would be no different than what the host can do.
These are the settings you can find when you have the CMC selected.
You're a life saver! I'll give it a try asap :D
Awesome! Now there's barely any lag whatsoever on either side!
There's only one issue, it seems that when the client tries to jump it instantly gets snapped back down to the floor? I am using a custom jump function since the default one in the CMC didn't suit my type of game, do I still need to use an RPC on my client to handle jumping even though these two options are toggled on?
Quick question, if I have an array of vectors will changing a value in it trigger a repnotify event?
Any element changed in an array will trigger a rep notify. (On client only if cpp, both if bp)
(Clients, and server if you call it as a normal function )
I thought bp had that weird thing where you need to use SetArray to trigger it
I tried this with a vector array and its only calling the repnotify on clients for one change only
unless you use fast array replication, I believe the entire array gets replicated every time there's a change
I'm not using fast array, have an array of structs.
Everyone always get the same value eventually.
@feral narwhal maybe show what you have so others can take a look
I am calling this from the gamemode every time I add a new spline point.
I am trying to create a spline that is replicated during runtime
what do you mean by "one change only"?
As in the repnotify string gets displayed once only for the client
i believe that is intended
I call this at least 3 times
all of the changes are going to get packaged into one replication iirc
are the values getting printed what you expect?
let me test
They r called within the same frame, so it should be the same on the receiving client on the rep notify
yeah okay I just tested and they're all received in one repnotify
property replication gets checked each tick
Is https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Plugins/NetworkPrediction the NetworkPrediction plugin intended for production and game use (or is it just required for replication), and if so are there resources or a quick start on how to use it to for example improve prediction on an updating vector?
I stumbled upon this by chance while searching for research on network prediction
kinda, but not really, Mover does use it though
not sure what the "or is it just required for replication" bit is getting at though
Can't find the documentation now but I saw on the official docs a page explaining how relevancy works, I believe theres some way to set the radius which an actor is considered relevant or you could turn on always relevant
Net Cull Distance needs to be the squared distance you want to use.... So if you want the object to be relevant within 10000 units, you'd need to have the NetCullDistance set to 100000000
Are you perhaps moving a component of the actor rather than moving the actor?
Hey guys, any idea why this clamp would give me different results on the client vs. the server player? This server RPC is being called on my look input btw. It's setting the rotation for my character's helmet light.
If the clamp is taken out and I just use the GetBaseAimRotation Pitch, it works fine.
It's like the transform of the flashlight on the client player character is somehow different than that of the server player character....
why is there an RPC at all here
assuming Base Aim Rotation is in a good state on server then just do that work on tick
you're basically spamming at the server "UPDATE THE FLASHLIGHT ROTATION" and it's like "geeze i know calm down, I could just be doing this on tick."
I haven't tried to do it on tick. I thought I needed to rep it so that the client was getting the rotation as well. I'll try that in a moment.
Right now the only syncing happening is through GetBaseAimRotation most likely
What's your goal, just to have a flashlight pointing the same direction on all machines, and clamped to those pitches?
Yes. Because when I just parented the spotlight to the player mesh it would yaw correctly but wasn't pitching with the player mesh. But if I just use the Control rotation without a clamp, it rotates past the player view
Sorry, it pitches up or down too far is what I meant.
It should be this simple
Tick -> get base aim rotation -> clamp -> set relative rotation
Yeah that's working great. I guess the server RPC was messing it up. Thanks for the fix. Does this work because the Get Base Aim Rotation AND the Flashlight are replicated?
Flashlight at least exists on all machines so everyone knows what it is and what it's connected to.
GetBaseAimRotation returns either ControlRotation (for local) or a replicated pitch, I think the pitch is built into Actor or Pawn but I'm not sure
setting ControlRotation clientside affects that replicated pitch
so the local client is using their ControlRotation, and everyone else is using that replicated compressed pitch. It's a holdover from the old Unreal days probably
Note it's just pitch I think, you won't get yaw or roll as they are assumed to be from your capsule for Character
Which makes sense since it would be rare to pitch your player capsule but you might want to pitch individual components.
Thank you for the fix and the explanation!
Is there any way to force an OnRep to fire when a variable is set, even if it is set to the same thing?
BP or C++?
Beat me to it ๐
bool AGameCharacter::ServerEquipWeapon_Validate()
{
return true;
}```
What does this function do specifically? Is it to check if the player isn't cheating? Or is it a verification that the server has done something correctly, before replicating it down to the client?
_Validate() calls are automatically executed when the server receives the associated RPC from a client. If you make the function return false the server will automatically kick the client.
Okay, that gives me some information. Can you tell me more about it? Like why does the server want to execute it and why are we kicking the client if its false?
You'd use it to validate whether or not it was a valid RPC for a client to be calling and validate any values that are incoming and automatically kick players if something isn't as expected by returning false. The logic for how you validate is up to you.
It's not something mandatory to use, but it is used as an anti-cheat measure by some.
An example.... Maybe you want to allow a client to send an RPC only once when they are joining the match during a Begin Play, but never again during regular gameplay, and you don't have any code yourself that under normal circumstances would allow a client to manually call that RPC. You can then have some kind of bool that gets set true when it's called the first time, and if the RPC is called a second time, you know that something is afoot as you don't have any code in place that would normally allow that RPC to be sent again from a client. So then you'd check in the Validate() if that bool was set true, and if so, then you can make this Validate function return false so that it boots them out of the game. You may want to do other things like logging or whatever disciplinary actions (like maybe a 1 time warning? notifying some external system of a player potentially cheating? whatever you like) before returning false
Thanks for the information! I appreciate the help.
Does someone understand what makes the MoverComponent move the UpdatedComponent ?
I've been trying to make my own MovementMode mode that makes my spawned Projectile via RPC move constantly forward .. but for some reason .. when its the server who spawn the bullet .. the thing moves .. but when its the client who spawns the bullet via ServerRPC .. it stucks at its spawn position in BOTH server and client ..
The Mover 2.0 related MoverComponent?
yes
The MoverComponent moves the UpdatedComponent via TrySafeMoveUpdatedComponent inside a given SimulationTick function.
can't remember the exact naming. SimulatedTick could also be the function name.
In the traditional "Client controls the Actor" scenario, the Client would provide all Client-only information to the Server by implementing the ProduceInput function.
Both would then run GenerateMove on the current MoverMode and use the generated move (or ProposedMove) in SimulatedTick to move the UpdatedComponent.
FinalizeFrame would then be used on SimulatedProxies to update the UpdatedComponent to match the SyncState.
If it's a Server-owned Actor, like a Projectile, then the ProduceInput part would be skipped and GenerateMove would figure out the Velocity based on other things.
Only on the Server then of course. All Client would then only updated to the Interpolated version of the SyncState in FinalizeFrame.
how to make an actor that's spawned on server invisible to only the actor that spawned it's controller?
Yup, that's how I'm doing it .. but still things doesn't work well when its the client who sends spawn the bullet via server RPC
I guess, according to what you said .. my problem is with the FinalizeFrame part of the code
Could be yeah.
The code is a bit funky in the native version and has a comment on it from Epic
But it basically checks if the UpdatedComponent and teh SyncState are different and if so sync them
Which Server and AuthProxy would never need to
Alright, I guess I have now a clue where to dig.
Thx !
Did you provide the Controller as an Owner or so?
didn't but I can
and then how?
I have a 'weapon slot system', which keeps track of different properties for each slot that can hold and use a weapon (right hand, left hand, ...)
Right now i'm using multiple replicated arrays on a component, and i just know that at the same index of each array there is the property of the same slot.
I was wondering whether would be better to use a single replicated array of replicated UObjects which would hold all the properties for each slot.
For sure readability wise it would help, but i'm concerned about the bandwidth cost. What would you suggest?
should I put the controller or actor on it?
I'm running an execute on server function first and then spawn actor on server
I heard playercontroller is null on other controllers so it becomes null on the transition
Where is the RPC being called in?
PlayerController of Client-1 is null on Client-2, Client-3, etc. ,but valid on the Server.
Server basically has all PCs
Clients only their own.
actor, run on server
I somehow succeeded in making it go invisible, along with the client prediction projectile by running a run on owning client function on the bullet
but then client can't see the server bullet as well
the client first spawns a client predict projectile that does nothing
the client call a custom event that's run on server
the server spawns the projectile
now I want the only the client to not see the projecitle
and the projectile I wanted to hide is simulated proxy on yourself if shot from a client (replicated from the server projectile) so can't differentiate it this way
Right, but you didn't answer my question. Maybe I wasn't clear enough.
Which Actor/Component does the RPC call in? Character? Weapon?
character
Right, so then you don't need to pass the Controller via the RPC.
Because the Server version of the Character also has that Controller.
You can pass the Controller as the Owner.
And the Character (self/this) as the Instigator.
Both on the SpawnActor node.
In BeginPlay of the Projectile you can then check either of them for being Valid and for either "IsLocalPlayerController" or "IsLocallyControlled".
character on client or server as the instigator?
You spawn on the Server inside the Character or not?
So just "self"
In theory Owner and Instigator should be valid on BeginPlay, unless Epic sets them after actually spawneing. If that's the case and you aren't using C++, you'd probably be better of making your own "ProjectileInstigator" variable on the Projectile, marking it as "RepNotify" and "Exposed on Spawn" and supplying the Pawn/Character (self) to that.
Then use the "OnRep" function in the Projectile, and fwiw BeginPlay too in case of Race Conditions, to check if the ProjectileInstigator is Valid and IsLocallyControlled.
If both are true, you are on the local player and can hide it.
okay, will try it
ok so here is the culprit .. I forgot to check the log
Interpolation out of sync. We don't have valid frames for this time for this sim. Frame 0. TimeMS: 38233. @ 52855
not sure what that actually means .. but I'll keep trying things till I understand
Someone familiar with unreal tournament's code can tell me how firing is notified to other clients?
I'm having a problem where if I test the game using Standalone, the game will freeze or it won't be able to change the level. I haven't seen any information about this anywhere.
When it freezes? A bit more information is needed
At the very beginning. It will open up this window and will remain black. I can't even move the window or close it by pressing the [X] in the top right corner. The only way to close it is by clicking in the editor, press on the three dots and change the mode to Play in viewport. That will close the window and proceed to play in the editor fine.
@normal fulcrum
Edit: Decided to let it play and it looks like it's just taking a bunch of time loading. Right now it says that it's preparing shaders (over 13k).
I hope this won't affect properly when playing multiplayer, which I just realized I posted in the wrong channel. Sorry!
ah, this standalone.
Apparently, it needs to compile these shaders, yes, then, when it's ready, it will load everything up
My experience with standalone is just bad,I would either package the game, or use PIE instead
Ok so, I confirm what you said .. but this is the case when using "Fixed" ticking policy
Basically my code was working perfectly when I switched the policy to "Fixed" without changes
However, things doesn't work .. only when the client sends a server RPC if I change the policy to Independent.
Since Independent seems to work much smoother for my game .. I think I'm gonna try to read about it more and understand how it works in order to use it instead.
The NetworkPredictionWorldManager handles setting up the services based on the tick policy
You can start there to figure out what calls
And then you have the Service_xyz.inl files for the different services that have Fixed and Independent versions
Alright, I'll start there.
Thx again !
You will never escape it Cedric
when sending unreliable RPC's, is it common practice to include some sort of timestamp in the data struct so that whoever receives it (usually server) can put the data in order if some network abnormality causes the data to be received out of order?
specific use case: replicating transforms as often as is practical. more specifically, replicating SKM pose in VR body tracking melee/projectile combat. only specific transforms will be replicated, the rest will be done by local IK. I will use simple lerp, and eventually use snapshot lerp to validate hits.
in the end, I probably need to experiment with various simulated network conditions to answer this. if packets are arriving out of order, that might indicate bandwidth saturation, which I'm guessing should be addressed first, and adding a timestamp won't help that lol.
on the flip side, timestamps are useful for performing snapshot interp for hit validation... ๐ค I will not be implementing nor using simulated proxy prediction, so no velocity data needs to be transferred.
regardless, I still think unreliable RPC's may be better for this. if I'm not mistaken, reliable RPC's use TCP instead of UDP?
Can you replicate activation and deactivation of brain component in controller or character class?
@lean tide all RPC's besides unreliable multicasts are ordered, so long as they are channeled via the same actor
And all communication is UDP
Hey all. Another quick noob question for y'all: Which class should I do my SetBaseSoundMix on and is that the same class I should be doing most of my player persistant variables as well?
Hello Hello! I am looking to see if there is an individual who will spend a few minutes with me, as I need to ask a series of architectural questions around dedicated server design within Unreal Engine 5.
Architecture, Solution/Project structure and some general design concerns.
Does anyone have extensive knowledge in that space?
My plan is to just tell everyone how bad it is so no one will use it and I can keep my peace.
Luckily you know as much about it as I do, in theory. I'll just redirect them to you.
Maybe I can get Lewis to make an account here and waste his free time.
Hm hm hm.
You should ask your questions. Otherwise barely anyone will answer you.
Dedicated Servers aren't anything super special. You usually get the Source Engine so you can build them and that's kinda it. Code wise you just make sure nothing plays on the server visual etc that doesn't need to.
Solution and Project remain the same.
My core issues is understanding how to architecture systems that are server-side only. I understand the preprocessor definitions but UE Macros can not live within the body of a preprocessor block which fine, I get it. However, it seems the only way to have isolated implementations is to build a server-only modules, there is no way to do that natively
what do you mean by "isolated implementations"?
there is #if WITH_SERVER_CODE guard. Code guarded by this define will only exist on dedicated servers
WITH_SERVER_CODE is 1 for game target
And how isn't a server only module a native way of doing something?
ah true. UE_SERVER iirc
Could use an OnRep that will call it. That said - AI runs on the server only, why do you need to replicate the brain component activation/deactivation?
For optimization
There are various classes, objects, structs, etc that I want are dedicated server specific. If with preprocessor definitions UE_SERVER / etc, there is still some sort of footprint client side.
Is there no way to have custom objects / classes that are server specific without wrapping the guts with a preprocessor?
There is no way to have clear abstraction between server and client?
hahaha fr fr
i thought networking was hard, but damn EOS is another level
its high modularity and seperation of systems makes it difficult to naviguate
There is a means in the project settings to exclude classes and modules from dedicated client builds.
This may be the approach I need to get a better understand of. I have multiple services that are server specific and there is no need for the client to have any idea of their existence; not even some empty stub class.
Didn't you already mention a server specific game module?
Yes, I was hoping that maybe there was an approach I was missing, trying to avoid the module approach
Why?
My question(s) were more about understanding what the best approach is. If going the server only module route being the only or correct way, that is what matters to me.
Can anyone share a more or less extensive list of best practices on lightweighting and optimizing the CMC for the most basic XY movement? The setup: isometric high speed hack'n'slash gameplay with RootMotionSource-based evade/dash moves, no physics (or as less as possible), capsules are used only as a retainers for obstacles, not pushing or similar actrions
The target experience - Windblown style gameplay with zero resyncs
Getting lots of correction majority of time when I use Lyra (dash, jump, normal moving with rotation) basically I get this in a fresh lyra project, any idea why ?
Iโm replicating an actor with a spline mesh component. Thereโs a listen server and remote clients. Spline points are added dynamically. Any connected clients and the server will see the dynamically added spline points as intended. However, late joiners will not receive the previous spline points. (All other actor properties replicate as intended for late joiners.)
Iโm implementing a workaround since further reading seems to indicate spline components are not meant to replicate? It is strange that it works fine with currently connected clients, however.
If anyone has further insight, it would be greatly appreciated! Cheers
when asking questions like this you should include the current network emulation settings for how much ping there is between client/server
how are they added?
Could be that the points are not replicated but the act of adding them is
you probably want some sort of onrep here if spline points themselves cannot do that, IDK if they do or not.
With AddPoint at runtime. The base function, not any RPC I made.
I think youโre right though. โAddingโ is likely replicated. I plan to add my own functionality to duplicate the points locally for late joiners.
It'd probably be as simple as OnRep_Points
you just need some code to add/remove/modify points in the spline to match the replicated data and you're all good
What about the spline mesh exactly needs to replicate?
Does it move the points? or just add points at x times along a stationary spline?
But yeah... Just use a fast array or regular array if it's small enough
On that topic, is subclassing to add replication a possibility?
I've never done it, but say there was some engine class with some property, can a subclass "enable" replication + repnotify on that property?
it depends on what it is
you can use macros to change the replication settings of parent rep properties
like DISABLE_REPLICATED_PRIVATE_PROPERTY
I don't know if DOREPLIFETIME_CONDITION_NOTIFY will add a repnotify for a member that didn't have one before
It's almost certainly easier to disable the parent and then make your own
If you want to change what it replicates
then just hook up what the parent does into your new one
But not everything is so simple... this is doable for some things but not others
Until some other thing expects USpline and not UMySplineAlmostExactlyTheSame
I would say the amount of data here is quite small so it would be less hard to just add a replicated array of points
Why? You are just using the replication to change the spline points
why the spline points are there is nobody's business
Are you talking about subclassing or making a parallel class that does the same thing
I mean subclassing here
ah yeah and just duplicating the data and using the onrep to shovel it in the original data
that'd work in a pinch
It would be arguably possible to just make a separate component that expects a passed in spline component for it to manage the points of
The points update fine once theyโre there. Editing, translating, etc. Just needs replication.
But it's all arbitrary... the real thing here is to have a replicated actor (or comp) property that has the points on it and onreps changing something
It doesn't really matter what it's on.... It just has to make sure it applies it to a specific spline component
Yeah I'd do that first
I have a lot of other functionality in the same actor, so a quick onrep_notify seems the best path. Another project, perhaps, Iโd try subclassing. However, feels like a spline compโs point data should just replicate like other properties marked for replication. The checkbox for โComponent Replicatesโ (I forget the exact wording) seems useless.
default ping, and ping with 100 200 300, I tested all pings and I have this
and this dsnt happen in a fresh ue project at all
only happens in my current lyra and a fresh lyra
i used both lyras, marketplace and latest source
I wonder i to package the game and test in shipping, if this would happen or not
That just means the component replicates, the data wihin it that replicates or not is up to the component
It means the compoments properties should be considered for replication, right ?
You can have hundrer rep variables in a comp, but if its not marked 'Component replicates' they will never replicate
Yeah, and if the component is marked as replicating but the inner properties aren't then it doesn't help much
Indeed indeed
It is weird to me that the essentials of a spline isnt replicated tho ๐
Would be like the actual mesh in a StaticMeshComponent wasnt replicated
SplineCurves are replicated ๐ค
In moooost cases, when using UE, you won't split the Client and Server code. You can use what is already suggested and that's it. If you come from some other framework where server and client are two fully different projects then you'll have to forget about that.
You could always #if WITH_SERVER_CODE && !WITH_CLIENT_CODE etc. (or whatever the defs are) and define everything 3 times ๐
well the && !UE_CLIENT part is pretty redundant
I'm assuming different code for dedicated servers, listen servers and clients.
I'm looking into SplineMeshComponent and it looks like it's not meant to be the spline data carrier anyway
it can only have 2 points, not much of a spline there. The spline data itself should be replicated, not the spline mesh component(s)
UE_SERVER is only 1 for dedicated servers
WITH_SERVER_CODE is 1 for game and server targets, 0 for dedicated client
the only thing I've put in a server module is stuff that is dedicated server only, which isn't really gameplay
it'll be things like backend
for sure
Are gamemode subsystems owned by the client or server?
I am starting to think that its owned by the server,
which means if a client calls a UFUNCTION(Server, Reliable) its going to get dropped because you dont own the subsystem as a client?
gamemode subsystems?
Sorry I mean UGameInstanceSubsystem
Also is there away to check in visual studio during debugging if your inside the server or a client?
GameInstance is per instance... client has one, server has one
in addition, they're not replicated
Oh fricc so you cant rep from a client UGameInstanceSubsystem to a Server one
That would make a lot of sense
I need to find a better subsystem type then
well none of them are replicated
oh hmm
but at least with a world one you could spawn a proxy actor or something
That is annoying
So theres no way to call a function from a client subsystem to a server subsystem, correct?
no? because who would own it?
I assumed it would work in relation to what owns it
in relation to what? not sure I understand
for a Server RPC to work, it needs to be owned by the player that's calling it
I thought things like controller owned the local player controller subsystem
gameinstance owned UGameInstanceSubsystem etc
subsystems don't replicate so the concept of ownership doesn't make much sense in this context
How do you replicate toggling on/off of brain comp blackboard comp, behave tree comp?
Gotcha
well there aren't "local player controller subsystems", there's local player subsystems
When is the best time to do that?
Ah thought you needed a controller to access them?
no, they're owned by the ULocalPlayer
you get a notification when the player controller changes
OnWorldBeginPlay probably
well even a proxy actor isn't going to do much in your case if you want Server RPCs
I cant go client subsystem -> proxy actor -> RPC to server -> Server subsystem?
I answered this yesterday
The answer is going to be the same
proxy actor per client ๐
an actor spawned by the client is never spawned on the server
Well it would be spawned by the server
probably would just create an actor component to put on the PC tbh
That might be a good idea
So at this juncture, what's the advantage a worldsubsystem has over a component on gamestate?
the auto-initialisation is pretty much the only thing
but hey, GFPs can also inject components if you do the setup
More easy global access as well
I do like the access and auto initialisation
I haven't attempted to do any networking with the subsystem version of my plugin but I'll have to soon
But, it would be a very tiny benefit imo (the easier global access that is)
The big benefit for me is extensibility.
I will have dozens of these and each one has a model struct, component class, and subsystem class.
https://github.com/AdrielKinnunen/SpectrelightPlugins/tree/main/Plugins/SLMechatronics/Source/SLMechatronics/Public/Devices
Is there anywhere else that is persistent between world changes?
(also for context I am a tools engineer and been thrown in to a network task lol..)
well if you use seamless travel, anything that's in the seamless travel list, anything else, not really other than things that have a longer lifecycle than the world
but everything in unreal replicates within the context of an actor
When I want to make a new one I literally just copy paste the closest similar file, rename, replace the guts, and done.
If I were to use UObjects instead is there a way to query at runtime for classes to instantiate?
Like instead of a manager subsystem + tons of other subsystems that automagically get instantiated, a manager subsystem/component + tons of uobjects that get instantiated.
not really tons but probably about 50
General question for replication:
- So if I'm understanding things right, typically the same logic will fire on both the server AND the client most of the time, but just in specific circumstances we differentiate between the two, is that correct?
- So lets say for initialization logic on an autonomous proxy player character, typically the logic will fire on both the client and the server independently, except for specific times when initializing UI and stuff right?
Is there a way to get all the currently connected player controllers / player states? I cant use the traditional add to array method when a player joins / leaves because I am using seamless travel.
well that sounds like reinventing the PlayerArray
is the player array your talking about built in?
yes, on the GS
does it not exist on the GM
not sure how that would be a problem since you can trivially get the GS from the GM
I am just trying to understand how it works because lets say I have some data like NumberOfPlayersAlive that I need to determine how the game mode logic will work. Will the player array update everytime a player loads or will it already have all the players from the previous map?
Usually it wouldnt matter but I am trying to carry over the number of players alive from map to map
hi, having an issue, this is fore a "buff" so when the client use ability apply buff on players in range
it works for server(listen) with self+ clients
but on clients it only works on self
well the starting part works* so just to short it down really
Need to see the whole path from input to there
probably missing the run on server event though
Looks like the trace would only be happening on the client. You can't call RPCs on actors (or components) that aren't owned by the client.
hmm but its hitting the players correctly
Yea on the client only.
but you men its opnly hitting on clientside
Where does play montage server go?
hmm
But then you're trying to call RPCs on their components.
ah gotcha, and tracing serverside is dumb ?
tracing serverside is great
Tracing serverside would make the most sense.... Otherwise you could have a client tell the server anyone in the game got the buff.
the message your client should tell the server is "I pressed this button"
Montage server is only Rpcing the montage
yeah lol just by playing the tracing from server everything works
noice ๐
makes sense tho
ty
In short:
when i create a default sub object in constructor, is the object created the same in client and server?
My problem:
i have a class inheriting from UObject (setup to be used as replicated object), and have a component with a non replicated pointer to an object of that class.
If i then assign that pointer in the constructor by creating a default sub object, and add that object to the replicated sub object list, would the sub object replicate properties fine?
I'm asking cause i did not have time to investigate, but it seems that the properties on the sub object are not replicating, and i was wandering if it was because the clients were actually pointing to their own instance of the sub object instead of the one the server is using
Yea that sounds like you're probably creating separate instances. The variable would only contain a reference to the locally created object.
But then why are components shared? (Are they not?)
I probably am misunderstanding the whole default sub object thing
If you spawn a component on the server at runtime and want to access it on a client you can mark it as replicated in which case it can replicate to the client, but the client still needs some way of referencing that object once spawned. Just because you may spawn that same component on the client side doesn't mean that it is the same object across the network.
https://ikrima.dev/ue4guide/networking/network-replication/general-replication/
Based on this, you need to make sure the object is named the same on both the server and client (so you have to have some deterministic way of naming the object) and override IsNameStableForNetworking() to return true, then you can set a non-replicated reference on either side and it should refer to the correct object across the network.
I will try, thanks!
How do you replicate toggling on/off a character movement component?
Anyone have a recommendation for how to know when game state has replicated down to a client?
game state in general or the gamestate actor?
I guess game state in general?
I understand all the networking stuff in that capacity
But game state itself isn't on something as a rep notified element is it?
I am not talking about a variable on game state
I am talking about the game state itself
begin play
I need other things to be aware of it being valid on the client - best way I could think of was basically having game state on its begin play manually raise an event on something guaranteed to be valid on the client, like game instance
But that felt sorta derpy
So was curious if there was something already provided in some capacity that could be use to key into when the game state replicates
there might be a replicated ref to gamestate with an onrep somewhere
Yeah thats what I was curious about
Lyra would make some sort of macro that just keep looping with wait till next tick until the object is valid
in the network latency settings, is the units in ms? i wanna make sure its not unrealistically high when testing
even with the longest distances the latency wouldnt be higher than around 250ms in real world right?
300+ is still possible even over high speed links.
so if the game still works with 500 delay and 40% packet loss is it safe to say its ready for the real world?
i always enable reliable on events that have vital information so i assume with packet loss the network protocol will have those packets sent repeatedly until its received
that's overkill testing imo
I wouldn't even bother making sure a multiplayer game worked okay with anything past 250ms
you'll be fine
what about units? because this wasn't answered and I am curious too
I have settings like this for emulation, and GetPingInMilliseconds() shows me about 200-230ms ping
those are captioned as "average" conditions but I think +200ms ping is BAD network conditions, isn't it?
are those good for testing or should I set something other? At the moment my movement is corrected sparsely by server but it still happens
it really depends on your game tbh. imo anything past 200ms is a lost cause. But for non competitive games where cheating isn't a problem (It takes two for example) a lot of stuff could be client authoritive or not completely replicated. In most competitive games though I'd say 200+ ms is terrible network conditions
packet loss is also important though
gotta make sure those packets are getting through
I honestly would not bother trying to make your game playable past 250ms, It's gonna end up being a horrible experience for both players who are and aren't lagging, or players who are lagging somehow gain an advantage
it's coop but I can't let movement to be client auth
if it's a friendly co-op listen server game, I honestly would let movement be client authoritive
I'd make as much as I possibly could be client authoritive
someone with 300 ping would be able to play just fine at that point
I know what you mean but I don't know if I would do something competitive in the future in this game. But if I remember correctly for make client-auth movement it is one checkbox?
sort of
cmc is weird I doubt it's just one single checkbox
but it's important to remember that if it's a listen server game, all bets are pretty much out the window anyway for any serious competitive game
the host would have the ultimate advantage of 0 ping, and cheats if they wanted to
it's up to you as the developer to find the appropriate balance of non hackable (server authoritive), and client authoritive events which rely on anticheat
people often forget that anticheat serves a large purpose in the battle of lag compensation. A good anti cheat would mean people can't abuse client authoritive functions, ofcourse that's way easier to say then to actually apply it
you have given me food for thought
Even 1% continuous packet loss is really bad and is not the norm for the majority of connections and is something effectively completely out of your control and is a problem on their end, not yours. All you can do on your end is try to make your systems so that packet loss doesn't completely break things and can potentially recover from it as gracefully as possible. As far as ping goes, there's only so much you can do about it as well, and usually it's more about the player experience than it is about the actual ping being a problem. There's no way you're going to support someone with continuous 500+ ping without the game feeling like crap for them in some way. I agree with Moxie, and realistically 250ms is probably the highest I'd test against as 250ms ping is like what a 56k modem would play with back in 1997, but I imagine there are still some people using dialup.
There's two on the CMC:
40% Packet Loss. Might as well kick that Player.
someone didn't play dota 2. 1% packet lost is unplayable
I always treat package loss as something that will happen and if it does happen it shouldn't lock up the game. Despite that, any visual problems it causes are unfixable in most cases.
When testing we always have it at 0% and 250ms ping is also quite high. Ping is just a delay after all so it doesn't really matter for games where players don't interact with each other. It won't ever break anything. Just doesn't feel nice.
In theory, a predicted client that doesn't interact with other clients can play on any ping.
Very naive theory of course
I had some sporadic 1-4% packet loss on my old cable internet connection trying to play some Black Desert Online.... Take 5 steps, game would force a reposition which in that game would give a mini-loading screen. Super frustrating.
That all said there are ways and systems to help with occasional package loss
NPP for example sends the last x InputCmds to the Server and the Server actually buffers a few InputCmds before starting to process them.
That way, if one is dropped, it will be part of the next batch
What is a 'good' approach to sending gameplay notifications between level-based actors in a multiplayer environment?
E.g.
- A switch for a door on the other side of the map?
- A 'boss' ability that can trigger a pillar to crumble or start shooting lazers at players
My initial idea was to use a 'get all actors of type' with some additional tags, but that seems very performance intensive and not ideal.
Ideally looking for something that doesn't rely on the specific level (no level BP usage)
GameplayMessageRouter
Ooo wow! Didn't know this existed! Looks perfect! Basically a sub-pub system?
This feels similar to event dispatchers basically? What's the key use-case differentiation between them?
I believe its just using dispatchers internally, with some tiny routing logic and subscription list
Its just way more generic than how one would usually use a dispatcher
Allows for easy data transactions between totally independent actors without the need to link them in any way beside subscribing to the right Channel and agreeing on the datattype
A tad hungover today so excuse my extra weird attempt of explaining it๐
Ahh good homie, yeah I think I get it, sounds like a good unreal-native solution with low overhead.
Reading the docs is says it doesn't replicate, so for most of my multiplayer use-cases, I would need to
- Implement a RPC broadcast function on the player (to use their RPC connection) and then
- broadcast the message on the server
- relevant (authority version of) actor picks it up
- authority actor actions it and replicates the action?
I also can't seem to find it in the plugins view; so I guess I have to go and rip it out of Lyra?
I am using multicasts, don't know if there is any other option for that
For button on other side of map - just increase relevancy range
What is that?
Not giving any context
The system could be used purely on the server side yes, and let the relevant actors handle their state replication as per usual
In my eyes it doesnt actually meed to replicate at all (the GMR, that is)
What do you mean?
For example, a switch for a multiplayer door;
- Client 2 pulls switch
- Client 2 needs to send a RPC to Server that switch was pulled
- Switch broadcasts gameplay message tag 'Open'
- Door (authority) is listening for 'open'
- door receives 'open' and updates its position
I would get the client to request the server if it can pull the switch
what if the interacting player have delay and other player actually pull the switch first
it would be akward to do some rewinding there
Client Tell Server, Hey I am pulling this switch.
Server checks if the switch is pullable. First come first serve.
If pullable, then set the variable that opens the door
Client-> OnRep-> Open door
another way to do it is to have the client only send a generic "Use" rpc and have the server determine what it's looking at and do whatever context sensitive action it needs to (like opening the door)
also i can't read "context sensitive" without thinking of conkers bad fur day lmao
I've never touched multiplayer in Unreal before, so I was wondering if y'all know of any good resources to check out?
Read the pinned messages
Would've thought I would be intelligent enough to work that out myself, guess not
Hey so I'm not sure I understand replication correctly. Is it true that all variables with "replication" enabled will only affect the host player and not the clients, but the clients can still see the changes applied on the host player? Is it smarter to just send all the variables through RPC regularly instead of enabling "replication" on the variables?
Hello I'm having problem replicating flashlight rotation in blueprints. The problem is that replicating just camera rotation won't work because of my hierarchy, where camera and flashlight mesh are attached to different bone sockets on arms mesh. I'm thinking about replicating spring arm rotation.
I've been struggling to destroy an actor and replicate it. How do I do it? I tried using multicast but it didn't do anything. Tried using server rpc but I can't since the actor doesn't have an owner and shouldn't.
It should be destroyed on the server
The logic to destroy it should happen on the server
Show your code, because destroying on the server and it replicating down works.
Make sure the actor is set to replicate as well
UFUNCTION(NetMulticast, Reliable)
void Multicast_DestroyInteractable();
void HandleDestroyInteractable();
void RequestDestroyInteractable();
void AInteractable::HandleDestroyInteractable()
{
Destroy();
}
void AInteractable::RequestDestroyInteractable()
{
if (HasAuthority()) Multicast_DestroyInteractable();
}
void AInteractable::Multicast_DestroyInteractable_Implementation()
{
HandleDestroyInteractable();
}```
I call RequestDestroyInteractable() on key press which calls without a problem.
Need more?
I set replicates to true
in the constructor
using binary code engine
{
if (IsValid(this))
{
if (bIsContainer)
{
if (ContainerReference)
{
HUD->TabMenuWidget->GroundContainer->ContainerInit(ContainerReference);
HUD->OpenGroundContainer();
}
}
else if (bIsCollectable)
{
if (InventoryComponent->HandleAddCollectable(CollectableReference))
{
RequestDestroyInteractable();
}
}
}
}```
And how do you call that?
The interact() function calls inside the player character class after pressing the key E
Show that function
void APlayerCharacter::Interact()
{
if (IsValid(CurrentInteractable))
{
if (TObjectPtr<APlayerController> PC = Cast<APlayerController>(Controller))
{
if (TObjectPtr<AGameHUD> HUD = Cast<AGameHUD>(PC->GetHUD()))
{
if (!HUD->bIsTabMenuVisible)
{
CurrentInteractable->Interact(HUD, InventoryComponent);
}
}
}
}
}```
Is Interact a server function?
Yes. CurrentInteractable->Interact is calling it on your local machine. Because you don't own it locally, it won't call any server rpcs
The interaction needs to happen on the server
So the player calls Server_Interact and that is where you do the rest of the logic
Quite the dependency chain
wait which interact. The APlayerCharacter::Interact or Ainteractable::Interact. The Ainteractable::Interact handles some checks before destroying the actor
You cannot call a server RPC from something you do not have network ownership of
Well then APlayerCharacter
Your local client does not have network ownership of the interactable
Well it should be fine then if I simply make it a server rpc no?
But inside of your Interact method on the interactable object, you are trying to do a server RPC
Please use delegates for things changing rather than gameplay interactions directly interfacing with the HUD
But yeah, it'll have to be on the character
It is getting dropped
Or anything else the player owns
Since the server is going to call the Ainteractable::Interact function it's going to handle all those checks and destroy it
Could be a component
The server is never calling it
Because the RPC is being dropped
Because your local client does not have network ownership of the interactable object
Well if I did this:
void APlayerCharacter::Server_Interact_Implementation()
{
if (IsValid(CurrentInteractable))
{
if (TObjectPtr<APlayerController> PC = Cast<APlayerController>(Controller))
{
if (TObjectPtr<AGameHUD> HUD = Cast<AGameHUD>(PC->GetHUD()))
{
if (!HUD->bIsTabMenuVisible)
{
CurrentInteractable->Interact(HUD, InventoryComponent);
}
}
}
}
}
this line: CurrentInteractable->Interact(HUD, InventoryComponent);
Would be called by the server no? So the server will handle the destruction:
void AInteractable::Interact(TObjectPtr<AGameHUD> HUD, TObjectPtr<UInventoryComponent> InventoryComponent)
{
if (IsValid(this))
{
if (InventoryComponent->HandleAddCollectable(CollectableReference))
{
RequestDestroyInteractable();
}
}
}
void AInteractable::HandleDestroyInteractable()
{
Destroy();
}
void AInteractable::RequestDestroyInteractable()
{
if (HasAuthority()) Multicast_DestroyInteractable();
}
void AInteractable::Multicast_DestroyInteractable_Implementation()
{
HandleDestroyInteractable();
}
- Player presses a key
- Does some checks and then calls server_interact
- We are now on the server, so we'll do our logic here - such as telling the interactable object that we interacted with it
- Server version is doing w/e it needs to - such as destroying itself
This is the flow
server_interact is on the player character
Because you need to have network ownship on something to call a server rpc
yeah I understand that
Otherwise, what sswires said. Don't gloss over that. Design wise, it is not good for your gameplay code to be interacting directly with the hud.
wait what. Why? I'm only checking if a widget is visible or not. That's all
Even then it's not a good idea to have it directly dependent like that, the character shouldn't even know what a HUD is
Can get some nasty circular dependencies very easily
hmm ok.
hey ...i never changed GameState (was always default ) .,...but now i tryed a custom GameState because i had to put a timer for deathmatch inside .Problem is that when i change to custom GameState only server can move others imposible to move ,,,anyone have an ideea why ?
You have to make sure that if you're using GameModeBase for your GameMode, that you use a GameState based off of GameStateBase. If your GameMode is based off of GameMode, then you need to use GameState.
so if the Gamemode is of a gamemode *(not gamemode base) then game state must be also gamestate (not of gamestatebase _)
Correct
oh shit ๐ now i get it :)) thanks man ๐
seems like my gamemode is from gamemode and i need a game state base
so last thing ..if i make both gamemodebase will still work in theory ๐
If you want to use GameStateBase, then you must make your GameMode based off of GameModeBase.
isn't it better to make an implementable IInteractable interface for actos?
Don't know
So - this works fine in blueprint but I want to learn replication in cpp.. Can anyone provide any guidance or help on what's wrong with this?
I am a bit of a slow learner so if you help and I don't understand please be paitent with me. ๐
โค๏ธ
void AMyProjectCharacter::StartSprintingOn()
{
GetCharacterMovement()->MaxWalkSpeed = 500;
}
void AMyProjectCharacter::StartSprintingOff()
{
GetCharacterMovement()->MaxWalkSpeed = 240;
}
void AMyProjectCharacter::OnRep_bWantsToSprint()
{
if (bWantsToSprint)
{
StartSprintingOn();
}
else
{
StartSprintingOff();
}
}
void AMyProjectCharacter::Server_UpdateCharacterSpeed_Implementation()
{
bWantsToSprint = !bWantsToSprint;
}
void AMyProjectCharacter::StartSprinting(const FInputActionValue& Value)
{
if (HasAuthority())
{
Server_UpdateCharacterSpeed_Implementation();
}
else
{
Server_UpdateCharacterSpeed();
}
}```
this shouldn't work neither on blueprint or cpp
you probably don't test your game with delay
Movement should be predicted otherwise people will just uninstall the game
imagine if it will take 1 second to sprint after pressing shift, wouldn't you stop playing the game?
I would assume there's just a delay but if it got worse then yes.
How can I go about doing predictions?
@burnt coral https://www.youtube.com/watch?v=urkLwpnAjO0&list=PLXJlkahwiwPmeABEhjwIALvxRSZkzoQpk&ab_channel=delgoodie
This break down the monstorious cmc and also comes with code to sprint in multiplayer and beyond.
https://discord.gg/uQjhcJSsRG
In this video I am introducing a series I will be making which explores the character movement component and how you can extend it in depth.
0:00 Intro
1:00 What is the CMC?
2:00 Do you need a custom CMC?
5:35 What does the CMC provide?
7:10 Outro
https://github.com/tranek/GASDocumentation
^ The Gas documentation probably better to look at for only the sprinting part.
but looking at delgoodie's video will give a very good insight
I appreciate this, I will do digging and come back with new issues if any arise.
Here's a brief on the problem:
The Character Movement Component has client prediction built in. This allows a client to move locally before the server knows about the movement, and then when the server receives the movement, plays it out on its side and replicates it out to everyone else if the server determines that the movement the client made is ok to perform, otherwise it will correct the client's position to what it thinks is appropriate.
The way this works is that the client's movement component sends timestamped movements to the server and the server then plays them back as it saw the world at those times. By changing the movement speed on either side first, it doesn't integrate with the Character Movement Component's own movement system and will cause corrections on the client as either the client isn't moving as fast as the server is expecting them to or the server sees the client moving too fast.
The solution to the problem is to integrate flags that are then inserted into the move list in the CMC so the server knows when the client requested to start sprinting and increase the movement speed at that time.
Should this be done for majority of everything and not just movement?
Nah, context is needed
Oh shit, i got a lot to learn... ๐คฃ
Game feel and player agency is where client prediction is important. Like... It doesn't really matter if an inventory system is client predicted (like moving things around in an inventory) but shooting a weapon or dodging are likely things you'd want predicted.
I will watch the video that ColdSummer suggested then I will come back and ask questions. Because the video might explain the questions I have now.
And there's no point in redundancy, at least not in my eyes.
doesanybody know how to use replays generated from dedicated servers?
i started the demo servers with -execcmds=demorec testfile
Why this doesn't work? Trying to replicate setting of movement component tick
{
return true;
}
void AN_Character::ServerSetTickInterval_Implementation(float interval)
{
if (GetCharacterMovement()->GetComponentTickInterval() != interval)
{
CompTickIntervals = interval;
OnRep_SetTickInterval();
}
}
void AN_Character::OnRep_SetTickInterval()
{
if (GetCharacterMovement())
{
GetCharacterMovement()->SetComponentTickInterval(CompTickIntervals);
}
}```
Does anyone have any advice on how to handle Soft Object References? I've set up data assets for my weapons that load in SOR, but we're seeing in Standalone only that after a short amount of time, our Soft References to our sound cues and VFX become unloaded again.
Currently we're loading the SOR only when a weapon is equipped, but weren't anticipating that the VFX/SFX for an actively used weapon would get garbage collected.
is your weapon a class?
I want to replicate a text render component. (This is inside of a blueprint named world select text).
Whats the easiest way to do this, and where should it be replicated?
Easiest way would probably be to just replicate a variable with an OnRep that then sets the text of the component.
I feel like im overcomplicating this alot.
So basically I have a Widget that when you change the combo box selection it sets the URL (for map server travel). And then sets the WORLD TEXT variable (the world text varaible is inside of the WORLD_SELECT_TEXT blueprint.)
This isnt super important right now because this all goes through the Steam advanced sessions plugin.
For testing and trying to get the replication correct, I have placed a flip flop node in the player controller that takes input from N. This sets the URL variable, which is OnRep, and in the URL OnRep the World Text variable is set.
In the OnRep World Text, I call a multicast even called "MULTI TEXT"
MULTI TEXT gets the URL Variable from the Lobby Game mode, then sets the World Text variable.
This works great for the server! But the clients dont see the change. The visibility of the spotlight is also not being replicated.
I feel like i made a stupid mistake somewhere, or just overcomplicated the code. So I may end up redoing it and trying to simplify it.
(on a random note, I need to research casting more, because I always struggle with what to put as the object).
Sorry, just wanted to reply to you so you would see this ^^
@static owl for a start game mode only exist on server
Gotcha!
Second, why are you using get all actor of class? You most likely diving to mp too early.
Third, don't use multicast, it has no place in this stateful behavior
you will need to store the variable in a place where client can reach if the client needs to receive that replicated variable.
Oh I will say one thing, I had the multicast BEFORE I started using OnReps, So i probably need to remove it
Do you mean like the Game State?
also replication works from server to client, not vice versa. Calling multicast on onRep as client will just call it as regular func at best.
GameState is fine
though you can just do this in the LobbyController imo
If i dont use the Get all actors of class, what would be the best way to reference a variable in another blueprint? Just regular cast?
The issue i run into alot is figuring out what to set the object of the cast to. Like if I am just casting to an actor blueprint.
Casting is just a type check. You need to know how to get and set references.
Not knowing how to do that and jumping to multiplayer is shooting your own foot. I am not gate keeping you, but I would give this advice to even my best friend.
The problem with multiplayer is that you need to know the state of multiple machines. Reference may be set in a machine may not be set in another machine, or you may get different
results. Learning Object Oriented Programming in multiplayer settings will just serve to confuse you more and you better off getting comfortable with OOP with just one instance before attacking multiplayer.
Just my 2 cent.
The question is, what is a "WORLD SELECT", why do you have multiple in the game, and why would you need to replicate the URL in a separate actor, and set them all to the same text?
You cast to the object you want to use properties/functions from. Ex: if you had a class called Person that was based off Actor, the game may just see it as an actor and not recognize it as being the Person class. However if you cast to Person, the game now knows its actually the Person class and can use the functions and vars from Person as expected.
Thatโs the main reason for casting, letting the engine know which class you are actually using specifically, like a Honda Accord, when the game just thinks its a generic Car.
So the world select is literally just the map change.
I made a blueprint which is a spotlight with default visibility to false, and has a text component.
All I am trying to do is that when i press the comboboxstring button in my widget, it changes the URL, then I wanted it to chnage the text in the blueprint I made containing the text.
This way all of the clients can see the map choice
Thank you!
For example, If i was to cast to the blueprint "BP_Square box", then what would be the object?
Like if i wanted to just change a variable there.
All clients have a Playerstate. I would make a class that extends that.
When you do the combo select, it sets the value on your custom playerstate, which onrep will then update all the clientsโ custom playerstates, which updates their widgets
Im using a Text Render Component in a Blueprint is that considered a widget?
I thought it would be different since its in the world
Ok, so your WORLD SELECT should probably be reading from the state of the game rather than having something update it.
Create an Event DIspatcher in your GameState.
Widget Input > RPC To server on PlayerController > Get GameState (Cast) > Sets OnRep Variable.
OnRep of Variable > Call Event Dispatcher that Variable changed.
Begin Play of WORLD SELECT > Get GameState (and cast) > Read current value of variable and set text of text component > Bind Event to Event Dispatcher on the GameState > Event sets text of text component
Now nothing really needs to know about the world select, but the world select needs to know about the gamestate.
What i mean is, if your bp square box was based off an actor, and you did a โget all actorsโ function, unreal will return you just an actor.
You know its a bp square box, but unreal thinks its just an actor. That is why you cast it to bp square box, so unreal knows what it actually is
If you dont cast it, unreal still thinks its an just actor and you do not have access to your custom variables
So you are just telling unreal what class an actor actually is. Its not magically transforming something into something else
I just mean, an actor needs to have โreplicatesโ set in order to replicate.
If it doesnt, you can pass your information to an actor that does replicate and have it pass the info back, like a middleman
@sinful tree @keen adder thank you both! I went off of what you said and ended up getting it to work! Going to look into the Event Binding more. Iโve used it a little with my health bar before and thatโs all.
Can someone tell me what you plug into the Enhanced Input when using Multiplayer please in the Player Controller (Im assuming its Get Controller but im not sure)
nvm this seems to work. ๐
I've marked an object pointer to be replicated in the UPROPERTY but when I create a new object and set it to that object pointer on begin play it doesn't set it at all. I'm assuming I missed a step.
Try this in the player controller class
Thanks I was using Self on BeginPlay and it threw me an error which seemed to clear up with Get Player Controller not sure why though ๐
The code should be in the player controller blueprint
You probably forgot to override GetLifetimeReplicatedProps() function
void AMyActor::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMyActor, Variable);
}
And you should set it on the server
Thanks
Wait nevermind. I forgot that server rpc can't be used if there's no owner. I'm creating the new object inside an actor which isn't owner by any client. What do I do in that case?
Multicast is the solution I'm assuming?
What are you actually trying to do?
I'm trying to create an object inside an actor that doesn't have an owner and set the new object to a TObjectPtr replicated variable
Just RPC before that
"hey server, do the thing"
If you're wanting to do that at the request or initiated by a client
Nah it's on the begin play. The object should be created right when the game starts. There's no owner
Never mind it seems that if you call server rpc on an actor it seem to not have any problems
tho it still doesn't work
why are you having to call a server rpc on it?
what gameplay mechanic are you trying to do
not have any problems
it still doesn't work
If by not have any problems you mean no errors in the output, then it's not how things works 
will GetWorld()->GetFirstPlayerController() always return the local player controller ?
- if run on listen server, will return the LS PC
- if run on any other client locally, will return its local PC
Hi, I've got a problem and I can't seem to figure it out :
Before, when I was coding my game in 5.4, I added screen space widgets as player name tags (in my lobby, and in game),
Everything worked correctly, until I upgraded to 5.5 : the server doesn't see the clients' nametags anymore (knowing i didn't change the code at all, just upgraded the version)
Hello
cannot what?
i hope i dont interrupt, maybe just read over me ๐
"Trace Under Mouse" doesnt work with Multiplayer.
I think its because i have many controllers.
I have added: Branch is locally controlled, but that did not fix it.
do you know what i can do?
sorry, corrected it : doesn't see*
Inputs are one of the things that normally only exists on the local computer, and that includes where the mouse currenly is located on the local machine. You'd have to RPC the mouse location to the server if you want the server to do something with it or replicate it out to everyone else. Rather than RPCing on tick, I'd recommend using the triggered output from your input event (Which is normally present on Enhanced Input event nodes). This way you can at least only be sending RPCs when there is movement of the mouse.
If you don't need the server to know the position, then you can just send the server the results of the trace and do so only when necessary, not on tick.
is it intended that you check Pawn for local control instead of RTS controller?
hmm i thought that locally controlled = my owned controller for my client
i guess i was wrong.
anyways, in fact i am trying to get info only for my local client here.
playing standalone, i still got that error warning that the RTS controller was empty now since i added some MP things.
i have to run over it again and think about what i did to introduce this error, even if i play single person standalone
thank you very much for the hints
anyone know what is the best way to prevent any movement before a round starts via game mode? Not really sure where the logic for this should be.
I tried messing around by preventing controller input which worked until I created a build then it didn't
C++ or BP only?
For the Movement itself, so WASD, you usually set the Movement Mode of the Character to None, both on Server and Client.
In C++ you could override some stuff in your own CMC to check if the round has begun.
I would move that information to the GameState though, so it can replicate properly.
For the View, so Mouse input, you kinda have to disable it via the PlayerController. There isn't really a server auth way to do that as this kind of data is client authoritative
I mean that's correct in theory. That check limits it to the local instance.
You'll need to debug it properly and explain what is not working. Put breakpoints up etc to see what is being called and what not.
Okay so lets say I wanted the players to start with no movement, I could do that within the game mode when they are assigned a character?
Or I think I would have to do it in the game state since it wouldn't be called for clients
GameMode is server-only 
Correct
The GameMode could spawn the players pawns in some state where they cannot move, then transition them to walking on match start. All the clients see is that their pawns can't move, then they can. Assuming that's a mechanic possible with Character, IDK as I don't use it.
If you have a replicated property on the character that controls this you can do it from the GameMode. But it's probably better to have that property on the GameState to reflect the match state or so.
Hello guys, I have a issue related to skeletal mesh replication when it is placed in level. I have placed an actor with a skeletal and a static mesh in the level, I have also attached the code but the static mesh is very fine it's replicating to all when changing the mesh but the change in skeletal mesh is only reflecting on listen server. Can someone explain is this there for a reason or I am doing something wrong.
Here is the video: https://youtu.be/Q_-fkJviS_0
Is there a reason you need to replicate the components? By default if the component is a part of the actors construction the client will create it locally. What you need to replicate is the state (enum, int, bool) and then when that value changes update the mesh the way you desire in an on rep function
But if I am replicating the component would it not replicate the change in mesh itself as it's doing with static mesh.
I have tried to update it on multicast but that didn't worked, can you explain at bit more or share an example? It would be very helpful.
Make a rep notify int. Change that value on the server in the on rep function make your mesh changes. Once that works you could expand that to use a variable thatโs a little bit more friendly like an enum or gameplay tag
Ok I will try that.
Hi, I have a question, but since it is long, I want to link to the topic I opened in the forum. I would be very grateful if you could help me ๐
Hi, Iโve been struggling to understand a particular behavior in Unreal Engineโs multiplayer system. I must admit, I havenโt deeply read the official documentation. I intentionally approach it this way because seeing the solutions Unreal Engine provides for the challenges I face helps me better understand why those solutions are important. Now, ...
You may not want to try too hard, I understand ๐
for some reason when I call Set Focus To Game Viewport trying to move on the listen server actually moves the client, wtf? ๐
it's weird, since mouse input still works in the listen server's game window, but apparently keyboard is being captured in the client's window, trippy
Hey all, I've got a question about the way unreal engine replicates structs
if I add a TArray inside of a struct with a UPROPERTY() above it, will it properly replicate?
will GetWorld()->GetFirstPlayerController() always return the local player controller ?
- if run on listen server, will return the LS PC
- if run on any other client locally, will return its local PC
How can I view network sync discrepancies? I have an object that I need to be accurately synced between client and server, so i would like to be able to see the client and server perspectives at the same time - is that possible?(outside of duplicating the play window)
Not accurately.
And perfect network sync is very hard.
Well, unless you use a single process. But that's not a true reflection of the environment your game willl actually run in.
When this linetrace event in the thirdperson character is triggered, I want to check the number of players with the event in the gamestate and if there is only one person left, I want to trigger the function in the gamestate again.
I want to write traitor win to all of players
but I can replicate it correctly
EOS and Steam usually assign a unique ID to a specific player and Unreal can read from them if you use their online subsystems to join games. What is the unique ID going to be used for?
I'm trying to replicate chaning the value of char movement component tick interval? I tried server and multicast. I tried OnRep.
Why would you even want to change this
I have a game viewport so that I can optimize my NPC Ai when they are far a way.
Also having trouble replicating toggling of the char move comp? I probably making silly mistakes
Hey guys,
Did something change in 5.5 regarding replication and widgets?
Tried to port a multiplayer project from 5.4 to 5.5 and everything works fine except name tags
Well seeing as widgets never were or ever will be replicated, I'm inclined to say no
do you know how?
Still trying to figure out why you want to specifically change this
How does it make sense from a LOD perspective when you have multiple players
Maybe not tick interval. But could be done to SK mesh. I can show/hide it per player
Maybe not either. Never mind.
You can optimize things like this client side, you don't need to replicate it down.
If you're trying to optimize things like this on the server, then perhaps use spawners that can spawn and destroy actors for you when players get near to them instead of using placed actors, but the server will likely need to always be running at appropriate speeds and have things visible in order to perform its own correct calculations for state.
So All i have to do is not use RPC. So can I toggle components on client side only?
