#multiplayer
1 messages Β· Page 714 of 1
I know this is old, but this works surprisingly well. Havent tested it in a fully packaged build, but works in Standalone on 4.27.
widgets shouldn't hold data
hello i have an issue when passing a variable from the server to the client and i dont know why if anyone could help me that would be great
in this picture u can see the call refresh is called from the server and passes the item array.
but when the client receives it the values are set to none why is that?
and again this part works on single player or on the listen server
one sec
i think so yea
If they are actors then your rpc is happening before they have been replicated, if they are uobjects then you need to do some additional networking stuff in c++ to make them replicate
Yes you can't replicate them without some C++ work
o thats great
this would then also apply for structs?
beacuse the reason i am doing it like this is when i acces a replecated struct from as client it is empty
if the struct has those uobjects, it won't have anything
on the client side
but a normal struct should replicate fine
it is an array of structs but yea it also holds the same objects among other normal variables
could you point me in the direction on what i should implement in c++
Search for subobject replication
It's basically an actor that takes care of the UObjects
thanks mate
thanks so if i understand correctly i wanna change my object blueprint to c++ so i can add replecation?
you create a C++ class, and parent your BP ones to it
thanks again
Hi can a variable in c++ be blueprint accessible and be replicated?
UPROPERTY(Replicated, BlueprintReadWrite /** or BlueprintReadOnly */)
int32 MyVariable;
@atomic barn
thanks
I'm trying to test a very bare bones setup of multiplayer by running in standalone mode: one as -server and another as -game from .bat files. It definitely works on a build from source version of 4.27 but definitely doesn't on a straight release.... does anyone know if you DEFINITELY need to build from source to have this type of network play work?
You only need to build from source if you want to package a dedicated server
A listen server will work just fine
thats what I thought but I cant figure out what I'm doing wrong. both are third person template vanilla projects and exact same .bat file setups. The from source version works fine. multpile clients can all boot in as a new player. On the release engine build all clients just take over the default pawn that was in the level.
I don't think the default templates have any real multiplayer functionality
You're saying one is running as -server and one as -game, but how is the second instance connecting to the server instance?
the pawn by default replicates, the running in standalone on our build version operates identical to the PIE multiplayer tests you can run in listen mode. the pawn runs around its inputs are replicated. the second -game instance has the ip pf the server it connects to. Basically following instructions from the book - Unreal Engine 4 VR projects by Kevin Mack / Robert Rudd.... give me 2 to screencap the bit.
How does replication work with level streaming?
I've got this replicated geometry cut actor thing
And it takes a chunk out of static meshes using booleans
But I'm not sure how it'll work if the static meshes are in different levels or if someone makes a cut in a level that' not loaded for other players
very likely that you need to take care of it^^
Is there some sorta delegate like
Like on level load, i should perform the cuts if the static mesh actor is loaded?
@chrome bay
I guess you have some system that replicates the cuts, so yeah, at some point you need to sync the cuts with the loaded meshs
yeah right now just the cut box dimensions and the cut static meshes are replicated
like as 2 vectors and a list of actors
so what's the question π
well if they are UPROPERTY I hope they get nulled^^
you will need to store their GUID or another identifier that the actor it self knows and can thus register again on reload
also i got another question, is beginplay called before or after initial replication?
like on server, if set some variables on begin play, does that get initially replicated out?
or is it only stuff passed on construction with SpawnActor?
It seems like my EventDestroyed is not getting called on listen server when traveling, is this normal?
But it depends if the actual match has begun play also
does replication of an actor first starts after its begin play got called or could it be earlier?
Initially Replicated Properties will be read in before BeginPlay is called yeah
I've had rep notifies get called before beginplay yeeeee
Generally just wait and have BeginPlay() call them again
Hey all. I have some variables in an animation instance that aren't being replicated. Is the animation instance not normally used for replication?
I'm using DemoNetDriver. On Server and on Client movement of the car looks ok, but on the replay car jerks like every 1/8 per sec. How to fix it?
nah it's not normally replicated
usually you stick the variables on your pawn, or compute them from pawn values
Turns out replicating it was a bit of a dumb idea
haha yeah, that's what I'm doing now
Thanks though
I was trying to avoid the pawn class getting unreasonably bloated
You could stick it in a component
That's what I do for basically everything. I hate putting anything in character
Components have additional cost, so it's pointless to do that if it's a character property
am i allowed to send, from the client, the property reference and a value and have it be set on the server? or do i need an RPC for every single property that can be set? eg if i have 2 bools and a string, would i need 3 RPCs from client->server to set those?
You just pack them in the same RPC
do you mean i can have a single RPC that would let me change all 3 properties?
sure why not? All you're doing is sending values to it
ServerSetSomething(bool b1, bool b2, const FString& TheString);```
ah nah i meant the RPC would just take a property/value pair
so i would make 3 calls to change all 3 values if that makes sense
No that won't work
Unless you send some FName to identify the property and an array of bytes to directly set it to
But that's hugely inefficient and smells of design problems
right
You're normally doing something very specific with an RPC
If you can set any property to any value, that's an open door for cheating
so i guess if i have some UI that has a bunch of scalar values i can change on an actor i would need an RPC for each one
That's different
oh
But ultimately, yes you need to send them somehow - either packed together, or with some ID to identify what you're changing.
Generally you never call RPC's directly from UI though
You don't want a slider to spam the server with 100 RPC's everytime it's dragged
right
how much of an additional cost?
The component adds an additional header, since it has to be identified. It's not massive, but it's not nothing.
Either way putting properties into a component only makes sense if it's logical data for that component
If it's a property of the actor, that's where it belongs
π€
The overhead for component replication is relatively low. Each component within an Actor that replicates will add an additional NetGUID (4 bytes) 'header' and an approximately 1 byte 'footer' along with its properties. CPU wise, there should be minimal difference between replicating a property on an Actor vs replicating on a component.
hey all, does steam multiplayer work in 5.0.1 atm ?
Steam doesn't do multiplayer, but Steam online features haven't changed particularly in 5
hey. im asking this because i have a silly and ultra basic idea id like to play with some IRL friends with, so I figured it would be faster to get a multiplayer template and spend a day or two to put my idea into practice
so the first hit i got on the marketplace was "multiplayer fps basic pack" but it says this:
What's the bug report like?
i have zero experience in network replication, servers etc, i use unreal for archviz and as a hobby,this is why i figured a pack would be a fast way
I don't have that particular issue myself
in 5 ?
(yes, in 5)
Is it possible to use AddStaticMeshComponent in multiplayer? I get this:
LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: StaticMeshComponent NODE_AddStaticMeshComponent-2 NOT Supported.
it is
if its added on server and replicated
or its added on client and server separately and has the exact same name
I have a bp inherited from this //Header UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite) bool ReplicateToEveryone = false; UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite) FName Name; //CPP void UInventoryComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); if (ReplicateToEveryone) { DOREPLIFETIME(UInventoryComponent, Name); } else { DOREPLIFETIME_CONDITION(UInventoryComponent, Name, COND_OwnerOnly); } }
But when i set "ReplicateToEveryone" to true in my bp defaults the "Name" var still gets set to OwnerOnly
GetLifetimeReplicatedProps() is called on the class
You'll need to make a new Blueprint Class of that component, set the flag, then add that class to your actors
This would work at the actor level because the actor blueprint is a new actor class, but it's components are not new classes
Im not sure if i understand, im not getting the "new Blueprint Class of that component" part
Do you mean "Add component by class" in bp or "UInventoryComponent NewComp = NewObject..." in c++?
If I wanted to handle rotating the character to face a target when a certain property is set, would one way to handle that be inside of the character movement component's GetDeltaRotation ?
I could do it inside of the actor tick, but I was thinking of lerping the rotation as the character is moving instead of just rotating the actor even when the character is not moving
well, I guess the second part of what I said at the end could be handled inside of the movement component too, so I guess ignore that part. The question really is, which method would be best to handle rotating the character towards a target in a multiplayer game?
how do you keep a replicated reference to something that gets loaded/unloaded with level streaming?
the reference gets nulled out on level unload
I have a "InventorySlot" struct with an FIntPoint index and a TObjectPtr<UMyItemClass>. The index replicates, but the object pointer won't. Is there something I'm missing? Or is that just not possible?
I know that UMyItemClass replicates fine normally - e.g. I have an AMyItemContainer with pointers to items, and those replicate on the network
Make sure that the UMyItemClass is marked as supporting replication and you also will need to override whatever component or actor you are using and manually call upon the pointer to be replicated
Unless you mean to replicate it outside of an actor or actor component. I haven't done that before.
I did all the stuff to make sure UMyItemClass replicates - like I said, I have actors with pointers to items (just like I'm trying to do with the struct) and everything works fine. The FInventorySlot struct is being replicated by an actor component. Other fields in the struct replicate fine, but the item pointer does not.
Hello, why all of a sudden ServerMove stops getting called and I just get acks?
Client can see server move but Server can't see Client move after a while
I'm curious as to why you use a TObjectPtr instead of the usual UPROPERTY and regular pointer (*) combo.
I'm sure you know this but UObjects have to be UPROPERTY(Replicated) to replicate.
I suggest you replace TObjectPtr with the bare *
how did you come to a conclusion that your item class doesn't replicate?
as struct not having a valid pointer because it replicated first does not mean the object didn't replicate after
TObjectPtr is a UE5 thing, they recommend it over raw pointers for properties/fields (but not function arguments/returns). Using a raw pointer didn't help.
Ahhh, I see. I haven't switched yet.
if you breakpoint AActor::OnSubobjectCreatedFromReplication on the actor responsible from replicating that UMyItemClass
does it hit?
The object field is null on the struct for clients but not the server. I know the rest of the struct is replicating because I added a MyRandomInteger field to the struct to test it; I can see that the structs replicate that number (and the FIntPoint index I mentioned earlier), but the object will always be null.
Ah, that is something I'm not familiar with. Lemme look into that.
if it hits - it means your UMyItem didn't replicate by the time you got a replication callback, and if the same actor channel is responsible for both struct and items, you should put the Super call at the end of ReplicateSubobjects
if it doesn't hit you either have a problem in ReplicateSubobjects on the Actor responsible, or you didn't override IsSupportedForNetworking on the UMyItem
assuming here that UMyItem inherits from UObject, if it inherits from UActorComponent, then it was not set to replicate
Those are good points. Talking this out has made me realize a few things I could be missing.
For more detail, the "flow" of what's happening is:
- Player steps on a button
- I spawn a new
AItemDropthat players can pick up (spawning happens on server, drop actor gets replicated.) When it's spawned, it calls a server-only 'Setup' function with a linemyItemPtr = NewObject<UMyItemClass>(withmyItemPtrbeing a replicated property on that actor) - Client or server player walks up close to the drop
- We try to add the drop to inventory: we call the server-only
TryPickUp(item)function, which will create a newFInventorySlot, give it the reference to the item, then add it to a replicated array of slot structs.
I've tested and confirmed that when I create the item object initially (step 2), the item is being replicated. All clients & the server will see the new AItemDrop actor, and everyone's copy of the actor has a reference to the same UMyItemClass object (again, I tested with random int IDs, everyone's machine gets the same ID replicated.) However, when we get to step 4, all clients & the server will get an updated array with slots that are replicating correctly, except for the item reference.
...however, I also know that the server deletes the AItemDrop once it has completed the TryPickUp, so I'm wondering if the item pointer is getting destroyed in that step. I'm also realizing: I probably need to handle the ReplicateSubobjects when the item is added to inventory, since that means it's owned by another actor. I don't think I'm manually setting any outer/owner, either.
And yeah UMyItem does inherit from straight UObject, and I do have IsSupportedForNetworking and GetLifetimeReplicatedProps properly implemented on the object. But like you're saying, I may not be properly doing replication on the actor side. Gonna double check all that.
bool UAttributeComponent::ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags)
{
bool WroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
for (USolsticeBuffBase* Buff : ReplicatedBuffs)
{
if (IsValid(Buff) && Buff->IsReplicated())
{
WroteSomething |= Channel->ReplicateSubobject(Buff, *Bunch, *RepFlags);
}
}
return WroteSomething;
}```
@ember sinew Do you by chance have a destroy function on the UObject that is called when the replicating owner is destroyed?
If you follow Jambax's tutorial on replicating Objects, there's a function like that that may cause your problem
short example of ReplicateSubobjects that replicates an array of UObjects
looks the same if implemented on Actor level
I am using blueprints and cant find hosted sessions, my guess is i should set bShouldAdvertise to true?
but how do i do that while using blueprints..
or am i missing something else
I actually found that tutorial before and it helped me clear up stuff I was doing wrong. Gonna give it another check and make sure I'm doing stuff right. As for the destroy: I don't have a destroy on the object itself. I didn't intend to delete the object, but it could be. I'll add the OnDestroyed or whatever to it and spit out a log, see if it's getting called.
its a UObject, you don't call Destroy on those usually
you just let go of the pointer keeping it alive and GC handles the rest
Yeah, in the tutorial it's a custom function that markes the object as dirty or something so that GC can clean it up
MarkReadyForDestroy() ?
Yeah this.
never had a cause to use that
I had to remove it also cause I don't want it to get destroyed that way
It just tied the lifetime of the object to the replicating actor.
You can remove the function if you don't need it
If I put the server and multicast and replicated variables code in a common-component then inherit that component. Would that network replication work?
as long as the Actor which that component belongs to is owned by the PlayerController, yes
otherwise, only multicast will work
So setting a replicated variable using server RPC wont?
you can do it in PlayerController, Pawn and PlayerState by default
Not using a component
A common component being shared by two components. And two separate components are added to two separate characters.
all Server and Client RPCs require that Actor whom they ultimately belong to is owned by the PlayerController
otherwise you'll just get a "No owning connection for..." warning in your Output log
Ah, shoot, yeah, I forgot some key ingredients from that tutorial (especially the whole "make sure the item's outer is an actor" bit.) Welp, got some work to do. Thanks for recommending that π
This should work then. A common component being shared by two components. And two separate components are added to two separate characters.
Oh.. this. Okay. Hope it fixes your problem.
it doesn't have to be an Actor, but due to fantastic quirks of Unreal, after it replicates on client the Outer will be the Actor whose channel was used for replicating the subobject
Just wanted to leave this out there in case it's handy. Article by Jambax
https://jambax.co.uk/replicating-uobjects/
Ha, that's like 80% copied from the other article, this is so important he wrote it twice π
can I only ever call server RPCs on pawns/controllers (aka something the client owns?)
I originally was doing a NetMulticast RPC call in the gamestate (which is shared between server/clients) but it seems to make more sense to do it from the pawn, even though I moved my original code from the gamestate to the pawn and it made no difference, I understand the syntax though, as the client, you call a function only the server should have access to, then call that server function, which will then call the base function
I'm honestly not sure why this isn't working, when playing as the server I am calling the function and it successfully NetMulticasts, but when I play as a client it never multicasts, even when I ask the server to do it
I'm basically going Pawn->FunctionInGameState->ServerFunctionInGameState->FunctionInGameState
is my logic messed up??
Yes.
You can only call server functions from player controller or something that pc owns.
GameState isn't owned by the pawn presumably?
Hi, does Replication Graph replace the default Network Relevancy System or are they supposed to be used in combination?
i have this function in C++ which is clearly marked as Client but is being run on dedicated server. i know this because i create a widget inside which crashes because PlayerController::IsLocalController fails because the netmode is dedicated cpp UFUNCTION(Client, Reliable, BlueprintCallable, Category = Interaction, meta = (HideSelfPin = true, DefaultToSelf = true)) void ShowUI(class AMob* Player); does anyone know why this would be happening?
the problem was that this function was on an actor that the player did not own. moving the core of this function to the player controller fixed it, although not being allowed to call an RPC on an actor that you dont own is annoying af and clogs up the player controller/player character
It is spawned by the GameMode, so it is definitely not. It's server owned
You just said the reason. See the table for reference:
i really need to get this printed out in a big poster and put it on my wall
I'm using Smooth Sync for my racing game - does anyone know how to fix the major discrepancy in the client locations? The actual position of the owning client severely outpaces the replicated position. It's almost as if the plugin is not using extrapolation. I've gone through all the settings and can't seem to figure it out.
Why not ask them in their official discord?
most movement components with prediction work like this:
1 - client applies its movement predictively and sends its FSavedMove to server
2 - server receives FSavedMove, applies it and sends the timestamped result back to client
3 - client receives the server result, then reapplies all moves that happened after the timestamp of last server update, and that is its position
which means client will always "be a little bit ahead" of where it is on the server, unless its standing still
I guess the main problem I'm having is, people cannot race side-by-side because they don't know whether or not there actually is a car to their inside or outside. The desync gets too far out of hand at 200+ KPH, like 5 car lengths
Can you provide a link? I have looked all over and cannot find it
he found the link here for posterity https://discord.com/invite/6VpgNQg
How does ustruct repnotify works?, changing a value inside the struct does not call repnotify
In BPs?
I always felt like modifying variables in BP without involving the Set node of the variable doesn't cause RepNotifies
E.g. adding to an array
im working in c++, but its for both, do i have to keep a loop to check which value changed in the struct and apply it?
Hm in CPP it should be fine to just modify the structs property. Not sure
Yea setting the struct fires the repnotify but changing a value inside the struct doesnt
In blueprint it does call the repnotify when i change the values inside the struct
But not in c++
Well, it appears to be also working with c++ version, gotta check the code then
when i send an rpc with a pointer parameter(for example a montage) what does the parameter looks like when sent over the network?
its the asset path?
No - owned by the GameMode
If it's an asset, then at first yes - the full string path is sent until a GUID is acked for that object by each connection
alright so there is no point in manually sending it, ill just let ue handle the thing
yeah, you don't need to do anything - just send the asset pointer
Or if you have a fixed list of assets you are using and can index them somehow, that's a way to save cost
make sense, thank you
Should work fine
C++ rep notifies work differently though (aka, properly)
BP "rep notifies" are just "when any change is made to this property regardless of who or where it came from"
And the difference between them is an endless source of frustration
Probably not now.. I wonder how many BP projects would outright break if they did
Just a silly legacy decision we gotta live with π’
Only solution and what rocket league does is to predict other clients locally based on their last known input to place them in the same "timeline" as your locally controlled car
The higher the latency the worse it will look as the only information you have to predict them is their last state from the server and their last input
If I have a door control panel ui that opens the door when I click a button in the widget, but I don't own the door, is the best/only way really to tell my local player controller to call a server RPC on itself to then call open on the door?
yes
I'm trying to better understand the workflow for client side actions that are performed on the server for actors I do not own. The way I described seems like it would clutter the player controller with dozens of RPCs which only exist to call a function on another actor
Usually something like this is done through a generic interaction system
You don't make it specific for every possible actor, you design a system that can handle many interactions
Do you have any recommendations for marketplace assets or further reading for these kind of designs?
Would never recommend anything from marketplace tbh
But a simple approach would be just a single "Interact" RPC that takes an actor and a gameplay tag
E.g. "Door.Open"
And through an interface, call a function on the target actor
e.g. OnInteract(Player, InteractionType)
Usually quite game-specific
Ooh I keep forgetting about gameplay tags
Ignore whatever Lyra did, it's awful
How much would it cost me to have you implement this for me? Haha jk unless...
Well me personally I have no time π
But tbh generic systems like these are the most fun things to make IMO
π
Sort of the same for me except I don't have the knowledge or experience to do it most of the time. Super rewarding when it works though. I might even specialize it in one day and not even worry about trying to make games
Yeah but then these are the times when you learn the most too π
Even if you reinvent it a couple of times, you learn a lot from the failures and mistakes
Throwing stuff in the bin is underrated
Great advice actually. I really need to learn to not be scared of having to rewrite code. I have this thing about writing code once and have it be perfect so I never have to revisit it and it's absolute hell. It means I get bogged down with tiny implementation details and micro optimizations that cost me days or weeks of time
I still do that tbh π
Very hard not to get too excited and over engineer once you get into a flow
But the first thing is identifying the problem, you don't want to pollute the controller with misc code from all over the place which makes sense - now it's just thinking about how to solve it in a nice way
I'll keep this in mind. Thanks for the help π
Continuation from my yesterday boggle - I'm trying to find out if this works by default in anyone else's launcher release of UE4.27.2 - https://nerivec.github.io/old-ue4-wiki/pages/how-to-test-dedicated-server-games-via-commandline.html
The way I was testing is by making a default third person project and using that. In a particular 4.27.1 build from source one of my coworkers made it works flawlessly. each game clients joins and they run around seeing each other. In 4.27.2 launcher release, 5.0 launcher realease or a 4.27.2 build from source it doesn't work the same. On those versions we have to manually use the console and type open 127.0.0.1
I'm trying to figure out if there's some type of bug or is something magical changed in the engine .ini's of that build that is making it work
what if we are talking of uobjects instances?
for example if i create a new object that is maybe some hit informations when a character is hit and i send this damage object over rpc(i know it does not make sense, its just the first example that it comes to my mind)
should i pass only relevant data and rebuild the object on who receive the call or there is some magic happening behind the scenes?
You can't pass objects created with NewObject
The object has to be network addressable
So it has to be reachable some other way, e.g as a replicated subobject of another actor
oh
so in this case where the object is just a transient object, how would you do this?
You can't
It has to be networked somehow, and reachable anohter way
If/When Epic takes this PR, you'll be able to send any data struct via the same RPC
https://github.com/EpicGames/UnrealEngine/pull/9087
i am currently trying to figure out how to send a wildcard through a blueprint function call to a blueprint event. decided to not use wildcards and just use an FString instead :( i dont like it but.. it will work for now
It is very fun
I'm just not a fan of it myself, I don't like how it's scanning and constantly granting/removing abilities etc.
Thinking of that time where Destiny 2 DLC got out of GamePass and players lost abilities mid game in PVP
I mean I use abilities for interaction but these are triggered from native code. But the interact ability is mainly for gameplay purposes and timed interactions
I keep seeing this in bunch of different places, though looking at the source code, the GameModeBase seems to spawn GameStateBase without specifying the Owner, so it's kinda left null there. How would I still conclude that it's owned by the GameModeBase?
Ah in that case it's owned by nothing, I always assumed gamemode spawned it with itself as the owner
Well, I don't think it needs to explicitly set the owner, because aren't null owners considered to be owned by whoever spawns it?
If this is true, because GM only exists on the server, it'd naturally be what owns the GS.
Nah it has to be set explicitly for sure, you can definitely have actors without owners
Hmm I do think you have to always specify the Owner explicitly, otherwise it's null owned. But null owned actors are like server owned, so it doesn't make much of a difference
But tbf it makes sense for it not to have any owner, GameMode wouldn't replicate to clients anyway
No point replicating a ref that will never resolve
Ah right π
So I'm part right. I'll accept it.
Is it a known bug that map actors destroyed via Initial Lifespan on the server still appear on clients that join after it was destroyed?
Hmm, as long as they are replicated it should work as expected I think
Client that joined late on the left still has spawns that got destroyed (not visible in the client in the right)

LogNetPackageMap: Warning: UPackageMapClient::InternalLoadObject: Unable to resolve default guid from client: PathName: GER_ForwardSpawn2, ObjOuter: /Game/PostScriptum/Maps/Wolfheze/Offensive/Single/UEDPIE_0_Wolfheze_Offensive_Single_01.Wolfheze_Offensive_Single_01:PersistentLevel
big rip, whines about it when I call a Server RPC if I try to spawn on it 
guess i'll figure out why it doesn't get replicated destruction info created for it
.... it does?
Relevancy issue maybe?
Always Relevant
Yea
There's a max range for actor destruction infos being replicated IIRC
But haven't got code atm so can't find it
does it come with a warning in the output log?
I don't think so
It just doesn't send out destruction infos for actors that are far from the viewer, but yeah here that would be a problem
gonna check all usages of DestroyedReplicatedStaticActors
Hey people, is there somewhere I can access replicated control rotation? I currently have my own replicated control rotation variable. But if it's already exist in somewhere I might drop mine and use it. (Using cpp)
Not seeing anything about visibility 
Alright, don't get that destruction issue without the rep graph
odd
Ay got it: UReplicationGraph::SetActorDestructionInfoToIgnoreDistanceCulling()
Beats me in what case you'd want to cull destruction info for map actors
especially always relevant ones
I have a component that creates a basic inventory such as players inventory, storage and that kind of stuff
And on its begin play it populates a replicated with repnotify(ReplicatedUsing) structure thats called InventoryData
when the player logins the repnotify function fires and creates widgets with data from InventoryData struct
What im trying to do is put this component on an actor owned by no one and act as a storage to the player
so when the player interacts with the storage actor it opens a storage widget with data relevant to him
or even as a marketplace with online data that everyone can access
But i can't seem to make it work as a storage(didnt try marketplace yet), the data is always empty
Can't find a way to make the actor load data relevant to the player since he doesnt own the storage actor
So i was wondering is my approach possible? should i stick with adding the inventory components to the player controller or is there a better way?
So it's like the stash in Diablo, shows different contents to different players?
I havent played diablo but yes, different contents to different players
That data should live in PlayerState probably, replicated to Owner only. The stash just acts as a way to interact with it.
It's your items, you can only get at your items when interacting with the stash
it's not the stash's items
Set it up such that you can open the inventory any time you want with a keypress, then just hook into the interaction with the stash
Sort of like a shulker chest in Minecraft
I've thought about keeping all data thats relevant to the player inside controller and make the storage actor just a way to open the widget, but its kinda hard to make new inventories at runtime with this approach
Is this inventory global or tied to the specific actor, just restricted per character?
i dont think i understand, you put the component in an actor and you have an inventory for that actor
I mean, if I put items in chest A and go open Chest B, are my items there? Is it like the WoW Bank where it's accessable from many spots or just from the one actor?
But another player can't see them right?
Yes, you only see what you put in it
I'd just add OwningPlayer to an item slot and filter by that
But there is no data for the slot to have
add it
hmm
I mean it all depends. I was leaning towards adding a global inventory to the PlayerState but then you said that each actor has a separate inventory so that changes things up a bit
What's the context, is this for a stash or bank or auction house or what
I think i'll have to recreate the system to do it this way
I'm working on a crazy inventory system too, but it doesn't use components as anything but an ID really.
Not doing any of the context stuff though, everything is the same for everyone.
The reason im using a component is to easily add/move it to another project by just copy pasting
All the logic is contained in the component, you just call events/ interfaces or functions from the component
A component is typically the approach, the wrench in the whole thing is the "ownership" mechanic.
Yea the ownership is what making it hard to me
is ownership a thing in other contexts?
maybe that should be on the item level
Marketplace seems easy to do since i just make the data replicate to everyone but im not sure
I dont understand, can u explain please?
just an item, a dropped item will be an actor that contains an item data
Like is it MY sword because it has my name/id on it somewhere or is it just the sword in MY chest?
might make it owned
Do you have item slots?
Yes, on client side they're widgets
I mean in the data
on server they're just structures
does a component just have an array of item structs?
yea
or an array of slot structs with item structs in them
exactly
which one?
Its a struct called inventoryData, which contains some data about the inventory like name, owner type and 2 other array of structs that hold the information for the slots
Maybe just let an InventoryComponent have multiple InventoryData
Usually it just has 1
but these special inventories have 1 per character
Yes, but the problem is, its hard to add a new inventory and keep track of it at runtime
i dont think i understand
Instead of one InventoryData, have an array of them
Most inventorycomponents will have 1 of them, but these special (subclassed probably) inventorycomponents would add more when interacted with by a player.
Or just have ownership on the slot level, and only show slots owned by Player or Nobody
I tried that, but had a hard time keeping track of the inventories like which index belongs to a specific actor
Yea i'll prob have to recreate the system to use objects to have owners?
I did make it once operate with objects, but i dont think it made it any good to me
You have 3 options that I can see. Add an Owner field to
- The InventoryData
- The Slot inside the InventoryData
- The Item inside the Slot
Which i did all of them, except for Slots inside the inventorydata, i instead used objects as slots
Anyway thank you so much for the information i really appreciate it, i'll look into doing slots with ownership if i couldnt make the current approach work
I see a blog post in the horizon
What happens when I replicate an array with object references in it? (in blueprints)
I don't see any options to mark objects as replicating
does the client only get a bunch of pointers, or does it replicate the objects as well
Hi!! I have a bot that looks at the player when it sees the player, is there a way for the rotation to be as similar as possible on the server and client. Currently it looks at me but if on the server it is looking at an angle of 90Β°, for example on the client it may be seeing at 80Β° or some other value close to those of the server, but never the same. How could I make it as close as possible to the server?
they get a bunch of guids
which they will then match with the object on their side
tho if it doesnt exist it will just be null
if you missed my slight kerfuffle in blueprints
I'm basically trying to create a large tile system
and trying to figure out the best way to communicate to the client about the world tiles it's near
I don't see a way to replicate objects actually
probably missing something basic
What does "look at" entail?
Is there a variable LookDirection? AimPosition? TargetActor?
What is a tile in your system? Like just 2d data?
the bot turns completely towards the player with a "Target actor"
more or less. location, tile type, ownership
Is the bot a Character?
it has relatively little information in it
Why object and not struct?
not a good reason, found out making them out of actors raw was bad so I stepped down to object instead
yes
I think I could make them out of structs easily enough
the data does get updated, but tiles aren't created or destroyed after setup
only the data inside
struct would work better?
Structs are plain old data so replicate easily. How many tiles total?
Then it's rotation should be replicated already. Is it yawing towards the player?
I'd prefer 100k/1m
if possible
the client would only need to know about a small subsection at a time
the chunky array would be server side
Is it static or dynamic? Procedural generation?
You could just start with replicating the seed + diffs
yes, but visually it is not exact, example in the server it seems that it sees the player's face but in the client it seems that it sees a shoulder
mmm, I think I misspoke
the tiles themselves are static, not all the info inside them is static
who owns the tile would change for example
Anyone know if large scale maps using world partition work well with a listen server multiplayer setup?
I can't find much info on the topic but what I have seen has implied it might be computationally heavy for the host to have to load multiple regions in at once
That sounds like plain old data to me. Maybe fast array of structs
Or GetSurroundingTileInfo(MyLocation)
yeah, more or less
I think you put me on the right path :)
structs + client owned actors are definitely what I was looking for
hi guys
me health variable has a big delay on playerstate when replicating
how do i solve that?
Increase the net update frequency of the player state.
Be careful though as it increases bandwidth usage (not sure if that's the correct terminology)
Also, why do you have the health on the player state? Seems like something that should be on the character even if you're replicating.
Unless the health variable outlives the character class?
thanks for the response
you are infact right, i probably should have that on the pawn
and thanks for the tip on net update frequency
i did played with that but i probably set it too low cuz it broke everything
maybe 0.4 second rate would be good?
I can't really say tbh. It depends on what other stuff are replicating in your game. The default should have been fine.
imagine counter strike
you really want as fast update on the health bar as possible
so you have good feedback on the damage youve dealt
i dont really want to rpc that
alright thanks for help!
Np
hi guys i have a question related to voice chat in dedicated server. i made according to the tutorial but the voice doesnt replicate to the other clients
anyone know what to do on this matter
If you wanted to smoothly rotate a player towards a target when "locked on", wouldn't it be best to just mess with AddControllerYawInput to have to naturally replicate to the server / other clients?
The only other way I can think of doing it is making the lock on action call a server RPC and then have the client and server call SetActorRotation
on tick
do you need to have savegame in unreal engine if you're using NoSql database?
Does anyone have a blog or write ups on some good practices for validation/anti-cheat for multiplayer?
You want to make your own anti cheat detection system?
Well, I want to integrate Easy AC but I know from reading their docs that the primary anti cheat is based on validating game state, inputs, etc. Or at least that's what I gather from reading it so far
No
Hi, I've got replicated actors attached to a replicated actor. In viewport and new editor window they work fine. However in standalone preview the children replicated actors do not spawn on the client but show on the server. Any body got any advice on this?
I am seeing this line in the server console which points to something - Server connection received: ActorChannelFailure [UChannel]
hey well it depends on what you want to validate
ie: client authorative server validated can use server validation to ensure things are proper, ie: checking the shoot was a valid shoot
or if you have a vehicle you could be checking on the server that it isn't surpassing certain velocity and that it isn't teleporting
it is really gameplay centric
and every game has different needs
in single player ive used a tmap of gameplaytag, fstat to define my stats for actors. since replication is not supported, how would i implement something similar? TSet?
and having the tag inside the struct
TArray is the only container supported for replication
But why would you replicate that anyway is my Q?
Ah wait.. FStat is your own type?
Either way the answer is to just use a TArray of structs, which combine the tag and data
You can also serialize the tmap to a tarray struct for replication purpose ( key-value sequence )
Ue5 GAS does this for replicating loose tags
Usually very special cases though, most of the time TArray<FSomeStruct> is preferable
mm thank you guys
Agree but also the stat definition could be an asset :)
And if they are dynamic the server should probably do the work anyway so no rep needed to setup the fstat
As you probably propagate it into components anyway ?
Even then I'd still make it an array
what do you mean by that?
@chrome bay would you happen to know how to send more than 64kb between server and client? Chunked tcp sockets? Would a custom uactorchannel work for this? I think I read something about custom uactorchannels but couldnt find much.
RPC it in batches maybe?
Replication system isn't really designed for large data sets
Little and often is it's preference
Custom sockets might be an option if you want to download a large stream of data early on
I did try that but if it was too fast in between it would fail
You can look at this
https://forums.unrealengine.com/t/replicating-large-arrays-and-data-sets/265029
But TL;DR it's not recommended to use the engines game-level replication for large data
It sounded like your map is only used declaratively not really at runtime and other components ( like health / GAS ) replicate their health then
Sorry misunderstood probably
yep, thats how im doing it
Itd have to be 2mb max worst case scenario initially only to a single player. From then on its just the updates
What's being replicated?
Uobjects
I mean what data
UObjects can't natively replicate without piggybacking off an Actor anyway
any good resource in which I could consult average network bandwidth and other stats employed by famous multiplayer titles?
their item data, couple floats. Fname. A bool. Some references to actors. A tag container.
And you can't generate that data client-side from a seed?
I suppose I could. Just dont know how π
I mean you're sort of stuck because if that all needs to be replicated for some reason, you don't really have any choice but to use regular property replication
And just wait until the engine manages to get it all out to the clients
How many objects are there?
its just the initial bunch. I've tested adding 2k of the objects to an array slowly and it did replicated fine. It wont change much. Just initially. Will the engine managed to get 1mb out to a single client?
If it's all in one array then it won't really work no
FastArraySerializer might work
If the array is that large you'll probably have to use it anyway
What was the conclusion between the tarray and fastarray?
bigger arrays, or bigger members?
tbh I don't think there's any fixed answer
But there's definitely a cap for regular arrays at some point
TArray still works nicely if the array stays fairly constant in size and you care about order
Because you still get delta replication
so what would be the problematic... the array size or the member size?
Both
Especially if you consider the initial non-delta packet that replicates the full contents
Whereas IIRC FastArraySerializer will sort of "chunk" them internally
so if we don't consider that initial replication
if we have a longer members in a reasonable sized array
probably it's just comparable
I think so. FastArray does have larger packets in general I've found
But
It does have delta struct serialization on by default now
It does seem to work, but I'm still seeing larger overall packet sizes
Can't figure out where the extra bits are coming from atm
yeah
I always struggle on what to use, really.
I end up using TArrays unless the array is very very very long
and later, when you profile you see and go like "shit i probably should have tried fast array" hah
I'm near enough in the same area. If the array is "reasonably" sized, like 10-40 elements or something, and it's size is fairly constant, I tend to find it cheaper
I did have a little test project.. wonder where that went
gonna be using it to replicate map marker data soon
The other benefit of FastArray ofc is the per-element add/change/remove stuff. That's useful
Every marker in HLL is it's own actor π
PS is either an actor or a component that registers on the map

refactor time soonβ’οΈ
yeah, I've wanted to profile one vs the other for ages, just never got around to it
issue with component is that it means the map marker won't show up for non relevant actors
even if it needs to
(β―Β°β‘Β°οΌβ―οΈ΅ β»ββ»
I was thinking about making this aswell
Actually I have drafted several use cases to profile
Oh I meant actors vs fast array in this case
TArray vs FastArray I did, for small data sets TArray seemed to be a winner
But also it's removals that get you
Fast array is probably lighter since it won't have all the actor overhead
You remove something from the start of a TArray, suddenly every element ends up being sent
yeaaa
ah actors vs fastarrays
I see... Zlo seemed to find extreme benefits from one over the other
I'll probs go fast array since i'm expecting 100 player markers + vehicles + objectives + spawns etc
so much useful info in here, thank you guys <3
and i'll split it into three actors, each relevant per team and one relevant for all
i gtg now! have a good day!
yeah, if we did this again, I'd have one actor for each type of marker + data
per team
it does have some overhead in FFAstArraySerializerItem
Yeah I know about the RepID at least, so that explains at least 32 bits
There were a few extra I couldn't account for, but didn't dig in deep enough
I'll have to find the numbers again
i kinda serialized some fastarrayitem structs to .json once
there was more then just repID there iirc
I think they've added some fixes for the delta stuff in 5.1 too, need to see if that makes a difference
generally, never had a bandwidth problem, or even close to it, but had to do plenty of CPU optimizations
Speaking of which, any idea?
Oh god
to youngling such as you: dial up is an ancient tech that used a modem to do internet over the phone line π
Zlo, you are not that old, come on man
xD
you are portraying yourself like an elder
Ok boomer
i am not, you are that young π

hahaha
"mum put down the phoneee, internet is down"
I've lived that
But yeah, old games with real engineers run over crazy budgets
for both CPU and bandwidth
π
I was also thinking about profiling Lyra as a starting point to see how much a UE5 multiplayer title would be as a baseline
maybe not very ideal, but we can get good and detailed numbers with insights there
Setting net.MaxConstructedPartialBunchSizeBytes really high worked. I doubt that this is a good idea though. don't replicated properties just get sent changes in variables?
They do, but the initial state needs to be replicated too if it's different to the clients' initial values
Also have to consider join-in-progress, where massive deltas might be sent
Yeah. This is just during a main menu like tarkov for big inventory. Being replicated to one person. So no need to send all that data to everyone. Though what would ramifications be having net.MaxConstructedPartialBunchSizeBytes so high? I guess in such a situation its not as bad because main connection server is seperate from game server. But could be possibility in game an array might be large but not that large
I am having hard time understanding the login process. I generate a url and token for player to join a server (127.0.0.1?token=secret). Server should verify the token by checking DB or asking a webserver (at least 100ms processing time)
FString AGameSession::ApproveLogin(const FString& Options) - This looked like a perfect method, but it is not async, which causes lag when checking if token is valid
bool ProcessAutoLogin(); Is async with OnAutoLoginComplete callback, but I don't have access to url options like with ApproveLogin (and it fetches the login data from commandline etc).
What is the right process to check if token is valid without locking the game thread?
You probably want to check it before they actually join at the game-level
Beacon would be a good way
Yeah. Otherwise lots of wasted time to load a level only to get kicked back to the menu again
Client sends server secret through Beacon -> Server checks asynchronously -> Caches result and tells it to the client who can join if it's valid -> Check cache in login
Thanks for the tip, I have never used beacons before. Just a sanity check, you are talking about this right? https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/OnlineBeacons/
Yep
Lovely, thank you very much
So anyone with a bit of clue how to solve this..
https://gyazo.com/608f19e772ebe9c58acb02233741b468
Trying to have a sprite turn degree around when mouse is at X position of its controller, and then update the rotate for everyone to see,
How do i call this manually? UInventoryComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
Why would you want to call it manually?
I want the variables replicate condition change based on an exposed bool
It'll only work at the class level
Yes, thats what happens
You can't do conditional replication that way
GetLifetimeReplicatedProps() is called by the engine at a specific point, so you can't really "call it manually" so to speak
ahaa
you can turn props on/off with PreReplication
let me check real quick
actors do this for replicated movement for e.g, depending on whether attached or not
Is PreReplication called manually?
no
none of it is
PreReplication() is called before just before checking for property changes
Do you mean when you press play?
no
every time the actor is replicated
or considered for replication at least
GetLifetimeReplicatedProps() is called once when the actor channel is created, on it's class
What do you actually want to do here btw?
So GetLifetimeReplicatedProps() is called on base class, but im having trouble understanding PreRep
PreRep is called on the instance, just before that instance is considered for replication
BTW this is all in the comments of Actor.h
Im trying to change replicate condition based on bool inside my bp details panel
If it's on a component, you can't
You have to create a new BP class for that component, THEN change the bool, then add that blueprint component class to your actor
You can only change conditions at the class level, not the instance level
I now understand i cannot do it with GetLifetimeReplicatedProps()
but this?
It will work with PreReplication yes
You'll need to replicate the property with a condition, you can use COND_Custom if you aren't using one already
I noticed that I can't update an animBP variable on server directly, I have to do it via rep notify, why is this?
AnimBP's don't replicate
Thats great, the only missing piece is how to use PreRep, imma look for a doc on that or something like that
Look at AActor::PreReplication
So it's either multicast or repnotify?
E.g. DOREPLIFETIME_ACTIVE_OVERRIDE(AActor, ReplicatedMovement, IsReplicatingMovement());
Unsure what exactly you mean but AnimBP's have zero network functionality. If you want to set a property in the anim BP, a replicated actor/component must do it
I mean i know those, but not how to setup the PreRep func
Just have a look at the actor
It's a virtual function you can override, nothing much to it
Whats the difference between RESET_REPLIFETIME_CONDITION and DOREPLIFETIME_ACTIVE_OVERRIDE?
Anyone know if large scale maps using world partition work well with a listen server multiplayer setup?
I can't find much info on the topic but what I have seen has implied it might be computationally heavy for the host to have to load multiple regions in at once
Why am i getting this argument truncation from ELifetimeCondition to const bool
with this DOREPLIFETIME_ACTIVE_OVERRIDE(UInventoryComponent, InventoryData, COND_OwnerOnly);
and this works fine DOREPLIFETIME_ACTIVE_OVERRIDE(UInventoryComponent, InventoryData, COND_None);
wait wat, it takes bool
So its for "when a property does and does not replicate"
mm.. so i was implementing the stat thing i asked before
im getting the stat from the array as a pointer and then edit it(it's a struct)
the actual struct does not change tho if it's replicated..the second i remove replicated property it work
what am i missing?
show code
send code
you can hit me if you want
the answer is that i was missing the component replicate boolean

ok so
uhm
https://i.gyazo.com/d5e54f66d853b129f7bc29fda9636eaf.mp4 happends when using get mouse position to turn a actor around, After brench of mouse position Calls server > Calls multi > Sets actor rotation
(Mouse is not moved in this recording)
wait.. i gotta pass the actor's location thru server and over to the multi.. dont i? <.<
what's "Shared" in net insights?
Found this comment by Zlo. Does anyone know how to accomplish this?
My usecase here is object pooling. I'd like to not destroy actors when they go out of reprange, so they can stay in the pool on the client as well.
If I'm not mistaken, actors that are part of the level are not destroyed when they go beyond your rep range, but stay frozen in their last known position when they were in rep range.
How can I trick the engine to do this?
From a quick look in the engine, it looks like this is handled in DataChannel.cpp
looks like the net driver has a function for that
o7
Oh wait, I think bNetTemporary is something else. It replicates only once or something of the sort π€
Yeah, wouldn't touch that
I'd probably just modify the net driver, or (haven't done that before so no idea if it's even possible), derive and override ShouldClientDestroyActor()
Hey, I have a client joining a listen server and both can see each other move correctly. After the host initiates a transition from the lobby to another gamemode and both pawns have spawned, he can see both players move correctly as well. However for client I can give input and control the vehicle on the host but I can't see myself move?
How are you controlling the vehicle
It's replicating vehicle input, I am a bit at loss why it stops working after going from lobby to the gamemode
I also get this warning but not sure if related "No game present to join for session (GameSession)", it almost seems like the client is connected to the host but in its own world
The problem with this is that you'll just have duplicate actors. When they come back into replication range, a new channel will be created and a new actor spawned
Even if they are part of the level? Surely I've seen in the past where, if I had an actor that was part of the level, moved out of rep range, and came back, it picked right back off where it was?
If it's a map startup actor it has to be stably named
So they must be spawned independently on Server + Client with stable names, trick the engine into thinking it's a map startup actor, and the rest should work
But channels will still be created/destroyed

hmmm, is this a silly approach?
And opening a channel sends all properties that differ from the serialized defaults
Because change history is lost with it
I imagine this is also something that you ran into with HLL no?
nah, we don't pool anything
The bullets are data only, no actors or anything
yeee
Damn
Is this actually an issue?
since they're all projectiles, so actors would never have scaled
Maybe, closing/opening channels a lot isn't advisable I'd say.. it's cheaper than spawning new actors ofc
Gosh I'm starting to think it might be better to just serialise the whole pool to disk or something. It feels dirty but this whole set-up is starting to cause a lot of friction π€
Place the pool on the map in editor
Yeah
π
Tbh, could just make them non replicated
I ended up using dormancy for pooled actor-based projectiles, still hits a peak though
And have the server just give instructions
To see if I get it:
- Spawn the whole pool on client and server, with exactly the same names.
- Trick engine into thinking it's a map startup actor (how though?)
- Rest automagically works
- yeees
- set bNetStartup = true
- in theory...
Whether it actually saves any real cost is anyones guess though
I would love to hear a few more words about that. Wouldn't you run into the same issue where the actor needs to be spawned in client-side once it hits rep range?
- engine makes you pay for messing with it
Well the spawning itself hitches a lot, which is why I wanted to pool to begin with π€
Trying to remember how I did it but I think the gist was:
1- Spawn a pool or replicated projectiles with the weapon, they should be dormant.
2- Remove from dormancy when "fired"
3- Return to dormant when "finished"
The downside is, dormancy has the same issue of sending all properties
So I had to trim down the # of replicated props per projectile to as minimal as possible
So still hits a ceiling
Got to about here:
https://www.youtube.com/watch?v=Y733GJnatpc
But still, the actor has to be spawned client side each time it wakes up and enters rep range right? Which defeats the point of pooling?
Dormancy doesn't kill the actor
If you're talking about relevancy range then yeah, that's a problem still
Yeah π€
But I don't see any good way around that tbh.. maybe the net startup hack might work
Still gnarly though
- I spawn 10 actors for my pool on the server, at 0,0,0.
- Player is 5KM away from 0,0,0, so pool is out of rep range, and pool actors do not exist client-side.
- Player requests something from the pool on server.
- Server moves the pool actor, client has to spawn it separately and pooling falls flat on its face
Gnarly indeed
If scale is such a concern, not using actors at all is probably a more sane approach
more E N G I N E E R E D though
The other massive problem I had is
You join a game where a few vics/weapons have spawned
Client times out trying to spawn all the replicated projectiles, majority of which aren't even active
IDK, it gets complicated
Multiplayer 
Is it possible to replicate a property to a specific group of clients?
negative
Well that's not strictly true, you can do some stuff with custom net delta serializers but for the most part, nope
I did take a look at doing something like that once
It wouldn't be too hard to create a custom condition and handle it
but there's likely better ways to do what you're trying to do
The closest thing i found is this AActor::IsNetRelevantFor
You can replicate an actor to specific connections yes
Which would be the easy way to replicate properties to a selection of players
Does RepGraph handle changing dormancy at runtime, automagically, yet? π€
void UReplicationGraph::NotifyActorDormancyChange(AActor* Actor, ENetDormancy OldDormancyState)
Seems like!
π₯³
There is a GenericToolServer.exe that is being distributed by Epic with the NASA MarsXR Challenge and requests network permissions independently of the standard Epic/Swarm editor request for similar network permissions.
It's unsigned. They assert that it is included with the Editor -- "this is a default message whenever you want to connect to a server using unreal engine multiplayer".. However if I search for that tool with my 4.26 or 5.0 installs it isn't found.. but there are 3 copies of it within the Challenge installation.
any thoughts?
it requests at installation, not when you are already in the editor and trying to run a multiplayer game
depends if u want to write custom udp shit or not
post bins
where
so how do i deal with notifies that play from a replicated montage?
the server is firing it two times of course
Hey slackers. I am currently encountering an issue described perfectly at the given link. The players are spawning into the server and seeing the map through the player controller, then they possess the pawn and have their vision blacked out appropriately for the level to load. I was wondering if anyone knows a way to block out the player controllers camera on start up, to avoid that view of the map. Using the player camera manager or a UMG to cover the player controller has not worked for me. Both are not active when the controller starts up.
Link: https://forums.unrealengine.com/t/multiplayer-level-open-glitch/51792
When my client joins the server (via open ) there is always a brief 1/2 second where the client seems to be rendering the view from the 0,0,0 position of the map. After the 1/2 second the player pawn spawns and the view is correct but that 1/2 second view is very annoying to me. How can I make this stop? You can see this easily enough with a ...
Hey, replication graph question, getting a server crash due to this ensure in UReplicationGraph::ReplicateSingleActor():
Something I don't get, isn't an actor that's getting destroyed supposed to be removed from the rep graph and not replicated?
Are there any pitfalls I should be aware about?
Use a camera fade, fade back in when the pawn is acknowledged on the client
Unfortunately that starts too late if I do it on beginplay so I still see the map, and it doesn't seem to work in the construction script
Use a loading screen perhaps?
Where do I attach the UMG? If the loading screen is a umg, that what I have seen in my brief research. Attaching it to the player controller before loading the level?
Ok, so.. I really dont know if this is the right place for this but I made a transforming mechanic, which now finally works if you do netmode client with 2 it works and matches, but if its netmode listen server the I assume host it is backwards. What is the possible problem or does it not matter?
Don't know what transform mechanic is or does programatically. If it doesn't work the same for one player as another regardless if they're listenserver or a client, then it's not being RPCed and replicated properly.
I have basically 5 characters and a human, the player can change to a character and human back and forth, I have "isHuman" and "isTransformed" both with repNotify. First one is where the custom events and the button press it located, the second is the multicast and the third is the graph inside isTransformed if this helps
anyone can send me something regarding animation notifies when dealing with network? i cant find sheat
Animation notifies won't trigger on a client if the animation is playing on a server and vice versa.
They will only trigger locally.
They're probably playing the same animations, yeah.
If you want network stuff to fire off when anim notifies happen, you have to add an extra level of code yourself to do it.
yes but im having trouble understanding what's happening in the first place to be honest
Hello, I'm attaching my characters to other actor when they get close, but on the client the character is out of sync, keep moving forward. I searched and found that there's a bug report on this, but it's been 4 years ant still the same issue on UE5. Anyone know if there's some way to fix it?
at the moment the montage is multicasted and the notify runs two times when asked from the server
How are you multicasting it?
from the server
You should be good then.
why is the notify triggering 2 times on the server then?
the code is really small and all inside the notify just to make sure nothing else is breaking the thing
Hello everyone. I want to ask you it is possible to predict AI-characters movement?
I have game I connect my camera to an AI character https://youtu.be/RG3_IHL0Wwc
But my AI is always a bit lagging, network settings is default π¦
It is possible to fix it?
Hello folks I hope you all are doing well. I am working on a multiplayer game for few months and now I am trying to create network system and there are two ways that you setup up your game on dedicated server but I wont use them because that's too expensive for me. And second that user can create its own listen server but that works locally and for all over network you need to port forward in your router.But there is no implementation or tutorial how to do it automatically without prompting user to do it. Can any one suggest me some ideas or advice.
Plus I use EOS online services but there are some issues for brand account only registered email can access EOS and not available for all users.
Listen server can work with Steam or EOS or whatever.
ill try again, does anybody have any idea on why an anim notify state on a multicasted montage run twice on the server?
im going crazy
Subobjects can not manage their own relevancy, right?
They are strictly bound to actors
In a party game do I store information like player scores, cosmetics and items in the game instance on the host or the gamemode?
Or is there a better place? It doesn't need to persist through game instances. In fact I don't want it to persist through game instances, I want it to persist only within the session
no it uses the actors
Game Instance: Stored specifically on the running game instance. Not replicated. Not accessible to any other instances of a game (eg. A server cannot run a "Run On Client" RPC on a client's Game Instance, nor can a client run a "Run On Server" RPC on the server's Game Instance)
Game Mode: Only exists on the server of the game. Not replicated to clients. Store data specifically regarding the game that clients should not be able to access.
Game State: Replicated. A single instance is created for the level. This should be used to store data about the current game session. Eg. Team Scores, Round Time Remaining.
Player State: Replicated. An instance is created for each player controller that exists in the game. This can be used to store data that all clients may need to know about any particular player. Eg. Player Name,
Character/Pawn: Can be replicated. Should be used to store data specifically about that character that doesn't need to persist through respawning. Eg. Current & Max Hitpoints
Player Controller: Replicated, but only to the owning client, no other clients can access. Should be used to store data that pertains, or can be replicated to only the specific client.
So based on the needs of who needs to know about your values, you should choose the appropriate place that:
- Stores data that is relevant to the class used. (Eg. It doesn't make a lot of sense trying to use a Game State to store information about the cosmetics a single player has unlocked.)
- Allows for replication as needed. (Eg. Game instance is completely out of the question as it can't replicate. It also doesn't make any sense to use the Game Mode to store the information about the cosmetics a single player has unlocked as it cannot be replicated to anyone from there.)
- Persists appropriately without having to re-replicate the data. (Eg. A "Character" class doesn't make much sense as when the player dies and respawns, you shouldn't have to re-send their cosmetic data)
- Allows for replication to the required people. (Eg. It might make sense to use the PlayerState or the PlayerController for replicating the available cosmetics, depending on if all clients need to know if that client has unlocked those cosmetics or not. If everyone needs to know, PlayerState. If only the one client, PlayerController)
Wow, that is very helpful thank you very much.
I didn't realise how they all differed from each other - especially the player controller.
I am stuck on scores though. You mention game state which I don't doubt is right, but as I use different levels for the different minigames there would be different game states. Would I need to pass the score from the previous game state into the next game state with the necessary changes?
You can store the score in the Game Instance at the end of a level and read it back into the gamestate at beginplay if others need to see it.
But then you gotta make sure that value in the game instance gets reset whenever an entirely new session is started.
I see, so for transferring the information through minigames I should store it on the game instance for the host at the end of a minigame and read from that gameinstance when the level starts for other players to see. I could probably just reset it when the host starts/joins a new session
I think I also need to move my UI functionality onto the player controller (like main menu pause menu etc) because it doesnt make sense to be on the character
The first part of this has me a bit confused.
If the game instance is the server, it can only use "Run on Server" RPC. If the game instance is a client, it can only use "Run on Client".
So if I had 2 custom events, one running on the server and one running on the client, the host would only have the server event run, and the client would only have the client event run?
Or does none of these work as "Run on Server" is client > server, and "Run on Client" is server > client
Game Instance cannot replicate. You can't run any RPCs on it at all. It'll only ever be able to execute on the local instance of the game that is running
I see, it still has the checkbox for "Replicate" with the dropdown so I was confused as to why it was there.
So if I want only the host to run something on the game instance I switch on has authority?
Yes and no. Authority doesn't check if you're running on the server always. Eg. If you're in the game instance already, everyone has authority of their own game instance. As long as you know you're running on the server using it, then yes.
Eg. Enemy takes damage and dies is usually calculated while running on the server under a "Has Authority > Authority" node, so calling game instance from there, you're probably running on the server already.
Weird
Am I right in using the Game Instance for transferring information between my levels in a session?
It just seems to work so weirdly with multiplayer that maybe there is a better way to store per-session information server side
Does anybody know if there's something already some function already built into the properties system that you can call to determine if a replicated property has been synced to all clients? As in it has net serialized to all required clients yet?
how detrimental is bandwidth spike like this?
What i understand is Unreliable RPC calls might not be sent depending on server load, but what about replicated variables? are the changes to replicated variables guaranteed to be sent/reach the client? what if i have an important information update like player items, should i use replicated variables or rpc?
replicated or rep notify probably is better
Also if have a a system that run fine with replicated variables, is there any bad converting it to RPC? like no more replicated variables just RPCs
Better than rpc?
RPCs and Replicated variables as well as RepNotifies are used for different reasons
You can't say they are better or worse in general
And you can't only use one of them for your game
What about this? because i feel like i will have more control with RPCs
Replicated Variables should eventually reach the Client.
RepNotifies in addition allow you to execute code inside the OnRep_ function.
RPCs are for one time events and can be divided into Reliable and unreliable.
You should never use RPCs for State changes basically
One example would be an exploding barrel
The explosion VFX and Sounds (if the Client can't predict them) would be an Unreliable RPC, because they aren't important if they are dropped and they are only interesting to whoever is close to the barrel. Not to people that come in later or aren't even connected yet.
The visuals of the barrel, being it is destroyed and some fire is permanently burning in it after the explosion, is State. Represented by for example a boolean bDestroyed.
This is something you want everyone to see even people that come close to it an hour later or people that join later.
So here you use a RepNotify boolean where you change the mesh and turn on the VFX etc in the OnRep function
So again, RPCs and RepNotifies are for different usecases. You can't only use one and there is no better or worse despite simply using the wrong one.
This part is killing me, whats the reason?
Because RPCs are only executed for the clients that are relevant at the time of sending it. So connected clients that are in range.
They won't fire again for someone who joins later or comes into relevancy range (e.g. a huge map where you don't care about the barrel that is 5km away)
Aha, what i meant is calling the rpc when the client requests the change
If you change the mesh of the barrel with it and someone comes into it's range later or joins later,the RPC won't fire for them again and the mesh would be wrong
like for example, an inventory system where a player drags and drops the item, client sends RPC with index and item to server, server checks if valid then sends another rpc to update inventory indices with items
RepNotifies will however call again whenever the variable replicates. So a new player will get the new bDestroyed value and the OnRep calls and the mesh will be correct for them
We are talking server to clients here
A server RPC (sent by a client) is fine as it has no replicated variable equivalent
Sorry my question wasnt clear enough
The inventory example is a bit more tricky
Yes you would send a Reliable Server RPC to the server to tell it that you modified the inventory
But doable, but will it be any bad compared to replicated variables? like performance wise or bandwidth
Yes exactly
The callback can then be a Client RPC, however a lot of users here would say use c++ with a Fast array bla (can't recall the name) for the inventory array because that has OnRep functionality per changed entry
Which is not a thing in BPs
So that more advanced array would basically tell you the changes while sticking to the idea that it's basically a state and should use a RepNotify
Only reason I'm saying this though is to make sure the whole state vs one time change is clear
You can use the client rpc to tell the client the update of the inventory
But you can do that with RPC, if i undertand
It might even never break in that example
Yeah but it's a special case. You could for example not do this with an inventory that is for the whole server
E.g. a Chest
Cause the other players that join later would not get the update
The idea is i had inventory system built with Only RPCs, now i have one with mostly RepNotify Variables, With RPCs i had way more control, Im just wondering is there a donwside to only using RPC performance or bandwidth wise?
Ahha, like for marketplace right?, that makes sense
Yeah or just a chest in the middle of the map like for Survival Games
Yes, but you can request the items from the server with RPC when u open the chest
I don't know about the performance diff between the two concepts to be honest. It rarely matters and there a lot of other things you tweak if bandwidth is an issue
That introduces latency when the users interacts
Would be much nicer if the chest was in the correct state when opening for instant feedback
Yea i agree
Or, you can call that RPC with Collision Box to make it nicer for instant feedback
Its like you have way more control with RPC, if i understand correctly
I mean sure. You could craft a system like that it might work fine for this usecase. My explanation is for general decision between the two concepts and while there might be some overlap between them, usually you find yourself using one over the other cause otherway round needs lots of workarounds
That depends what you mean with control
Reliable, unreliable, when to send the changes and things like that
Why is there a need for more control when all you want is the client to have the latest inventory array
The RPCs are still send whenever the engine can. You calling them doesn't guarantee timing
Could even be that a variable replicates before the RPC is sent
Or at the same time fwiw
The reason is, there is a chest i want to show a group of clients Items A, and another Group of clients items B, if that makes sense
I find it easier to do with RPC than diving deep into Replication
Sure
I can't argue against that cause it would need some more work to get this going with just replicated variables
I would probably still go for the more work approach
Yea thats the only downside i found about going only RPCs so far, extra work
But that's up to you. Can only give you the advice here
I really appreciate the information, and sorry for taking so much of your time, Thanks!
guys can u give me advice ? So, I have created a dedicated server where I can connect using IP 127.0.0.1. Then I have added an EOS subsystem to the project and to do this I have created in C ++ functions to create a session, find a session and join a session. I need the game to work so that my dedicated server will run all the time, where sessions will be created, so the session creation will still take place on the server side. I did this by calling the create function via blueprint using a custom event on the server side but it doesn't work. I don't know how to do it can you advise me? In short, I need a server that will run 24/7, I will connect to the game (to my server) and there will be sessions (games) created on the server where we will connect as players.
You're going to have to be more descriptive than "doesn't work."
100% rpc is not the way
its answer for me ?
Yes.
I was printing messages in LOGS (creating session ETC) And I was calling these functions on server side and when I was watching logs of a game and also log of server aftter clicking on CREATE SESSION inside game I got log message ( created) in my client game log not in server log
so i thought its running still localy not on the server side
So how are you calling these functions "server side"?
like this
You can only call server commands like that on client-side actors that are "client owned" - character, player controller, player state, etc.
Call it via your player controller or player state or whatever
EOS -> Pc -> server -> EOS
what but code is in game instance or how do you mean it maybe I am too dumb XD
You can't use the game instance to do it
-> means "call a function on"
so Should I code this inside player controller ? but its right way ? I want make a multiplayer game where server will run 24/7 and games will be created there players will join sessions or leave
I wonder if some short pdf or book about development of that type game does exists ah
I want make a multiplayer game where server will run 24/7 and games will be created there players will join sessions or leave
this make no difference to how server RPCs work.
i know but i dont actually know how its work exactly ah... but okay I will make these functions inside player controller and try it but problem is that instance is c++ class and I have it coded there and maybe I need make new player controller with c++
If i have an array of structs inside an array of structs how can i tell which value has changed OnRep? do i have to loop thro all of them?
in c++
Does any know if the method "onMovementUpdated" in the character movement component is called every tick?
Loop time, @ancient adder
Anyone?
is there a certain way to take control of the server model??
when playing i can use the client model to move but when i switch back to the server screen im unable to move the other model
any ideas??
(btw its set to "play as listen server")
Can someone point me in the right direction on how to replicate animations when using this new "Blueprint Thread Safe Update Animation"?
I have a bunch of variables in my ABP that feed into the state machine. But I can't set those to be replicated due to the above, it results in compile errors.
Kick client if you join from standalone if in viewport mode works correctly, how to fix it?
I don't get it. Nothing in the anim blueprint of the Lyra game is set to replicated but the animations all work fine over network obviously.
How did they achieve this?
Anim BPs don't replicate
You replicate values on the characters, and the Anim BP uses those values
Yeah that's how I would normally do it.
But within that Blueprint Thread Safe Update Animation thing you have to access properties, which I cannot just modify or replicate on my character.
So how is that done?
I have an InventoryComponent for each player, stored on their PlayerController. This mean that functions like "AddToInventory"/"RemoveFromInventory" should be Client functions, not Server functions, right? Right now I have them set up as server functions that are being called by other server functions (e.g. "DetectedItemPickup"), but it looks like they aren't getting called at all.
I'm also curious... are there any good guides on best practices for ownership? E.g. in this inventory system, new item objects are spawned and owned by the server, but when player's pick them up and have them in inventory/equipped I figured I should make that player the owner. Is this reasonable?
Okay I tried the normal approach with regular animation blueprint update function and replicating the variables in the character class.
Almost got it, but it does not replicate from client to server.
Does anyone see a mistake?
If you're this new, don't bother with EOS right now. Just develop the thing while testing dedicated server on a 2nd machine or PIE.
Why are you doing it like that.
@dark edge I don't know it better. Got a suggestion?
The movement is predicted
Just set up animation to be driven by movement (idk if last input is predicted/replicated or not) and it'll work everywhere. Look at the default 3rd person template
Velocity and forward vector are already synced
I'll study the template. But for the sake of learning: Since I will need to replicate variables eventually, what is wrong with my approach?
Taking animations out of the context. Just in the light of variable replication.
Skip the multicast, the variables are replicated already
But also remember that they aren't gonna be smoothly updated per frame on clients, you'll want to do some clientside smoothing for stuff that changes rapidly.
Like say you're replicating a vector AimPoint
So client sends it to server (unreliable run on server event on tick)
Server sets replicated variable
It won't necessarily update as smoothly on remote clients as it did on the sending client (bandwidth, jitter, etc)
With the multicast either multicast or replicate state, don't do both (they'll conflict)
With your code, a remote client is setting Velocity on the multicast AND when the server changes it and it replicates. So it'll be spazzing all over the place.
FVector replication is now 200 bits?????? π©
Idk, maybe the switch to doubles?
yes π it seems like
FVectorf and FVectord were the explicit types, right?
20 bits per component for the quantized ones
but yeah replication budget goes up by default
also I'm seeing this Shared a lot in the Net Insights profiler... and I don't know what they are referring to
I think I know what it is... but haven't dug in the sc to confirm it, if someone here knows I'd appreciate it
bumpin because this is a little annoying, and I can't find a documented cause for it oof
This event is not firing for me at all (took inspiration from the third person template).
Why?
Hey, wild question but I have a security system using scene capture components and it's viewable on a widget and works fine but if the camera is too far from the person looking through the camera nothing is replicated through the captured camera. Im pretty lost on how to handle.
You may need to set it to be AlwaysRelevant. It sounds like the Camera Actor is being culled by Network Relevancy.
so interesting enough that didn't work but if I set another character to always relevant I was able to now them on the camera.
if anyone is interested this seems to have fixed the issue. idk if its the best way to handle it but it works well enough.
@dark edge I did it now as per the third person template and none of my animations are replicating (and they are using the 3 vectors you see in the picture). I am lost
Destroying a replicated player (actor remains visible)
Hello,
I have a dedicated server and some clients. On the server, each client's AMyCharacter spawns an actor (MetaHuman blueprint) that it attaches to itself. The replication is set so that they appear and move correctly on all the clients.
The problem is when a client quits (OnLogout, the server calls DestroyActor on the controller), the MetaHuman stays present on the server and can be seen by remaining/new clients.
On the server, UWorld::DestroyActor is getting called for the AMyCharacter and the AMyCharacterController,
but their virtual destructors aren't getting called.
Do you know where I might be going wrong?
Thanks very much π
Question
If my host commits a "damage" twice,
should i not multi-cast line-traces, and the dmg apply of the line trace?
https://gyazo.com/dad40c4c7667c7f947708c903f23c159
https://gyazo.com/61561a9af9ab7879bec9b5b540823b2e
this one for e.x hits users twice
Hi everyone, Iβve got multiplayer working on my VR game. Iβm now trying to setup user profiles so each user can save settings and avatar changes etc. has anyone done this?
My multiplayer is hosted on a gcp server
This setup seems to make no sense. You donβt want to do line traces or run other logic from a multicast
hm? i tought ya always had to multi-cast visual effects
I have a replicated actor containing a 3d widget and a sphere collision. When a pawn overlaps with the sphere collision, I want the widget to be visible only to that pawn. I'm messing around with owner no see and only see, but I'm not sure if that's what i need to do. Any ideas?
From a really high level, can someone explain some of popular methods (even conceptually is fine) for making the player lock their rotation to a target? I've heard that PhysicsRotate is one way its been done. I've looked at that method and I am not quite sure what benefit it would give me over calling say SetActorRotation from the server on the player character's or controller's tick
I originally thought that I would use AddControllerYawInput and just handle it client-side, but I was told in the CPP thread that it was not a good idea to do that.
If you call set ActorRotation on the server, wouldn't it have a better chance to cause corrections?
(which you don't want of course)
so far, I've tried a few things. They all either don't work at all or get me close but have issues. Right now I just have a check in the character's tick to see if the target actor is valid. If so, then try to "lock on" to it.
Super::Tick(DeltaSeconds);
if(IsLocallyControlled() && AttackComponent && AttackComponent->IsCameraLockedToTarget() && CameraManager)
{
const FVector CameraDirection = CameraManager->GetCameraRotation().Vector();
const FVector CameraZeroedDirection = FVector(CameraDirection.X, CameraDirection.Y, 0);
const FVector CameraLocation = CameraManager->GetCameraLocation();
const FVector SourceLocation = GetActorLocation();
const FVector SourceZeroedLocation = FVector(SourceLocation.X, SourceLocation.Y, 0);
const FVector TargetLocation = IRaevinTargetable::Execute_GetWorldTargetPosition(GetAttackComponent()->GetLockedTarget());
const FVector TargetZeroedLocation = FVector(TargetLocation.X, TargetLocation.Y, 0);
const FVector SourceDirection = GetActorRotation().Vector();
const FVector SourceZeroedDirection = FVector(SourceDirection.X, SourceDirection.Y, 0);
const FVector TargetUnitDirection = (TargetZeroedLocation - SourceZeroedLocation).GetSafeNormal();
const float LoopDotProduct = FVector::DotProduct(SourceZeroedDirection, TargetUnitDirection);
const FRotator TargetRotation = UKismetMathLibrary::FindLookAtRotation(SourceZeroedLocation, TargetZeroedLocation);
if(LoopDotProduct > 0.0 && LoopDotProduct < 0.98f)
{
if (LastRotationTick.IsZero())
{
/*LastRotationTick = CameraManager->GetCameraRotation();*/
LastRotationTick = GetActorRotation();
return;
}
const FRotator Tmp = FMath::RInterpTo(LastRotationTick, TargetRotation, DeltaSeconds, 0.5f);
/*UE_LOG(LogTemp, Warning, TEXT("LoopDotProduct %f. Camera Direction: %f %f %f Target Unit Direction: %f %f %f RInterp Rotator Yaw: %f Target Rotation Yaw: %f"), LoopDotProduct, CameraDirection.X, CameraDirection.Y, CameraDirection.Z, TargetUnitDirection.X, TargetUnitDirection.Y, TargetUnitDirection.Z, Tmp.Yaw, TargetRotation.Yaw);*/
const float turnAmount = (Tmp.Yaw / DeltaSeconds);
AddControllerYawInput(turnAmount);
/*SetActorRotation(Tmp);*/
/*const AActor* LockedTarget = GetAttackComponent()->GetLockedTarget();
const FRotator NewRot = UKismetMathLibrary::FindLookAtRotation(GetActorLocation(), LockedTarget->GetActorLocation());
SetActorRotation(NewRot, ETeleportType::None);*/
}
/*const AActor* LockedTarget = GetAttackComponent()->GetLockedTarget();
const FRotator NewRot = UKismetMathLibrary::FindLookAtRotation(GetActorLocation(), LockedTarget->GetActorLocation());
SetActorRotation(NewRot, ETeleportType::None);*/
}
else
{
LastRotationTick = FRotator(0, 0, 0);
}
Am I anywhere close to getting what I am looking for?
Use the same rotation method you use unlocked
Just when locked, instead of adding yaw and pitch from input, you're setting your rotation (or you can formulate it to still add yaw and pitch) based on some function (look at rotation)
There's really nothing fundamentally different between locked on and not, just now you can't change whatever direction is the locked one, and instead it's updated another way
by "updated the other way" do you mean the server is updating it instead of the client?
I think the issue is I need to rotate the camera / controller. Otherwise I would have to uncheck use controller yaw and I want both the camera and the character locked to the target
so trying to call SetActorRotation on the character class does nothing, because it is taking the rotation from the camera / controller
Just update ControlRotation using lock on mechanics instead of mouse/stick input when locked on.
Hi is there any function which one can use to get the pawn controlled by the client ?
from the client controller you can invoke GetPawn(), it is also in Blueprints
How can I make an inventory save system on a dedicated server. For example, what should I do to delete everyone's inventory whenever I want. How exactly is it stored?
how do i cast to the client controller though?
were are you trying to get the pawn?
do you plan to have split screen? or multiple players per local viewport?
actually i want to cast to the actor that is being controlled by the client player and check it equals another actor
I mean use GetOwningPlayerPawn
thanks also if i want to create the widget, will it auto assign the player controller if i dont manually assign it via blueprints?
what do you mean?
There are many ways to approach inventories, if you use the search function of discord in this same channel you will see multiple breakthroughs... as for doing an action in every client... you'd author these from the server
I mean in blueprints like when u create a widget u assign βget player controllerβ to the player controller pin, so if I donβt do that will it automatically assign itself the client player controller
Thx
uh, actually I'm not sure, let me check rapidly the source code, don't do much UI these days
@atomic barn It feels like the widget won't be created unless you tell which owning controller will hold it
Oh then how do I know which player controller I need to assign to it
The one which owns the HUD that creates the widget


