#multiplayer
1 messages ยท Page 585 of 1
I mean, it shouldn't be any more expensive to do than any other movement, since almost all movements in ue4 are already physics-based. Its not like you're somehow replicating the physics calculations, just the resulting velocity & locations
I replied here because I thought my question was more multiplayer related, but I appreciate both answers. I have already put some work in a custom solution but found out about physics actor later on and seems more realistic
certainly not going to discourage you from trying out your own solution, but maybe at least give the built-in ones a try if you've hit a snag. And maybe ask in #legacy-physics because i dont know anything about physics constraints ๐
https://www.youtube.com/watch?v=R52qmIler-E followed a pretty good tutorial
Anyway I appreciate your help!
no problem!
Does anyone know a way to get replicated UProperties to retain their value if an actor suddenly becomes relevant? For example: An actor enters net relevancy range from outside it, the local client needs the values for all of that actor's replicated properties from the server, but they are not populating for me
I can't even find a good and concise way to phrase it to google. All my searches so far have not lead to anything relevant. So any suggestions there would be welcome too
hmmmm im sitting here thinking to myself loudly! i want a menu like "PUBG" where as when you open the game you are in "MainMenu" lobby? where you can just start inviting friends to your "Lobby" and then set som settings and then instead of searching for a game you would set the settings for the current "hosted game" that you are in from the start! how would that work exactly?
as stated i was thinking loudly to myself and i came up with that i would need
GM_MainMenu
PC_MainMenu
Level named MainMenu
that opens as default on startup, then in PC_MainMenu just set at Event BeginPlay -> Create Advanced Session -> On Success -> Open Level (Options = Listen)
so when the player opens the game he would've already hosted a game and is ready to just start inviting up to 3 mates (for a total of 4) to the already hosted game session and then change the sessions settings (map, mode and so on) and press play?
am i wrong about how todo this or would this be the way?
That's usually done with Beacons
They are a lightweight way of connecting players. You basically get the replication stuff from UE4 but you don't need to connect to and open a level
Not much documentation despite the Steam Party Plugin on the Marketplace though
duuude are you serious!!! that Steam Party thing is expensive ๐
@thin stratus ooh wow, it's full of stuff!! i might actualy buy this!! it's EVERYTHING i need....
What does it cost atm?
$99
Hah, half a day. Good one
Yeah I usually tell my clients to buy it instead of paying me to code it from scratch
It's not perfect but the time it takes to get there is a lot
I would say with all the problems and hoops to jump through, a week if unlucky. For someone not knowing how it all works, longer
Just to put the price into perspective @vestal cobalt
I am guessing that the Client 1 isn't aware of something that Client 2 and server is.
Also, is there a reason that the shooting is a multicast? Just do it all on the server and then multicast to spawn the sound and the effects. @shut loom
That's what I said, all the logic of the shooting must run on the server and then multicast only the particles and sounds.
Where would be a good place to implement networking logic?
as in maintaining session functionality. A separate class and instantiate in a game mode, or maybe a game state object?
You typically would run the shooting on the client, then notify the server so it can verify and apply results
How you do that is up to you
Can you run multiple dedicated servers on one computer? I can see only one running server. The second server is running on a different port, but I see an error:
Warning: STEAM: Failed to initialize Steam, this could be due to a Steam server and client running on the same machine. Try running with -NOSTEAM on the cmdline to disable
Solution: https://answers.unrealengine.com/questions/787258/view.html
Hey, i'm still learning replication do some one can explain me, how to know where is the server and where is the client ?
i know we can use authority to do some logic but that is not that i want to know.
When we are on the player input we say that is client side right ?
but where i can know where is suppose to be the server side ? i'm a little confuse.
@tawdry wing Basically, replicated Actors have their code running on the server (dedicated server hosted somewhere by you, or a player acting as server) and the clients (the other players)
Authority checks allow you to know where your code is being run
What is on server, what is not, is mostly up to you
Except creating, destroying or doing large changes to objects should be done on server
Usually, player input is handled locally, the client does stuff while telling the server about it, the server does the same stuff, and confirms with the client that the stuff was done
I'm creating and joining a session like this using steam online services
when creating a session online there are no sessions found when either me or my friend create a session (both of us connected to steam using the same engine version)
when creating a session on line a session is found correctly but I don't travel to the map and get this in the logs
[2020.11.04-13.55.26:547][ 8]LogNet: Warning: UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 20.02, Real: 20.02, Good: 20.02, DriverTime: 20.05, Threshold: 20.00, [UNetConnection] RemoteAddr: 10.0.0.50:7777, Name: SteamNetConnection_0, Driver: PendingNetDriver SteamNetDriver_0, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID
[2020.11.04-13.55.26:547][ 8]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionTimeout, ErrorString = UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 20.02, Real: 20.02, Good: 20.02, DriverTime: 20.05, Threshold: 20.00, [UNetConnection] RemoteAddr: , Name: SteamNetConnection_0, Driver: PendingNetDriver SteamNetDriver_0, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID, Driver = PendingNetDriver SteamNetDriver_0
[2020.11.04-13.55.26:548][ 8]LogNet: Warning: Network Failure: PendingNetDriver[ConnectionTimeout]: UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 20.02, Real: 20.02, Good: 20.02, DriverTime: 20.05, Threshold: 20.00, [UNetConnection] RemoteAddr: Name: SteamNetConnection_0, Driver: PendingNetDriver SteamNetDriver_0, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID
[2020.11.04-13.55.26:548][ 8]LogNet: NetworkFailure: ConnectionTimeout, Error: 'UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 20.02, Real: 20.02, Good: 20.02, DriverTime: 20.05, Threshold: 20.00, [UNetConnection] RemoteAddr:, Name: SteamNetConnection_0, Driver: PendingNetDriver SteamNetDriver_0, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID'
[2020.11.04-13.55.26:548][ 8]LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr:Name: SteamNetConnection_0, Driver: PendingNetDriver SteamNetDriver_0, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID, Channels: 2, Time: 2020.11.04-13.55.26
anyone encountered a simillar problem before?
@bitter oriole thanks for your time. ๐
incresing the no of found sessions results in:
[2020.11.04-14.50.49:066][923]LogBlueprintUserMessages: [BP_CVRT_PlayerCharacter_OCULUS_C_0] 1sessions found
[2020.11.04-14.50.49:066][923]LogOnlineSession: Warning: STEAM: Session (GameSession) already exists, can't join twice
[2020.11.04-14.50.49:066][923]LogBlueprintUserMessages: [BP_CVRT_PlayerCharacter_OCULUS_C_0] Failed to join session
[2020.11.04-14.50.49:066][923]LogBlueprintUserMessages: [BP_CVRT_PlayerCharacter_OCULUS_C_0] joining session
I am zero-ing a montage's blend time in the server before playing, and then playing that montage on clients too, somehow this blend value is getting back to the clients and they are not blending at all. I've checked the AnimMontage class, and there doesnt seem to be any replication, and as far as I'm aware if you send a packaged asset's pointer through an RPC it is not actually archiving anything, just sending the ID over. Any clue on what could be going on here?
@meager fable The player trying to join has already created or has a "Game" session, that's why it can't join
@unique kelp I would check to make sure the "zeroing" code isn't running on the client as well
It might be too early to determine roles etc.
Can I make an Actor stop replicating at runtime? I tried overriding IsNetRelevantFor but that doesn't seem to give me the results I want. I want two Clients close to eachother to replicate but not replicate to a client that's far. I also don't want to rely on Net Cull Distance.
I'm trying to make my first multiplayer. Where would you put server settings that should be replicated? Game State seems to get reset when I travel between levels
GameInstance if you want to preserve data.
GameInstance doesn't replicate though
@chrome bay It's done on BeginPlay, by which point roles should be fine. We already have a ton of authority checks and attaching the debugger to the client shows that it doesn't hit those parts. Thanks anyway
to the gamestate.
HasAuthority doesn't necessarily mean it's not running client-side still
for a replicated actor?
It depends but can also vary based on how early you're making that change
I would check GetWorld()->IsServer() to be sure
or IsNetMode(etc..)
Wouldn't hurt, fair enough, thanks
Jambax, do you know how I can stop an actor from replicating in the game mode? As in replicate to one client but not replicate to another client?
Well you can use IsNetRelevantFor so long as you aren't using replication graph
I assume you mean the pawn right?
not player states or something
Yes the character
But I'm not sure how IsNetRelevantFor works..
I tried it but can't seem to get the results I want.
If it's a distance-based thing, just use NetCullDistanceSquared
there's no reason not to
The issue with NetCullDistance is that I have other criteria as well.
Last I checked, net relevancy was checked on like 5 second intervals, so if it is time sensitive you will probably want to handle it on top of that
Like if Cleint A spawns an Actor but Client B is close to that actor but far from Client A.
Then it should still replicate.
not cull distance, but like the "IsNetRelevantFor" override
Yes but I'm just not sure how IsNetRelevantFor works.. I tried it and igves me weird results.
Well the Pawn is always going to be relevant to whoever controls it
What are the two arguments to isNetRElevantFor the two actors. What exactly do they mean?
Is it should Actor B replicate to Actor A?
No
RealViewer = the clients' player controller usually
ViewTarget = the view target of that players' controller
So RealViewer is themselves.. and ViewTarget is whatever they're viewing?
no
RealViewer = the client
So the client being considered for relevancy
ViewTarget is right though, is whatever that client is currently "viewing"
Just reading the comments btw
Yes I was looking at the doc it was just kind of confusing.
Meh ignores docs
Because when I override IsNetRelevantFor then check if distance between A and B is greater than 50, return false.
look at code
I also lose control of my actor.
Yeah that's not what it is
Yah
Just have a look at the default implementation
This is still a bit confusing because does that mean ViewTarget can also be themselves?
And okay.
it could be yeah
Actor relevancy is considered Per-Client, so RealViewer is always going to be that clients' player controller
ViewTarget could be anything
But what if the say the client isn't viewing another client..Does that mean IsNetRelevantFor wouldn't even get called on it?
no
The Server will iterate over all replicated actors for every connection
IsNetRelevantFor is only eval'd server-side
I think the viewtarget is meant to be the pawn
yeah usually it is
the pawn that the real viewer is using
no
The pawn that the player is using as their "View Target"
View Target is often what the camera is attached to, or something like that. When you possess a pawn the server/client set the view target as that pawn.
And the player camera manager might choose to do something with that ViewTarget variable, or not
If you haven't set it to anything else, you can assume it's that connections' pawn
Okay so ViewTarget is that specific client for which the function is being called on.
no ๐
oh my gosh..
RealViewer is the player controller
I must be so dumb
But that doesn't make sense though..Why would IsNetRelevantFor get two arguments one for the player controller and one for the pawn.
It's for convenience, the controller doesn't usually have a transform or any physical presence in the world
And to evaluate distances it uses the view target
E.g, the player controller could be at world origin, whereas the pawn it controls could be 2km away
So what exactly is the purpose of the function IsNetRelevantFor.. maybe I'm misunderstanding it.
To determine whether this is Net-Relevant for RealViewer
So to determine if it should replicate Client A to client B assuming A is overriding IsNetRElevantFor, I would need to grab this->GetLocation and RealViewer->GetLocation.. ?
Yeah
which is what the default does
return IsWithinNetRelevancyDistance(SrcLocation);
aka return FVector::DistSquared(SrcLocation, GetActorLocation()) < NetCullDistanceSquared;
Okay so if there is an instance of This->PlayerController == RealViewTarget , then I would always return the Super::IsNetRelevantFor?
Because I imagine it does get called on itself too..?
I don't understand what you mean
IsNetRelevantFor is called once on every actor. Not on every actor for every other actor
So it's either they are relevant or they aren't relevant.. There's no deciding if they are relevant to Client A or Client B?
Like let's say I want Client A to be relevant to Client B but not relevant to Client C
Psuedo code:
for (UNetConnection* Connection : AllClientConnections)
{
for (AActor* Actor : EveryActorInTheLevel)
{
if (Actor->IsNetRelevantFor(Connection->Controller, Connection->Controller->ViewTarget, SomeLocation)
{
Connection->Replicate(Actor);
}
}
}
That's what the Server does
ViewTarget and SrcLocation are just convenience parameters
I would just look at the default implementation
It's very self-explanatory
@chrome bay What doesn't make sense though is why does returning false on IsNetRElevantFor make my client uncontrollable
It essentially makes my character's pawn immobile
are you just returning false for the pawn?
I'm not sure what you maen by returning false for that pawn.
I'm not sure what you mean by returning false on IsNetRelevantFor
Yes
So should a check be done if this != A ?
I think I get it now. So what i need to do is everytime IsnetRelevantFor is called.
I need to iterate between my own connected actors.
And decide from there if it should return true or fallse..
@chrome bay is that correct?
iterate?
yes.
every time it is called, the server is just asking, "should this controller be able to see you?"
you just need to run whichever logic decides that for your case
Well what I want is a case like this, Client A can see client B but not client C.
likewise Client C can see client B but not client A
So client B and C and see eachother
But not C and A
Is that possible with IsnetRelevantFor override?
then you need to identify somehow if the pawn that is overriding this function belongs to client A/B/C, and likewise if the controller that is passed in as a parameter belongs to client A/B/C
Can youg ive me the pseudo code of how it might look?
{
return (IsPawnA() && RealViewer->IsControllerB() || ....... );
}```
the logic inside there depends on what you want to do though
probably put it in a separate function
obviously RealViewer wont have a "IsControllerB" function
What is IsPawnA is that the pawn for ClientA?
but if you cast it to your controller type, or get the pawn for that controller and do that
It just means that this object is already the pawn you are interested in, so it would have a variable or a member function that you can use to check if we are A, B or C
So IsPawnA is this but checking if it's A B or C like this->IsClientA for example.
I personally hate using "this", but yes, essentially
probably better to check it with flags, but this gets the point accross
IsPawnA() && RealViewer->IsControllerB() If this->IsPawnA && RealViewer->IsControllerB meaning ClientA && ClientB?
yup
Okay so let me write out what it would look like if it was based on distance and you can tell me if it's correct?
assuming your view targets are the pawns directly, you can also cast the viewtarget to your pawn type and do the same as you do with this, but with that other pointer
Yes they are Pawns.
@unique kelp In this example does this mean Client A is replicating to B but not C
{
return (IsPawnA() && RealViewer->IsControllerB() ||
IsPawnA() && !RealViewer->IsControllerC()
);
}```
Or let's say I flat out wanted it to replicate to every client except Client C.
{
return (IsPawnA() && !RealViewer->IsControllerC());
}```
Is that correct?
sure
I think it's all making sense...slowly..
I think it would have made it simpler if this function could just be overridden in the game mode, with two arguments passed Controller A and Controller B , iterating every controller of connected clients.
It's not for controllers, though
But maybe I'm just dumb..
controllers are just replicated to their owner
Okay , i'll try some things with my new found knowledge and see how it goes!
feel free to redirect these checks to the gamemode and write your own function there though
So override the actor's IsNetRelevantFor in the gamemode?
no
bool IsNetRelevantFor(const AActor* RealViewer, const AActor* ViewTarget, const FVector& SrcLocation) const
{
MyGameMode *gameMode = Cast<MyGameMode>(GetWorld()->GetAuthGameMode());
return gameMode->AreActorsRelevant(this, ViewTarget);
}
Oh okay like that.
Yes that might help too!
Alright thank you so much and Jambax for all the help and description!!
I greatly appreciate it.
I'll try somethings with this now.
glhf
Hi
I m getting NPE PlayerState->GetUniqueId()
for unique net id
if i try to play in PIE
the reason is OSS and login not called.
so any work around?
Every time I want to test, i don't want to do auth via OSS (which consumes a lot of development time)
If i do using OSS and Login gets called, i don't get NPE.
@unique kelp @chrome bay Thank you both so much for that explanation I think I got it all figured out now!
How do I destroy a client's pawn from my game world ?
When it stops replicating the character just freezes.
I want to remove it.
Do I call destroy on the character or the character's player controller?
Destroy on the character
Do I use true for bNetForce?
If it's the client destroying them off their view.
I'ms ending an RPC to the client to destroy the actor off their game.
bNetForce guards the destroy call so it will succeed only if you have authority over that actor.
In a multiplayer game you should have bNetForce to true and for characters, as they are likely replicated, call a destroy on the server and it should auto destroy on every client.
Oh but I don't want it being destroyed for everyone. Just actors who are far distance from it.
To actors who are close to it, they should still be able to see it.
Why is why I'm destroying them on the client.
And not on the server.
Or maybe I shouldn't destroy it?
Just hide it.
And unhide it later?
Yes I think that would be better.
It sounds like you are trying to achieve the same thing that relevancy distance for replication is for. Don't you want to use it?
Yes but that doesn't actuall yhide the actor off the screen
Once they are no longer replicated.
It just leaves them there..
Like if I use NetCullDistance and they go beyond that.
The character still appears ont he client even though it's not replicating.
I just want to get rid of them off the screen.
I think that actor should be auto destroyed after few seconds automatically if he is outside of the relevancy
It doesn't though.
It stays on there until they become relevant again
Unless I'm doing something wrong..
But to me they just stay there lol.
I think I can just hide them though.
let me test that, because that sounds weird
Yes thank you.
I'm testing with ThirdPersonExample
But with networking on.
Using OSS
Anyone have any idea why my velocity would work when im moving forwards X = 1, but when X = -1 it wouldnt move backwards?
@twin juniper confirming. For actor spawned at runtime the actor is spawned and destroyed automatically whenever I jump in and out of relevancy after few seconds.
The difference is if the actor is already placed in the level then it won't be autodestroyed whenever I walk out from relevancy, but it won't replicate anymore.
hey guys i want to work on eos and i want to get started how would i get started
I actually tried RPCing to the client to hide it and the client ended up hiding themselves..
lol
So anyone know why the engine devs decided not to call OnRep_PlayerState on the server when PlayerState is updated?
OnRep events are never called on server
i know, they need to be called manually. Usually the convention is to call it after altering the variable but the engine doesnt do that
No, it is not a convention
why wouldn't it be? They're mimicking repnotifies in blueprints, which are called on server and client automatically
what have I misunderstood?
There is nothing to misunderstand, Blueprint designers simply decided to have repnotifies fire on server too, when Blueprint was implemented a decade after C++ repnotifies
The UE4 gameplay framework mostly predates Blueprint
In C++, these events are client only
As they should be, imho
why wouldn't a server want to (optionally) react to when a variable changes?
Because the server is changing the variables, so you just call the stuff you'd like to if you also want it on server
It's usually not the case, though
Especially on a dedicated server
well I could call the stuff I'd like to if the change occurred in my game's code, but some variables with OnRep functions like playerstate are changed in enginecode. So there's no opportunity to call the stuff I'd like to on the server when i changes without altering the engine to match what seems like a reasonable consistency
if I was the one changing these variables, I could call OnRep, but since I'm not I have to rely on the convention of calling OnRep serverside, but for playerstate they dont
Why would you want to override that specific event anyway ? PlayerState should be changed literally once
its changed during possession and unpossession, which can happen any number of times depending on the game
good point though, maybe do it during possession
Ah, that's in the Pawn class I guess
In this case you have possession events
And you can likely easily extend the code changing PlayerState
yeah, I think that will work for this case. Its still seems odd to me for engine code to not call OnReps on server for variables they're changing and let the gamecode decide whether to do anything there, but at least I have something to work with
thanks Stranger
ShooterGame's ShooterCharacter even has this in PossessedBy
// [server] as soon as PlayerState is assigned, set team colors of this pawn for local player
so yeah, guess that's where they expect reaction logic to be done
Is it perfectly fine to call ForceNetUpdate() say 10 times a second?
I have a case where I normally need a very low net update frequency but in specific moments need data to be passed down ASAP which I use ForceNetUpdate for
Is it fine to be called 10 times a second (would it be the equivalent of just having a net update freq of 10?) or would it be better to just set the net update frequency to a higher value for those periods?
Speaking of, does anyone set their player state net update frequency higher than the default 1 time per second?
yeah it's fine to do that
If you're using rep graph you can't change the frequency at all anyway
Great thanks
OnRep events are never called on server
@bitter oriole I do it a lot for my listen server when I need both the server and client to do the same thing after a variable changes and don't want to create another unique function for it
Is this bad?
I would have a lot of very simple extra functions if it's bad to call OnRep functions on listen servers
No one said it was bad
OnRep events are never called on server
That's just a fact
As in never automatically did you mean?
As in they are never called by the engine
You can decide to call OnRep_XXX yourself if you think that makes sense
Great thanks
Personally I don't, but hey
I could make loads of simple functions to be fully correct
But would just bloat and make things harder to read
void OnRep_Impact()
{
PlayFX():
}
where PlayFX(); contains one line
Yes I could call PlayFX() on server and PlayFX() from the OnRep but in some cases it's a little simpler to just call directly
Probably just preference
If the common function being called is only calling one line itself then it feels like I'm adding more clutter than necessary
Personally I would rather repeat the line that have OnRep functions, which are ostensibly client-only by design, run on server
But yeah, opinions
It makes more sense thinking about it
Especially if moving to dedicated in the future- less headache
Makes no sense to call Onrep there of course
Good to know and something I should probably improve
I mean basically imagine you're diving back into your codebase one year after working on it and half OnRep methods are also called manually on the server
do i have a complete misunderstanding of replicated variables?
i thought that if the server sets the value,t he value is automatically replicated to clients
is that not true?
@sand crescent ive used it extensively
@quick flint can you help me with adding lobbies and having teams
im making a br and mp game
alright thats fine
@quick flint all my code is already networked all of my code its just the matchmaking right now
alright you can message me tommorow
@quick flint you are correct. Replicated variables are changed on the server and then automatically replicated to clients
So I updated the defaultengine.ini with the steam online subsytem snippet. but when I start my project in Standalone. I don't see the steam message. I also enabled the plugin.
Hey All - I've built my system and have multiple clients connecting to a listen server on my PC - "all good". What are the next steps to try this with a friend? Can we just share the code and run UE and he connects as a client to my server? Or do I need to package, etc?
Is there a way to have input run on the server and the client
Returns true if the given key/button is pressed on the input of the controller (if present)
For functions like this
Hey guys I realize this post is sort of lengthy but was hoping someone out there knows a solution to my current situation. I'm fooling around with the CMC right now and I realize most people do this in UpdateFromCompressedFlags.......```
void USSCharacterMovementComponent::UpdateFromCompressedFlags(uint8 Flags)
{
Super::UpdateFromCompressedFlags(Flags);
// Update this CMC with the info stored in the compressed flags
bWantsToRun = (Flags & FLAG_WantsToRun) != 0;
} So my question is is it okay to skip this step and manually manage bWantsToRun outside of this function? So UpdateFromCompressedFlags(uint8 Flags) would be empty like this......
void USSCharacterMovementComponent::UpdateFromCompressedFlags(uint8 Flags)
{
Super::UpdateFromCompressedFlags(Flags);
}```and I would instead manage setting bWantsToRun outside this function. The reason I want to avoid letting UpdateFromCompressedFlags(uint8 Flags) handle setting the bool is because UpdateFromCompressedFlags(uint8 Flags) essentially just listens to what the client wants and proceeds to copy its value without any gameplay checks (ie. the player is out of stamina on the server). So basically I'm trying to achieve having the client and the server run their own simulations based on if the player can run or not on their side because I don't want the client always being able to tell the server to run.
Hi Guys, I have issue with replicating the Projectile
I'm getting network correction
even though I run the projectile on client and server side
This is how AddForce event look alike
Wow itโs just unsolved questions after unsolved question
@quick flint you can do some replication variable tricks where you set a variable after every time the input delegate is called
How can I track that a new player has joined the session? To update list of players in session. in OnlineSubSystemSteam
@timid moss I know the guys at Flopperam were testing that out so u might be able to get some help on their discord server
@balmy pike postlogin in the game mode
Hey All - I've built my system and have multiple clients connecting to a listen server on my PC - "all good". What are the next steps to try this with a friend? Can we just share the code and run UE and he connects as a client to my server? Or do I need to package, etc?
@ruby rock you can use some sort of online subsystem to create a lobby system
@balmy pike postlogin in the game mode
@clever plinth oh, thx
@balmy pike np ๐
@clever plinth Was it recent? Trying to find where they were talking about it
also thx a lot btw didn't think anyone would answer that ๐
np, Iโve been in situations where my questions are ignored and it really sucks
@timid moss if u join their server they should be able to guide u in the right direction?
I think that old stream was already deleted due to the 14 day limit
@clever plinth - yep have done that, I think I've found what I was chasing. I need to package the build, I can't test from 2 UE engines.
Dominate performance here by Aphix.
xD
Aphix i'm very rusty on multi, and reading through Exi's great compendium is good. But trying to remember something
So, if I run something on the server, the server knows about it. That's fine. If I want all clients to know what's up, that's a net multi
And onRep notify is just a function that plays on the client when the server replicates something?
Does the steam 'Advanced sessions plugin' work in a packaged game? I heard from a friend that its a plugin only for testing purposes and doesnt work in real games and before I make my matchmaking system I want to know if this plugin will work when my games on steam.
Awesome, thank you @bitter oriole
Hi, i had a fully working function that was replicated (reliable), but now that I set it to unreliable, it doesnt work properly anymore, is that normal?
because I was told that reliable functions are harder for the server so I wanted to optimise it a bit
reliable means that if the server has a lot of things to execute it will add your function to the queue, unreliable means it will skip it
Unreliable is as the name suggests unreliable - it will be dropped in times of high network use / when connection is saturated
If that RPC must go through, it should be reliable. You can use insights / network profiler to figure out why the connection is saturated in the first place
From there you can figure out what needs optimisation
insights / network profiler
Without using those first you're pretty much blind otherwise
so i have to use both?
okay okay thanks ๐
Does anyone know if net cull squared distance is not editable through blueprints? Can't seem to find the setter, probably locked off?
It's usually something you set up in the defaults
Can't set it at runtime in BP
Yeah, I have a usecase to set it at runtime Cedric :\
I see Jambax, hmmm
Maybe I could make a C++ function library that I can pass an actor into?
You could but tbh you don't usually change it at runtime
A lot of my actors have wildly varying render distances and tick ranges, that I handle through an actor component. I want to more closely align the replication range with those, so that I don't end up with actors stuck in the air, not replicating but still visible
That sort of thing
Don't really want to break out my calculator each time to manually swap that out
Hey, I am following this tutorial -> https://www.ue4community.wiki/legacy/how-to-use-sessions-in-cpp-eyad3cu0#prepare-your-project-to-use-sessions-and-onlinesubsystems
But there aren't any "UnrealNetwork.h" or "Online.h" files. Are they re-named? Any suggestions on how I can proceed?
I am at the #Changing the "YourProjectName.h" step
@twin vine "UnrealNetwork.h" is now "Net/UnrealNetwork.h", not sure about "Online.h"
Thanks @twin juniper I'll update here if I find the loc
After including the online modules in GameName.Build.cs, generating vs files from the .uproject file let's me to #include "Online.h"
But it doesn't find the file itself for me to review
So the project builds and runs but I can't see the file.
"Net/UnrealNetwork.h" is fine.
@twin vine use #include "OnlineSubsystemUtils.h"
Would be nice if UE had patch notes for issues like that.
@balmy pike I have that in Public Dependency Modules as well
Interesting thing is that VS does not complain about the non-existence of the file, but it doesn't go to it.
^ while building*
Why is it when I try to hide another player's pawn on a client..the client ends up hiding themselves...
I call Actor->SetIsHidden and SetCollisionEnabled
@empty axle When you had checked the character being removed from view after they stepped out of net cull distance. Had you tried removing them from the view manually when they were already in game and not spawned?
IsHidden is replicate iirc
So if you set that on server side, you'd set it for all players (on that actor)
But I'm telling the client to execute it.
Through a Client RPC
BUt when I tell that client to hide a specific actor, they end up hdiing themselves..which is a bit strange.
As in I tell Client A to hide Client B.
But Client A ends up hiding Client A..
How can I limit the amount of times the server has to do position correction
When I jump the server corrects it
that would probably be because your brute force jump is not predicted
how do we set up 'prediction'
@thin stratus through overriding isnetrelevantfor the pawn that's passed into the function when I pass onto the client that I want it to hide
you need to push the jump through the CMC
how do i do that?
but prior to that I also check if (viewtarget==this) to make sure they aren't doing it to their own pawn
thing is, when you move with CMC
I'm just using ACharacter::Launch
you create SavedMoves
when client receives a server update for position
it replays all the SavedMoves it has since the time the correction was sent
and if the locations match after that
its fine
your launch character doesn't account for that
@twin juniper Isn't IsNetRelevantFor already causing replication to end and the actor to be destroyed if you return false? Why the hiding?
hmmm
@thin stratus that's the problem though, they aren't causing the actor to be destroyed.
Sounds like a long process @winged badger
Detailed explanation of Character Movement Component
Apparently if the actor is already in the game world before the client connects.
Then they won't autuomatically be destroyed.
Ah, so it's not just a Character, it's a some random actor
Maybe set the "netLoadOnClient" to false? or whatever that is called
On al the characters?
@twin juniper Not sure, I honestly would expect them to be destroyed
But your issue is that you are hiding the wrong one. I would start logging some object names and see what's happening
i haven't had to integrate the extra movement form through CMC to date
Does anyone get that error?
Assertion failed: NetGUID.IsDynamic() [File:D:/Build/ UE4/Sync/Engine/Source/Runtime/Engine/Private/PackageMapClient.cpp] [Line: 2630]
yes someone else had tested this yesterday too and they said when the client is already in the level before the other client joins.
so can't tell you how off the top of my head
When spawned a component to everyone, and triggering component inside
it means it expects a dynamic (Spawned at runtime NetGUID) and its getting static (Loaded from Package/Level)
the last bit in NetGUID signifies static/dynamic
i tested it in stable closed source(mean that downloaded from launcher)
still same
so objects doesnt support netguids?
im making a item passive like lol game with components,
fires trigger when a health below %30 but then its crashed even reference is valid
they support them just fine
but if you're spawning them on every client separately
they should not be replicated
i know they're not replicated. but i wanted just fire a node from server to checking
oh well wait maybe i found solution leme try it
not talking about variable holding a reference being replicated
talking about the object itself
@thin stratus wait this is just a thought but I think I might know the issue. When tellling the client to hide an actor I shouldn't pass its pointer to that client..
Because that client could have another value at that pointer..
does enable component replication helps?
You are spawning a Component In BP that is marked as Replicated?
No i was trying spawn them on every client seperately. since only server check and when it pass, then spawn effect to everyone
now im trying with enable component replication and spawning from server
well yeah it worked anyway.
(why i did seperate Components without replication:: guess network performance? because that component counts may high due to every items have passive)
it seem has limitation for without replication
does anyone know
how expensive it is to call an RPC on tick
the RPC only sets one float value and that's it
it doesn't do anything else lol
and my tick interval is set to 0.1
oh wait what.... components have no ticking like netfreq? i profiled(network profiler) it with 1000 components spawn, only shows that rpc fires. have no info about components yikes...
so we sure that will not impact network performance with 1000 players x 1000 components?

@quick flint If you must send it regularly, at least make it unreliable
Though to be honest, it's probably better to find a different solution that doesn't involve sending a value that way if possible
@bronze arch components are replicated via the owning actor, so they adopt all frequency/relevancy properties from the actor
Replicating with a function would fit better as far as I get from your description @quick flint
replicating the float property*
Though to be honest, it's probably better to find a different solution that doesn't involve sending a value that way if possible
@chrome bay we couldnt think of any tbh, because its dependent on the player input
@bronze arch components are replicated via the owning actor, so they adopt all frequency/relevancy properties from the actor
@chrome bay
But then why it doesnt show in netprofiler?
@bronze arch If it's not replicated as you said, then it won't show in the network profiler
Its replicated, since it doesnt support unreplicated netguid.isdynamic crash
I ticked replicated component, the outer reference is player character
Maybe it has nothing to replicate?
U mean variable replications?
@quick flint yeah that's fair enough if it's sending input. I would at least make it "unreliable" then in that case
Maybe try to avoid sending duplicates if you know the server already has the latest value, or send at a lower rate
basically we are replicating a float "KeyTimeDown"
well I lowered the tick interval
to be 0.1
so it should only send 10 ticks a second
for this component
@chrome bay
Right, I guess you would only send it if the key was indeed down at all
Not sure though
@bronze arch Right - if the variables aren't changing, then it won't have any cost
Apart from the initial cost to create the component (if created at runtime), and any initial replicated variables
@bronze arch Right - if the variables aren't changing, then it won't have any cost
@chrome bay im only use one multicast rpc for effect if passes something from server
never use variable replicates in components since it replicated already in player character(like hp, mp, level)
so this will no cost except spawning and rpcs? does it saves net performance like non-replicated?
Well, there is some inherent overhead because it's an extra replicated object to keep track of for changes etc (components also have some default properties that are replicated)
component properties/rpc's are also slightly more costly then actor properties/rpc's because of the extra header required
But that's not something you should typically worry about
Unless you have lots of those components sending lots of RPC's constantly, like character movement does.
nah, not constantly, it have cooldown to fire. even CD is done, it need to check requires like if player get damage below %30 hp. then it activates CD and effect same time.
ultimately the network profiler just shows you what's being sent, that's it really
yeah as far as i see, it not much cost like a normal actor replication
it might show up within the actors' properties but i can't remember
nothing about "yay component" here
(test project ofc)
only shows triggered rpcs
(sorry for that bad naming rpcs xD
So simulated proxies doesn't update regularly right? They don't update when there not in the players view right? Because I have an Cloth stretching bug in Multiplayer.
From the last seen position (when we turn around from that client and that other client moves away) to the newly seen position of the other client (when we turn around again and see the other client again).
How can I avoid that stretching bug?
Anyway thank you all who helped me. Have a nice day everyone! 
I'm learning Online Subsystem features and I wonder if there is a comprehensive example / tutorial for managing sessions. Do you know of any?
how am i supposed to use this
how do i know if i have potential network issues
so i can fix t hem before they become an issue
i want to do some sort of regular check
for potential network issues
in our code base
how would you suggest that?
what should i be looking for
I just want to try and catch any potential issues early on in development @chrome bay
i just dont know whats expensive and what isnt
same as anything really just package and test/profile often
test with packet loss and lag etc too
outside of editor in a "real" environment
If you have an on rep property in the character but want part of the on rep function to run only on the owning player's machine, is IsLocallyControlled() the correct way to gate that?
Looks to be the case, just sanity checking
Hey I want to start making my game around eos because i started a little bit with oss matchmaking but it didnt have all i wanted i have seen the sdk and the docs can someone please help me with starting and how to get it setup all my code is already networked i wanna add matchmaking and lobbies
If you have an on rep property in the character but want part of the on rep function to run only on the owning player's machine, is
IsLocallyControlled()the correct way to gate that?
@grizzled stirrup jop, correct
@quick flint you can simulate lag or specify limited internet speed to see how your code runs
In your project [PROJECT]/Config/DefaultEngine.ini you can add ConfiguredInternetSpeed, ConfiguredLanSpeed, PktIncomingLagMin, PktLag, etc. to simulate specific settings, and watch your code.
Holds the packet simulation settings in one place
Where does the client store a list of replicated actors/pawns in the level?
Nowhere really, there's a list of actors and some of them happen to be replicated
lol @vivid prawn when i set my packet loss to be 500, it looks like i dont even jump
PktLag i mean
@chrome bay
well, 500 is pretty high! LOL... but, that's how you check your Server/Client performance ๐
@vivid prawn yeah, 500 is if i tried to connect to a server in China or something
from north america
Hehehe... yeah, then I guess that's why there are servers around the world.
Guys I m facing a wierd problem, if I spawn a collision box on server the overlap events are generated, but when i attach the same collision box as sword to pawns, the overlap events are not getting generated?
After choosing this option the events started to generate, so I m curious why it isn't enabled by default.
Does it have some bugs?
What is the bNetForce argument on DestroyActor?
@shut loom Print something on the false of that IsValid. If the print isn't firing with that small change, it's because that pointer isn't valid.
@twin juniper if it is set to false it won't let you destroy the actor if you don't have Authority role on it. So it protects from destroying actors from a client if it is replicating. If you set it to true then you will be able to destroy actor on a client side even if it is replicating.
ah okay
Im having this strange issue now where I have a variable thats replicated and I destroy it on the server but it doesn't destroy on the server or the client. I'm calling UWorld->DestroyActor
I'm also checking if the pointer is valid.
The pointer gets overwritten eachtime an object is spawned. But before the spawning occurs.
I check if pointer is valid, if it is, I destroy it, then call spawn.
But it seems the destruction is not occurring,
You could check the return value from DestroyActor
Alright I'll do that now.
Hey guys, I have a question about ReplicationGraph, I don't completely understand the method PreAllocateRepList(ListSize, AmountOfLists), based on what do I decide what the list size should be and the amount of lists?
Yes I found the issue. I was destroying it in the wrong location
@tulip ferry By default, there is basically a full multiplayer stack for character-based games (first-person, third person shooter, etc)
@meager spade i ended up getting it all working btw
Is there a reason why the host widget UI only updates once? Client UI updates correctly
And onRep notify is just a function that plays on the client when the server replicates something?
@glad sedge yeah, whenever a value changes
Unless otherwise specified by you
I had no clue that eXi was the Cedric Neukirchen eXi
His guide is so good
Is there a way to see how much information is being sent between client and server etc
Great thank you
hello guys i'm having a problem with my dedicated server it causes this warning
https://media.discordapp.net/attachments/536252182388015105/774045009992351764/unknown.png
Hopefully quick question, I am trying to use advanced sessions w/ stem on the right is what should show up blueprints is identical so I figure its some problem on my end. Steam is running and I am signed in. At this point I really don't know what to do to fix it so even if its something stupid like mispelling smth any help is much appreciated
Hello, I have sub level not "always", but BP loaded. When I load them on server with "Load level instance" on server only, Clients sees nothing. When I multicast the "Load level instance", then all clients see the level, but the actors in the level are not replicated. When the actors in the loaded level per "Load level instance" begin to move, nothing happens on client side. I used the same actors in "always" loaded sublevel, so it must have related to load level in bp per "Load level instance".
I search web but found no answer... how properly load a sublevel with replicated actors with "Load level instance" so the actors are replicated in normal way, like movement and everything else?
Hey, guys, physics running via the server is very jumpy how to resolve this ?
Network Insights or Network Profiler
@meager spade what's the diff?
i remember the old network profiler
is the new thing basically just an upgrade?
to that small c# project lol
@tranquil yoke networked physics is best not attempted unless you have plenty of experience under your belt, and are very comfortable with c++
its a nightmare
@sleek elk there is an engine bug where always loaded method, iirc, doesn't set the level visible to clients
i think they fixed it in 4.26, its been around since 4.1
@winged badger what is involved, i need to attempt this, have lots of work related to physics.
but it is more like, Spawn a ball and then allow ball to be hit. and also allow other people to see the same thing, It does not need to be perfect for now, just a smooth experience for all ?
@inner sand there is a steam API limitation where you won't see server instances running from the same machine you're searching for them
@winged badger Project is not actually a game, but there is some things which are physics related . it is like 10% of this.
think is physix won't have the same result on same machine running the same identical scenario twice
so yeah, networking it is a bitch
so server have multiple instance and it is simulating the physics for all the instance multiple times ?
most networked physics includes constant updates via custom structs
and very few objects affected by physics
and even then you won't get the exact same state, but it might converge close enough
is there a doc or example to read so i can learn about this more.
it seems like a hard job to do.
maybe but everything network physics related is painfully specific to the problem
there are no generic solutions
but my current implementation is, Spawn ball on server , spawn a player on server with a bat.
if bat and ball has a collision, then do a hit and replicate the ball and bat position to everyone ?
it is not correct way ?
you'd have to do client auth collision
but the thing would still jitter on server even with low-moderate lag
@tranquil yoke : I had a conversion in Reddit last 2 days about replication. Beside projectiles it was about physics. It's a in depth talk, even when its not directly your situation I think its very interesting related to your question: https://www.reddit.com/r/unrealengine/comments/jn3qsh/replicating_2540_ai_character_physics_projectiles/
that is, at least by title a much simpler scenario
as you don't have a server spawned ball coming at you
thing is with say 0,2 sec ping for client
server's ball instance reaches the point where collision will actually happen
0,1 sec later, client hit the ball with the bat, ball on server is 0,1 sec of ballistic trajectory past that point here
0,1 sec later, server RPC arrives on server from the client, informing it of collision
at this point server ball is 0,2 sec past the collision point on server, and 0,1 sec on all other clients
see the problem here?
and if you do server auth, the game will feel incredibly choppy
Perhaps cheating is not a big thing, so server evaluation is not needed. If it is... when client hit locally, make RPC to server inform about hit. Check on server if someboidy hit before, if not, take it as real hit reardless of any extra validation on server. Just do collision check on every client by itself
this is where physix kicks in
if you try to predict the collision server side to react to the ball
yes cheating is possible , no validation yet
i pretty much guarantee you that ball will start flying in unique direction on server and all clients before it gets corrected
physics projectiles are easy incomparison
you do client auth, server common sense validation
client fires a predicted projectile immediately
For position i would do physic simulation only on server, replicate position to clienst and interpolate to make it a bit smoother. But that's the same topic from the Reddit link I postet above.
but it doesn't exist on server before the server RPC arrives
There is no server RPC, using HIT component and Engine physics to do everything
if the idea is to be able to try to smack that ball in a particular direction
the controls will always feel terrible with that approach @sleek elk
How do you predict server collision ?
where i'd try and cheat
Client can cheat
not that cheat
only thing we need is ability to hit ball with a bat
the smoke and mirrors approach
i'd make the batting client's ball fly faster
and arrive there half a ping before it does so on server
its ballistic trajectory
so the moment its launched, and client gets the info it knows exactly where the ball will be at any point on its path
if you increase the ball's velocity enough to consume the lag on the batting client
then scenario becomes, in order
batting clients ball arrives, collision happens, RPC is sent
0,1 sec later server receives the RPC and its ball just reached about the collision point
0,1 sec later all other clients get the collision information, just as their ball reaches the collision point
Should i use Engine Physics, to do the bat and ball ?
or RPC only and predict everything ?
Somebody used "Load level instance" already for a sublevel with replicated actors?
i had a similar problem
but it was more then 3 years ago, and i don't remember it well anymore
all the NetGUIDs for static actors were good
but they just weren't replicating
(from the sublevel)
and it was working in only one of the load mode Blueprint/AlwaysLoaded, don't remember which
RPC referencing a static Actor would work just fine
Hmm, its curios I find so little information about it when I google for it. It seems when I read it that it should work like expected. Nobody write that sublevel and level load in multiplayer is not possible.
Yes, always load is working fine. But having a level loded with BP and then load it, make the AI actors on the sublevel not moveing for clients.
Can i see server collision and server ball position
@tranquil yoke there is command, moment, i search it
ok thanks
it is a bug
@winged badger is there anything, that i can see how physics is behaving, for lower ping, without deploying to Server actual
and i heard it being fixed in 4.26, but again, not 100% sure im remembering the right bug being fixed
net pktlag=200 into console
I cant see this command on console
"p.NetShowCorrections=1" was the one i meant @tranquil yoke
Is serverTickTime is related to all of this stuff ?
Error message I get when sublevel is loaded and actor do things on client but are not replicated: "Not currently registered. Aborting"
I do not get the point, sounds so easy. This es exactly my topic, and the creator the the question just did it by loading the level on server: https://answers.unrealengine.com/questions/908284/how-to-stop-replication-for-load-stream-level.html
@tranquil yoke : Yes, I would at least try it. Also tick is a point spoken in the long reddit thread. I would try first without changes, then with changes
I don't get it. Switching it to "always load" it is working fine directly.
Switching back to "BP loaded" and load the map on server eper BP, client is not getting actor replicated anymore. The player gets hitte by ai, so it seems the client ist replicated into server word, but client gets not replicated the sublevel actors.
5 o'clock in the morning, enough work for today. I hope tomorrow for more luck with replicated level loading. Read a lot again, but everything I found says it works just when the server load the level ๐ฆ
Hi all, Iโm am trying to build a multiplayer scoreboard that displays all players on the current servers names, score, level, a custom string variable and ping. I can get the score, level, ping and other variable listed in a scroll box when players hold the backspace button, but am struggling with the players names displaying correctly. I have tried using the game state for each player in the game state player array, as well as functions in a game instance to get the players name at start of game but have hit a wall. Would appreciate some advice/help ๐ Feel free to DM if you would like to tackle this with me and need more info / pictures of current code. Thank you in advance ๐
I am having a dastardly time trying to replicate these clouds. I don't understand what the heck I am supposed to do. I've followed every damn tutorial I can find on YT and I can't figure out what I am doing wrong. Here is a basic rundown on what I am trying to replicate... The cloud runs on a bunch of float and integer variables that determine a number of things like where it spawns how big it is etc etc... How on freaking earth does one go about replicating this? All the variables end up changing for every client ..but I need a set of variables that are the same on every machine (obviously the clouds need to behave exactly the same on every machine as it is the foundation of the game).. Yet I can't even get the cloud to move anywhere but on the server...just moving the cloud from one point to another will just not replicate on a client. I've done all the custom events and run on server, switch has authority, multicast bla bla bla everything and anything between and I am I sooooooooooo confused what on bloody earth I am doing wrong
Are you using input velocity or projectile movement? Those should replicate. @round star
@sleek elk why not load the level and spawn each actor by yourself
For an endlessly incrementing OnRep int that is just used as a trigger for cosmetic FX, is it best to use a uint8 to be more efficient?
As far as I know when the uint8 is > 255 it'll automatically wrap back to 0 when incremented, is that correct?
yep correcto
Thanks!
Is there a simple API method to get the ping to the server in C++?
@twin juniper (int32)PlayerState->GetPing() * 4;
@grizzled stirrup Thanks, trying it now.
out of interest, why multiply by 4? Is the value divided down so it can fit in a uint8?
ExactPing is more accurate
But is only available to the owning player and server
The other ping is rounded and replicated for other players
When i set a replicated variable in a game mode it is always ran on the server and should also be set on all clients correct?
not in the game mode
game mode isn't available to clients
whatever it is should be in the game state
so if in game mode i do
AActor->MyReplicatedValue = whatever;
```\
it will only be set on the server?
I thought you meant a variable of the game mode
But yeah, it doesn't matter where you set it from. If AActor is a replicated actor, and the value is set server-side, it will rep to clients
@chrome bay What is ExactPingV2?
is it possible to turn off server corrections for AActor classes for a given period?
Hmm well you can disable replicating their movment by turning it off server-side
I'm trying to detach a ball from the player and the balltrail (niagara ribbon) trips for a sec before detaching
and I think that is because the server is correcting the ball position when detaching
yeah but I need it to replicate the movement ๐ฆ otherwise it won't detach in the correct place
if I disable replicate movement the ball position stays {0, 0, 0} even tho it's attached
(you do see it attached for the client tho)
The Server is the only thing that should handle the detaching, as that is replicated too as part of replicated movement
Or more accurately "AttachmentReplication"
If you detach client-side then I wouldn't be surprised if it's in the wrong place for a while
Hello, will the player state work correctly when testing multiplayer in editor?
Hello!
I have a problem. Calling "QuitGame" on a dedicated server does not work? Anyone know why?
Call it on tick with a multicast rpc that passes 3 FText's on tick @void nest
And does that work even when there are no players on the server?
Because the dedicated server is supposed to shut down on it's own after a while when no players are on it
@worldly raft yeah
So I made my own game state and havent changed anything in it..but when I replace the default game state with the one I created I am unable to move the client characters
Make sure your game mode derives from AGameMode I think should fix it @round star
Has any 1 implemented stuff like paid skins or cosmetics? i am wondering what would be the best way to implement this in a safe way?
Make sure your game mode derives from AGameMode I think should fix it @round star
@dark niche Yep that fixed it lol
i assume i would have to query the inventory server(like steam) when the player joins a dedicated server so that it would get the equiped skins?
Hello everyone, is there something specific so that an actor placed in world will replicate its properties and fire OnRep_() stuff for a client joining, like in the initial bunch? I already checked NetLoadOnClient, AlwaysRelevant and Replicates
(well, actually it's the onrep of a component of the actor). If i trigger an event later after the join, the OnRep will fire, but I don't have the initial value replication even if server value is different from default value that the client has on load
Hello, I have sub level not "always load", but "BP loaded". When I load them on server with "Load level instance" on server only, Clients sees nothing. When I multicast the "Load level instance", then all clients see the level, but the actors in the level are not replicated.
I read several answerhub topic simlar, but their people complain more about how to change that actors are not replicated. Most sound that doing "Load level instance" on server also replicate actors in it. Is there anything I need to do when using "Load level instance" to load a level with replicated actors so clients have them replicated?
I'm looking to make a multiplayer game with physics based movement - all of the reference I can find on that is pretty out of date (~2014) - is there a modern good way to do that someone could point me towards? MovementComponent seems to be all kinematic
Hey! I've recently worked on some custom movement, where the server stops replicating the character's movement and teleports the player to the end location while the player predicts the movement smoothly on its client
The server resumes replicating the movement once it's over
However, I've started seeing this in multiplayer:
Once the client performs the movement, it's completely out of sync and for some reason keeps getting corrected by the server
one correction would be acceptable, but it keeps doing it, and I've never had that happen before
any idea of places I should look at to fix this issue?
Corrections continue even when the player is standing still, which is quite odd
LogNetPlayerMovement: Warning: *** Client: Error for BP_Survivor_C_0 at Time=87.699 is 0.000 okay might actually not be that 
why does it consider 0 as an error, there's no diff between server and client
EDIT: Aight so it desyncs when the origin is shifted 
is there any easy sample for NetDeltaSerialize ?
@solar stirrup I have this same issue
@solar stirrup cute profile picture btw, let meknow if you figure it out
What version of the engine @quick flint ?
Hey do you know how can i add a loading screen while the players are loading my gameplay map ? and the loading screen remove when every players have loaded the map?
How do I do client-authoritative movement (since it is physics based) without using a CMC, since those are kinematic?
I'm looking to make a multiplayer game with physics based movement - all of the reference I can find on that is pretty out of date (~2014) - is there a modern good way to do that someone could point me towards? MovementComponent seems to be all kinematic
@red musk Had a discussion on reddit last days, physic sim in mutliplayer was one part. Perhaps just rad and and perhap jump in and add your questions. https://www.reddit.com/r/unrealengine/comments/jn3qsh/replicating_2540_ai_character_physics_projectiles/
Question. What would be a good spot to store a ton of variables essential to the game? I have a large tiled landscape for multiplayer..and I have dozens of variables I need replicated to drive certain actions of actors..would the game instance be okay to have them in? Then use the server instance to drive all the clients
the game instance is for the client and the game instance is not destroyed when you join a new world so i think you should not put variables here
if you want the variables to be server-based then put your variables in GameMode
but i'm probably wrong
what type of varibles you wanna store?
player name? or something else?
its to run an atmosphere that drives an entire weather system. The variables themselves are computed with a multitude of equations...easy for single player..but this is a multiplayer game..and it's just a mess. So I am just trying to work on basic replication right now. I am trying to get a cloud to move on server and client. Always runs on server never on client...works prefectly for a staticmeshactor but not for an Actor itself..I dont know why
I figure even if it's in the game instance the server will always have authority..any unused data I can just clear it if I have to when server disconnects from a game
I can have all my functions in the game instance and call them in the game mode..that was my thinking anyway
wait i know
i said something wrong
do you want to display the Km/h of the player
no that was just showing the speed of the cloud
lmao
the fact it says 0 means its nothing sending the velocity to the cloud actor of the client
idk why..it's replicated..and the actor is replicated..and the game mode sends it to the actor
so I dont get it
do you know Multicast in the gamemode will always fail?
even if its calling the multicast from the instance?
wait you send the multicast to the game instance?
game instance has a multicast that updates a variable to the cloud actor
I call that function from the game mode
event
w.e
finally got it...yea game state works XD had to set the variable itself to replicate even though it was passed through the event that was multicast..is that normal?
I guess it is.
you should use GameState
@rustic spruce Thank you
I want to disable location from replicating when replicate movement is enabled, but keep rotation in tact. Can someone point me in the right direction?
is there a way to do conditional replication for ReplicateSubobject or ReplicateSubobjectList? like if i have an array of UObjects I am replicating but I want them to be owner-only?
hey, I've written a super basic blueprint that get's all of my stair objects and changes the visibility of them. I'm trying to sync it up to work with replication and MP but I'm struggling. I've been trying to use the logic from underscore's multiplayer replication (part 1) video & Reuben Ward's 30min networking video but I'm going in circles unfortunately. Is anyone willing to give me any pointers / potentially have a look at the blueprints?
fun fact. I changed my play setting to "play as listen server" and it worked! Spent way too long on this
the reason something works on listen server but not dedicated is that as listen server you have authority, so there's probably some weirdness with authority or RPCs that you should check out
also, try whatever you were doing from one of the other client windows (not the listen server window) and see if it still works
That makes sense. I actually tried that and it didn't work. I'm trying to call the client to call the server to run the task but it's still not working properly from there
I've got the client calling a custom event which is set to "Run on Server". And than that event calling the servers event
idk if that makes sense or not
I think I'm having a similar problem in another context lol
so
I'm trying to replicate projectile spawn. My logic is currently:
- Spawn the projectile locally on the auto-proxy
- We are the auto-proxy, so call an RPC
ServerSpawnProjectileand send it the projectile information - Now we are the server and successfully run the RPC function with the given parameters
- But when we are the server and call
GetWorld()->SpawnActor<...>(...), an actor does NOT spawn????
Anyone have any idea on why the server RPC wouldn't successfully create an actor?
I am the very confused
@robust ivy post some screenshots of your functions
@austere needle is your projectile replicated? if not, what might be happening is that the server IS spawning a projectile, but it's totally separate from the client's and the client isn't seeing it
the server doesn't see it at all
the client sees it cause the client spawns it locally and then notifies the server
but the server doesn't spawn it
@robust ivy the top function is what you're triggering on the client with a key press or something right?
yep. If they press q it calls the top event
and your auth strings are running?
what is this inside? player character/player controller?
did you set the _Server event to be run on the server in the details?
it's inside of the basic stair geometry blueprint
see my problem is living in a custom actor c++ file. I've seen people mention on a couple threads that RPCs won't work if the local client doesn't have ownership of the actor you are running the RPC on
could it be some hinky ownership issue?
okay, there's your problem, you can't call a run on server RPC from that because it's not something the client owns. If the client is the server (your Auth is true string) you can do whatever, but if the client isn't the server, it doesn't own the stairs so it can't call an RPC to the server
yeeeeeeee
I think I have the same problem but I don't know how to properly set ownership to the 'client'
the client by default only really owns the player controller and the pawn that your player controller is controlling
i think maybe some other stuff, but definitely nothing that is just placed in the world
you just need your RPC earlier basically
ok. So I should do the auth check in say the level blueprint first?
instead of "Press Q > tell stairs to do stuff" it should be "Press Q > RPC to the server to do stuff > server tells stairs to do stuff"
no, you should do it in your player pawn or player controller
so inside your player controller:
Event Key Q does your authority check, if authority then call Multicast Q, if not then call Server Q
Server Q will just call Multicast Q
Multicast Q will THEN call whatever function inside your stairs to change visibility
the difference between that and what you have is that only AFTER the multicast do you go into the stairs blueprint, everything before that is inside the player or controller
that makes sense. I'll give it a shot and see how I go. Thankyou! I appreciate it!
no problem, networking is a huge learning curve for a while
it starts to make a lot more sense once you've got the Ownership/Authority concepts down
but i still haven't stopped running into weird stuff i don't know how to do lol
yeah i feel that once I get the workflow of it all it'll be something which clicks
then you get to have fun trying to work on prediction to make the game not feel laggy as hell waiting for the server to do everything ๐
@austere needle can u post some screenshots
top piece of code fires when you left-click
I'm pretty sure it's also an ownership problem for me
but that would mean that ideally any RPC replication functions need to live in my character class
which would be annoying
you can also do RPCs inside actor components
so I'm trying to figure out if I can set the ownership of this actor class to the client so RPCs work
what is this class?
so this is a weapon class that is spawned in and attached to the character skeleton
aactor
i know there is a way to set owner, let me look real quick
I have access to a SetOwner(AActor) function
You can set owner
but I'm not sure what the correct actor to set is to get RPCs working
i mean you can just call it after you spawn it right
Unless you detect the actor with an overlap or so
oh its like a pickup
If you spawn it you can pass it as the owner pin
But this is probably placed into the level
yea right now, the Character is spawned in and 2 WeaponActors are attached to it
and I want to run RPCs from within the WeaponActor custom classes
to keep my code not-all-over-the-place
yeah you just need to call SetOwner on the server at some point when attaching them
And the weapons are spawned too?
yea
Then pass the character or its owner as the owner when spawning the weapons
Spawn actor node has a pin for it
makes sense
he's in cpp
Has to happen on the server of course
ye its one of the spawnactor params
yeah, if you just pass the player character it should work fine
Ah sorry too many bp users
hey while you're here do you know if i can conditionally replicate subobjects?
so then the idea is to have the server spawn in a weapon and assign the owner, then replicate down to the clients
im replicating a few arrays of UObjects, and i want some of them to be replicated only to the owning client
So the array replicates?
I've only ever replicated UObjects using the generic ReplicateSubobjectList function
You can do it per array i assume
But not sure if you can do it per object in one array
i have a component that has three arrays of UObjects, one of which doesn't need to replicate (easy), one of which should only replicate to the component's owning client, and one of which should replicate to all
i can split them by array so it shouldn't be per object
Hello, is there something specific to do so that a replicated property being a UObject subclass pointer is properly replicated on client connection?
i just didn't know if there's a way to do "owning client only" in ReplicateSubobjectList
Yeah then just give the array a different rep condition
oh, no i mean i'm not trying to rep the array as a property
@glad wharf look up subobject replication iirc
well
i am
but i also need to rep the objects in the array
since they are UObjects they need something to replicate them
So like the playercontroller
I checked the doc but not sure to see what I missed. The property is inside a actorcomponent replicated, itself inside an actor replicated
Thanks eXi, i'll continue to dig in
I'm not doing it often enough to give you an example of subobject replication
Sorry!
No problem! Thanks for the pointers, now I know where to look more
https://gyazo.com/23173efaa61de87b0544211c17f9735e
so i've done this in my buff container, and it works great, but every object exists on every client.
i want to do something similar but i don't need every object to exist on every client, only on the owning client
Hm not sure atm without looking it up
okay nbd
@vivid seal late reply because I had to grab dinner, but I got it working very easily with your instructions and now it all makes so much more sense. Thanks heaps!
No problem dude, gl with learning everything
When I create a session for either steam or lan, do I have to load a level after create session succeeded.
For the life of me I can't seem to get this right.
This is my code in my Character BeginPlay() function. If I'm not crazy, it runs on the server only: https://i.imgur.com/0ffdkh1.png
Then I use DisplayAll InfantryWeaponMaster Owner in the console of both the client and the server to check the ownerships of the weapons that the server is spawning.
No matter how I try to set ownership, I can only set the ownership of the server's own weapons. I can't seem to set ownership of a weapon to a client. Most of the commented code are my various attempts.
Anyone have any tips on what I'm missing? I feel like it's something stupidly simple.
@summer tide pretty much. I'm pretty sure the flow is... get the session to join -> try to join the session -> if you joined, get the connection string of the session -> then clienttravel to the connection string which would load the destination level
now if you're talking about hosting, then its the same idea
create the session -> if you successfully created the session, travel to the level
so yea, loading the level comes after the session stuff
@austere needle Do I have to use OpenLevel after host has created the session? I'm trying to stay on the same level and only show the host and joined players info.
BP
im not totally familiar with bps unfortunately
but the thing that loads the level is gunna be your server/client traveling I'm pretty sure
so you could host the session, then wait for something else to happen
like a button click or whatever
so it's totally possible to host a game, sit in a lobby level, have players join the session and load into the lobby level, then servertravel everyone to the next game-level once the host clicks a button
@austere needle Is the spawning happening on the server? If you know your owner already when spawning you could use this code that you already have which is Params.Owner = GetOwner();
HasAuthority() makes sure it's running on the server right?
If I un-comment Params.Owner = GetOwner(); then I see this on the server instance: https://i.imgur.com/EHxLV1D.png
And on the client instance all 4 say "none"
so it's only setting the owner of the items the server itself would own
You shouldn't set player controller as a owner
so then what should the owner be set to?
cause that's what GetOwner() sets it as
from a Character
If it is a weapon of a character then I woul set it to character then
Player controller is not replicated
Yes
holy shit I think that worked
maybe
we'll see
ownership seems to correctly set to the character and proliferate down to the client. just gotta figure out why the weapon wont fire now lol
It should be perfectly fine to use the Controller as the Owner too, in case you swap characters and what not.
The PC is after all what defines the ownership, even if you use the Character.
The most important thing is to do this on the Server (setting Owner).
so params.owner = GetController() would work as well then?
cause yea I would prefer to use the controller
Theoretically yes
switching pawns will be a thing
It would make sure your Weapons stay owned if you swap characters, at least in my mind
tho techincally the weapons probably wouldn't need to follow the transition
right
so maybe I dont need that
Shouldn't make a difference for your problem
Even with that you can't execute RPCs?
I can't test those atm
the weapon pointers aren't carrying down to the client
so even tho the actor is spawned, the client references are nullptrs
so the variables in question are PrimaryWeapon, SecondaryWeapon, and CurrentWeapon
I check them on left-click
on the client they are nullptr
so I thought I just had to replicate them
but that doesnt seem to work atm
Okay so 3 things then:
- Character set to Replicate?
- Variables in Character set to Replicate?
- Weapon set to Replicate?
Then your weapons should replicate just fine
on character: https://i.imgur.com/AID7y2A.png
on weapon: https://i.imgur.com/Gfy4B87.png
character header: https://i.imgur.com/1jDyO8I.png
And character cpp?
the first picture
If you never had a variable replicated in a class and add that specifier, it will annoy you about the missing function
But if you have the function, yeah you can forget that step
@austere needle Could I use LoadStreamableLevel instead of OpenLevel?
I'm not sure. I'm not familiar with LoadStreamableLevel unfortunately
You will need the OpenLevel call because of the ?listen argument
Otherwise Clients won't be able to connect
What is the goal of this?
is open level equivalent to a servertravel?
Something like a Party in the MainMenu?