#multiplayer
1 messages ยท Page 116 of 1
I would start with just trusting the shooting client, and then once it works, add some verification if you want
You aren't going to get roll back and all that but you could do something really simple like this?
Thanks...I will see what I can rig up. Spent time on my asset integration and first person view, only replicated stuff is movement, aim offset, shooting and weapon pickup. I would think that item pickups and inventory could still be server authoritative, and do movement, shooting and aim offset client auth...
And tough trying to convince the wife to let me spend $350 on a plugin (GMC). LOL
I mean it all depends. You aren't even going to do a correct sprint without C++ unless you want to do some very cheatable stuff
I think watching youtube multiplayer tutorials that does it with pure bp is already a mistake imo
just look at the number of "sprint in multiplayer tutorial" out there
literar copy paste of same trash code that doesn't actually work
like it looked fine bcuz they didn't emulate lag and doing it in editor with 0 ms
the moment latency is introduced, it's unplayable
By the way, the cheatable sprint I'm talking about is basically client side authoritative Sprint. Just clamp the input size when you're not sprinting, and allow it to go to size 1 when you are.
I hear ya, but all I have. Free time is a premium, and it is spent in UE. ๐
As mentioned on another thread, I have 12 or so game ideas I want to do over the next umpteen years, 2 are FPS's and dummy me started my trek with one of the FPS's LOL
I have multiplayer exp on a number of projects, just not in UE or C++
So clamp it so they can't cheat or that is how they are cheating?
They can cheat by just not clamping it.
Basically, you are trusting the client to not send a full-sized movement input to the character movement component when they are not sprinting.
But it will work perfectly, you're basically emulating an analog stick only being pushed halfway when walking, and being pushed the entire way when sprinting
Someone directed me to this: https://www.udemy.com/course/ue5-multiplayer-fps/
I dont see anything in the curriclum about lag compensation though...
If you want a good FPS multiplayer tutorial you should use Stephen Ulibarri's course. He uses C++ (because you should) and he adds server rewind, client prediction, lag compensation, and a bunch of stuff.
He has a 10hr section on lag compensation.
+1 on stephen's multiplayer shooter course. Anyone wanting to learn networking with ue should take that
ahh, so this one?
https://www.udemy.com/course/unreal-engine-5-cpp-multiplayer-shooter/
I guess it will be trivial to make it first person as it appears to be third person?
As it is on sale for $17 bucks (82% off) I may move on to one of my games that can be multiplay in blueprints (social hangout type stuff/not fast paced) and take that course. Kill 2 birds with one stone, make my game and finally, after coding since 1982, learn C++.
Yeah that would be a good plan.
I've never profiled before do I use the console?
That course go through network clock, lag compensation, rewinding, client prediction, etc
Start with the stat commands and then record some gameplay and look at it with the profiler
Also you can easily get access to alot of Udemy courses if you have a library that has access to Gale
// Camera pitch replication
UFUNCTION(Server, Reliable, BlueprintCallable)
void ServerCameraPitch(double Pitch);
UFUNCTION(NetMulticast, Unreliable, BlueprintCallable)
void NetMulticastCameraPitch(double Pitch);
And then in the main
void Look(const FInputActionValue& Value) {
// input is a Vector2D
FVector2D LookAxisVector = Value.Get<FVector2D>();
if (Controller != nullptr) {
// add yaw and pitch input to controller
AddControllerYawInput(LookAxisVector.X);
AddControllerPitchInput(LookAxisVector.Y);
FRotator Rotation = FirstPersonCameraComponent->GetComponentRotation();
ServerCameraPitch(Rotation.Pitch);
}
}
void ServerCameraPitch_Implementation(double Pitch) {
NetMulticastCameraPitch(Pitch);
}
void NetMulticastCameraPitch_Implementation(double Pitch) {
FRotator Rotation = FirstPersonCameraComponent->GetComponentRotation();
FRotator NewRotation;
NewRotation.Roll = Rotation.Roll;
NewRotation.Pitch = Pitch;
NewRotation.Yaw = Rotation.Yaw;
FHitResult CameraHitResult;
FirstPersonCameraComponent->K2_SetWorldRotation(NewRotation, false, CameraHitResult, false);
}
I am currently doing this to replicate camera pitch. But I noticed that the client's camera jitters when looking up/down. Any idea on how to fix that?
when playing either coop or dedicated in pie my character rotates slowly on server and remote clients, i didnt have this issue before. what could it be caused by? i can move perfectly fine and the character rotates how it should on the local player. idk if this makes sense
oh found the culprit, not sure why i set it to 0.66 at some point...
The pitch component of ControlRotation should already be replicated
Get base aim rotation or something like that
Are you saying I don't need to do all this extra stuff?
I'm not sure if the entirety of control rotation is implicitly replicated, but the pitch is for sure.
Ahhh Gotcha. I just swapped it and it's working A LOT better. No jitter whatsoever!
void NetMulticastCameraPitch_Implementation(double Pitch) {
FRotator Rotation = GetBaseAimRotation();
Call:
FRotator Rotation = GetBaseAimRotation();
ServerCameraPitch(Rotation.Pitch);
Maybe I have a misunderstanding of Multicast or am just using it wrong. I am testing out creation of a multiplayer FPS. So I thought that I want to show the pitch to both server and client. Are you saying I should just run on server instead?
Everyone already has the pitch, automagically
Just use get base aim rotation whenever you want the pitch
Sorry, I am a noob, are you saying to do this then? AddControllerPitchInput(Rotation.Pitch);
Adding controller input should be done on owning client only
That modifies the ControlRotation, which implicitly drives the stuff that GetBadrAimRotstion uses
Sorry, I am confused. Where would I use the GetBaseAimRotation()'s result?
Wherever you wanted to. Whenever you want to know the pitch
Right, and currently I only want to know the pitch for the FirstPersonCameraComponent to visually show to the other clients and server that it's pitching. I tried to set it directly, but it didn't seem to replicate (probably doing something wrong)
I have just packaged a dedicated server but whenever i try to run it it throws a notification:
PS: I havent cooked assets for server yet
Image
In shipping?
just compiled the server.target.cs file and started the .exe file upon which its giving this error
Using which configuration?
Development Server
Not shipping then.
Have you tried deleting your binaries and intermediate folders and recompiling?
It might just be a fubar build.
Also i have just recently converted project from binary engine to source
Honestly I'm not sure if that error is created by UE or by windows because the exe is broken.
so maybe thats causing isssue
That shouldn't be too much of a problem.
Just delete binaries/intermediate and build again.
alright
Just bought ๐ eager to dive right in! It's one helluva long course, so I guess I will skim and adapt the course learnings to my current project
Wow this course is great. Exactly what I wanted
I guess the moral of the story is to ask the community for learning advice before embarking on studying a topic ๐
Update: You have to cook assets fro server before running it. Fixed the issue.
Please just do one thing: Use more than one resource. The tutorial might be great, but it might also do a lot of stuff "wrong".
It's best to learn from multiple places and then deciding which way of implementing something feels the best (or even discussing it here).
Could I just add the stance into the FSavedMove?
That is one of many things you would need to do
At least if you want corrections to properly replay the moves between the correction and the current predicted move :P
Unless the "stance" can be deduced by already known things
No it wouldnt be able to. So it would def need to be in a FSavedMove so that it knows that if it is crouched, which stance.
I'm not entirely sure about your specifications for that feature, so hard to point you anywhere.
We do have a github repo pinned on this channel that shows some examples on how to extend the CMC
The general idea is to send any data the server needs via the ServerMove.
Inputs can be send via the InputFlags or whatever thye were called (check the mentioned repo).
More info would need you to implement a custom ClientDataContainer or whatever they are called (has a freaking long name).
Anything that has to be known to replay a move that can't be deduced from other information has to be placed into a savedMove
And that saved move has to implement a bunch of functions to ensure that the new property is also handled correctly
Such as does it allow combining a move
And then you might also need to handle the correction itself. Similar to ClientDataContainer there is one for ServerData when a correction is send.
FCharacterNetworkMoveDataContainer?
Optionally needed of course, depends on the feature
There are two, I don't have the engine open and I won't open that today anymore, it's 10 PM :P
That could be the right one yeah
And with all of that you'd then need to utilize the existing functions of the CMC to use those new properties and code your feature
Which highly depends on what that feature is
If it's similar to Jumping or Crouching then you can check how they use the Input Flags to start ands top crouching
And what they save in the SavedMove etc.
Yeah I have looked at PredictedMovement and I have also been using Delgoodies version as well.
I guess the only thing the server needs to know is if it is crouched, and then what stance it is at. And then the player can change the stance while still crouched. So I would just need to keep that stance updated. I also thought about using it as indicating whether or not you are crouched. If it is 0 then that means not crouched. Then 1-5 would be the stances.
So if I went with that, I only need to use a single byte.
different crouch levels/stance
How are they controlled?
mouse scroll
So first scroll is level 1, down to level 5?
yeah
And scrolling up goes the opposite direction?
Does the play have to actively crouch or is that triggering the crouch?
that triggers it. So basically if you are holding the crouch button and let go, you will crouch to the lowest by default. If you hold crouch and scroll you can go up or down depending where you are at in the crouch.
If I don't hold crouch and scroll?
so if I held crouch and scrolled down I would go through the different crouch levels
nothing happens then
Okay
Does the Level need to be saved between 2 crouches?
E.g. if I crouch and go to the mid level and uncrouch
would i still be at the mid level next time I crouch
Or does it reset
It would be nice if it did that.
So saving?
yes
Yeah then you'd need to:
- Send the Input for + and - to the Server via the available InputFlags that are still free
- There should be a function that handles the Crouch Input and Crouches/Uncrouches based on that. I would try to place the logic to check for the + and - key input there and simply check if we are crouching or not.
- Based on that you can set a CrouchLevel int then
- You can also set a Replicated Crouch Level on the Character (CMC is not replicated by default and I would keep it that way) with an OnRep to drive animations and capsulse size for SimClients if needed
- Save the CrouchLevel in the SavedMove, implement the required functions with that in mind
- Send it from Server to Client on corrections to ensure any form of Correction tells the Client the correct CrouchLevel
- You might need to override the function that replays the moves (ClientHandleCorrections or something like that) and save the current CrouchLevel before replaying
- Not 100% sure though. Epic does that with some stuff because the SavedMoves literally change variables on the CMC and if that last change it replays is different from what is currently going on (like a key being pressed) then the client would suddenly not do what they think they do (if that makes any sense)
Wow, it's Cedric himself! I was studying your guide in tandem with the Unreal docs, but I feel like I need a supplement like the Udemy course to show me the networking edge cases / failure scenarios.
The advice of learning from multiple places is excellent, I will keep that in mind
By input flags are you talking about the compressed flags?
Those are used like a bool
Yeah if you need more than 4 new ones then you would need to use that container I talked about and add a similar setup
Most people are fine with 4 though
i made a tutorial on making more
Yeah I think I can start working on something now though with a plan. thank you for the help
and just sending custom data in general
Join my discord server at: https://discord.gg/PwGBQBR7MM
If you liked the video please hit the Like button and Subscribe! If not feel free to dislike.
I have that open in another tab lol
lmao
i downloaded the the smooth network plugin and then came back to it a couple days later. I was looking in it and I was so confused. then I went back to the github and seen it was a plugin for blueprints.
Yeah that's great. It would be good if this stuff would be part of the CMC Git Repo
If you ever find time to PR an example, that would probably be great
if u look at the old master branch
theres a more easy to read example for sending custom data
tho note dont take that directly since its client auth, since its input data
The 4 examples are sadly very similar to each other
And are missing that custom data stuff
I think they have the ResponseData
But not the MoveData
In his example he actually has a bug due to a timer.
I think it was the prone timer.
I want to have a timer that shows how much time has been elapsed, its for a multiplayer game and it should be the same for all clients. Where would the correct palce be to handle calculating time elapsed, the game mode, game state?
This basically, but it is C++
Like so many things in Multiplayer
You can try to mimic that in BPs fwiw
Hmm is there any wya to do it in bp, its just a simple timer nothing to complex
also depends on how exact it needs to be
Okay ill have a look
Damn that makes sense
The naive version would be
- ReplicatedVariable in GameState
- Set it to, I think, GetServerWorldTimeSeconds() only on the Server on Tick
But this does not account for the Ping to each user where it might take 100ms for one and 50ms for another
You can also try Epic's function with just using GetServerWorldTimeSeconds() directly (function on the GameState)
But it's not very nicely synced
Unless that changed recently
Thanks alot for your help you went above and beyond for me i appreciate that
Im going to try run tests then with the link you gave me vs the bp server world time sec function
Thanks
Ah yeah, there is a timer
I usually use a Timestamp
And then use the ClientTimestamp to calculate it
@grand kestrel Maybe worth improving the Prone code to not use a Timer
He knows. its logged as a issue on his github
Ah
Yeah okay, can't hurt to annoy him
Yeah ๐ I have other priorities atm
Feel free to PR if you'd like, otherwise I'll get to it eventually
That's a good point, I was going to make a game, but that's not important ๐คฃ
I can't say I have the time either. I'm only really answering between doing other stuff
Is there an engine example somewhere I can copy/paste
Don't think so. I can try to find something I did
If I don't do it now it might get put off for quite a while lol
I'll have a look, if it looks like it'll start taking time I'll do it later ๐
Ja it's quite old actually. You'd save the a float timestamp in the CMC and SavedMove.
And then use it like this:
bool UVRTCharacterMovementComponent::CanStartBoost() const
{
if (!IsValid(VRTCharacterOwner))
{
return false;
}
if (!VRTCharacterOwner->CanStartBoost())
{
return false;
}
const bool bEnoughBoostPower = BoostFuel >= MinBoostFuelToBoost;
const bool bIsFalling = MovementMode == MOVE_Falling;
const bool bOnCooldown = GetRemainingBoostCooldown() > 0.f; ////////// <<<<<<<<<<<<<<<<<<<<<<<<<<<<
const bool bHasFuelTanks = VRTCharacterOwner->GetCurrentFuelTanks() > 0;
return bEnoughBoostPower && bIsFalling && !bOnCooldown && bHasFuelTanks;
}
float UVRTCharacterMovementComponent::GetRemainingBoostCooldown() const
{
const float CurrentTimestamp = GetTimestamp();
const float RemainingCooldown = BoostCooldown - (CurrentTimestamp - BoostCooldownTimestamp); /////// <<<<<<<<<<<<< BoostCooldownTimestamp
return FMath::Clamp(RemainingCooldown, 0.f, BoostCooldown);
}
void UVRTCharacterMovementComponent::SetBoostOnCooldown(bool bNewValue)
{
if (bNewValue)
{
bBoostOnCooldown = true;
BoostCooldownTimestamp = GetTimestamp();
}
else
{
bBoostOnCooldown = false;
}
}
float UVRTCharacterMovementComponent::GetTimestamp() const
{
if( CharacterOwner->GetLocalRole() == ROLE_Authority )
{
if( CharacterOwner->IsLocallyControlled() )
{
// Server for owned Character
return GetWorld()->GetTimeSeconds();
}
else
{
// Server for remote Character
const FNetworkPredictionData_Server_Character* ServerData = GetPredictionData_Server_Character();
return ServerData->CurrentClientTimeStamp;
}
}
else
{
// Client for owned Character
const FNetworkPredictionData_Client_Character* ClientData = GetPredictionData_Client_Character();
return ClientData->CurrentTimeStamp;
}
}```
void UVRTCharacterMovementComponent::PerformMovement(float DeltaTime)
{
Super::PerformMovement(DeltaTime);
// [..]
if (bBoostOnCooldown && GetRemainingBoostCooldown() <= 0.f)
{
SetBoostOnCooldown(false);
if (VRTCharacterOwner->GetCurrentFuelTanks() > 0)
{
ResetBoostFuel();
}
}
}
That's only a part of it
But should bring over the general idea of a timestamp vs a timer
Yeah that's pretty clear, I'll work on it in a moment
bBoostOnCooldown was needed iirc, but maybe that can be removed if there is a smart idea. Without that the remaining BoostCooldown would be far below 0 and still trigger the code in the PerformMovement
That boolean also needed to be in the SavedMove
The rest is a lot of boilerplate shit for the SavedMoves and corrections
I also can't say if that is the best way of placing all those events. But it worked damn well for VRTribes
I'll probably do it that way ; I might experiment more if I had an active project that needed prone ๐ฆ Better than missing edge cases
Yeah it's not easy to figure this out without testing a lot. There is a lot that might just go unnoticed
Like the need to set stuff when combining saved moves etc
That's a good point
I'm going to do it later then ๐คฃ
My upcoming game will have some prone, probably, so I'll do it then and I can test
Yeah, it's not a major issue that people can't work around
No point doing it wrong a second time by rushing it
upon connecting my game from editor to dedicated server running on my machine game establishes a connection with server and loads the map but merely for 2 seconds and then editor crashes with this error:
any idea ?
Guys, I want to set the locations of all players to one location. Character_BP (RunOnServer) -> GameState (RunOnServer) -> Then using For Each Loop (get all player controllers), I cast PlayerController -> Set Player Locations (RunOwningClient) iin playercontroller.
But it's just work for Server, not working for Client. Does anyone know?
Anything I can call on my actor so that it replicates as soon as possible instead of waiting for the next replication cycle (which can be a way if NetUpdateFrequency is low)?
ForceNetUpdate() is the best you have
Awesome to know, it kind of failed me before sending that message, but now that I've recompiled it seems to be working ๐ช thank you!
Why not just
On Server:
Get players array -> for each -> get their pawn -> set their location
thx it worked
Does anyone knows why set actor rotation doesn't work? (or set actor transform not working for just rotation)
for this system "Get players array -> for each -> get their pawn -> set their transform"
It does work, it's just it's instantly being changed because you are using control rotation to drive the rotation of the character.
That's right, after I add ControlRotation it worked, but only for Server.
On Client side only Location works properly, control rotation does not work.
I think this is because ControlRotation is not suitable to be replicated and I am starting the process by doing RunOnServer.
But I don't know the solution (if my inference is correct .d)
Just set control rotation for the player too if that's a thing
Ok I am confused. When extending FSavedMove_Character do I need to do anything special to add custom state data?
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
hey guys, any tips for predicting slide movement? Once I add in some emulation it gets really laggy, if anyone has done this type of thing before i'd love any info ๐ thanks
Slide is just an axis limited crouch with a different animation and movement speed.
It shouldnt be difficult to implement when thought of in that way.
look at the tutorial from delgoodie, he does sliding, wall climbing, dash, etc
During replication, how does a client know which actor the replicated data belongs to?
Replication happens within the context of actors. It can't not know
That's like asking how I know which email address sent me a message. It's implicit.
If you're asking about the specifics of how some ID gets resolved to an actor, that's probably going down the stable naming rabbit hole.
Hi all! Can someone suggest good course about creating and working with multiplayer in UE5, please?
Are you already comfortable in Unreal?
I have 2 years of commercial experience as Gameplay programmer. My problem is al my previous projects/prototypes was pure single player + we use GAS a for bit, but mostly for creating GE and some Temp Buffs. So i have 0 experience in multiplayer and because of that i lost most of my job opportunities
So, yes, I'm comfortable with UE, but I'm lacking multiplayer experience and I want to fix that by taking a few courses.
I can highly highly highly recommend Stephen's c++ multiplayer course: https://www.udemy.com/course/unreal-engine-5-cpp-multiplayer-shooter
If you jump on his discord - he gives out coupons almost weekly that makes the course cheap. It uses best practices that many people in here talk about, and it talks about server side predicition etc that most others dont.
He's also in the final stages of a deep (400 video+) course on GAS that is extremely amazing.
By far one of the best paid resources - and its crazy cheap for the value it gives.
The GAS course is just next level though - its amazing...
ok thx
hey there, what is the best way of replicating a pawn's/character's rotation?
I can't imagine creating my own rep notify variable and updating it on tick is the way to go ๐
(assuming I don't want to use the player controller's control rotation)
hi. does anyone know how to replicate 3d widget? My situation right now is when new player just joined the room while the current players in the room turned on the 3d widget(mic on), the new player cannot see the 3d widget which actually was turned on. How to solve this?
My setup right now : widget bp cast to character bp which have custom event run on server then pass to custom event run on multicast and set flip flop to set hidden the 3d widget to true or false
It's already a candidate for replication. There might be a flag you have to turn on, I forget.
Don't try to replicate the widget itself, replicate the state that drives it
Mic on should probably be a bool on PlayerState
Show your component tree and how you actually open the door
hello will PlayerController->GetNetOwningPlayer()->GetUniqueID(); will contain the same unique id from the player state, which uniquely identifies that player if you are using EOS or steam?
because the playerstate uniqueid is a FUniqueNetIdRepl
so i'm assuming it's not the same
Repl is just a wrapper
Same underlying value afaik
so how do i get the actual int32 that PlayerController->GetNetOwningPlayer()->GetUniqueID(); gives to confirm?
it's not an int32
Depends on the platform and implementation
You can use ToString() on it afaik
do i need to do 3 custom events for (for example) use? (run on server, run on client and multicast)
Hi, I have a component that has a Uboxcomponent. I try to setup attachment to the owner of the component, so the boxcomponent stays on the mesh of the owner. I dont understand why this wouldnt work
You shouldn't use a multicast there.
Anyone who joins after the multicast won't know about the grab.
Use a replicated variable.
but if i don't use the multicast then if the client grab's, the server and client see's it but when the server grabs then the client see's it but server doesn't (the set transform)
Add a variable to your player, "grabbed object", with an onrep. When that onrep fires, attach the object to the player. Or whatever you do.
Instead of attaching where you are, simply set that variable instead.
And wait for the onrep to do the attachment.
what if i don't want player's to join after the grab?
It's still a better system.
i really don't know what u talking about, i only watched like 2 tutorials about multiplayer
Then watch more.
so i removed the multicast and authority switch and now if the client grab's then the client aswell as the server see's the hand change transform but when server grab's then the server see's the hand change transform but the client doesn't
it look's like this
That's why you need the replicated variable.
i don't know what that is....
It's a extremely core part of multiplayer. You should learn!
okay i learned what replicated variable is and what rep notify is but i still don't know how to do that
I have just packaged a dedicated server on my local machine and now i want to create a session on this server upon request from a game instance running on android device. How can i configure Server for this?
Android Device is able to connect with the server
@dark edge
okay i did the grab but what about drop? do i use the same variable?
the grab one works but the drop one doesn't
what is the best way to prevent the destruction of the player state if a client disconnects and reassign it when it reconnects? In theory overriding CleanupPlayerState would prevent the destruction of the player state when the player controller is destroyed, and overriding InitPlayerstate would allow me to assign the existing instance, instead of creating a new one, but to get the right player state i need to use the unique id, which means i need to have to way to get the unique id on the player controller before creating the player state. Is there a way to do that?
Yes. When you drop it, just set the vars to none.
okay i did but now this happens
@dark edge ideas :/ ?
Show collision for frame only
Drag the frame mesh, and each of the door meshes into the world and show the collision view of them
yeah nothing wrong with them tbh
but its only showing on 1 clent its not rpcing on the others when its opening
id say thats the first issue
the gate is a npc actor wich is always the server so idnno why its not rpcing ?
Is your "Event Use" event being called on the server?
bump
@sinful tree
is being called from a player character bp then to a parent class interact_BP then to the door object
do i need to call it from the player character via server ?
Multicasts can only be executed by the server to be seen by everyone else.
yeab but since im only calling a function on a npc unit on the server shouldent it be enough with just that npc from the server calling the rpcing :/
What I'm getting at, is that whatever your execution flow is, it must be running on the server for the multicast to work.
yeah but anything the "Door" dose since it only exsist on the server is always run on the server since its replicated
but im guessing i got that wrong :/
cuz i called it via server and now it rpcs as it should from the player
Example:
If you have a client pressing an input and then that eventually ends up calling "Event Use" without the server knowing about the input from the player, then it's only running on the client, so the multicast won't fire.
The correct way would be:
Client presses button > Run On Server event > Server calls "Event Use", then multicast fires correctly.
yeah exxactly
but i though when i call a function on a npc actor thats alwys only on server side
and from the npc it calls the rpc then it should work in the same way
not that i would have to call it from the players server side to make it rpc
but yeah i understand what you mean
its just i got it on the other foot basicly
but nice that works
however ?
ideas ?
The way to look at it, is that each instance of the game is its own separate thing. When you call a function when you've triggered an input on the client, it's running on the client. If something triggers on the server such as say an overlap being detected, then the server would be executing it as it knew about it. No instance knows what the other is doing unless you communicate to the other instance. There are effectively two ways of communicating between those instances:
- Replicated Variables
- RPCs
Replicated variables will only replicate if they are set on the server. Setting a replicated variable on a client only changes the value on that client. When running on the client you can change replicated variables on other actors that the client doesn't own, but it's only changing on that client's instance of the game.
RPCs are a means of sending an instruction and some data between the instances. Multicasts attempt to send the instruction to anyone who has the actor relevant, basically like an "Everyone hear this!" message, but these can only be sent by the server. "Run On Server" and "Run On Client" are very specifically tied to the "Owning" client, meaning that in order to send the instruction from the client to the server (Run On Server) the client must own that actor. Similarly if you want the server to send information to the Owning Client of the actor, then you'd use a Run On Client RPC, but again, it'll only work if there is a client that owns the actor you're attempting to call it on. No owning client, no message sent.
hello
any one have a GIF that explain CLIENT PREDICTION vs NO CLIENT PREDICTION?
I need it to put in a personal documentation
bump
yeah datura thanks for info i kinda semi" knows all that" im still learning obviously but this is just a weird thing i encountered but this cleared it for me
however the collision this i dont get ./
Can you confirm that the frame does NOT have collision in the area where the doors will be?
Pathfinding
show navmesh
i mean if im looking at it with "playercollison view mode / vision collision" etc then i cant se any collisio
Yeah your 2nd video looks fine, now the problem looks like pathfinding
I bet your navmesh isn't updating
so pathfinding doesn't know it can walk through the door now
yeah that makes sense since i can test from otherside and walk
so how would i update that ?
navmeshvolume has option to auto update or something like that
hmm
cant find any options like that :/
ill google
yeah so its the navmesh thats the prob atleast
No Prediction:
Client Prediction
@sinful tree thx you.but I meant a GIF of an example in a game
why is that happening
the grab one works
No navlink proxy?
@dark parcel wassthat
look it up, maybe that's what you need
hi, this is kind of a multiplayer question kind of not. I'd like to setup some kind of daily challenge system, where the game fetches some global challenge on a server. I'm assuming an HTTP request is the way to do it, any advice on the simplest way to setup the backend for that?
Purely a guess but you could maybe do something like a data table to hold all your challenge stuff in it. Title, description, requirements, rewards, time limit, etc. And in your game you can setup some button or timer that once it is triggered it does a RPC to server to get a random challenge, or however you want to get it, and then a client RPC with the challenge.
I'm pretty sure he meant literar server since he mention HTTP request
Oh not sure what that is. I was just thinking of like a daily quest system
had a friend doing an API call for me so I can broadcast Announcement. I used HTTP request for that
would you want the client to do the http request or would it be better if the server did the request for you?
yeah correct
Hey, is the print string broken in 5.3? I only see client 0 printing
@rugged oasis Any more information on what you are trying to do?
Is the problem that the client tries to move?
I've already found the problem. thanks
Does the challenge need to be determined by a remote server? Could it not be some list that your game servers would already know about based on the date, day of week, month, etc? You could have pools for the week of what could happen and swap those around based on the month, etc. No external communication required really.
I had same thought! users could change their local time to manipulate challenge though
which removes some of the magic lol
its currently a singleplayer game I should add
Well, then they could just cheat their way through obtaining the challenge too if they wanted ๐
But yea I guess if you wanted that restriction it makes sense.
but yeah, in theory if I could just ping some server anywhere for some daily value
doing it externally is nice too tho, you can change the challange on the fly and you wouldn't need the client to update the game
that could be a seed for a locally fetched challenge
Anybody know/have experience with any other way of networking VR roomscale movement other than the VR expansion plugin?
To me it seems a bit weird to replicate your roomscale movement to the server to reproduce the movement, but I'm guessing that's the only way to do it with server authority?
I've briefly considered having client authoritative movement since I'm working on a co-op project. but I'm afraid stuff like enemies grabbing you will result in rollbacks.
(I have a physical character setup with roomscale movement that tries to sync your room and actor movement to keep the collision at your location)
Hello!
Why do I feel some jitter when moving my pawns?
When I enable Network Emulation (with the Average profile), it feels like my characters sometimes jitter a bit. They're getting corrected by the server.
Why is that? Is Unreal's CMC enough for multiplayer games or should I roll out my own networked character movement component?
Should these jitters be happening with the Average profile?
@old sky CMC is usually enough, but if you need any additional Network movement features you'll have to use c++ to extend it
The jitter is probably cause the average profile has Package Loss
Ah, that makes sense. Thanks!
Here's another question: how would I add something like Wall Jumping?
I understand that with server authoritative movement and clientside prediction, I have to send my inputs to the server and compare my results with the server's once they arrive.
What's the right way to handle this with Unreal's architecture?
c++ and custom character movement stuff
Some stuff might be possible in BPs, but most of it needs a custom CMC C++ class and everything in C++ directly tied into how the CMC wants it
hm un UE4 there was an option on project setting for the Navmesh" Rebuild at Runtime" but in 5.1 there isent anyone know where it went =)?
or runtime generatiion "Dynamic" should be the same ?
yeah it worked* ๐
wow thank you so much for this
How do I send an RPC in an actor from the client to the server?
The actor is an interactive item in the world (like a door) that has been placed already on the map.
Can I do that without the player controller or player pawn?
I just can't seem to wrap my head around it ๐ฉ
Hello hello everyone, Is there any way to specify this for a variable in blueprints? "REPNOTIFY_Always"
No
Ownership is something very important to understand. You already saw a table that contained entries like โClient-owned Actorโ.
Shameless plug /j
Ehhh, I don't think so
Not sure tbh, but if it's not in the settings then probably not
Yeah it isn't :/ I have an array of structs and if I modify the struct by ref (Set members) the repnotify doesn't trigger
Thank you cedric
Thank you. On your page it says
.... we create the ServerRPC in the PlayerController and let the server call an interface function on the door (for example 'Interact').
How is this interface call on the door replicated to the client?
The door state would be replicated
Not the interface call itself
The RPC just tells the server to interact with the door
Ah ok, so actually the server changes a replicated property which is then automatically replicated to relevant clients.
Yep
Thank you a lot. I find this approach a bit inconvenient. Because this way you always have to modify the player controller for all kind of stuff.
Imagine adding a lot of other interactive actors in the world. Each time you have to modify the player controller and add new functions there.
You can make an Interaction Component on your player controller
And using an interface for interactions means you don't have to write different code to interact with different actors
One component to interact with any actor that implements the interaction interface
Just many different implementations of the interaction interface
I see makes sense. But still can't just copy and paste my BP_Door to another project or distribute it on the marketplace. The other one must modify their player controller.
You can put your interaction code in a plugin
Component, interface, and BP_Door
Then they'd just have to add the component to their PC and it would "just work" with some minor tweaks
That would work. I still wonder why there isn't just a way in the engine that allows sending clients RPCs to servers for unowned actors in the same blueprint along with the player controller initiating the request.
The server can still verify correctness etc. But everything would be in the same place ๐ค
Being able to call an RPC on an unowned actor would mean that you could then call RPCs on any actor. You'd have to implement checks on every single actor to ensure that the player is or isn't allowed to run that RPC. Ownership is the thing that ensures that security to begin with.
True, but just add a new replication type here that allows it ๐ค
I wouldn't waste time on arguing this
This will not be a thing anyway
This is a years old design decision and that's how all games in UE do it
For me it is not wasting time, for me it's learning how the engine works.
I like to understand why something is how it is.
A replicated Interaction is something that involves the player controller or any other client owned actor or their components anyway.
Once you have called the RPC, you just need to call a generic interface to that actor, passing along a reference to the actor that called the interface if you need it to call back to it in any way.
Client Input > Server RPC w/ Actor Ref > Interface to Actor Ref, with calling actor > Server does whatever validation etc. and performs the interaction as implemented on the interactable actor
The main reason for this is that Epic devs decided that calling RPCs on non-owned Actors is more work than just limiting it. This makes sure no one can call RPCs on e.g. a Character or PlayerState of another player to adjust things they shouldn't
having to add all kinds of checks for this is more work
The interact system is probably one of the only times where this is a restriction
On top of that it also makes a lot more sense to call the RPC in the InteractComponent
Thanks I think this is the way to go.
@thin stratus I see thanks.
bump
How many bytes can be sent at once over the network in unreal?
For server to a connected client
I think it was 8000 bits last I checked the profiler
the profiler can distort the truth sometimes
In fact many things can... it's up to you to believe what's really true
this is why myself and @pallid mesa switched to transparent ethernet cables
harder to get tricked when you can profile with your eye
if the wires get red-hot then yep, shit's broken. And you might have plugged the cable into main power rather than your router.
If I wanted to implement a leaning mechanic that allows a user to lean anywhere from like 45 degrees to the left or 45 degrees to the right, what would be the best way to handle replicating that? Like they could lean to the right 1 degree, 2 degree, 3 degree, etc.
I am going to guess the best way would be to add custom network data to my cmc but curious if there is a better option.
If the leaning doesn't affect movement directly, you pro bably don't need to put it into the CMC
Then it would be enough to just do it quick and dirty through a PressedKey RPC, with an OnRep value (Bool if you just need to know left vs right or float if you need more control) that skips owner so you can predict it
i feel like that could be a lot of RPC calls in a short amount of time. is that an issue?
leaning we did just via the animation and keeping the lean state in sync, nothing complicated
but depends what "leaning" you want
i agree
LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_SurroundedCharacter_C_0. Function SE_FlashlightTrace will not be processed.
hey I got this error when trying to play in editor as listen server + a client. the server works just fine but the client cannot move.
I'm getting the follow error on a mac unreal 5 when a client attempts to ClientTravel(). this works on my linux
```LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionLost, ErrorString = UIpNetConnection::HandleSocketSendResult: Socket->SendTo failed with error 2 (SE_EBADF). [UNetConnection] RemoteAddr: 127.0.0.1:7777, Name: IpConnection_8, Driver: GameNetDriver IpNetDriver_6, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: NULL:Samuels-MacBook-Pro.local-D606E39F45468DD4136D96A66DA244C2 Connection will be closed during next Tick()!, Driver = GameNetDriver IpNetDriver_6````
any help appreciated
guys im using servertravel but it always travel to the same map, how do i fix that?
Post your code on how you are using it.
const bool ServerT=GetWorld()->ServerTravel("/Game/Unreal/CubeRage/Content/CubeRage/Maps/Maps/TestMapsPlugin/Travel?listen");
Well if you are passing it a direct level name like that then of course it will always travel to that level....
Is that using Steam?
Actually seems to be generally used for SocketSubsystems
its incorrect then?
If you don't want to travel to /Game/Unreal/CubeRage/Content/CubeRage/Maps/Maps/TestMapsPlugin/Travel then yes
do i have to enable listen server on the game instance to work or something like that?
im new to multiplayer sry
no. i'm just testing ClientTravel() on localhost in PIE
I'm currently using the Steam Advanced Sessions plugin and was wondering if there was a way for a host who is hosting a session with multiple clients to join a new session and carry over all the clients from their old session. I was also wondering if the host could create a new session and migrate all the clients to that new session. Finally I'm looking for a solution to if the host leaves a game one of the clients first creates a new session and has all the old clients connect to that new session. Anybody have suggestions or even better yet blueprint screenshots showing how they've implemented joining a session with a lobby as well as migrating hosts?
not sure if this will help or not>>
https://www.youtube.com/watch?v=NUKTKFYbW_w
Check out my inventory system:
๐ฟhttps://www.unrealengine.com/marketplace/en-US/product/multiplayer-inventory-drag-drop
Part 2 https://youtu.be/jpeofkeVXSA
Videos mentioned in the tutorial:
https://youtu.be/zJbmpq2FnNs
https://youtu.be/ya6FQktr_OE
๐ท๐ฌJoin my discord server https://discord.com/invite/eX3p5q6
00:00 Intro
00:55 Player Platforms
...
Ok, have a simple pawn and pitch and yaw replicate nicely when doing a listen server with 2 players.
When generating a Host and having a player connect (2 players, standalone) I get no pitch replication. Is there a reason for this? Did I miss something?
@ivory bear Thank you!
Hi!
Is there any way to make a C++ event for whenever a specific variable changes?
Basically, I have a variable which tells me what is my current weapon index.
When it changes on the server, i want the clients to hide the old weapon and bring in the new one.
Do I have to check for this change on every tick or are there observer events I can use?
You use OnRep_ functions - check out the multiplayer guide for how to use it.
In BP It is called on both
In C++ it is only called on the Client
You must call it manually for the Server in C++
Im using a fixed size array to represent the player held weapons, but this array (even though Im using a FastArray implementation) does not replicate when I send the current Player ref to a RPC call
FastArrays need to be marked dirty when you change them, otherwise they dont know to replicate.
Do you have code to share?
Its hard to pinpoint an issue with just what you have said
Yes I do, one question tho, Im mot adding nor removing anything the array per se, Im just canging a n index content
Does doing that makes marking as dirty not work
You need to mark that element dirty if you changed it
So the element it self Ok Imma share the code
/** This must be called if you add or change an item in the array */
void MarkItemDirty(FFastArraySerializerItem & Item)
StoredWeapons.Items[((int)InPickedWeapon->GetSpecification().Type) - 1].Weapon = InPickedWeapon;
StoredWeapons.MarkItemDirty(StoredWeapons.Items[((int)InPickedWeapon->GetSpecification().Type) - 1]);
You should be managing it inside of the FastArray Container
But sure
Thats what you need to do
This code is ran client side and it works
Uhhh you shouldnt be doing that on the Client
How do you expect it to replicate?
Replication only occurs from Server to Client
Changes are made on the Server, the Server then replicates those changes to Clients.
Oh that makes sense
3 max
Ok, why are you using a FastArray?
I thought the reason it wasn't replicating was the nature of the TArray like TMaps not replicating at all
No
TMaps do not support replication at all.
Neither to TSets
TArray does
Infact, your usecase is better handled by just a simple TArray
I would not use a FastArray for replicating 3 elements which are just pointers to Actors.
Way overkill
And unnecessary.
And complicated for what its doing
Yeah doing this FastArray impl I was thinking, this is too much
Just go back to using a TArray.
Especially considering it seems you misunderstood the issue
Which was Server to Client replication
Is passing a UObject* as a param on a Server RPC call viable on this scenario?
like It wouldnt send a GUID but the real UObject* object being the player character
No pointer replication will EVER send the Object
That just doesnt make sense
Only static assets can be replicated by UObject*
AActors if set to replicate can be replicated like this
Since AActor supports replication out of the box
UObjects do not
If that ACharacter was spawned by the Server, its ACharacter* can be passed around yes.
Because it will exist via its NetGuid on all Clients
Since ACharacter is replicated by default
Great
This is not true for other AActors though
You must enable replication on other AActors yourself
I think you should go through the Pinned Messages in this channel
And read the Multiplayer compendium
You are missing some fundamental knowledge.
Yeah I tried doing rough but Im lost lol
Keep trying. Keep reading.
I was able to make it work standalone
Standalone isnt networked.
So of course it would work
Listen and Client are the only networked setting in the PIE button
Good luck
How can I increase this?
Hey,
has anyone a good tutorial for a Multiplayer Truck and Trailer system? I have Trailers working fine in singleplayer. In Multiplayer the Trailer always desyncs and the movement stutters like crazy.
The Trailer is attached via a Physic Constraint and the calls and actors are all set to replicate. Any ideas or tutorials?
Does anyone know how I can Replicate Control Rotation? it's not working. (it starts from GameState)
Isn't control rotation a local value?
I don't think you can...
You can, but you need to replicate it from the local controller, i.e. it's the client that would tell the server its control rotation
Is GameState (RunOnServer) -> For Each Loop -> PlayerController (Multicast) wrong?
Server doesn't know the client's control rotation, so it's rather incomplete
PC's net owner is local.
What you are trying to do? I mean the feature.
What is the truck, a Chaos vehicle?
Server knows part of it, at least the pitch is networked by default
I do it this way:
.h
/** Replicated control rotation for animations. */
UPROPERTY(Replicated, meta=(AllowPrivateAccess))
FRotator ControlRotation = FRotator::ZeroRotator;
.cpp
void AMyPlayerState::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
const APlayerController* PlayerController = GetPlayerController();
if (!IsValid(PlayerController))
{
return;
}
if (!PlayerController->IsLocalController())
{
return;
}
ControlRotation = PlayerController->GetControlRotation();
}
The reason to have it on PS is basically to allow everyone know the control rotation of a certain player.
The only thing I want is to gather all the users in the game around a point and make them look somewhere.
But I can gather them to one place, but I can't make them look.
Actor Rotation doesn't work, because I have control rotation on. (So it just work for Server, not working on client)
So you should send an RPC from server to client and ASK client side to do facing.
And you might disable input at the same time too
Multicast?
Yes, just multicast to client side for example client game state
And in game state you executing "Force facing" event then how it is implementing is on client side.
yeah
Does the truck itself network perfectly with latency simulation?
Hello, I'm trying to make a grab attack for my AI, but I have some network related problems.
The ability itself works perfectly in single player, though in multiplayer it behaves in a weird way when applied on clients, i.e. the host still can be grabbed, and the animations play correctly.
The feature is separated in 2 abilities: Grab_Attacker and Grab_Victim.
The first one is used to play replicated attacker's animation, determine the victim, setup the victim position, toggle certain components, and deal the damage.
The second one is used to play replicated victim's animation.
What works in multi player: attacker's animation, victim determination, deal the damage.
As for the victim position I set the victim in front of the attacker, so that the animations will be consistent. I use the AActor::Teleport() to define where the victim should be, but for some reason it doesn't work for clients, I've checked just in case whether the feature is even supported by the CharacterMovementComponent, and it seems to be; in fact it does override the UMovementComponent::OnTeleported() and does something.
As for the victim animation it doesn't play at all for the client, but it plays it for the server, but after 2-3 seconds since it should've started.
That's how I play the victim animation: https://pastebin.com/w7vW4Uez. The ability does activate immediately after the attacker identifies the victim, however the animation takes a few seconds to start for the server, and it never starts client-side (even though it should). The ability resides on the victim character by the way.
Here are some logs I get mid grab: https://pastebin.com/CqG4zQVu. CH_LivingMannequin is the attacker, CH_Customer is the victim. I have no clue why it tells that the attacker is stuck, and that the CreateSavedMove hits the limit of 96 saved moves.
Also, to avoid some issues I disable the capsule component and the character movement component on the victim for the time it's being grabbed, so that the grab animation can be played properly, allowing the attacker move the victim as they want without interfering with physics/collisions.
Does anyone have any idea what may be wrong in my approach?
This didn't work either :/ Game State (Server) -> ForEach Loop (playerstate) -> Multicast
It actually seems very simple and I'm probably making a small mistake.
Logically, it should be replicated automatically, but I couldn't find out why it not works in clients.
You need to get the controller from local instead of passing from the server.
Multicasting in playercontrollers makes zero sense
there's nobody to multicast to
playercontrollers only exist on server and OWNING client, not on other clients
Ok, so where exactly should I continue this action that I started with GameState (Server)?
Just multicast to the client gamestate, getting the controller in client game state and do what you want.
No idea why you want a loop though
Because it needs playercontroller
like this
But you have already multicasted to every client. And you should input this with getting local player controller
looping -> owning client (in playercontroller) not worked too
Do you mean something like this
What are you ACTUALLY trying to do here? What is the game mechanic
SomeReplicatedActor:
EventMakeEveryoneLook(Multicast)
Get local playercontroller(s) -> set control rotation
You can get playercontroller 0 if you want, there might be other ways to get all local playercontrollers (typically 1 but might be more if you have couch co-op)
This will work as long as you don't have multiple local playercontrollers
After pressing a key, an event runs in GameState (on the server), I want to teleport users to a point in the game and ask them to look at a point. (In order to hunt the Demon in the game, they need to go to that point and look at a point. So they will gather in a circle.) These are the code in GameState. https://blueprintue.com/blueprint/-zn8oq2r/
Where should I add this to the code above?
Gamestate event -> teleport all player pawns to the place -> call MakeEveryoneLook which will make the LOCAL playercontroller rotate to look at the point
Why would you?
I like you dyed your hair
Nah, that can't be real
Are you telling me that I should go back to using Timers like a peasant now?
Aha, so the hype is gone 
The hype is all over #verse now I get it
Thank you so much it worked
Thank you so much!
I have a crowd manager that is moving actors around (instead of them using their own movement components). Sending a fvector is 12 bytes, so that limits me to 8000/12 = 666 replicated updates (under idea circumstances, nothing else being replicated to increase the sent chunk size). I want to handle numbers in the thousands, which would be sending 60000 bytes for, say, 5k controlled actors.
Also, on an unrelated note for a completely different issue, if you have sequencer moving around an object that replicates its movement, will that show for all connected clients?
That limit is there for a reason. I mean the bigger your packets are the more time the server/client are going to spend serializing/deserializing these packets
Which is done synchronously
Meaning you will 100% start getting hitches if you manage to do that
Anyways there is UNetConnection.MaxPacket fwiw
@fathom aspen - any updated thoughts on GMC since you bought it? Any regrets or issues youโve encountered?
Iโm thinking Iโll pull the trigger and buy it; just trying to make sure firstโฆ
Nah nothing really. I have barely even touched it. The author seems too responsive to messages sent in their discord and that's what matters to me the most (I bought it for educational purposes ^^)
Will look further into the CMC/GMC 's science once our game releases next month
Yeah, cool. A responsive author is a very good sign.
Is there any further news on GMC v2?
From 2 days ago:
The GMC v2 beta for everyone is drawing closer, and I'm pretty confident that I'll manage the release before the end of September. Stay tuned for more news.
Oooh. Ok cool, guess that seals it then; Iโll just buy it now. Thanks.
Apparently the v2 "supports" the GAS
as in some peeps in the v2 beta are using it with the GAS, but it's still not as supported as the CMC & GAS are
Yeah, thatโs actually what I need v2 for the most. And apparently enhanced Input as well?
Yeah EI is supported/going to be supported in v2
It doesn't matter if I trigger an interaction (server) in an Acora component owned by the player
because Player is owner this component
yes?
Hey, OnPostLogin, I'm SetControlRotation the controller. Working fine on server, not on client. Need multicast?
why is that happening
I assume cause yo uaren't replicating this stuff?
but the grab one works
i'm using repnotify
this is how it all looks like, the top one works fine but the bottom one only does the client thing and the server see's like nothing changed
if you mean a server rpc
you can call Server RPCs in any actor you have ownership of, and any components of those actors
Hey everyone, I'm just wondering if the gamestate has a different way of replicating variables in c++ compared to other classes? I've put in the usual:
UPROPERTY(replicated)
void MY_Gamestate::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME( MY_Gamestate, TF_World);
}
and set bReplicates to true in the constructor, but it's just this class that is not replicating its variables. I'm wondering if it has to be done differently?
Why is your class called MY_Gamestate and not UMY_Gamestate
Dw was missing #include "Net/UnrealNetwork.h" in the header ๐คฆโโ๏ธ
Yeah it does have a A prefix I just typed it differently in discord
๐
thanks
Did you.... type out that whole function definition instead of copying it 
In any case glad you figured it out
underscores in class names ๐คฎ
haha no just changed the name cus it's called something stupid ๐
Capitilized words in class names 
where's the dark mode
had to disable it to see my emoji class names
xD
Can anyone point me in the direction to learn about Generating Invite / Lobby codes? (Something like the code that Phasmophobia generates when you create a lobby)
Anyone have experience swapping from Listen Servers to Dedicated Servers? Wondering how much work it might be. A majority of the game uses GAS for abilities.
If it was done correctly, it shouldn't be too hard.
If it wasn't, it might be hard.
Looking into this now
How did you handle the cooldown bool in the saved move
Was it a compressed flag or something else
Just a bool tbh
So using setmovefor/prepmovefor?
Yeah it was set alongside the CD timestamp
It was mainly so that PerformMovement ticked function wasn't calling the remaining cooldown < 0.0 part over and over
Maybe there is a smarter way to have that with one variable
Not sure. I think it makes sense that it would be needed
@thin stratus
So far it works quite well, I can't get it to desync at all
I've also just noticed I forgot to prevent jump during prone heh, so that's getting fixed here too
Since you're here, I have a git question, I've made these changes in my link branch which I usually just git rebase -f origin main to pull changes from main into, but this time I need to do it the other way, I don't think I really want to rebase in reverse, of course I can just cherry-pick the commit, but does that cause any issue when I rebase normally in the future (probably not?), is there a better way, such as simply committing the changes I made in link to main instead?
That's cool to know that it works
Heh I actually need a timer exactly like this for a different system so the timing was fantastic
Git is absolutely not my comfort zone
More than the typical fetch pull commit push merge is nothing I can do with that
Mm sadly mine either, I can use it in production but I always need to ask questions from time to time, I'm no expert, just a user
Well that's fine, I will just commit to link and cherry-pick to main
@thin stratus
If you don't mind reviewing
https://github.com/Vaei/PredictedMovement/commit/647e09807ca602fcf0b4086d21992ca794806e5e
https://github.com/Vaei/PredictedMovement/blob/main/Source/PredictedMovement/Public/Prone/ProneMovement.h
https://github.com/Vaei/PredictedMovement/blob/main/Source/PredictedMovement/Private/Prone/ProneMovement.cpp
I imagine the biggest updates would be getController(0) type stuff and then making sure the server doesnt access audio or visuals?
More or less yes. Listen server usually we are guaranteed a controller, while DC we are not
Also try not to use GetPC(0) if you can actually help it
Is the best way to save player controllers when possessed
Save? Wdym by save?
Save a reference to, so I can grab the same controller later. Like if I have gamestate save which player controller is which player
just save it
but why do you need to do that?
pawn always has a ref to its own controller
if it exists
Get get pawn uses a player index, so I would need to at least save that if I'm not assuming 0 is always local
When working with multiplayer and in reference to an actor that is related to a player, like the playerstate, their controlled pawn or their controller, each of them have a reference to one another. If you code your stuff right, you never need to use any of the "Get X by index" style nodes.
Gamestate has a player array already which is the array of playerstates of all players. "Which player" is a bit harder to determine from that array, but it is doable, especially if you have a reference to something else about the player, like their controlled pawn or their controller, but again, if you had a reference to either of those, you could just get the playerstate from those.
But could I save the player index when the pawn is possessed, then I could always get it from gamestate
But why do that? The player controller has a reference to the pawn.
The pawn has a reference to its controller.
No need to worry about indicies.
You technically shouldn't be trying to get reference to a specific controller/pawn/player on the gamestate unless you have some sort of information about the player to begin with.
But even get player controller is using an index
What method do you use to not use any indices?
Pawn has its own get controller method that gives you the controller. It does not do anything by index.
There's zero reason to store the controller anywhere else, the pawn already knows what is controlling it.
But if you are on a child actor trying to get access to that controller would you then be getting the parent, and then using the parents (pawns) get controller function to get it's controller? Instead of using get pawn on that child actor.
Or on a UI widget on the viewport, would you be grabbing the HUD and then get owner player controller or get owning player controller etc
What's the context, what are you actually trying to do?
Each pawn has 12 child actors that can fight another pawn's actors. And those go another 2 child actors deep ( so a child of a child of a child of a pawn). When I'm on the deeper children or on different widgets on the UI on the viewport I have been using the get player pawn to get the pawn and then calling functions I need from there. But those use an index. In our listen server setup get controller 0 is always the local player controller I believe so it works. But the worry is if it will still work when we go to dedicated servers or if all of those need to change.
I was just wondering if I should save the player index on the children at possession so I can always get whatever I need from that child actor by using the index instead of having to work my way back to the Pawn or HUD through parents etc.
So don't use the functions that take an index...
All widgets have access to the player controller that owns them
And that player controller knows what pawn it possesses
You're making a problem for yourself by assuming you need indices in the first place.
I need to create essentially a player controllable platform for multiplayer. This platform is something players could walk on as they moved it around the world. What is the best base class to do this in? I'd love to take advantage of the Character class and it's replication, but the 'platform' won't be capsoliodal at all (though it will utilize control rig, not that those are related, but figured I'd bring it up). Would that be an issue?
Is there a different class that I should utilize because it would work better? E.g., a pawn?
The good news is the movement of the 'platform' will be relatively slow
you could send movement commands to the actor or make the platform a pawn and possess the platform
Since it's slow enough, will those movement commands be replicated smoothly enough? I suppose I can do some client side lerping... ๐ค
Do you need to control the platform and character at the same time?
The player will always be in control of their character, they may control the platform at the same time, but with different controls
I doubt players will be moving themselves while moving the platform (cause it'll be hard), but I'm not preventing it/planning on preventing it. And other players can be moving on the platform while a player is changing/moving it around.
If it's not being actively changed, then the platform will be moving at a constant rate/direction
Just make it an actor
Then move it via SetPosition/Rotation?
However you want
From a replication stand point, what's usually best?
Really want to avoid jitter (so, will probably have to do some client side lerping)
The most important thing is that it plays nice with characters standing in it.
Is there any special considerations I need to keep in mind for that?
I mean just go try stuff. Get everyone to agree on the movement of the platforms then get it to play nice with the CMC
Ok, thanks!
Yeah those could also work
You should probably add a button to open the full project settings
And focus the network section
how do i fix the physical animation lag when multiplayer?
its only these two options in the project settings? Or did you mean the Editor settings for multiplayer?
Eh yeah editor probably
these ones? kk
gotta work out how to focus a section - i'll try to find an example
I think the advanced play settings might do that already?
Or do they just open the whole section?
it just opens it to the top
Hm.
Why would it being multiplayer have anything to do with it?
i'm trying to make my first multiplayer, but when i try to create the session for the listen it fails...
Yo guys can i ask here for help?
im kinda stuck for days because i cant replicate something to other clients
if someone has some mins pls tell me xD
@soft flare you will have more chance getting help if you share your code/bps
describe what you are trying to do then specify the problem in details
uhm yea i can try to explain it
Sharing some screen shoot would be a good start
so i have a host and join systen, and whenever someone joins a host the client sees something else than the host. Example i equip skin 1 on host and start a server, the client joins and sees everyone with his skin but the host sees all skins corret, whenever someone joins and there was a player in the level already it doesnt replicate his stats
the window in the bottom right corner is the person that joined
you change skins in the menu before you join a lobby
How are you equipping the skin? Thru RPC?
๐ซ
Yea thats something else xD
How do you actually equip the cloths? By accessing variable from Game Instance I suppose?
just a heads up, I hvaen't actually tap multiplayer yet but I will see if I can work it out
nah it works like this, you equip the skin and you have a "selected skin" var in the character, whenever you start a level it saves it and loads it when youre ingame
The problem is
when the new player joins
he sees the wrong variable on "selected skin"
He is allways seein his skin
can you share how you load the skins?
Whenever someone joins it does a multicast on EQUIP SKIN event
Ohh you mean replication
Remote procedural call
Oh
basically a way to run function in Multiplayer setting
But here is the scenario
You execute Multicast from the server, the function apply to all existing machine.
The problem is the player that have yet joined the game, they don't execute the RPC call
wait can we go private call and i discord stream you?
Yea ik but
Use repnotify to handle state not updating scenarios for late joiners or when players re-enter into the netcull distance of a replicated actor. Multicasts only work if you're already connected to the server when it happens.
Yea heared some people talk abt it but i dont understand how to use it it keeps dooing it wrong
Multiplayer is hard, replication is the easy part
Do i need to call the function again when people join later?
but that still took a while for me cuz I'm not bright
You just change the variable from replicated to repnotify. Then you double click on the variable's set node and its like a function.
OnRep-> Change Skeletal Mesh
So thats what i do now:
you change your skin in a "rep notify" node
and you start the game, then when someone joins he sees the correct skin and i dont need to recall it? or do i need to call the even in a muticast or something?
So that function runs whenever the variable changes. If its a boolean for example like "isDoorOpen?" then you can just start with a branch. If isDoorOpen? = true, execute event to animate door. If isDoorOpen? = false, execute event to move door into closed position.
Repnotify the Skin
Go to the Repnotify function
Get Mesh -> Set Skeletal mesh to the variable
Done
and after that look at documentation and some youtube (cough) for more info
Ive been lookin in the internet the whole day... xD
You just set the values as want for whatever makes sense, but then inside the repnotify you handle the switching logic.
thats why i am asking here
Yeye alright
Thanks ^^
i try that now
Hm
still same thing
Thats what happens on the menu widget ui
thats what happens inside the rep notify
Not enough experience in mp but I don't think that's gonna work
So when you change cloths are you only changing the material?
Well then you want to repnotify the mesh and the material
Yea wtf
hahaha
but not even the mesh is changing
let me throw the other part in real fast
The logic to resolve the actual material can be done somewhere else
the repnotify logic should just set the material/skeletal mesh
imo
Nono it changes in skeletal asset
Resolve material -> Set material(repnotify)
OnMaterialRep-> Get skeletal Mesh -> Set Material
The same with the skeletal asset
Do the logic to get the Skeletal mesh -> Set the Skeletal Mesh (repnotify)
OnSkeletalMeshRep-> GetSkeletalMesh->SetSkeletal mesh
I cant 100% follow but i try that
other machine doesn't need to know how you get the material or skeletal assets
They just need to know the current Repnotify variable
hmm okok i try that brb xD
thanks for all of this โค๏ธ
what exactly do you mean by resolve, you mean the Run on server and multicast part?
no that shouldn't even be RPCed I think
the only thinng u need to RPC(Server) is the repnotify variable if you are client
Move this somewhere else for a start
To the character?
I dunnoe, I guess
You are changing the materials by ID tho, that's quiet a number of variable u have to replicate
the array is like a skin inventory
If you organize the blueprint nodes a bit more and use color coded comments it will make things easier for you in the future.
yea ik
@graceful flame Do you know a way for the other machine to join later? other than emulating lag
in Pie
Start pie with one client then you minimize and look for the add client button, I think Play becomes add client or maybe its beside pause. Something like that.
I'm in vs building my project so i dont have ue open at the moment.
@graceful flame Thanks , I never know we can do that
Or if you're running the packaged built game client exe you can just keep opening new ones
but it will have the same auth (if you have any auth setup)
the thing is
there is elements in the game, like fire ice and stuff
it works fine for them
Even late joiners see the correct element
its just everything else xD
are they even replicated? are they pre-placed?
then those stuff you see probably already exist in each client and they just play it as it is
uhm
the way i did it was that
begin play calls it for me and whenever someone joins it does another beginplay for all actors
Let me try something real fast
IT WORKED
LOL
i dont even know why
So here is what i did
This is what I did
You can repnotify the number if you want
Idk how this is gonna fit but i think i leave it like this for now
I changed the cube color and late joiners still see the same material
bro im almost crying jesus this is gonna speed up m
damnnn
You say you have no idea abt mp and still know more than me
But yea thanks allot my guy how you have a wonderfull weekend โค๏ธ
@graceful flame u aswell
this discord is truely amazing xD
Hey everyone, I'm building a multiplayer survival game similar to valheim or ark, and am now working on the building/crafting aspect where you can place down meshes like doors, walls, etc. The straightforward way would be to just have every building piece be its own AActor with a static mesh and functionality. Considering players could build bases with 1000s of these pieces, I'm wondering if this will cause performance problems down the line, both in terms of rendering and in terms of networking?
Probably, test it.
Rendering should be ok nowadays but it all depends
Just fire it up and spam building parts all over the place and see where the bottleneck is
My plan is to be able to host listen servers with large worlds where players could be in different areas at once (minecraft-style), which is probably a lot for the server to handle and makes it a bit harder to test... Was trying to avoid building everything just to have to rebuild it all in a different way, but you're probably right
I think you're insanely over-scoped but speculating without testing isn't worth much
If 1 actor per part is too much, consider 1 actor per part island (building, Space Engineers Grid) or even some sort of manager that handles it.
Yeah its not the easiest project ๐ I'm a decent programmer and have already got a procedural world that loads/unloads as you move around + a replication graph going, but even that has been a challenge so far... Yeah that was my other plan, to have one actor per 20m tile that handles everything within it
Until you've tested you have no idea. Just go test (with a realistic client count)
Yeah will do, thanks for the advice
guys i want to to use servertravel or seamless travel, where do i remove the current widget before the travel?
currently when i use servertravel the widget stays between maps, i dont know why
Seemingly because their Outer is persistent, but the research is still on going...
There is a static helper function "RemoveAllWidgets" iirc
You could try it out on EndPlay of HUD for example, as the latter gets destroyed regardless of the travel
do i have to start the session so the server can travel to? or just creating and using servertravel or seamlesstravel already work? cause im just creating the server and traveling but it doest change the map.
This is run on the game mode but the game mode cannot destroy actors on the server like this right :/ ?
Game mode can do whatever TF it wants
game mode is the top dog
guys shoud i use servertravel or openlevel with ?listen ?
Is there something similar too ClientInitialize that is called on a listen server client, want the server to wait before spawning some actors but cant seem to find a central place to call the process from that works for both listen server client and clients.
Hey, im trying to get a multiplayer prototype up and running. Having an issue where an actor has authority on the local client (Ownership chain traces back to the local client's player controller and Has authority is returning true), but any calls to execute on server events are getting dropped
Relevant BPs ^
I see the print string appear from the first picture, (Authority: True), but the second print string never appears on the server or client (using listen server)
edit: Realised I may be quite dumb and I think I have different versions of actors across both client and server
After calling Tear Off on an actor is it possible to restore the actor replication?
Nah, it's meant to be an irreversible operation
If you want a reversible option, look into dormancy
Now my mind got puzzled hold on
When I call let's say a AActor.ServerRPC
If I change the values of the said actor (It is replicated) inside the RPC method
Am I changing the AActor server instance?
The server is a dedicated one
Yes? Values you change while running on the server would be changing the server's copy of the actor. If the properties that you are changing are marked as replicated then the value you're changing it to would also be sent to any clients that have the actor relevant.
In the engine code, USocialParty implementation, they demonstrate beacon use to reserve slots in a server. Before travelling all clients to the map, they call DestroyBeacon(), which internally cleans up the Net Driver.
However, when I do this, the client GameNetDriver gets destroyed and the client loses connection as soon as they join the map.
I'm trying to figure out how to destroy the beacon net driver without kicking the client out of the game.
The workaround I thought of was to tear off the beacon client to make sure the beacon net driver isn't using any bandwidth while they're in the server
It effectively closes the entire Actor Channel.
The ActorChannel would need to be setup again.
Not sure how viable that operation is
It shouldnt be destroying the GameNetDriver?
First time looking at setting up a dedicated server got some questions:
It seems like the main idea of a dedicated build is to compile out code that shouldn't exist in a client?
Also, from what I have seen so far, the editor can not directly connect with a running dedicated server instance?
Yeah I would have assumed it would clean up the Beacon Net Driver but for whatever reason the client loses connection shortly after arriving in the map
The biggest difference is the lack of rendering frontend. As you say, it's compiled out.
As for the editor/dedi, not sure.
From what I can understand so far, a dedicated server is not needed for development.
Its a build specific version that holds logic, that the client has not.
For example, all calls via HTTP requests would only exist within the server build only.
This, reflecting the authoritative design of the network communication of UE.
Not quite.
The dedi server removes rendering. The client version removes potentially logic, but there's also a listen server that has both.
You could, and should, exclude private stuff from a server build if you are never going to distribute it. Either via plugins or #if code.
But it's kinda irrelevant if you're going to distribute a listen server capable build.
Ok, still compiling the source at the moment.
That is where I am confused. Has the client code got exist in the server build? (the CLI commands I have seen reflect that it has to run the same project and map).
Everything I do has to be dedicated only, because the system would have to be out of reach for users.
Generally you don't want to use #if UE_SERVER do stuff #endif, but rather #if !UE_CLIENT
That works for listen servers implicitly. In both server and client code (!UE_SERVER for clients) . Or maybe I'm wrong about that, but I think UE_SERVER is just dedi server builds.
And UE_CLIENT is just client only builds.
It's been a while.
The editor doesnt connect with a deidcated server insance- but you can attached a debugger and handle things there. You can also attach a ImGui network visual logger to have data from a dedicated server streamed to a client for debugging
Thanks for the feedback, one moment, I will check the code that would occlude the logic form client/server build type (may be where I am getting confused).
Also that debugging method is something I would be looking at later on, but good to know log data can be relayed in that way.
@latent heart @woven basin it was is exactly where I was getting confused, I shall explain:
The code block wrapped within the condition #if UE_SERVER *CODE #endif is compiled out of the client.
So this means the code should not exist in the client build at all (exactly what I need).
However, the development process (the UI project) would hold both client and server logic.
@latent heart #if !UE_CLIENT I guess wouldn't specifically exclude a client from being a server (maybe safer option for some projects).
So for development (not testing), then as long as the editor can run the #if UE_SERVER blocks, then a dedicated server is not needed for development.
It is needed for testing tho, to make sure one build type can not accidentally do something it should not.
I need to test out the editor with the #if UE_SERVER to make sure what I am thinking is correct.
Try compiling editor code with #if UE_SERVER.
If that code runs, you're fine.
Also, a dedicated server is needed for development.
Because you need to test things in a live environment. Listen servers, what you'd get in the editor, are juts fundamentally different in some respects to dedicated ones.
In both game logic and excluded code.
It will, in fact, highlight where you've written bad code.
Or "it works on a listen server, but not in dedicated servers" code.
Or failures in your testing procedures because you're testing on listen servers instead of purely remote clients.
Especially in c++ code where onreps work differently than in BP.
(slightly)
You can pretty easily debug a dedi server by launching it directly from your ide. Just launch your client also from the ide and connect to the server. Without using the editor, if that's what you have to do. It may or may not require packaging.
So a dedicated server is needed for development but the editor can not communicate with a dedicated server instance.
Hmmm, I am thinking maybe a project code find and replace of #if !UE_CLIENT with #if UE_SERVER to take advantage of running a listen server along side the editor for productivity reasons.
Unless is another way to go about it. Seems one would have to keep building out server stand alone builds otherwise.
this might be the wrong place to ask, but can anyone recomemnd me a webSocket library for RPCs that can run on C# and C++ ?
Actually, I may have worked out another way to go about doing it (I forgot how C++ build's work as I have been doing allot of BP's recently).
You should still test with a dedi server.
Hello! So I'm getting to a point where I'm trying to understand how to setup a dedicated server to spawn sessions dynamically as needed. A fairly typical scenario is:
- Select their character and get transported to the lobby map (this is probably where the initial dedicated server session would start)
- Once enough players queue up in the lobby map, those players that queued to go the "match"
- After the match is complete, going back to the initial main "hub" lobby in (1)
What i'm slightly confused about is (2), is how to have the dedicated server itself know when players are queuing to start a new session for the new map and initiate travel for those players
how to replicate this? the clicked actor variable is not passed from the client to the server
Where is that node?
Also never use the get player controller node that has the index option.
Unless you don't actually care about your multiplayer stuff working properly
Or potentially single player in edge cases.
If that is a player owned actor or widget, which is required for your rpc to even work, you can get the player controller a better way.
(you can't send an rpc from a widget, but it will allow you to get the correct pc)
But widgets have their own function also
Yo guys anyone can help me out? im having this problem for a really long time now.
every time i use (random int/float in range) it gives diffrent variables on every client. someone knows what to do?
Yes, don't use them on different clients? Or set the seed.
As long as they then do the same number of randoms, they will get the same value. Of course, if anyone joins late, they will need to catch up on the random value rolls...
(if you set a seed value)
Use "random" node in server and send value to client(s)
I dont use set seed, i use run on server and then after the variables are set i do multicast
Event beeing calles
randomizing on server
Send to all clients
idk whats wrong it gives me totaly wrong variables now aswell
seems like the "randomize" part is beeing completly skipped now
if found it out, the variables that are randomized and are applied have the setting (replicate) wich for some reason messed up the replication totaly, so when i put replication on variables what exactly does it do? seems like it completly messes up my multicast
Forget that, i had a (destroy actor) in my nodes.... xD
Hey peeps... i think its about time to discuss how neat it would be to guarantee variable replication for POD types in BeginPlay the 100% of the cases in Actors, net startup or not...
I haven't tried Iris in this aspect, but the legacy networking system doesn't have any place in which you can guarantee variable replication and gamestate to be valid at the same time
it does the trick for non netstartup actors but for preplaced actors replication can absolutely happen after beginplay
which is a very big inconsistency if you think about it from an architectural point of view
makes networking harder, by default
I do agree, makes you hate yourself for using net startup actors, which are incredibly useful when utilizing Initial dormancy
they are needed, indeed
The best I found to workaround that was to hack my way by marking all my replicated varaiables as rep notifies variables, and using PostRepNotifies combined with BeginPlay/GameStateEventSet(delegate)
isn't there a setting 5.0+ somewhere to delay event begin play until ready for replication?
Yeah there is IsReadyForReplication, but I guess that was to indicate if the actor is capable of firing RPCs
But good point, I never dug deep into that
just so I can follow along this topic - are you saying if I have a replicated object pre-placed in the world, the client will load the pre-placed object. But if the server has subsequently modified it before I joined, the object would do BeginPlay() on the client, and then receive some additional stuff a few frames later from the server, causing a state that might never have occured to appear on the client?
100%
so we need a flag to say "dont begin play this object until the server confirms it is ok to start"?
The problem here is inconsistency compared to spawned from replication actors and convolution that you need to make them "consistent"
Yeah, more like let's guarantee BeginPlay is called only if PODs have replicated
"PODs"?
Literally as it's the case if GameState is valid
ints/doubles/floats (Plain Old Data)
Trivial data types
Which are guaranteed to have replicated by the time BeginPlay is called on spawned from replication actors
That way we have very cool guarantee of "if BeginPlay is called, we are guaranteed to have recieved all our replicated properties (mapped ones actually), along with a valid GameState"
this would avoid having to "wait" for the gamestate in your onreps (as one of the use cases)
Cant we just override AActor::PostNetInit() and where it says DispatchBeginPlay(); - do a check for Gamestate there?
If Gamestate not yet replicated, create a callback to the Gamestate rep notify to get it to beginplay this actor when it arrives?
so if Gamestate has not arrived, the actor wont start?
That's the problem, PostNetInit is not called on net startup actors, but only ones spawned from replication
arh...
There is no global callback to when properties have replicated in net startup actors
The goal is to delay the begin play, yup. I havent personally saw the CVAR @supple vapor mentioned above
IsReadyForReplication seems to only be for ActorComponents. We'd want it on the AActor itself right?
i think the proper route would be for postnetinit to be called also on netstartup
and wait until then to not disptach beginplay on clients
but thats just my opinion, unsure if there are other better approaches
That function has a very cool name, but what it does in action, is far from what its name suggests
And yeah it has something to do with calling say a client RPC on beginplay but it not reaching the client since the owning actor wasn't yet ready for replication
Or at least that's how I interpreted it last time