#multiplayer
1 messages · Page 161 of 1
🤦
I just realised
Don't listen to me
Its a bad idea
It was, that you can store scores in the array, and call OnRep every time the score changes
but in that case .... should i store all player state references as slots inUI ?
But you can store it inside player state
You can.
But what I am saying is the PlayerState itself would have Kills, Deaths etc as replicated properties
Which means their values would update for others
So you can view those changes in the UI
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooh
now i understand i think
@drowsy meteor I think you should read the Network Compendium in the Pinned Messages
To understand replication and the PlayerState
i read the cedric doc
6 times is the minimum recommended times to go through that compendium
Any less and you miss to much
// USomeComponent.cpp
// Function to change the color of material instance locally, private/protected for option 1, public for option 2
void USomeComponent::SetShiny(float ShininessValue) {
if (IsValid(DynamicMaterialInstanceVariable)) {
DynamicMaterialInstanceVariable->SetScalarParameterValue(ShininessParameterName, ShininessValue);
}
}
// A server RPC or a function that's being called from server upon some kind of an event
void USomeComponent::FunctionThatRunsOnServer() {
float newValue;
AMyClientOwnedActor* player; // We can consider this as either controller, state or pawn
/*
* Do calculations/checks to decide the new value of the shininess
* Obtain/decide which player should change the vlue
*/
// Option 1: Send multicast RPC with the target player to not have dependency on other player classes
MC_ChangeParameter(player, newValue);
// Option 2: Send client RPC with self as target to not send RPC to all clients but only to the one that actually requires it
player->CL_ChangeParameter(this, newValue);
}
// A multicast RPC to check if player actor is locally controller to filter, so change can be applied only on the target player
void USomeComponent::MC_ChangeColor_Implementation(AMyClientOwnedActor* Player, float Value) {
if (Player->HasLocalNetOwner()) {
SetShiny(Value);
}
}
// AMyClientOwnedActor.cpp
// A client RPC that resides in pawn, state or controller to change the value on the target component
void AMyClientOwnedActor::CL_ChangeParameter_Implementation(USomeComponent* TargetComponent, float Value) {
if (IsValid(TargetComponent) {
TargetComponent->SetShiny(Value);
}
}
Is there a standard to follow between one another between these options?
For me the downsides are
Option 1: Sends RPC to all clients unnecessarily
Option 2: Creates a dependency for locally controlled player type, so the component is not a plug and play kind of a type anymore
I want to go with option 1, but I'm curious if that would be a bad move
Couldnt you let the owning actor take care of the specific implementation?
Comp checks / calculates whatever it needsz then passes final value to the owner of the comp through a delegate?
if (Player->HasLocalNetOwner()) { ? 🤔
secondly, why is this component not on the players character anyway
then you can just send a client rpc from the component, no need to do anything else?
Still trying to find some/any information on scaling UE multiplayer beyond the usual 20-50 max players you see in most UE games. Does anyone have any information that might help?
Mostly Ive heard you gotta go outside unreals replication system to go beyond ~100 or so players
Comes up whemever someone says they're making an MMO
One of the more recent discussions about it
This usually involve seamless transition from one server to another, but this isn't an easy task to be done. I remember I found some plugins and projects about this in the past, couldn't find them fast now, but found this:
There is also an YT tutorial:
An Epic Mega Grants backed Master Thesis about creating the Next Generation Multiplayer Games.
In this topic we will learn how to set up our multi server architecture using Unreal Engine 4 and Spatial OS, we will then work on dynamic interest management and offloading our AI to another server.
Article:
https://github.com/jpetanjek/NextGenNetGa...
Lots of games out there doing 100. I've done it twice now. All I can say is everything counts. Profile a lot and optimize where neccessary
AllConnectedPlayers as RepNotify in the Gamestate, then all clients could act upon that
would make this a tad cleaner imo
you could then have that trigger a event dispatcher, which the UI could listen to
Can you advise what is the best way to proceed if there is a certain logic and a state with which it works, and this state needs to be replicated to all clients? For example, the round number and the class that changes this number. Is it better to spawn a separate actor and encapsulate the state and logic in it, or use a scheme similar to the one in the image?
In general, this scheme seems to scale well, but I’m not sure how correct this approach is
Thanks for the info. Much appreciated. I've come across a few things like Open World Server 2 (https://www.openworldserver.com) which claims to be able to automagically divide a map across multiple servers, spinning them up and down as required, to SnapNet, which claims to be a full, high performance replacement netcode for multiple engines including Unreal and Unity (https://www.snapnet.dev) designed specifically with large server populations in mind.
I was hoping someone might have some experience with some of these third party systems.
Hey!
We have a problem where arrays replicated through FFastArraySerializer don't replicate if set by reflection. We have also tried mark every item as dirty after this
if set by reflection? what does it mean
We set the data via reflection when we load the game
and then the array don't replicate that data, even if they're marked dirty afterwards
Since I stated the player is either state, controller or pawn, wanted to use a common function for all of them to show the logic. I would use IsLocallyControlled or IsLocalController according to the specific classes
On my current setup, that component is a skill component which is added to a player that can use the skill. Upon using the skill, I want to do stuff on that target character's client only. So going with a client RPC would make the result visible on the bearer of the skill, not the targeted player. I also considered adding a replicated "effect" component to the target player's character, checking if the owner is locally controlled on the begin play of the effect component and doing the stuff there. But I believe doing a multicast with target player on the parameter is performance-wise more optimized than having another component
That still requires the owner actor to have logic about the component which is again considered as dependency I believe? Plus due to the above explanation it wouldn't work for my case
I want to consider components as separate modules themselves, so adding a component to an actor shouldn't require anything else than configuring the editable variables. My question is more about if I'm going too far by thinking that way and trying to prevent that kind of dependencies
It is, yes
I personally view that as the project specific implementation
Just like an inventory / equipment / skill / quest comp needs some project specific implementation
I mean, yes I don't think for this specific skill component, it doesn't need to be as reusable as being able to use it on another project. But still, if I would create a new pawn class that let's you play as something alse, rather than our current characters that inherits from ACharacter, I would like to be able to still use that skill on the newly created pawn class for the same project
I've never gone that far, I just try to avoid as many assumptions as i can about the owner
Why would it require a pawn or character at all?
What if you wanna re-use it on a tower?
Like s towerdefence thing or whatever.
how to implement replication to a group? e.g. TeamState replicated to a team members only?
Hi, I'm working on an online co-op project. I have been exploring several methods for executing attack animations for NPCs. In this project, I have utilized the Gameplay Ability System and now Im unsure which method to use for executing the attack animations:
- Replicate the necessary variables and handle them through the animation instance and state machine.
- Use Gameplay Cue.
- Use the PlayMontageAndWait blueprint node and handle them through a blueprint child class.
You would usually use a PlayMontage node in the GA that performs the attack, cause that should replicate already.
@restive geyser
Thank you 🫶
Pardon me but I don't understand that if you imply it could be required on places even if it doesn't make sense at all right now, so it shouldn't be considered like that or it should be as independent as possible for that kind of cases too?
Hey everyone, could someone explain to me why all actor’s OnBeginPlayOverlap is triggered even when only one actor overlaps the component? What is it about inheritance that does this?
https://forums.unrealengine.com/t/multiplayer-onoverlapbegin-called-in-every-actor-at-once/438584/7
from the overlapping event - get other actor (it’s your pawn/char), then cast to pawn and from it, you can check If pawn locally controlled. trigger fires on all players because all they have a local copy of this trigger. and also they have replicated copy of each other. when this replicated copy of player overlaps this trigger, then this clien...
I don't think this is something that would be explained with inheritance or replication/multiplayer. TriggerBox exist on every player's computer, whether it's replicated or not. And it'll be checking if it overlaps with any of the specified collision types on each computer. It's up to you to filter the overlap event to implement your logic on server/listen server, overlapping player or other players
Just like BeginPlay, whether the actor or the component is replicated or not, it will run
Collision responses aren't replicated, so you can adjust your triggerbox to generate overlap event only on a specific player's pc
It was just a hypothetical
Could be said for an Inventory for example,
You'd want to avoid locking it to pawn/character/playerstate
As then you cant simply add it to some Chest
My personal rule of thumb is just to assume as little as possible about the owner
Some assumptions must be made for certain stuff. You won't get around that directly
(You could provide interfaces and get stuff that way, but then you force the owner to implement said interface)
What i dont understand is, even though an actor didnt overlap with the box, it is triggered. In fact, all the actors of the said class has its overlap event triggered. Which makes me doubt that is related to server/client filtering problem.
Yeah but for some reason, just like the post I included previously, they act like they are multicasted or something
overlaps run on client and server
but i have never had a trigger/overlap box detect every player if only one entered it
Interesting… My bug is pretty much identical to this person’s https://forums.unrealengine.com/t/multiplayer-onoverlapbegin-called-in-every-actor-at-once/438584/7
from the overlapping event - get other actor (it’s your pawn/char), then cast to pawn and from it, you can check If pawn locally controlled. trigger fires on all players because all they have a local copy of this trigger. and also they have replicated copy of each other. when this replicated copy of player overlaps this trigger, then this clien...
All proxies representing the same player will also trigger it , on all clients
^
Unless you filter it by locallycontrolled or otherwise
so if you have 4 clients
Yes of course. But my problem is its triggering on different clients
Yes
how many clients did you have
Precisely
thats correct
Oh its supposed to do that?
Server, Autonmous Proxy (local client), Simulated Proxy (remote client), Simulated Proxy (Remote Client)
for the same player
Oh sorry. Maybe i misunderstood you. Total events triggered would be 16then. 4 events for each world
?
so you have server, and 3 clients
Client A enters overlap
You will get 4 calls
Server Side: 4 overlaps triggered for each player. Client 1: 4 overlaps triggered and so on
Server for Client A
Yeah…
Client A locally
Client B for Client A
Client C for Client A
no
whay you mean Server side 4 overlaps for each player
Ok if I have something like OtherActor->GetName in the overlap function
And i logged it
Their local names differ
It would have 4 logs, printing: player1 actor(server), player2 actor(client1), player3 actor (client3), player4 actor(client4)
the names wont match
Even though, say only player1 overlapped it
In a case like this, I try to filter if locally controlled, so the event only happens once
Server and 3 client
just print the players player name from playerstate
it will be unique for each connected player
Or that ^
Yeah but my point is, if i do that. All four players names will be printed
^^^
May i send you a dm privately the day after tomorrow? I can’t get to my computer cuz i have a surgery scheduled soon🥲
1 second
i will show you
1 server and 3 clients
1 player entered overlap
paste this and call this in your overlap
and connec the other actor to the pawn cast
and you will see the name is the name
Huh… that looks a little different from mine. Ill have to check on Friday. But from my memory, it seemed to have different names for each line. Basically saying all the players triggered the box
because you printed the actor name
which will be different
like i said
you cant rely on that, the names wont match (unless its pre-placed in level)
I see. I’ll check out the PlayerState name. Thank you👍👍
Hello,
Let's say that I want to replicate an array of 100 locations. These locations will be handled differently depending on a boolean. Should I switch this to an array of structs or is it better to just replicate 2 arrays and use different functions for example?
Probably a struct with a custom NetSerialize if it's just a bool
gonna post a screenshot of my reddit post so i dont clutter the chat. but i need help!
im new to databases AND servers so im not sure how i would set up an rpc or whatever else might be needed to accomplish this^^^
I would recommend having a web API instead to prevent this absolute can of worms
I know a little about sql but i know nothing about that. Do you have any idea where id start, is it easy to learn?
also the point of mysql was clients could also make their own server and the database schema would be provided. is that still a viable thing with web api?
normally this is done with some kinda REST api
i could accomplish that with varest i assume. how would i go about setting that up though? and this solution is also modular so i could give my friend the dedicated server build and his server would have different stored data than mine for example
is it set up like sql where its a database? again i know close to nothing and i dont know what id google for it
Then do you really need a DB with a separate server instead of something like SQLite if the storage is effectively only persistent to that one server instance?
Also you would have to really careful to avoid SQL injection, and the client being able to run effectively an arbitrary query is going to be difficult to ever be secure
I appreciate the insight. It seems mysql is not a good fit for what im trying to accomplish.
the idea of it also was i could have two separate servers (like official servers after release) have the same data. so for example client has a stored character on server one that they can also retrieve on server 2.
but also want clients to be able to host their own dedicated server.
Would i go with a rest api then considering that?
Potentially yes, but you'd likely have to release some reference implementation of the API server. The game server directly talking to a database server could be acceptable but only if the server talks to it and the client has no ability to run any queries and any queries you do run on the server are well-protected against SQL injection.
I also have my doubts about that plugin but I don't have access to it. Potential GPL violation if it's using MySQL Connector, and does it provide async access to the database?
though I haven't used MySQL in years, always preferred Postgres
it does provide asynchronous actions
my thought on making the database method secure was having all the query functions in the gamemode( that way its only stored on server and clients cant access them ) and then blueprint interface call preset up query functions defined in the gammode
from the player controller or other actors
I would probably always code the server/service that talks to my DB outside of UE and have UE talk to that server via different levels of accesstokens.
Hello there !
Does anyone know how to share Unique Net ID with clients so that I can make use of MuteRemoteTalker function to mute spectific players for specific clients ?
I'm currently calling it from the Server because this is the only place BPUniqueNetIdStructure exist
is there any information or resources on how to do this? im not sure what to even google to start learning and implementing it.
Not sure. I would probably start with choosing a language
that sounds like a good idea thanks
... Yes
I also scanned the NPP for the past week. Partially impressed, largely worried
Network Prediction Plugij
Plugin
The thing that drives mover fwiw
Mover itself is relatively simple
I need to get data from game mode to client. How can i do that?
Using GAS will always make you juggle at least 2 Prediction Systems.
Until they implement it into NPP or whatever. Physics-wise, they might concentrate on Chaos, which is of course shit, cause NPP would then not be the only one that drives "everything".
What worries me is the state of it and the lack of work on it.
There lots of todos that might never be addressed.
You can probably make it work, especially with Mover, but there are few things you just don't have that e.g. CMC offers.
E.g. Combined Moves or smoothing of Corrections.
You can also more or less forget to run Fixed Tick sims with Mover, cause there is no smoothing for the frames that the client renders but the Sim doesn't progress.
The system itself is a template hell, but I somewhat understand why.
I find it harder to follow, because you don't have way to just check where the call comes from
The Object itself just has a function "ProductInput"
But not inherited for anything
The way it's called is by being passed as a type into the simulation and then they just do:
FNetworkPredictionDriver<ModelDef>::ProductInput
So you kind have to find all those calls
But it cuts down on virtual functions I guess, which is cache friendlier I assume
NPP itself, if we ignore some of the type stuff, isn't too difficult
There are some "Services", which the Manager sets up.
And whenever a new Instance of some Simulation gets added to the System, it registers with those Services. These are e.g. Services to ProduceInput, to Tick the Simulation, stuff like that.
You can't really add Services without changing the Engine though, but in theory you have most of what you need from the ones that exist
There is a bit of a weird chain of events that ultimately calls NetSerialize of the Structs of the ModelDefinition
Those structs are e.g. the Input that is send to the Server and the actual State of the Simulation that is replicated back to Clients and kept in sync.
If I find the time in the future I might write a bit of a blog post about it with some diagram, but currently, as usual, too busy
I have some question,
My game has two class 1. UGameItem : UObject 2. FItemInformation (UStruct)
FItemInformation is used to sending RPC.
UGameItem is saving acutal data for using across game.
I'm using FItemInformation sending RPC to server and client.
And When receive FItemInformation, Client or Server will create UGameItem based FItemInformation And Stores in Inventory
(Which is mark as Replicate TArray<UGameItem*> Inventory)
So, The question is
Client is adding item predictly (Adding Item locally and Send RPC with FItemInformation)
Server Receive ItemInformation and Create UGameItem and Adding Item
Is OnRep function will triggering? (As far as I known, Rep function will not happen if received data and client owned data is identical.)
(I'm considering this for performance issue. If it's not really need to consider, please let me know. I'm just need to know This implement is correct and efficient)
XD ...
I need to get data from game mode to client. I have savwd items dropped in gamemode, and I need that info on actorcomp
Not work for me
Is it possible to replicate an array of objects?
yes but use the fast array serializer
Is this possible to use in Blueprint?
Shouldn't be using blueprint structs anyways they tend to get corrupted and cause all sorts of headaches if you decide to change them after using them.
I'm new to Unreal, so I may be confused, but I don't believe I'm using a struct?
what do you mean by array of objects then?
I guess? "Inventory Item" is a blueprint class, and a child of "Object"
You can replicate them yea
as far as i know its just a reference so you're replicating the array of references
When I add items to this on the server, they don't seem to be replicating to the client. thought the array does get longer, the items are empty.
Oh, that would make sense
but if you want to use actual structs aka objects then you should use the fast array serailzier
Which blueprint is this happening inside of?
This is inside of a GameState blueprint
Though I'm also trying to do something similar inside of my PlayerState blueprints
well if its something like an inventory it should probably only be part of player state imo because you want to have each player manage their own inventory
GameState could be used for something shared like a Guild list or something
Yeah, the Inventory in the GameState is just gonna be where I store items that are on the ground
Any help with this?
Then when a player picks an item up I'm gonna transfer it into the inventory of a PlayerState
GameMode is server only. Typically you don't access data from it on the client. Use something else like GameState or a new Blueprint actor that behaves like a manager.
I have to pass all gamemode funciona to gamestate?
GameMode is useful for stuff like the overall rules of the game. If your game uses a timer then you can store the starting value in the GameMode. If the game has a win condition such as number of kills then keep that int in the GameMode. Then the GameState can be used for keeping track of the actual round time and the number of kills.
Shure, I'll move all to my gamestate
Hello. How to replicate chaos destruction? The only thing I managed to do was spawn the master field, but the location of the pieces is not synchronized with all players
And how can i acces to game state from actorcomp? using get game state and then cast it?
virtual void GetLifetimeReplicatedProperties(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

I use bp 😱
Then theres no hope
Id still love to hear some suggestion to fix this mess 😅
- bp dialogue is owned by server
- npc is owned by server
- dialogue object cant be replicated(but local copies exist)
... its a mess
To lock it to only 1 client
So if playerA talks to the NPC playerB can listen in, but cant interact (without being rude and dismissed) sorta thing
first argument is a class not an object
Correct
Just correcting since you're explaining it to someone :p that's what people do on this server
Is it possible for player B to check and see if the NPC has an owner that =/= the server and do something different based off that?
Like when a player interacts with the NPC, set that player as the owner then at the end of the interaction set owner back to server
I wouldn't use ownership for this
I'd have a separate replicated property to determine who the NPC is talking to right now
Ideally i'd just send some float and some index for the current line being executed, and how far along we are on that one
erh, not super accurate
Its with VO and facial animation
the text part can just "start at the next dialogue entry" sorta thing
Fair point. I do fear a tad that this setup will more or less go unnoticed to the average player
And i can imagine it being annoying, having to wait for your pal to finish the dialogue, before you can start, because it's part of a quest chain, and simply "tuning in" mid-way isnt giving you the progress...
quick question, should i do line traces for interaction on the server or on the client ?
In my game there can be up to 5 players
on what?
So in my case i would call the line trace on the client and if i hit something, i tell the server to do its own line trace and then confirm my hit result?
the player will have a line trace called every 0.2 Seconds to check if there is anything to interact with them.
If the line trace hits something i want the player to be prompted with a popup like "press f to open door"
and if the player presses that key i want the door to open
alright then I will try this attempt
thank you for your help
how should i go about if i want to replicate some vr motion components?
not sure if here or #virtual-reality is the best. but seems like a replication thing.
I'm trying to make an inventory system where each item is an Object so it can store information and have logic inside of its class. I have a InventoryItem (subclass of UObject) and some subclasses of that for different objects. Is it possible to replicate instances of these objects, or do I need to rethink my system?
Whats the difference between use and consume?
why can't use be consumed on use?
- Uobject
- InventoryItem
- Usable
- Equipable
- Weapon
- Equipable
- Usable
but should be possible to replicate them yes
they're just Uobjects, afterall
Useable would be something like a tool that can interact with certain items, whereas consumable would be food or healing equipment that can be eaten/used from either the viewmodel when held or in the inventory
And a weapon will need systems for storing attachments
My weapons store attachments, and are setup like i suggested (Except for parent being Actor in my case)
ofcourse, my storage doesn't allow for differentiation since im not using uobjets,
so that specific part must be held by all slots, regardless of their use
When I try to replicate an Array of InventoryItem (or a subclass) instances, the InventoryItems are empty
did you set up replication in InventoryItem?
they dont replicate by default
That's what I'm trying to figure out
Should I create a system for serializing the InventoryItems, and replicating that information, or is there a better way to store items as instances?
To clarify, I'm giving the GameState an inventory that consists of all items currently on the ground
The GameStates inventory is what is being displayed in the top left. I wanted to figure out replicating that before I try to replicate it for playerstates
I have a UI where the host of the game can press on some cards to enable / disable the roles they don't want in the game, and was wondering what's the best place to have the variable (being a map between the name of the role and a boolean to say if it's enabled or not) to later use that variable to add or remove some of those roles in the gamemode ?
In the image above, the colored icons are the enabled roles, and they grey one are the disabled ones
CMC dies mostly cause of the SceneComponent Transform Updates iirc.
I don't think it was very expensive on its own
Mover is probably, in its current stage, more expensive :P
Cause Mover, or rather NPP, also runs this crap on the SimProxies iirc
I'm noticing server travel takes ages until clients are fully connected again, almost 20 seconds
why is it so slow? is there a way I can speed it up somehow?
What do you mean fully connected?
Seamless Travel means no one is disconnected during a travel.
as in, clients are in the new map, and all actors are init etc
Yeah sorry, I meant 'properly initialized' when i said connected
Well thats typically down to how long it takes those Clients to load the level.
If I have a potato machine, its going to take me longer than someone with top tier hardware to travel to the same level.
Thing is those levels load super fast in singleplayer (for the same client, on the same machine)
I find myself inclined to attribute the slowness to networking
Profile it...
Link?
Oh
Heh didnt see it just there
You want to minimise the number of Components for ANY Actor that moves in general.
CMC especially
Transform updates are expensive in general.
Im not well educated on the nuances of Iris, but from my understanding it is purely a low level rewrite of the networking layer.
It is being rewritten to make sure that it can be faster than the current implementation.
Didnt someone attempt to adress the transform updates and made huge savings on it 🤔 Sounds like a worthy engine edit if so
It changes nothing about how you deal with Replication and/or RPCs etc
Its changes are abstracted away from you for the most part.
🤷
No thats called Push Model
Which has been in the engine for quite a while.
Its a CPU optimization
You as the programmer are responsible for telling the replication system when a property has changed and needs to be updated across the network.
#cpp message found it. Vblanco
Silly you
push model is actually fairly discussed and documented, and it's also become the standard in the UE codebase
it is still a matter of luck for whether or not you stumble across it
It kinda is though lol
Thats quite useful so I pinned it.
hold up, why do we need this
doesnt the engine already do this?
There are probably reasons why it doesnt do it like that.
You dont NEED it.
Im not sure what the tradeoffs are.
So I wouldnt necessarily recommend you go and use it everywhere.
Perhaps ask Blueman or Intax why they made it.
And what advantages/disadvantages it provides
I'm wondering how much faster it is, or what else the engine does that slows down normal paths
No clue
Oh I just realized this may not actually be seamless travel
Seamless Travel is something you need to enable on your GameModes
As opposed to a Hard Travel, which causes Clients to disconnect.
You generally always want Seamless Travel.
But ServerTravel is the command for telling the Server to move to a different Level.
How it moves is either Seamless or Hard
I see, why I thought I was using seamless travel I have no clue, I haven't touched this BP in a while, I'll read up on how to enable seamless travel and things should be faster
ty
Well, no.
Enabling Seamless Travel doesnt magically make things faster.
But do read up on it.
dang it seems like a lot of initialization assumptions i've made in my code base (like caching stuff) are no longer true with seamless travel, where some actors persist but others do not 💀
Very few Actors persist across a level transition in Multiplayer.
You do have the option to cause any Actor you like to persist however.
Thats an advanced workflow
i'm actually down for killing as many actors as possible during the travel
You dont have to do that if thats the case.
The engine does that for you when it unloads the level
The exception being the default Actors that are kept
Like the GameMode, PlayerController, PlayerStates
Oh player states survive? Looks like I'll need to just have some event that gets called during seamless travels and put some reinitialization logic in it
It only persists to the point that it can be queried by a new PlayerState for any properties you want to retain from the previous level.
Take a look at AGameModeBase::HandleSeamlessTravelPlayer for further info.
And consequentially APlayerController::SeamlessTravelFrom
Any insights on what's lighter to send over the network, TSubclassOf<Something> or FGameplayTag?
If you have FastReplication of GameplayTags enabled then the FGameplayTag would be lighter.
A TSubclassOf is just a pointer to an asset, so it will be quite compact in its own right.
Would you mind elaborating on FastRepliaction of GameplayTags enabled?
Why are you concerned about bandwidth of these types?
When it comes to network optimization, CPU overhead is generally a more pressing issue.
And where you would want to focus most of your efforts
Bandwidth these days is not that big of a deal.
That's a good point right there
Its a GameplayTagsSetting
I guess you mean I should worry more about the stress on the CPU than the size of the packet itself, is that it? Not saying the packet size is not important, but ignoring CPU would be a mistake.
Yes
Ah yeah, 100% with you. 99% of the things going through the network are being as cached as possible. I'm stressing RAM a lot, no doubt.
Im not advocating for ignoring bandwidth considerations
Only that you will see more improvements optimizing for CPU instead.
I really appreciate you signalising that. It actually validates the work we've been doing here.
For example, the more properties that the CPU has to iterate over for a given Actor, or the more properties the CPU has to serialize into a packet, the slower it is and the slower it will get that packet out.
Only send the minimum you can get away with
The more I work with network, the more I realise performance is all about creativity than anything else lol
There is no one size fits all approach.
Hence, ✨ creativity ✨
Understanding the tools available to you and what their pros and cons are let you make more informed choices about how to architect your networking
To make it more optimized.
Deduce information on the Client from what comes down from the Server as much as possible.
the more properties that the CPU has to iterate over for a given Actor
We are also probably talking about each and every component/property an Actor is marked to replicate, right? hehe
Instead of replicating an entire HitResult, consider just sending the Location and Direction for resolving the same hit.
And let the Client deduce the HitResult
Yes
Push Model is also something you should employ where you can
It is a big CPU optimization.
Fear intensifies.
We talking the way ECS would handle networking, aren't we?
No
Push Model is simply the programmer taking the responsibility of marking individual replicated properties as dirty when they change, so the Server doesnt have to do expensive comparisons every frame to check if a property needs to replicate.
bSimulatedProxyTraverseLedge = false;
MARK_PROPERTY_DIRTY_FROM_NAME(APGCharacter, bSimulatedProxyTraverseLedge, this);
For example
bSimulatedProxyTraverseLedge is a replicated property that uses Push Model
Ive changed its value to false on the Server
And thus it needs replication to Clients now that its changed
Oh, okay, I see. When changing bSimulatedProxyTraverseLedge, you'd do the check just-in-time and mark it as such.
So we call MARK_PROPERTY_DIRTY_FROM_NAME to tell the networking layer that this property needs to be sent to Clients
Instead of the Server checking its value every frame against its previous state the last frame
Which takes CPU time
Especially when you consider how many potentially thousands of properties might be marked as replicated
The Server has to do these compares on each Actor for each of its replicated properties
Taking that responsibility as a programmer, reduces the CPU overhead for the Server having to do it.
Ah, gotcha.
Which is a big win.
This model seems fairly new as a built-in functionality in the Engine, right? 5.3.
net.IsPushModelEnabled=1 I believe this is totally backwards compatible?
In the sense of it won't break anything that exists already
No it wont break anything
As its opt in per property
But it should be enabled by default
The Engine uses it everywhere
DOREPLIFETIME_WITH_PARAMS_FAST
Okay, brilliant! #TIL.
Matt, thank you once again - you always put me on the juicy tracks, hehe.
👍
One last question I believe - what's at stake by enabling it?
As far as I can tell not much. It warns about it not working correctly if the Client and Server have different sets of GameplayTags
Which, I dont understand how that would be possible.
Unless some native tags are only made available with #if
🤷
anyone please ? ☝️
Does the Host choose these prior to starting the level they get used in?
Meaning you need to be able to know those choices across level transitions?
yes, he does the choice in the lobby
If you cant provide constructive responses, dont respond at all please. Read our #rules thanks.
sorry sir, I was trying to be funny
I apologize
Then the Host might store that in their GameInstance, when they transition levels the GameMode can then read that.
Alright and I have another issue which is when selecting some roles to be off, and I close that game settings menu by pressing G, and then pressing G again to open it everything comes back to default (the roles section), why is that ?
Probably because you arent reading the current choices and reflecting that in the UI?
Your UI isnt just going to magically know what choices were made previously.
Widgets that get closed are destroyed.
When you open it again, its a brand new Widget.
So it has no idea about the previous state.
You have to tell it what state it should be in.
my widget isn't destroyed, I just play with the visibility so that's why I'm confused 🤔 Does visibility refresh things to their default state ?
No it doesnt.
Then why does it refresh back to the default state ? 🤔
I dont know. I have no idea how you have setup your Widget...
Probably best to ask in #umg
As this is outside the topic in this channel now.
alright
I think I need a sanity check
A client can't call any RPC's that are inside of an actor component on a server owned actor right?
I'm transfering items between a chest that the server owns and the players inventory, and the client can call an rpc to dragdrop items from the chest, but can't use that same rpc to dragdrop items to the chest
client calls an RPC in the unowned actors inventory component*
even though as far as I thought it shouldn't be able to
As is tradition I've figured out the issue less than 15 mins after posting lmao I'm calling the event from the inventory component in general but completely forgot that doing it one way calls the function in the server actors component and dragdropping the other way around calls the event on the players own inventory component
For some reason my server is randomly crashing without giving log, where is actually happened. This occurs when there are 2 or more players, and doesn't occur in the packaged game. Might the lack of resources be the problem? E.g. running out of memory
Attach a debugger?
[2024.03.14-03.33.21:170][372]LogEngine: All Windows Closed
[2024.03.14-03.33.21:170][372]LogWindows: FPlatformMisc::RequestExit(0, UGameEngine::Tick.ViewportClosed)
[2024.03.14-03.33.21:170][372]LogWindows: FPlatformMisc::RequestExitWithStatus(0, 0, UGameEngine::Tick.ViewportClosed)
pretty much says here
How can I do to attach it immediately? When it happens, it happens almost instantiously
pass -WaitForAttach
Well, I didn't close the viewport
How can I do it in editor?
what?
Is this happening in Editor?
oh standalone editor
Oh, I though I mentioned it, but it turns out I forgot. It happens only in editor
Not happening in packaged game
Are you hitting a Blueprint Loop Iteration limit or something?
🤷
You can invoke a Client RPC from a server owned actor as long as the rpc happens on a client owned actor right ?
NPC(Server Owned) -> ACharacter(Client Owned)
Npc invokes on char
You can call a UFUNCTION(Client) RPC from any Actor on the Server, because the Server always has Authority over that Actor.
Perfect, thats what i thought
Clients that call a UFUNCTION(Server) RPC must ensure that Actor has a NetOwningConnection.
Thanks !
but without that actor having an owning client, it will only be the server that runs the RPC
The target of the RPC itself needs to have an owning client.
right, ok, thats what i understood from Matt aswell
makes sense
trying to clean up some of this logic as it got a bit out of hand during 'protoing'
Is it safe to assume that if an OnRep Playercontroller is valid, it's gonna be my playercontroller? (except for host?)
Would it even trigger for those it won't replicate to 🤔
I'd say so. I can't think of any reason a client would receive a PlayerController OnRep for other player controllers.
yey! It worked 🎉
feels like it was a wast improvement from earlier
Can somebody help me? When the host presses the startmatch button, the match gets started correctly, but the loadingscreen doesnt show up
Hi guys. My AI is only chasing the listen server how can it chase all clients too
Or nearest player
I used ai move to on begin play very basic
You've got a few problems here.
Game mode only ever exists on the server, so you can't run RPCs on it and expect it to do anything on clients.
Your "LoadScreenOnAllPlayers" is marked as "Run On Server" so it wouldn't be received by clients even if you were trying to have them do it.
The moment that "Server Travel" is called, it can start trying to move everyone over, giving no time for them to display a loading screen.
Unfortunately, you won't find a good way to do a loading screen in multiplayer in blueprints.
This isn't really #multiplayer related as AIs would be executing entirely on the server. You may have better luck in the #gameplay-ai channel.
Is there some way to display a normal widget on all players?
Not reliably in blueprints. Like.... You could run a multicast on something like gamestate which could display the widget for everyone, and following that multicast call, delay the Server Travel command a few seconds. Your clients would still experience a "hitch" when they are moving over to the new level, and the widget would be removed when they've loaded into the new map.
Thanks!
The trouble with doing it this way is that you don't know if clients received the multicast by the time the server travel takes place, so some clients may not necessarily have the widget being displayed when they've received the instructions to move over to the new map.
Oh sorry
I have to execute on multiplayer so i thought it's multiplayer
I found a thing that works!
Hey there, has anybody got an idea on how I can make large lobbies, without when the hosts disconnects the lobby stopping?
Surely you've tested and confirmed this in a shipping build , with server and client on different computers to verify the reliableness of it
Not yet, I will though
To soon to claim its reliable then^^
Things change , especially if you add in some ping etc
I didn't know the wording, sorry haha
true
I wouldn't bother... you will have to write the implementation your self
Oh god...
Does possessing/unpossessing a pawn changes any dormancy or relevancy settings?
I'm making a game that will require that different players stream in different levels/data layers independently from one another. From my research, this is hard coded to be impossible, but was hoping that someone here might know a workaround or different method to achieve the end result?
Multiple dedicated servers
It's a topdown casual game, with a listen server architecture. I want to make a level with multiple floors but unsure how to isolate different floors when players traverse
That would be total overkill for this game
So then, what comes to my mind:
- Render everything on one server, but make custom relevancy, based on the level, and replicate actors for level
Aonly to players on levelA - Trust one ore more players and make them a listen server. This has a downside of being dependent of that one player internet. E.g.
Warframe(I fcking love that game, btw) does something similar. Each mission has a host as a player - There is a plugin for multiple levels on the one server, but it requires custom coding, as these other levels e.g. can't replicate. Give me sec, I will find a link
For the plugin to work on multiplayer, you have to replicate everything trough main level anyway
If anyone's available, I'd really appreciate if I could have some help troubleshooting an extremely weird bug.
I've recently gotten a game of mine onto Steam meaning I've switched to Steams networking, as a result I'm using the "Advanced Sessions" plugin, however there is some weird behaviour that I cannot find anything about online.
When joining a session, it will register the connection, however it will not open the level or create a player controller, both the client and server have a slight "hitch" due to them connecting, and further so upon the host closing the server the client (Which is still on the menu) gets booted back to the default level due to losing connection.
This is my code for hosting
and this is my code for joining
I don't use advanced sessions (but I do have steam integrated). i found that, inside the handling of OnJoinSessionComplete(SessionName), I had to call GetGameInstance()->ClientTravelToSession(SessionName) on the client to actually connect
i.e joining a session and actually travelling to the server are two different things, unless I am horribly mistaken
I'll give it a try
It's possible, I'm used to Unreal Engine 4 and used to use the older sessions, in those versions join session was meant to automatically open the level
and I had no problems in those versions, with normal sessions or advanced
post back with results
Will do, thanks
One final thing
I am using blueprints and cannot find this exact node, would "servertravel" work?
no clue lol
Alright
Final thing I'd like to mention since it would be stupid to not mention
I am using "PlayFab" as well, and have not directly setup authentication when connecting to a session, I'm unsure if that is needed since the documentation for it is atrocious
Hello, does anyone know what are good approaches to handle things like rigid bodies in multiplayer?
I have mana tokens enemies drop, and there can be up to 80 of them on the scene at once. They are vacuum-attracted by nearby players. When an enemy dies, the mana token flies upwards in a direction within a cone, and is affected by the gravity to slow down, and fall to the ground, bounce a few times depending on the hit normal/ground, and then remain in rest.
I thought about leaving the simulation local, so that each machine simulates them on their own (the environment the mana tokens can be influenced by doesn't change, except players, but they collect mana anytime they collide with the token) using the same inputs - spawn transform and initial force. However, it didn't work out. I think the issue is that any ping will make clients simulation behind by difference in time between server and client spawn time.
physics replication is a whole other level
without fixed timestep, etc its near impossible
network prediction could help
but again physics replication is a headache
we ended up faking it with projectile movement
just shoot it up and let it have some bounciness
Wouldn't it be simpler without physics being a little randomized? It it would be totally deterministic, it shouldn't be that big of the problem, if you just replicate it in correct order. Or am I missing something here?
Hello, I turned off all the replication stuff on my character, yet the server and client characters still spawn in eachothers worlds. How do I stop that from happening?
is TMap replication supported?
Nope
what do you guys do when you want to?
There are different ways of doing that, but usually you replicate what you want using supported containers, such as TArray with a struct containg the key and the value you use in your TMap. There's a seamless example of how you can replicate TMap
https://www.youtube.com/watch?v=4US1mHsGcs4
TMaps and TSets cannot be replicated uproperties in unreal.
However, they have some convenient methods to convert to an array, which we can use for replication.
That being said, this needs to be used carefully. As frequently converting your set or map data structures to an array could be a performance issue.
An alternative, is if the logic neede...
Redundant copies of the same data 
Yeah, that is true, however, the approach is seamless. You could use TArray directly, but sometimes it's very annoying to use it as it doesn't support the same features
You'd be better off just writing a struct that wraps the TArray and providing helper funcs for it
There's rarely a case where the replicated Map/Set is so large that it warrants duplicating the data for o(1) lookup time
See also FFastArraySerializer
Derive that, add your own Find() and Contains() functions - ez
is there a length limit to a replicated string?
Is this correct ?
There will be, but IDK what it is off the top of my head
Essentially yeah
I mean, the Client can actually do whatever they want, but that's how it should be done generally
Because I thought the server runs the game once and do the stuff on it directly instead of having the server instance behind the scene and generating a client instance for the host to play on
Hello
is the HUD class only on client ? or is there a server version to
Only on clients
okay ty
Yeah, that counts in clients hah
Are you specifically asking about a Listen Server? In which case yeah, there is one game instance. That post without any context doesn't say anything specific.
(the 2 last errors can be ignored here)
it is server side
Also, widgets won't be valid on a dedicated server of course
It's not spawning before joining, just the log message is written after all that join work is done
So you can ignore that
nope
look again first message second screenshot
I can see that. It means nothing, the log message is written when it's written
The player joins, the gamemode does a bunch of stuff, then the log message is written to say " they joined"
so it could be after/before the login ? regardless the ouput log message order ?
okay so its only printing joined at the end
yep
okay im dumb, i recently changed the net mode to test in real conditions my code
i am using "get player controller 0"
so ofc it wont find anything
get player controller 0 will just get whatever the first PC is, whether that's the local user or the first client
now i guess i have to do a call back to spawn UI when player joined ?
The clients local AHUD class can manage all UI
Yeah my question is about a listen server (so when a player is hosting the game). But wait, you said yes but at the same time you say that there's only 1 game instance, I'm confused 🤔 Isn't the host running the game instance twice, one for the server and one as a client for the player to play on ?
Don't need to network anything for that
all "main" stuff is there, but not the inventory
No, a Listen Server is ONE game instance. The host is the player, there is no network "client"
well the return value is not null, so idk why "create widget" is returning null
Servers shouldn't manage client UI, if that's the question. Clients should work that all out themselves
Widgets can't be replicated
And usually they are stripped out on dedicated server builds anyway
so that means the screenshoted message I sent above is wrong ? #multiplayer message
does this mean the widget is null ?
Presuambly yeah
any reasons why ?
A dedicated server won't create widgets, for obvious reasons
It's a UI element, the clients should create and manage their UI locally
well this is suppose to happen
If that's running on the Server, then you're trying to create a widget for the player, then add it to the servers viewport - which obviously doesn't exist
on begin play of the character, it create and show the inventory UI
Well BeginPlay will run on the Server and the Client
You should use IsLocallyControlled if you have to use anything
okay
But again realistically, the HUD class should be creating and managing all widgets
There's no garauntee IsLocallyControlled() will return the right value on BeginPlay
usually it will, but not always
okay, i guess ill change that
ty for helping that much
im new at networking in ue, but its fascinating
sometimes i wonder what should be run on server and what should run on client
for example, i got multiple rooms in my map, each room is covered by an actor ("location volume"), when the player enter/exit this volume stuff happens (only locally, (updating widget text, chaging values in player state))
should this be running on owning client ?
Or a Has Auth check on the location volume and if they're "Remote", run the logic on the actor reference that enters/exits
okay ty
when starting sprinting, the max walk speed of the player character is changed in a actor component
i did some testing, and whatever i did, i only changed the max walk speed on the client OR on the server, never both (so the character is a bit laggy because it keep chanign between both speed)
this is the event called on input started
I'm trying to actually implement replication for the first time I have a question about a detail of how it's done.
I have an actor component. This component is replicated, and it's UPROPERTYs are replicated. One of those properties, though, is a TArray of a custom class. Do I also have to explicitly replicate that class, or does the replication of the array holding it cover me?
depends what this "custom class" is
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "DcsInventoryEntry.generated.h"
class UDcsItemDataAsset;
/**
* @brief Represents an item in an inventory. For internal use only.
*/
UCLASS(Blueprintable)
class DCSINVENTORY_API UDcsInventoryEntry : public UObject
{
GENERATED_BODY()
public:
UDcsInventoryEntry();
void SetItemData(UDcsItemDataAsset* NewItemData);
UFUNCTION(BlueprintCallable)
UDcsItemDataAsset* GetItemData() const { return ItemData; };
void SetQuantity(int NewQuantity);
void SetItemId(FGuid NewItemId);
UFUNCTION(BlueprintCallable)
int GetQuantity() const { return Quantity; };
UFUNCTION(BlueprintCallable)
FGuid GetItemId() const { return ItemId; }
protected:
UPROPERTY()
FGuid ItemId;
UPROPERTY()
UDcsItemDataAsset* ItemData;
UPROPERTY()
int Quantity;
};```
That's it's header file
Hmm. It's a UObject, and those don't replicate by default, right? So I should update this class to provide GetLifetimeReplicateProps, IsSupportedFoorNetworking, an Replicate Subobjects, right?
If it's a subobject then you'll want to replicate it as one, yes
you mean currently there is no limit?
when SetToWalk On Client is called after SetToWalk On Server (called elsewhere), it will create a infinite loop
is there a way to have this work, without duplicating my nodes ?
okay the issue was because i was calling SetToWalk On Server on server & client
doing this on srver would create the infinite loop
also, whats the point of "replicate component" ?
? the issue here is you call "set to walk on client" on the client
wdym
uh authority switch. but in non-MP that'll be an infinite loop (standalone & listen server net modes)
i am using play as client
It seems that my controller has no input after seamless travel, even Debug Key nodes don't work, should I be re-enabling it somewhere? 🤔
on input events, i call set to walk server / set to spritn server
Might want to make sure you have the inputMode set to Game properly
wdym by predicting inputs ?
running it on the client and then telling the server
Right, I'll make sure that's the case, ty!
rather than waiting for the server to process the input
@lament flax If we ignore the fact that you will never get this correction free with CharacterMovementComponent in BP, then all you need to do is replace the SwitchHasAuthority - Authority -> ClientRPC with SwithHasAuthority - Remote -> Branch(IsLocallyControlled) -> ServerRPC
well thats already the case ?
the input are called only in client
you said the input action called the server event
And in theory that ClientRPC that sits on the left is wrong
so that sends an RPC to the server which modifies the movement speed, then it sends an RPC back to the client to tell them to do the same
the pins are fired only on client here
yes, so there's always going to be at least an RTT delay on those inputs
could you explain the goal of this change ? the current code is working
So okay, let's step back from the image for a second
and then the client
Yeah, THEN, the Client
That takes time, cause PING
But again, let's start further back:
sooo, you can bypass ping ?
im kinda lost, i'll be happy to understand what you guys are trying to tell me
You can avoid atleast some of it
Input is Local Only. So only calling on the Client.
The proper way, again if we ignore that BPs can't make that proper anyway, is to FIRST set the Speed Locally, so the local Client gets the change instantly.
After that, you want to call a ServerRPC to set the Speed on the Server.
Speed here needs to be an OnRep/RepNotify variable and in the OnRep function you want to set the MaxWalkSpeed variable of the CMC (CharacterMovementComponent).
The only thing you want to then still do is not set the MaxWalkSpeed on the LOCAL client in the OnRep (so filter it with isLocallyController -> not -> branch -> set MaxWalkSpeed), because otherwise you might get problems if you spam the keys.
I can't type ffs :D too much work today already
in case this matters, later on i will add stamina, so i though about doing the check on server (does the player has enough stamina ?) then run it on client if the player has enough
does this change anything ?
Its been a long day for all of us lol
No, you can locally check the Stamina as well as on the Server
But I can tell you that in Blueprints, you will get corrections, because you are completely bypassing the Prediction System that lives internally in the CharacterMovementComponent.
Sprinting, with or without Stamina ,can only be done without corrections in C++
what are "corrections" ?
If you don't care about that, then yeah, just add a "CanSprint" function in front of the SetWalkSpeed on the Client and on the Server
How big is the prediction window in the cmc?
i would like to care, but i would like to stay BP only
let me try this
UE is Server Authoritative. So the Server is the one that ultimately will be "correct".
Every Move/Step a Character performs first runs locally, and then on the Server (Client triggers it on the Server). If the Client tells the Server "Hey I did this and ended up here." and the Server performs the Step but ends up somewhere else (sqrt(3) error), the Server will correct the Client.
That's a Correction
Sprinting needs to be communicated through the internal ServerRPC of the CharacterMoevmentComponent
So that the server starts sprinting in the same logical frame as the Client
Otherwise they end up in different places
You will always get a correction when starting or ending sprint
During a sprint it's fine
The higher your ping, the worse this will look
You are probably testing in the editor without any simulated ping atm
Now the Stamina just overcomplicates this, because that would also need to be in sync, but if the Client locally modifies the value it might be out of sync
That will mainly start showing when stamina gets close to being empty
then if the bp has corrections, whats the difference with cpp ?
In C++ you can inherit from the CharacterMovementComponent (CMC) and properly tie Sprinting and Stamina into the flow of the CMC
This is unavailable to BPs
The ServerRPC is only one puzzle piece fwiw
so, without cpp, what would be the best option ?
this ?
There are also so called SavedMoves, which the Client keeps locally. Whenever a Correction comes in, it's from a Move the Client performed some time ago. To not just get teleported back to that earlier place, the Client discards all moves that are older than the correction and replays the ones that they are still waiting to be acknowledged.
In C++ you can add information to those SavedMoves, which is often needed if one adds Multiplayer Movement Functionality.
damn, there is a lot of back end
Yes
You gotta live with the Corrections in BPs
Multiplayer needs C++ in every corner
If you stick with BPs you gotta live with the worse "world" of the two
oh, i didnt thought it was that needy
Take it from me who works with this Engine since, idk, 2014 (holy shit it's 10 years).
im not bad at cpp, but i'll to spend time in BPs
could i maybe expose stuff to BP from cpp ?
Some of it, but not all. The CMC uses types that can't be exposed to BPs.
E.g. you need to Inherit structs and override functions on it
so its kinda impossible to make a game that wont have all clients out of sync at some point with BP only ?
BPs has no Struct inheritance or even functions on Structs
They wouldn't be out of sync "forever". Just whenever something is done outside the CMC C++ that affects movement, it would probably cause some corrections before getting back in sync
The higher the ping, the more violent they will be in form of teleporting the player around a bit
well ig i will have to find at what point "this specific ping and higher" make the game horrible
if its 100, then idc, but if its 20/60...
If you ever want to get into CMC and C++ stuff, we have some examples pinned to this channel
It's a GitHub repo with some examples
With a bit of luck you can even try to plug together the Stamina and Sprint example and just "go with it" instead of understanding it
As long as your Movement doesn't get more complicated than that
mouvements wont be crazy
You can already try how bad it is with your sprinting
how can i simulate ping ?
Assuming you set it up the way I explained
It's in the Advanced Play Settings
next to the play buttons the 3 dots, bottom most entry
In that new window with a lot of settings it's a bit further down
Network Emulation or so
You have to enable ti with the check box
Don't set PackageDrop to anything but 0 if you want to test ping
PackageDrop/Loss is something that will make everything look worse than it is, and should only really be tested to see if your network code makes a player fully lock up
okay
(at least in its wider sense, there are reasons to test package loss, but they are advanced)
i should make lag the client right ? and not the server
if both lag, it will be 2 time worse no ?
And then spam the sprint button
I think so yeah, I never put much thought into this. I usually just print the Ping somewhere xD
ill do your setup, test it, then try some bad ping configs
Could just applying a multiplier to the value input of the player work for sprinting in mp?
and hope that later on i wont find a thing only "good to do" in c++
Something like this
Guess i've tested it before, but its been a while
InputKey -> SetMaxWalkSpeed = SprintSpeed -> ServerRPC
ServerRPC -> SetCustomSpeed = SprintSpeed
OnRep_CustomSpeed -> If Not IsLocallyControlled -> SetMaxWalkSpeed = CustomSpeed
@lament flax Maybe that's easier to read
Yes but then you allow cheating
ive looked a lot of definitions and examples, but sometimes i still dont get it
How?
"server rpc" mean that you execute from server on owning client ?
Client -> Server
oh
If those are troubling you, read the Compendium please. If you have already, read again :D
i will read it again xD
Got it i guess
If you have a ListenServer coop party game or so
Then sure, that's a work around fwiw
very small, but i think you misspelled this :)
I have a 1 sec timer wrapped around (i guess that's the word) a HasAuthority check, so the player stops sprinting if stamina goes below something
and ty for the docs, its well written
So that runs on the server, also does the boolean changing from bIsSprinting and stuff like that
so i did this
6 times !
Thats the recommended amount these days
your idea is :
- change speed for client to what we want (
sprintspeed) - in server set a
custom speedto what we want (sprintspeed) - when onrep notify is called on server (not is locally controlled) -> edit the speed to what we want (
sprintspeed)
i kinda dont see why using on rep notify
is it to prevent data loss ?
To ensure replication to all clients
Even if you were out of range when you started sprintingn
They will still get the update as soon as you become relevant
trying to send a variable from client to server but it just appears as empty on the server not sure why
What is "ItemObject"
Because if that is a UObject Child BP, then this is expected
oh yeahhhhh
this makes sense
The first method doesn't need to be a ClientRPC. You are on the Client with the Input.
Yes
You only need RPCs if you go from Server to Client, Client to Server or Server to Everyone
+- some rules
The OnRep is mostly cause you are changing state
Speed is a State, it persist after altering it
RPCs are for some one time changes/calls
If someone is out of range or joins late, they don't get the RPC
Where were you when Unreal was freed?
The OnRep however calls again
I was somewhat happy but also somewhat sad
Cause I had a shit ton of Free Months to gift
I don't remember what I did with my refund / credit.
what is weird is that the component isnt replicated
so i dont see what a replicated component mean
yeah it's a child of a c++ class that is a uobject, why is this expected and how can i pass this through to the server
UObjects don't replicate by default
You need to replicate them via an Actor's Subobject List
Which I haven't done lately, so you gotta search for some info on that or check if there is a pinned mesage with help
UObjects on their own can't replicate
Which Component
well i guess its because i am not testing the movement at the same time
without enabling replicating, all players with the sprint component will spint/walk
the sprinting events and speeds are in a component
If you ahve an extra component that has RPCs and Replicated Varibles in it
Then that needs to be set to replicate
Alongside the actor itself
all this is in a ACBP
in editor, with the net mode to clients, how can i tell UE to use <this connected keyboard> to client x, and <this other connected keyboard> to client y ?
Multiple keyboards, not without a lot of trouble would be my guess
just alt tab between windows or use a controller + kb
the thing is i would like to do stuff at the same time
like moving around
so switching windows isnt really what i would like
Either hack it to work with multiple keyboards if that's even possible, use a gamepad, alt tab, or use a separate computer
you can maybe do some windows stuff to route the keyboards separately but I'm not sure
ill try with kb + gamepad
now i need to see how to set the kb to pie 1 and gamepad to pie 2
PIE settings, should be default though I think
i tried and the kb and gamepad just works for the focused pie window
is there a size limit for replicated variables? specifically string length limit?
So when I use the editor network emulation thing the average ping is worse than the min/max ping that I set? Like when I set the average ping to 100 min and max actions can take well over 1000ms for the client
Is that normal or am I doing something wrong there in the settings
It shouldn't be 10 times, no
I changed the "Emulation Target" setting from everyone to client and now the ping is what I'd expect. I didn't realize it emulated latency for the server too but it makes sense if the server is a host
Tried looking up replicating uobjects but i'm confused on it, anyone know a good video tutorial of how to do this?
Trying to figure out a behaviour that I was not expecting in my GAS multiplayer project.
I have a Gameplay Ability that starts a niagara effect on an actor I access from interfaces. The ability launches correctly but the rest of the logic only happens on the Server and the Owning client and I can't understand why other clients don't even print anything.
I tried even adding RPCs from server and multicast in the logic but it's not changing the result.
I'm not sure why this is happening
Edit: I am actually an idiot, the actor was not replicating
When my player starts overlapping a box, i am getting its controller as you can see on screen.
when first entering the box, the event is called twice on client.
the issue is that for some reason "Player State" is null on the second time
how many clients total?
The overlap is happening on both, the pawn is remote on both, the player controller will only be valid on one
how can it happen on bother players characters ?
both players MACHINES
oh
on my machine, my guy entered the box
on your machine, my guy also entered the box
on both machines, the guy is remote
i see
on my machine, the playercontroller is valid. On your machine, it isn't
so i need to check for is locallycontrolled ?
If that's what you care about yeah
Is there an overhead of calling RPC in an already obvious content. For example, calling a function "Server_MyFunction" in a server owned actor from a known server context?
Yes but whether or not it matters, depends™️
How many times per second are you calling it?
how does OnRep Notify work with event dispatchers ?
What do you mean?
OnReps and Event Dispatchers are very very different things with no relationship to each other
The dispatcher is local, it'll work as normal. You can call it from a RepNotify function.
before anwsering your question ill ask a more simplier to be sure i understood correctly.
when setting a var on rep notify, do you usually have to put something in the function ? (like setting the variable)
i firstly asked because you can set the replication mode of event dispatchers
It is not a specific function per say, mainly events but just been thinking of it is worth to emphasize the context in some areas. Especially when calls travel through multiple blueprints.
The repnotify is a function that runs when the variable changes (in BP) or is replicated to client (in C++)
Are EDs able to be stored as properties in UE5 now?
I would argue that EDs are not replicated.
I don't really understand what it might mean for an event dispatcher to BE replicated.
maybe because its on client
Whatever is most ergonomic for the design and with the least exceptions to the rules is what I'd go with.
Id say it means nothing
thats why i was asking the use cases
since i saw the options
Probably none and it probably doesn't work.
well changing to any replication other than none seems to do nothing, the ED isnt fired/received
It's probably a bug or oversight that you can even set the replication condition to anything other than None
I like setting up code to just work no matter if it's standalone, listen, dedicated, or client
Very true! I was mainly curious to know 🙂
Hate to be like this, however if anyone currently active in chat has any ideas as to the problem here, please let me know.
sometimes it looks like the ED isnt called on all clients
the binding of the ED is on begin play of the game state, on server and each existing clients
and when i try to play mutliple games, sometimes (and rondomly) one client isnt updating ( == ED not called)
just did another test and sometimes no clients fires the ED
hi all, whats the proper way to manually set character rotation over a network? I'm lerping a rotation for something and on host its smooth but not on client
im assuming its bcause im using SetActorRotation() on tick, wheras CMC probably requires something else
show your code
Any particular reason it's not driven through the CMC stuff? What SHOULD be driving the rotation of the character?
good question, I was just looking at a target so I decided to do it through controller focus, and use the rotate to controller function on pawn, seems smoother
It seems that client pointers to UObjects are broken when that UObject changes from one RegisteredSubobject list to another. Even if both owning actors are relevant to the client, such that the object is immediately available, the pointer seems to die. Is that expected? 
Forgot to mention that I'm also changing the outer from the one actor to the other 
How can I prevent this in multiplayer in editor, if I'm suing pawns instead of characters? Updated component is a mesh component
Hi everyone, I will like to ask if there is a limitation on replicated variable size? I have a vector array that set to replicate when ever array size more than 200, the system freeze for late joiner
Yup, there is one
thanks for the confirmation. any work around if let say I want to send huge data? I am thinking if let's say there is no other way, I might store the data somewhere in server (a empty bp with all the needed variables), RepNotify a boolean to ask the server to send the data through Multicast? or RPCs (Multicast) also have limitation on the size?
Sec, searching for one article
I think it was this one:
https://vorixo.github.io/devtricks/data-stream/
You might be also willing to look info fast array replication
thanks a lot, this is a big help
Do we agree that "HUD" class is generated for each player / each player receives one when they join the game ?
Yes
APlayerController::ClientSetHUD
This is called by the GameMode
During AGameModeBase::GenericPlayerInitialization
I think the issue isnt really THE event dispatcher but a overall server/client execution issue.
In the game state i start a timer by event to count time.
This is executed on the server and clients.
My new idea would be to have the server update the time variables, and have the server and clients to fire EDs if conditions are meet
But idk if i should do this since the looping timer is very frequent (less than a sec)
How can I use 2 player starts, and if I spawn 2 players, so they spawn in different locations?
If you go down in the details pannel there is a list of players if i remember correctly
I don't see anything like that
There is a function in the game mode called "Choose Player Start" that you can override. You do whatever logic it is that you want to use to determine what playerstart to use and return it or any other actor you want to use as the start location.
Is it possible to make a actor visible to player 1&2 but invisible to player 3&4? I tried using OwnerNoSee, but it is limited to a single ownership. I been stuck on this few days now. Any help is greatly appreciated.
My guess would be to call the event that set the actor visibility on the specific clients
Now the thing is, how to get the 2 specific clients you want
Thanks, I forgot to mention this is for local split screen
Will replicated variables sync up without server explcitly updating the variable, if the client locally modifies them?
And is there some actual distinction between client and server, on a client that's hosting (Listen server)?
(e.g. can you run "Client side logic" , explicitly as any other client, when you're the host?)
Technically, no. A client that modifies a replicated variable locally would retain the value the client set it to until such time as the server replicates the variable.
When you make a change for example. There are replication conditions on variables, and it may not necessarily replicate always.
But would it ever replicate "by itself" because a client changed it locally?
No
When the server makes a change to the variable, it determines whether or not it should push a replication to clients.
if a client changes a value, and the server has no way of knowing it did, then there's no means for the server to know that it should push an update.
the level BP is owned by the server i imagine ?
Not entirely sure what you mean here. When you call a "Run on Owning Client" event as the server, it is checking who the owner is of that actor. If on a listen server on an actor owned by the listen server, then it would execute on the listen server. If it's owned by a client, then it would execute on the client.
Basically I'm wondering if its possible for the host to be in a state where the code doesnt recognize it as the host itself
so it would act as any other client
and not have authority over replicaited variables etc
I tested this on a project (for kicks),
and there's no distinction at all
"Run on client" is still the server, if the client in question is the host
its a long discussion in #umg that brings this up
The host has authority over all actors spawned by the host.
Any actors that are spawned by clients it wouldn't know about.
So yeah, if you run a "Run on Owning Client" event on the server on say, a character, and that character happens to be the character that is possessed by the host's player controller, then yes, it would execute on the server.
Yepp, that's exactly what my testing said aswell
when the owning client is the server, it is still considered server, even if "gated" with a RPC Client (no RPC happens as it is I, the master server)
I wouldn't look at RPCs as "gates". Marking something as "Run On Server" doesn't mean that it'll only execute on the server, it means you're allowing the client to call to the server to execute it. (If they own the actor!)
Same with the opposite - it's a means of allowing to make a request to the client.
Server changed HP both as client and server. Every change counts.
Client changed hp 4 times as server and 7 times as client. Only server changes count
It executes as far as you have authourity to do so, no?
if its not your actor, it's just a local event ?
I'm not 100% on this, but I think if it's a locally spawned actor on a client, and you attempt to run on server, I think it would execute locally. if it's a replicated actor owned by the server or some other client, then no, it would not execute.
Just like widgets
(got no clue why we can even mark those event as replicated but that's another story )
In this case it ran locally, as if no RPC was ever attempted
Widgets aren't actors, and they don't replicate. I think being able to mark events and variables as replicated is just a byproduct of being able to set them up in blueprints. I doubt it's even checked by the engine. If you're looking at an actor, it probably does some checks on the actor before attempting to execute the event to see if it is supposed to send the RPC or not.
Like, if you attempt to run on server event on a replicated actor from a client that doesn't own that actor, you'll get a message about no owning connection - and same with the reverse when trying to run on owning client when there is no owning client (including the server itself)
in those latter cases im not sure the event triggers at all
it does
not even getting an error
or log
Thanks for confirming btw. Exactly how i've understood it to work (except the last part. Would prefer them to block and ignore)
🤔 Strange I totally thought it would ignore. Could've sworn I've even seen that behavior but maybe it was attempting to call a server RPC from a client on an unowned actor.
i got some question regarding var replications and event dispatchers
the other way around is ignored. Client trying to Server RPC on a server owned actor
i'll ask them after you solve your issue squize
Go ahead, I'm not really having an issue^^
thanks
on what is called onrep notify ?
if i call it on server, its server only ? or server + all clients ?
In BP its server and all clients
IF the server sets it
if a client sets it, onRep is not triggered
(the value of the variable change locally)
(i think if a client sets it, it'll actually fire the onrep locallly for that client)
Let me verify..
in my game state i got a timer by event that adds time to make a fake 24h day, im converting it to multiplayer.
the thing is, i got some events disptachers that are linked to local client stuff (HUD)
how should i correctly
- update time (variables)
- fire the ED on server and clients
note : the timer by event executes its event pretty frequently (around 0.1s)
seems like that's not the case
OnRep -> Broadcast ED ?
would trigger both on server and clients
It does
well, if i set the var on server event, its not calling anyth ED on clients