#multiplayer

1 messages · Page 161 of 1

obtuse field
#

Array

fossil spoke
obtuse field
obtuse field
#

Its a bad idea

#

It was, that you can store scores in the array, and call OnRep every time the score changes

drowsy meteor
#

but in that case .... should i store all player state references as slots inUI ?

obtuse field
#

But you can store it inside player state

fossil spoke
#

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

drowsy meteor
#

ooooooooooooooooooooooooooooooooooooooooooooooooooooooooh

#

now i understand i think

fossil spoke
#

@drowsy meteor I think you should read the Network Compendium in the Pinned Messages

#

To understand replication and the PlayerState

drowsy meteor
#

i read the cedric doc

fossil spoke
#

Read it again

#

And then once more.

drowsy meteor
#

i tohught i got everything 🥲 i guess not

#

u got it

#

thank you a lot for the help

hoary spear
#

6 times is the minimum recommended times to go through that compendium

#

Any less and you miss to much

upbeat basin
#
// 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

hoary spear
#

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?

meager spade
#

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?

plush mauve
#

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?

hoary spear
#

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

obtuse field
# plush mauve Still trying to find some/any information on scaling UE multiplayer beyond the u...

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:

https://github.com/jpetanjek/NextGenNetGames

GitHub

An Epic Mega Grants backed Master Thesis about creating the Next Generation (Multiplayer) FPS. - jpetanjek/NextGenNetGames

#

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...

▶ Play video
chrome bay
harsh ice
#

my player list is visible on client but not server

hoary spear
#

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

inner hearth
#

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?

inner hearth
plush mauve
# obtuse field This usually involve seamless transition from one server to another, but this 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.

woeful ferry
#

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

urban moth
woeful ferry
#

and then the array don't replicate that data, even if they're marked dirty afterwards

upbeat basin
upbeat basin
# meager spade secondly, why is this component not on the players character anyway

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

upbeat basin
#

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

hoary spear
#

I personally view that as the project specific implementation

#

Just like an inventory / equipment / skill / quest comp needs some project specific implementation

upbeat basin
#

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

hoary spear
#

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.

urban moth
#

how to implement replication to a group? e.g. TeamState replicated to a team members only?

restive geyser
#

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:

  1. Replicate the necessary variables and handle them through the animation instance and state machine.
  2. Use Gameplay Cue.
  3. Use the PlayMontageAndWait blueprint node and handle them through a blueprint child class.
thin stratus
#

You would usually use a PlayMontage node in the GA that performs the attack, cause that should replicate already.

#

@restive geyser

upbeat basin
# hoary spear What if you wanna re-use it on a tower?

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?

timid birch
#

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

Epic Developer Community Forums

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...

upbeat basin
# timid birch Hey everyone, could someone explain to me why all actor’s OnBeginPlayOverlap is ...

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

hoary spear
#

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)

timid birch
timid birch
meager spade
#

overlaps run on client and server

#

but i have never had a trigger/overlap box detect every player if only one entered it

timid birch
# meager spade but i have never had a trigger/overlap box detect every player if only one enter...

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

Epic Developer Community Forums

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...

hoary spear
#

All proxies representing the same player will also trigger it , on all clients

meager spade
#

^

hoary spear
#

Unless you filter it by locallycontrolled or otherwise

meager spade
#

so if you have 4 clients

timid birch
meager spade
#

it will do Server, Client Client Client

#

for 1 of them

timid birch
#

Yes

meager spade
#

how many clients did you have

timid birch
#

1 being the only player that overlapped

#

1 host, 3 clients. 4 players in total

meager spade
#

yes

#

so you would get 4 calls

#

1 Server, 3 client

#

for 1 overlap

timid birch
#

Precisely

meager spade
#

thats correct

timid birch
meager spade
#

Server, Autonmous Proxy (local client), Simulated Proxy (remote client), Simulated Proxy (Remote Client)

#

for the same player

timid birch
#

Oh sorry. Maybe i misunderstood you. Total events triggered would be 16then. 4 events for each world

meager spade
#

?

#

so you have server, and 3 clients

#

Client A enters overlap

#

You will get 4 calls

timid birch
#

Server Side: 4 overlaps triggered for each player. Client 1: 4 overlaps triggered and so on

meager spade
#

Server for Client A

timid birch
meager spade
#

Client A locally

#

Client B for Client A

#

Client C for Client A

#

no

#

whay you mean Server side 4 overlaps for each player

timid birch
#

Ok if I have something like OtherActor->GetName in the overlap function

#

And i logged it

hoary spear
#

Their local names differ

timid birch
#

It would have 4 logs, printing: player1 actor(server), player2 actor(client1), player3 actor (client3), player4 actor(client4)

meager spade
#

the names wont match

timid birch
#

Even though, say only player1 overlapped it

meager spade
#

you should never rely on GetName for matching

#

then you will get 4 calls

high lotus
#

In a case like this, I try to filter if locally controlled, so the event only happens once

meager spade
#

Server and 3 client

hoary spear
#

Try a replicated variable

#

Set by server

meager spade
#

overlaps are ran locally

#

not replicated

hoary spear
#

I ment to confirm / debug

#

Whats going on

meager spade
#

just print the players player name from playerstate

#

it will be unique for each connected player

hoary spear
#

Or that ^

timid birch
meager spade
#

do it

#

and screenshot and send me

hoary spear
#

^^^

timid birch
meager spade
#

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

timid birch
#

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

meager spade
#

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)

timid birch
#

I see. I’ll check out the PlayerState name. Thank you👍👍

gusty slate
#

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?

chrome bay
#

Probably a struct with a custom NetSerialize if it's just a bool

gusty slate
#

Interesting, I'll have a look

#

Thank you 🙂

marsh nacelle
#

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^^^

lost inlet
marsh nacelle
#

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?

meager spade
#

normally this is done with some kinda REST api

marsh nacelle
#

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

lost inlet
#

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

marsh nacelle
#

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?

lost inlet
# marsh nacelle I appreciate the insight. It seems mysql is not a good fit for what im trying to...

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

marsh nacelle
#

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

thin stratus
#

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.

ember jasper
#

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

marsh nacelle
thin stratus
marsh nacelle
#

that sounds like a good idea thanks

thin stratus
#

... 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

rain condor
#

I need to get data from game mode to client. How can i do that?

thin stratus
#

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

native tapir
#

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 ...

rain condor
#

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

olive anchor
#

Is it possible to replicate an array of objects?

olive anchor
#

Is this possible to use in Blueprint?

graceful flame
#

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.

olive anchor
#

I'm new to Unreal, so I may be confused, but I don't believe I'm using a struct?

graceful flame
#

what do you mean by array of objects then?

olive anchor
graceful flame
#

in most programming languages object is a struct

#

oh you mean a UObject?

olive anchor
#

I guess? "Inventory Item" is a blueprint class, and a child of "Object"

graceful flame
#

You can replicate them yea

#

as far as i know its just a reference so you're replicating the array of references

olive anchor
#

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

graceful flame
#

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?

olive anchor
#

This is inside of a GameState blueprint

#

Though I'm also trying to do something similar inside of my PlayerState blueprints

graceful flame
#

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

olive anchor
#

Yeah, the Inventory in the GameState is just gonna be where I store items that are on the ground

olive anchor
#

Then when a player picks an item up I'm gonna transfer it into the inventory of a PlayerState

graceful flame
# rain condor Any help with this?

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.

rain condor
#

I have to pass all gamemode funciona to gamestate?

graceful flame
#

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.

rain condor
#

Shure, I'll move all to my gamestate

oak lake
#

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

rain condor
#

And how can i acces to game state from actorcomp? using get game state and then cast it?

solar stirrup
#

virtual void GetLifetimeReplicatedProperties(TArray<FLifetimeProperty>& OutLifetimeProps) const override;

rain condor
#

I use bp 😱

hoary spear
#

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

solar stirrup
#

first argument is a class not an object

hoary spear
#

Correct

solar stirrup
#

Just correcting since you're explaining it to someone :p that's what people do on this server

warped oxide
#

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

solar stirrup
#

I wouldn't use ownership for this

#

I'd have a separate replicated property to determine who the NPC is talking to right now

hoary spear
#

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...

quartz star
#

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

ripe lotus
#

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.

olive anchor
#

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?

hoary spear
#

Whats the difference between use and consume?

#

why can't use be consumed on use?

#
  • Uobject
  • InventoryItem
    • Usable
      • Equipable
        • Weapon
#

but should be possible to replicate them yes

#

they're just Uobjects, afterall

olive anchor
#

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

hoary spear
#

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

olive anchor
#

When I try to replicate an Array of InventoryItem (or a subclass) instances, the InventoryItems are empty

hoary spear
#

did you set up replication in InventoryItem?

olive anchor
hoary spear
#

they dont replicate by default

olive anchor
#

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

vagrant grail
#

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

thin stratus
#

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

unkempt tiger
#

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?

fossil spoke
#

Seamless Travel means no one is disconnected during a travel.

unkempt tiger
#

as in, clients are in the new map, and all actors are init etc

#

Yeah sorry, I meant 'properly initialized' when i said connected

fossil spoke
#

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.

unkempt tiger
#

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

fossil spoke
#

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.

hoary spear
#

Didnt someone attempt to adress the transform updates and made huge savings on it 🤔 Sounds like a worthy engine edit if so

fossil spoke
#

It changes nothing about how you deal with Replication and/or RPCs etc

#

Its changes are abstracted away from you for the most part.

fossil spoke
#

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.

hoary spear
fossil spoke
#

Silly you

unkempt tiger
#

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

fossil spoke
#

It kinda is though lol

fossil spoke
unkempt tiger
#

doesnt the engine already do this?

fossil spoke
#

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

unkempt tiger
#

I'm wondering how much faster it is, or what else the engine does that slows down normal paths

thin stratus
#

No clue

unkempt tiger
fossil spoke
#

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

unkempt tiger
#

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

fossil spoke
#

Enabling Seamless Travel doesnt magically make things faster.

#

But do read up on it.

unkempt tiger
#

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 💀

fossil spoke
#

You do have the option to cause any Actor you like to persist however.

#

Thats an advanced workflow

unkempt tiger
#

i'm actually down for killing as many actors as possible during the travel

fossil spoke
#

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

unkempt tiger
#

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

fossil spoke
#

Take a look at AGameModeBase::HandleSeamlessTravelPlayer for further info.

#

And consequentially APlayerController::SeamlessTravelFrom

gloomy tiger
#

Any insights on what's lighter to send over the network, TSubclassOf<Something> or FGameplayTag?

fossil spoke
fossil spoke
gloomy tiger
fossil spoke
#

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.

gloomy tiger
#

I am resolving a jigsaw right here. The jigsaw of shooting at 0.07 Fire Rate.

#

Hmmm

gloomy tiger
fossil spoke
gloomy tiger
#

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.

fossil spoke
#

Yes

gloomy tiger
#

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.

fossil spoke
#

Im not advocating for ignoring bandwidth considerations

#

Only that you will see more improvements optimizing for CPU instead.

gloomy tiger
#

I really appreciate you signalising that. It actually validates the work we've been doing here.

fossil spoke
#

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

gloomy tiger
#

The more I work with network, the more I realise performance is all about creativity than anything else lol

fossil spoke
#

There is no one size fits all approach.

gloomy tiger
#

Hence, ✨ creativity ✨

fossil spoke
#

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.

gloomy tiger
#

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

fossil spoke
#

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

fossil spoke
#

Push Model is also something you should employ where you can

#

It is a big CPU optimization.

gloomy tiger
#

We talking the way ECS would handle networking, aren't we?

fossil spoke
#

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

gloomy tiger
#

Oh, okay, I see. When changing bSimulatedProxyTraverseLedge, you'd do the check just-in-time and mark it as such.

fossil spoke
#

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.

gloomy tiger
#

Ah, gotcha.

fossil spoke
#

Which is a big win.

gloomy tiger
#

This model seems fairly new as a built-in functionality in the Engine, right? 5.3.

fossil spoke
#

No

#

Its been around for a long time

gloomy tiger
#

Oh, really?

#

Geez.

fossil spoke
#

Yep

#

4.23 maybe? Or 4.22

#

🤷

gloomy tiger
#

net.IsPushModelEnabled=1 I believe this is totally backwards compatible?

#

In the sense of it won't break anything that exists already

fossil spoke
#

No it wont break anything

#

As its opt in per property

#

But it should be enabled by default

#

The Engine uses it everywhere

gloomy tiger
#

DOREPLIFETIME_WITH_PARAMS_FAST

fossil spoke
#

Just take a look at AActor

#

And its GetLifetimeReplicatedProps

gloomy tiger
#

Okay, brilliant! #TIL.

Matt, thank you once again - you always put me on the juicy tracks, hehe.

fossil spoke
#

👍

gloomy tiger
fossil spoke
#

Which, I dont understand how that would be possible.

#

Unless some native tags are only made available with #if

#

🤷

gloomy tiger
#

Oh, okay. I shall experiment that, let's see.

#

Aight, thank you! ⭐

fossil spoke
#

Meaning you need to be able to know those choices across level transitions?

vagrant grail
fossil spoke
#

If you cant provide constructive responses, dont respond at all please. Read our #rules thanks.

twin juniper
fossil spoke
vagrant grail
fossil spoke
#

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.

vagrant grail
vagrant grail
fossil spoke
#

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.

vagrant grail
#

alright

warped oxide
#

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

obtuse field
#

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

meager spade
#

[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

obtuse field
meager spade
#

pass -WaitForAttach

obtuse field
obtuse field
meager spade
#

what?

fossil spoke
#

Is this happening in Editor?

meager spade
#

oh standalone editor

obtuse field
#

Oh, I though I mentioned it, but it turns out I forgot. It happens only in editor

#

Not happening in packaged game

fossil spoke
#

With PIE?

#

Or Standalone?

obtuse field
#

Selected Viewport

#

With PIE the results are the same

fossil spoke
#

Are you hitting a Blueprint Loop Iteration limit or something?

obtuse field
#

nope

#

I use almost no blueprints in my project

fossil spoke
#

🤷

hoary spear
#

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

fossil spoke
hoary spear
#

Perfect, thats what i thought

fossil spoke
#

Clients that call a UFUNCTION(Server) RPC must ensure that Actor has a NetOwningConnection.

hoary spear
#

Thanks !

meager spade
hoary spear
#

the invoking actor must have an owning client?

#

e.g. the NPC in this case?

sinful tree
hoary spear
#

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'

hoary spear
#

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 🤔

sinful tree
hoary spear
#

yey! It worked 🎉

hoary spear
#

feels like it was a wast improvement from earlier

dusk pecan
#

Can somebody help me? When the host presses the startmatch button, the match gets started correctly, but the loadingscreen doesnt show up

harsh ice
#

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

sinful tree
# dusk pecan Can somebody help me? When the host presses the startmatch button, the match get...

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.

sinful tree
dusk pecan
sinful tree
# dusk pecan 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.

sinful tree
#

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.

harsh ice
#

I have to execute on multiplayer so i thought it's multiplayer

dusk pecan
#

Hey there, has anybody got an idea on how I can make large lobbies, without when the hosts disconnects the lobby stopping?

hoary spear
hoary spear
#

To soon to claim its reliable then^^

#

Things change , especially if you add in some ping etc

dusk pecan
#

I didn't know the wording, sorry haha

dark parcel
upbeat basin
#

Does possessing/unpossessing a pawn changes any dormancy or relevancy settings?

magic vessel
#

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?

magic vessel
#

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

magic vessel
obtuse field
# magic vessel That would be total overkill for this game

So then, what comes to my mind:

  1. Render everything on one server, but make custom relevancy, based on the level, and replicate actors for level A only to players on level A
  2. 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
  3. 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
obtuse field
obtuse field
plush shoal
#

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

unkempt tiger
# plush shoal 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

plush shoal
#

and I had no problems in those versions, with normal sessions or advanced

unkempt tiger
#

post back with results

plush shoal
#

One final thing

#

I am using blueprints and cannot find this exact node, would "servertravel" work?

unkempt tiger
#

no clue lol

plush shoal
#

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

mystic estuary
#

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.

meager spade
#

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

obtuse field
magic karma
#

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?

warped berry
#

is TMap replication supported?

mystic estuary
warped berry
mystic estuary
# warped berry 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...

▶ Play video
chrome bay
#

Redundant copies of the same data facepalm

mystic estuary
#

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

chrome bay
#

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

warped berry
#

is there a length limit to a replicated string?

vagrant grail
#

Is this correct ?

chrome bay
chrome bay
#

I mean, the Client can actually do whatever they want, but that's how it should be done generally

vagrant grail
# chrome bay Essentially yeah

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

lament flax
#

Hello

is the HUD class only on client ? or is there a server version to

solar stirrup
#

Only on clients

lament flax
#

okay ty

solar stirrup
#

Servers do not have any UI

#

HUD, Widgets etc

hoary spear
#

Hosting client is also server , fyi

#

A bit troublesome to handle sometimes 😅

solar stirrup
#

Yeah, that counts in clients hah

chrome bay
lament flax
#

(the 2 last errors can be ignored here)

chrome bay
#

Error looks like it's Client side tbh

#

Can't tell

lament flax
#

it is server side

chrome bay
#

Also, widgets won't be valid on a dedicated server of course

lament flax
#

server spawned the player character

chrome bay
#

It's not spawning before joining, just the log message is written after all that join work is done

#

So you can ignore that

lament flax
#

look again first message second screenshot

chrome bay
#

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"

lament flax
#

so it could be after/before the login ? regardless the ouput log message order ?

#

okay so its only printing joined at the end

chrome bay
#

yep

lament flax
#

well, there is still the "server: "

#

so the server spawned the character ?

chrome bay
#

The server always spawns the pawns yeah

#

Server spawns anything that's replicated

lament flax
#

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

chrome bay
#

get player controller 0 will just get whatever the first PC is, whether that's the local user or the first client

lament flax
#

now i guess i have to do a call back to spawn UI when player joined ?

chrome bay
#

The clients local AHUD class can manage all UI

vagrant grail
chrome bay
#

Don't need to network anything for that

lament flax
chrome bay
lament flax
chrome bay
#

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

vagrant grail
lament flax
#

does this mean the widget is null ?

chrome bay
#

Presuambly yeah

lament flax
#

any reasons why ?

chrome bay
#

A dedicated server won't create widgets, for obvious reasons

#

It's a UI element, the clients should create and manage their UI locally

lament flax
#

well this is suppose to happen

chrome bay
#

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

lament flax
#

on begin play of the character, it create and show the inventory UI

chrome bay
#

Well BeginPlay will run on the Server and the Client

lament flax
#

so i should have "authority" switch ?

#

to run it on client ?

chrome bay
#

You should use IsLocallyControlled if you have to use anything

lament flax
#

okay

chrome bay
#

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

lament flax
#

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 ?

quasi tide
#

Or a Has Auth check on the location volume and if they're "Remote", run the logic on the actor reference that enters/exits

lament flax
#

okay ty

lament flax
#

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

eternal dune
#

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?

lost inlet
#

depends what this "custom class" is

eternal dune
#
#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?

lost inlet
#

If it's a subobject then you'll want to replicate it as one, yes

warped berry
lament flax
#

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 ?

hoary spear
#

The client can have authority over this actor

#

Thats prob your issue ?

lament flax
#

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" ?

lost inlet
lament flax
#

wdym

lost inlet
#

uh authority switch. but in non-MP that'll be an infinite loop (standalone & listen server net modes)

lament flax
#

i am using play as client

unkempt tiger
#

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? 🤔

lament flax
#

on input events, i call set to walk server / set to spritn server

lost inlet
#

ah so inputs will always be delayed by ping then

#

rather than predicting it

thin stratus
lament flax
lost inlet
#

running it on the client and then telling the server

unkempt tiger
lost inlet
#

rather than waiting for the server to process the input

thin stratus
#

@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

lament flax
lost inlet
#

you said the input action called the server event

thin stratus
#

And in theory that ClientRPC that sits on the left is wrong

lost inlet
#

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

lament flax
thin stratus
#

You only set the value on the server

#

So you aren't predicting

lost inlet
#

yes, so there's always going to be at least an RTT delay on those inputs

lament flax
thin stratus
#

So okay, let's step back from the image for a second

lament flax
thin stratus
#

Yeah, THEN, the Client

#

That takes time, cause PING

#

But again, let's start further back:

lament flax
#

when doing nothing - when holding sprint

#

printing this

lament flax
#

im kinda lost, i'll be happy to understand what you guys are trying to tell me

hoary spear
#

You can avoid atleast some of it

thin stratus
#

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

lament flax
#

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 ?

hoary spear
#

Its been a long day for all of us lol

thin stratus
#

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++

lament flax
#

what are "corrections" ?

thin stratus
#

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

hoary spear
#

How big is the prediction window in the cmc?

lament flax
thin stratus
# lament flax what are "corrections" ?

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

lament flax
#

then if the bp has corrections, whats the difference with cpp ?

thin stratus
#

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

lament flax
#

so, without cpp, what would be the best option ?

thin stratus
#

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.

lament flax
#

damn, there is a lot of back end

thin stratus
#

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

lament flax
#

oh, i didnt thought it was that needy

thin stratus
#

Take it from me who works with this Engine since, idk, 2014 (holy shit it's 10 years).

lament flax
#

im not bad at cpp, but i'll to spend time in BPs

could i maybe expose stuff to BP from cpp ?

thin stratus
#

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

lament flax
thin stratus
#

BPs has no Struct inheritance or even functions on Structs

thin stratus
#

The higher the ping, the more violent they will be in form of teleporting the player around a bit

lament flax
#

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...

thin stratus
#

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

lament flax
#

mouvements wont be crazy

thin stratus
#

You can already try how bad it is with your sprinting

lament flax
#

how can i simulate ping ?

thin stratus
#

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

lament flax
#

okay

thin stratus
#

(at least in its wider sense, there are reasons to test package loss, but they are advanced)

lament flax
#

i should make lag the client right ? and not the server

thin stratus
#

Doesn't matter tbh

#

But yeah

#

Client In/Out 50

lament flax
#

if both lag, it will be 2 time worse no ?

thin stratus
#

And then spam the sprint button

thin stratus
lament flax
#

ill do your setup, test it, then try some bad ping configs

pure hearth
#

Could just applying a multiplier to the value input of the player work for sprinting in mp?

lament flax
#

and hope that later on i wont find a thing only "good to do" in c++

pure hearth
#

Guess i've tested it before, but its been a while

thin stratus
#
InputKey -> SetMaxWalkSpeed = SprintSpeed -> ServerRPC

ServerRPC -> SetCustomSpeed = SprintSpeed

OnRep_CustomSpeed -> If Not IsLocallyControlled -> SetMaxWalkSpeed = CustomSpeed
#

@lament flax Maybe that's easier to read

lament flax
#

kinda

#

im having a hard time with the term "RPC"

thin stratus
lament flax
#

ive looked a lot of definitions and examples, but sometimes i still dont get it

pure hearth
thin stratus
#

What keeps your client from sending 1.0 all the time

#

Even if Stamina is low

lament flax
#

"server rpc" mean that you execute from server on owning client ?

lament flax
#

oh

thin stratus
#

If those are troubling you, read the Compendium please. If you have already, read again :D

lament flax
#

i will read it again xD

pure hearth
thin stratus
#

If you have a ListenServer coop party game or so

#

Then sure, that's a work around fwiw

lament flax
#

very small, but i think you misspelled this :)

pure hearth
#

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

lament flax
#

and ty for the docs, its well written

pure hearth
hoary spear
#

Thats the recommended amount these days

lament flax
#

your idea is :

  • change speed for client to what we want (sprintspeed)
  • in server set a custom speed to 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 ?

hoary spear
#

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

brisk swift
#

trying to send a variable from client to server but it just appears as empty on the server not sure why

thin stratus
#

Because if that is a UObject Child BP, then this is expected

lament flax
#

this makes sense

thin stratus
lament flax
#

so i can make a standard event ?

#

thats not replicated ?

thin stratus
#

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

thin stratus
#

The OnRep however calls again

thin stratus
#

Cause I had a shit ton of Free Months to gift

dark edge
#

I don't remember what I did with my refund / credit.

thin stratus
#

I was using it for free anyway

#

Moderator perks

lament flax
#

what is weird is that the component isnt replicated

#

so i dont see what a replicated component mean

brisk swift
thin stratus
#

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

thin stratus
lament flax
#

without enabling replicating, all players with the sprint component will spint/walk

lament flax
thin stratus
#

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

lament flax
#

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 ?

dark edge
#

just alt tab between windows or use a controller + kb

lament flax
#

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

dark edge
#

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

lament flax
#

ill try with kb + gamepad

#

now i need to see how to set the kb to pie 1 and gamepad to pie 2

dark edge
lament flax
#

i tried and the kb and gamepad just works for the focused pie window

warped berry
#

is there a size limit for replicated variables? specifically string length limit?

warped oxide
#

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

thin stratus
#

It shouldn't be 10 times, no

warped oxide
# thin stratus 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

brisk swift
#

Tried looking up replicating uobjects but i'm confused on it, anyone know a good video tutorial of how to do this?

ebon basin
#

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

lament flax
#

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

lament flax
#

2

#

the event is called twice for client 0 (the one who entered the box)

dark edge
# lament flax 2

The overlap is happening on both, the pawn is remote on both, the player controller will only be valid on one

lament flax
#

how can it happen on bother players characters ?

dark edge
#

both players MACHINES

lament flax
#

oh

dark edge
#

on my machine, my guy entered the box

#

on your machine, my guy also entered the box

#

on both machines, the guy is remote

lament flax
#

i see

dark edge
#

on my machine, the playercontroller is valid. On your machine, it isn't

lament flax
#

so i need to check for is locallycontrolled ?

dark edge
#

If that's what you care about yeah

lament flax
#

i didnt thought about that

#

ty for helping

zinc canopy
#

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?

dark edge
#

How many times per second are you calling it?

lament flax
#

how does OnRep Notify work with event dispatchers ?

fossil spoke
#

OnReps and Event Dispatchers are very very different things with no relationship to each other

dark edge
lament flax
#

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)

lament flax
zinc canopy
dark edge
fossil spoke
#

Are EDs able to be stored as properties in UE5 now?

#

I would argue that EDs are not replicated.

lament flax
#

the thing is, when i set the ED to repnotify its not called anymore

#

🫠

dark edge
#

I don't really understand what it might mean for an event dispatcher to BE replicated.

lament flax
#

maybe because its on client

dark edge
lament flax
#

since i saw the options

dark edge
lament flax
#

well changing to any replication other than none seems to do nothing, the ED isnt fired/received

dark edge
#

It's probably a bug or oversight that you can even set the replication condition to anything other than None

dark edge
zinc canopy
plush shoal
lament flax
#

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

pseudo merlin
#

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

dark edge
pseudo merlin
lucid badger
#

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? Thinkge

lucid badger
#

Forgot to mention that I'm also changing the outer from the one actor to the other Thinkge

obtuse field
#

How can I prevent this in multiplayer in editor, if I'm suing pawns instead of characters? Updated component is a mesh component

severe zealot
#

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

obtuse field
#

Yup, there is one

severe zealot
# obtuse field 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?

obtuse field
obtuse field
severe zealot
vagrant grail
#

Do we agree that "HUD" class is generated for each player / each player receives one when they join the game ?

fossil spoke
#

This is called by the GameMode

#

During AGameModeBase::GenericPlayerInitialization

lament flax
# dark edge show your code

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)

obtuse field
#

How can I use 2 player starts, and if I spawn 2 players, so they spawn in different locations?

lament flax
sinful tree
oblique nymph
#

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.

lament flax
#

Now the thing is, how to get the 2 specific clients you want

oblique nymph
#

Thanks, I forgot to mention this is for local split screen

hoary spear
#

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?)

sinful tree
hoary spear
#

And server replicates it when?

#

Is it a continous thing?

sinful tree
#

When you make a change for example. There are replication conditions on variables, and it may not necessarily replicate always.

hoary spear
#

But would it ever replicate "by itself" because a client changed it locally?

sinful tree
#

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.

lament flax
#

the level BP is owned by the server i imagine ?

sinful tree
hoary spear
#

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

sinful tree
#

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.

hoary spear
#

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)

sinful tree
#

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.

hoary spear
#

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

hoary spear
#

if its not your actor, it's just a local event ?

sinful tree
#

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.

hoary spear
#

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

sinful tree
#

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)

hoary spear
#

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)

sinful tree
#

🤔 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.

lament flax
#

i got some question regarding var replications and event dispatchers

hoary spear
#

the other way around is ignored. Client trying to Server RPC on a server owned actor

lament flax
#

i'll ask them after you solve your issue squize

hoary spear
#

Go ahead, I'm not really having an issue^^

lament flax
#

thanks

#

on what is called onrep notify ?

#

if i call it on server, its server only ? or server + all clients ?

hoary spear
#

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)

sinful tree
#

(i think if a client sets it, it'll actually fire the onrep locallly for that client)

hoary spear
#

Let me verify..

lament flax
#

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)

hoary spear
hoary spear
#

would trigger both on server and clients

sinful tree
lament flax
#

well, if i set the var on server event, its not calling anyth ED on clients

sinful tree