#multiplayer
1 messages ยท Page 82 of 1
Nope
the dll compiling won't affect it at all?
hmmm
so if I play in editor, would I have to do standalone and turn on the 'run in one process'?
You can also just setup a test case that doesnt require the login process
Why not just feed it a prebuilt base64 value
Just to test that your code works
Making games isnt easy.
haha ya
People think it is, until they try it.
No, no your game idea of a CryptoBarbie with NFT clothes sounds interesting.
lolol
We are trying to get it to not lag
we did a test run last week with 3 of us
and I was getting 45fps on a 5700XT and they were around 50-60fps on 4080's.
standing next to a castle that is almost fully built but
there is a 3x3 grid of world partition right now
and it's like that, with nothing but that in it.
well... I say nothing, but there's probably 'stuff'
there were floating islands before so who knows what is there.
I think the replication is what is killing it
the castle floor 1 has around 50 light "sconces' around the walls that are replicated
I am assuming that even if I can't see it, the server still tells me that it's on * 50 lights
Do they need to be replicated? Are you turning them on and off ?
you could
it's a castle that is massive, and meant to house hundreds of people
so there are floors of dining halls
and each floor has wall lights. We will probably have them on all the time
but there are ones on tables that are toggleable by players
Are you working on Third Life? ๐
Sounds neat
We want to make it so that you can use characters from other projects in it.
but that means we have to make APIs to communicate outbound to other projects.
So lets say, your doll is in space in some other one. Their servers have to request a 3D model of their character in our game in whatever format they use.
It's a nightmare
some use Unity, some use some javascript thing
Cross-engine stuff eh
Good luck, sounds like a nightmare not worth bothering with.
lolol
ya, that's in the future though
we tried to make a consortium between a few of the larger projects, and no one seemed interested so we dropped the discord server
I actually wanted to figure out how to export a character's 3D assets to some generic format as a file on a server side, not a plugin in-editor.
But couldn't find one lol
I would assume it'd have to be custom made.
like, export something to GDL or whatever that binary format is that javascript uses. or three.js
GLB
Albion guys were kind of smart using Unity as a front-end in that regard I guess.
everything else is like Python servers and what not
have a backend that converts some server side objects to X target code.
I bet they could just port it fairly simply on a client to interpret in that way.
anyway. Off topic...
back to work
I have this with server reliable, playing with 2 player as Clients but dosent move, should move right?
Im using a interface
Okay, im trying to turn on and off a light, i have a switch with a interactable interface
don't multicast
protip
just don't use multicast
until you know you want it
OnRep is your friend here
Owning Client:
Input -> run on server RPC
Server:
Server RPC -> set replicated variable
Everywhere:
OnRep -> do something with new variable
What is 'Replication'?
Ok, i dont know what is this
Read what I linked, it's down towards the bottom
but basically
special function runs when replicated variable is updated (this is good)
so when bIsPowered is updated, you can toggle the light
Mmm okay i'll try
But i never reach the Server Function because i dont have authority
I dont know why, i never reach the Server Functions
Yeah should be
I've got a problem with the fast array serialiser. I'm using it to be a more efficient method of updating my clients with the arrays but the post replicated add, etc are not being called on the listen server player
What do you mean by 'listen server player' ? The host or a client?
OnRep is only called on Clients, not the server.
These functions:
void PreReplicatedRemove(const struct FReplicatedAreaClueArray& InArraySerializer);
void PostReplicatedAdd(const struct FReplicatedAreaClueArray& InArraySerializer);
void PostReplicatedChange(const struct FReplicatedAreaClueArray& InArraySerializer);
I've never used them but looks to me like they only get called on Clients also
Yeah, but with on rep, you can call them on the server to allow the listen server to receive the client side updates
I'm trying to find the same for the fast array's functions
when it comes to the replication property Net Cull Distance Squared what geometric shape is representative of it?
I was thinking a sphere but I'm not sure
and this is applied in the z axis as well
ah perfect thank you! oop-
yeah rep graph is 3D distance as well, just actors are sorted into 2D cells first
keep in mind though the connection takes a few seconds to actually decide to close the channel, so it's not an immediate hard-cut off
but it's an immediate replication once it crosses that threshold distance?
(at least it seems immediate?)
The channel should open again once it's within that distance if it was closed, but the actor has to be non-relevant for a few seconds before the engine stops replicating it
Assuming there's bandwidth to send it in the same frame it became relevant at least
Thank you very much for your time and explanation!
Good day to you guys, is there any body here that have experience with unreal engine Steamcore multiplayer setup which is non region locked?, If anyone get the experience you can let me know so we can discuss and negotiate on my work
You have to call your add/update/remove functions yourself
No real way around it unfortunately
I was halfway through implementing my own dirty array implementation before reading this, it's now working pretty much how I expected ๐
LogGameMode: Display: Match State Changed from InProgress to Aborted
LogGameState: Match State Changed from InProgress to Aborted
LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr: 127.0.0.1:17777, Name: IpConnection_0, Driver: GameNetDriver IpNetDriver_1, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID, Channels: 2, Time: 2023.05.05-14.34.06
LogNet: UNetConnection::SendCloseReason:
LogNet: - Result=FailureReceived, ErrorContext="FailureReceived"
LogNet: UChannel::Close: Sending CloseBunch. ChIndex == 0. Name: [UChannel] ChIndex: 0, Closing: 0 [UNetConnection] RemoteAddr: 127.0.0.1:17777, Name: IpConnection_0, Driver: GameNetDriver IpNetDriver_1, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID
LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionLost, ErrorString = Your connection to the host has been lost., Driver = GameNetDriver IpNetDriver_1```
I cannot play in multiplayer in pie, here is the log, can anyone help?
Literally the first line:
NetworkFailure: FailureReceived, Error: 'Could not find a starting spot'
Should be a big clue
How do i prevent the player controller from saving a startspot?
Hello Slackers ! I'm having some trouble with multiplayer and movement replication. I want a diablo like movement, so I use the BP method SimpleMoveTo when user clicks on his screen. It works, but on the client it looks like it does not know it's moving. Like it's all laggy and feels very odd. here is a gif for sample :
Whereas on the server, it runs perfectly fine.
Anyone has an idea where is my mistake ? ๐
You should predict the movement clientside as well
And you'll likely have to implement your own replicated movement component for this kind of movement
๐
Hey guys, i am having an issue with the packaged game where i can find multiple sessions when refreshing. When i try to join one of those it takes me back to main menu only. Here is my refresh button code. It is from widget BP
So I think I found out what's happening and why I can't test this editor. It's when it tries to load a world partition map in the editor. It starts to load, I get a flash of the map and then unreal crashes ;s
[2023.05.05-18.08.26:072][148]LogWindows: Error: appError called: Assertion failed: PIEInstanceID != INDEX_NONE [File:G:\UnrealEngine\Engine\Source\Runtime\Engine\Private\WorldPartition\WorldPartitionLevelStreamingDynamic.cpp] [Line: 451]
ahhh
https://forums.unrealengine.com/t/using-pie-to-connect-to-dedicated-server-running-world-partition-crashes/532395/12
Gets rid of the crash...
Hi there. It's not rly about UE, but maybe somebody knows any good Network library that built on top of UDP and allow reliable and unreliable UDP functionality and also is cross platform. I've heard about ENet library so far, but seems like it's a bit old one, maybe there is some newer\better? Main requirement is to be decent for MMO game that means it has to be able to handle a lot of data transfer.
enet is the gold standard, it being old doesn't really matter.
it's also still under active development
Is there a way for a client to tell the server it has deleted a UObject or to otherwise clear the shadow state of a UObject for a given connection (the server knows in advance which client will be deleting the UObject since it is the one calling the RPC to do so). It's for a UObject that is conditionally replicated to some clients, but once I no longer want to replicate to a given client I want that UObject deleted on the client, but the client could later on become interested in the UObject again
yojimbo or
https://github.com/ValveSoftware/GameNetworkingSockets
but maybe UE reliable unreliable RPC is enough for u
why is it not showing the correct avatar but it is showing the correct player name? I tried it with my dad and he saw his avatar as mine and i saw mine as his. The first image shows the same as the 2nd but in the first the important nodes for the player name are selected and in the 2nd the important ones for the avatar. I can't see a major difference there tbh. Anyone has an idea?
you should be using a repnotify, not a multicast
What are you trying to do here?
but the text works
Multicast = race condition if this is a thing that happens at begin play
What are you actually trying to do?
i am trying to display the player name and avatar over his head
avatar being some image?
and does this apply to all characters on all machines?
wdym?
like any time a character is visible, they have a name and avatar over their head?
yes
ok so have name and avatar be replicated variables on the character / pawn
with repnotify turned on
and in the repnotify, do the actual "showing"
that simple
then the server just sets
Name = "Mingebag"
Avatar = Mingebag.jpg
or whatever.
And it'll Just Workโข๏ธ
well that's just a happy coincidence, that would probably not work for late joining or if there's any appreciable lag or whatever
do not multicast state, use repnotify on it
Name and Avatar are not temporary. If for some reason they don't get the multicast, they will never know.
Name is probably already replicated depending on how you're doing it. But learn Repnotify and use it, it'll be 100x simpler and more robust.
Yeah PlayerState.PlayerName is replicated
hm okay
Mingebag ๐คฃ
i'll test it out
IYKYK
For your design, start by doing this. Start by just doing bindings in your widget to GET the name and avatar.
later, you can make it more eventful to only run when name or avatar is changed.
or on whatever event guarantees an up-to-date name and avatar
make a function in the widget to update itself, call it on a timer. See if that works robustly. Then figure out when to call it (when name and avatar are in a good state)
but nowhere should you need a multicast for any of this.
Lol thatโs not at all what I expected
It was the default name in GMod so if your name was Mingebag that means you're a nub who hasn't changed their name or model yet.
depends on ur use case
Nice
When i searching sources many time i saw item instance has its own string id, i wonder why they need them? Instance object hasn't unique id itself?
anything spawned by server will be existed to all clients?
or the server needs to spawn the same thing on all clients by calling multicast?
If the Actor is set to Replicate, it will be automatically spawned on Clients
The base actor class is set to replicate, it will apply to all child or they needs independent call for set to Replicate ?
The child classes would also then be set to replicate
Unless they themselves have overridden that.
You may need to do some reading on the concept of Inheritance in Object Oriented Programming
I have an Item base class and it is set to replicate true, and that class has a child called WeaponItem, when I spawn weapon item on server it spawned in the level but the skeletal mesh comp in this actor is not replicated
if I set to replicate true on the skeletal mesh comp, it replicates
yes, by default it is set to replicate because the base class is replicated.
but spawning it on server, the components never replicates unless I set them to true as well
I read somewhere this is a bad practice to replicate comps separately if the actor is itself replicated
actor should replicate them automatically
That makes no sense
It might be bad practice to circumvent component replication and do it yourself. But you still have to tell the actor that a components wants replication.
is there a function to define this actor should replicate all of the components it has?
Ok, I will tick the boxes of all of them, but still I am strongly thinking that I need to replicate the actor properly using:
virtual bool ReplicateSubobjects(class UActorChannel* Channel, class FOutBunch* Bunch, FReplicationFlags* RepFlags) override;
Ok, thank you already ticked them and now it is working.
and this function is assigning unique keys for every newly replicated object?
bool bRepCond = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
if (Item && Channel->KeyNeedsToReplicate(Item->GetUniqueID(), Item->RepKey))
{
bRepCond |= Channel->ReplicateSubobject(Item, *Bunch, *RepFlags);
}
return bRepCond;
Supposing that GetUniqueID does that reliably, then yes
hmm Ok
any idea how to test the audio component between two clients on the same pc?
Have one client use the left channel and one use teh right? ๐
perfect idea
I were planning to mute the owner client which is firing, and the other client should listen to his sound
but I will follow your perfect idea
client one = left, client 2 = right
so I'm using bUseControllerRotationYaw = true and from the server I want to rotate a character that is controlled by a client, I'm getting the controller and doing SetControlRotation(FRotator), but this does not work from the server, except for the listen server player ofc
is this normal? I assumed it would already be replicated, do I have no other option than to send an RPC/create a rep notify?
It's normal. ControlRotation is a client authoritive value. What is your goal with this though? Why force the player's view to a place from the server?
Hello, In local multiplayer whenever Player 0 spawns and possesses a pawn it works fine, but if player 1 is spawned in, it seems like player 0 gets depossessed. Even though it works as intended if player 1 spawns first... Any clues?
If I feed a TMap server-side only, it is a server variable even if not possible to replicate right ?
not following the question, if the TMap is server side, it is indeed server only
But how can I ensure that the TMap is server side ?
I just manipulate it within server code ?
Not sure what you mean. If the TMap is local to the server machine, it can't exist on a client machine
Might need to post code
Not really following
Yeah sorry ofc
UPROPERTY()
TMap<FName, FGameplayAbilitySpecHandle> ServerBinds; // In the header file of the inventoryComponent
// In the function GiveAbilityCard() called by the server
FCardDetails* TempCardBinding = CardAbilitiesDT->FindRow<FCardDetails>(CardName, "Context");
if (TempCardBinding) {
FGameplayAbilitySpec Spec = FGameplayAbilitySpec(TempCardBinding->CardAbility, 1, -1);
ASC->GiveAbility(Spec);
ServerBinds.Add(CardName, Spec.Handle);
}```
I add something to ServerBinds in the function that is called from server which means server keeps track of this TMap I believe
new to multiplayer blueprints and getting real stuck... how would you go about calling a "spawn Niagara system" event which is within an actor thats spawned by a character?
THen yeah, it'll only be populated server side. On client, it'll just be an empty map
Oh ok nice
but i can do "predictive" stuff by also adding stuff in the TMap client side (not my purpose anyways)
The client can change whatever values they want, nothing is stopping them really
Hi all, question regarding Custom CharacterMovementComponent, when using method UpdateFromCompressedFlags() to update some booleans e.g. for sprinting - when trying to debug (Rider IDE), the breakpoint only stops when running as client - why is that??, and is there a way to test for listen-server? ๐ฎ Thanks in advance!
Hy so i got a spaceship which i made using blueprint. I want to add multiplayer to it how do i go about adding it
any yt tutorial suggs..
Literally a million things in the pinned messages.
its when I teleport the player
I want to teleport to a certain place on the map and then make him "look" at something by rotating him
if you wanna be able to check server vs client. Without that, in your case, it would run client code first then it would go through the server one
how to prevent spawn two players at one PlayerStart?
solution:
https://youtu.be/TkiNU5sjjXU
If I "get" a variable on the server via Runs on Server and a getter node, and then pass that variable to a Runs on Owning Client as the input for that node, what does the client actually receive? I've tried passing an actor's data component this way but the client logic always sees it as empty.
My system involves two different actors with instances of the Inventory System and I want to be able to see the contents of e.g. the treasure chest on the client. The treasure chest items are only generated and kept in the server's copy.
It works when I set the component and the underlying inventory array to replicate
Hey guys, please can anyone point me to some guide on what is the correct way to make two players posses each different pawn when spawning in local multiplayer?
when I spawn 4 players
and spawn a cube on server , the cube only shows on players index 0, 1, and 2
the index 3 didn't seen the cube
why is this happening?
Solution:
adding delay of 0.2 sec before spawning the cube solved this issue
is this a bug in unreal or what?
Hi, folks! When I'm testing multiplayer in the editor, does the Output Log shows logs for all game windows or just the main one in the editor?
Whenever I try to build a mission system that supports multiplayer, I always end up hating it and deleting it. I am always torn on how to structure the classes. I first built it to where each mission class represented a player's mission and their state, but then I didn't like it because it was not really efficient. If you have 50 people with the same objective of "kill xyz monster" then you could just have one instance of that objective that has a listener for when monsters are killed, incrementing the player's count as the requirements are met
Is there anyone here that have experience with unreal engine Steamcore multiplayer setup which is non region locked
If a UObject is created on the server and replicated via ReplicateSubobjects to a client, but later the client clears all its hard pointers to that UObject, will the UObject be garbage collected or will something keep it alive because it was created by the server?
you are calling server on server which call server again and this is making an infinite loop
Why won't this Server_TransferAllItems event fire? I call it on the left and it breakpoints there, but none of the code runs on the server event on the right
is it because the client doesn't have the ownership or something?
add a check HasAuthority
still won't get to the breakpoint
print string on remote
prints as Client 1: Hello
Only the owning client can call a server RPC.
client is not authority
a client is never the authority for a replicated actor
that's not relevant
Figured it was ownership but how do I establish ownership?
In this case it's an actor with an inventory system component that I want to transfer the items from the chest to the player inventory. So Set Owner of the treasure chest's inventory system component to the player character for this?
no
RPC through your player character
the player doesn't own a random treasure chest in the world
Not quite sure what that entails
it entails moving your networking to the player or something the player always owns
the player should not own random actors placed in the world
This is an Inventory System Component that (one of which) is on the Player Character BP
ok, and the one on the player character is owned by the player
so you're free to RPC through that
or the player themselves
Gotcha, so the game is basically saying I'm running this logic on the treasure chest's component, which I do not own
correct
nor should you own it - most server RPCs will go through the player controller, player pawn, player state, or a component on any of those.
If you want to interact with something in the world, you make a generic "i want to interact" server RPC on the player and then let the server decide how that should work with the thing you want to interact with.
In this case, maybe you have a "Transfer All From Other Inventory" server RPC on the inventory component, which then runs whatever you want on the server.
So here, I was calling the Container's component
The bottom one there is the player's
Right, so you'd need to be calling something on your own component instead, probably passing in the container's inventory as an argument.
aye, lemme swap those see what happens
sweet, we made it to the breakpoint lol
with tons of other bugs, but progress
thank you
hello so i want to make a pawn Blueprint which i made for spaceship movement to have multiplayer in it. i tried to follow a tutorial but couldnt get it to work. (the image is for spaceship yaw).
i made similar ones for the pitch and thrust
but they dont seem to work
the client doesnt update the position of the server spaceship, and the server spaceship in the client window dissapears suddenly
how to call this MyFunction on Server in MyFunctionServer in C++?
MyFunction(AItemWeaponMag* WeaponMag);
UFUNCTION(Server, Reliable, WithValidation)
void MyFunctionServer();
MyFunction will need arg , dunno how to do it ๐ค
thinking to do
UFUNCTION(Server, Reliable, WithValidation)
void MyFunctionServer(AItemWeaponMag* WeaponMag);
but I don't like it
That is how you do it
Hi all, I would to save player location to database (mysql) on multiplayer in real time. Anyone has any ideas for this? thanks
Wouldn't be ideal, I wouldn't do that since your mysql instance would be very draining on CPU/RAM etc
Instead, update it on player leave (if you are doing a game that you spawn in the place you left at) and possibly every 10 seconds or more
I am thinking to use socket. do you think it is a good way?
Hello everyone, I need help here, there's a race condition happening here I guess and I do not know how to handle it.
the problem here is the server will set the max speed and everything is fine, but once I call the clients to edit theirs it fails to get the pawn.
but it worked if i add a delay before calling it on clients.
this is my PlayerState Blueprint, and this called after PossessedBy() from the pawn
If you want the server to push updates to the client, I believe you need to use onRepNotify
hello people
I'd like to make an open world multiplayer game and I was wondering if any of you could point me into a direction for what to look online since I don't know much about making a multiplayer game
Check pinned posts in this channel
will do, thanks
What's going to be the most efficient, yet somewhat acceptable way to handle dead bodies in a multiplayer game, where I want to support 100ish players? Right now, I'm trying to get the character mesh to ragdoll when someone dies, but the physics replication is a nightmare. If I spawn a ragdoll actor, it still has the same problem, but there's a hiccup where there's either two bodies or the first one disappears.
The other option is a replicated FTransform member variable, but that only transforms the mesh's position, not the bones/etc. The other idea is the replicate a transform variable, and let each client do their own ragdoll calculation, and just use the transform to keep it in the same spot for everyone.
Not sure what to do.
don't replicate it at all ideally - let clients handle physics themselves. If you really need to keep them all in sync then leave them at a very low network tick rate and think about only replicating a single location rather than the full state of the ragdoll.
How do you check authority in Components. Since they are not an actor or character, checking HasAuthority seems to mean nothing here. Would be great to get some help on this, thank you.
It's based on the authority of the owning actor
So you can do GetOwnerRole() == ROLE_Authority
Thanks @solar stirrup .
I have the following scenario where Authority is never true, even though I am in a networked game.
Authority = running on server. Did you drag a node off the remote to see if youโre running it on client ?
Works when I move the node to remote.
Yeah, so your event is running on the client
You should go quickly check @sinful tree โs recent post in #blueprint . He gave a very good explanation to a question there that was prly meant to be in this channel to begin with
Okay perfect. I think this was the direction I was going in. Going to replicate a transform variable at the root of the mesh to keep it in the same position, but let the physics be handled by each individual client.
Actually. I derped. The actor's world location is replicated, so that's all that's needed to do. Whoops.
you'll notice hard snaps when reping down ragdolls
thats normal due to the unevenness nature of the ragdoll
and the accumulated time error sums up, attempts to snap, it fails and repeat until server doesnt seend more loc updates in physics state update
Actually, I figured out why this happened, these functions are being called after BeginPlay immediately, which in that time the server hasn't replicated the pawn to the client ( or something like this ).
And I solved this by adding a short timer to check whether the player has a valid pawn or not, then I call these functions.
note: the Applied value is replicated.
Hi everybody!
I'm moving my BP multiplayer (Listen server) prototype to C++.
Previously for my map generation (Think something like Diablo) I was using a "MapGenerator Class".
I'm now thinking on moving that functionality to GameInstance (Or maybe GameState) is there any obvious disadvantages for this?
i'm going to check those, thanks!
Hi! I'm wondering if anyone has some clever way to structure their networked code well. I find that since RPCs can only be called by their owning actor, I end up having these big messy "god" classes with a bunch of different RPCs responsible for different things. Ideally, I want to split up the logic and behavior into smaller, more concise classes that are responsible for performing specific tasks. While components can be helpful for this purpose, theyโre not always the best solution.
I have an interface in C++ with a number of child classes; each child has their own different behavior, somewhere within those implementations, I need to call RPCs to achieve my desired behavior. I currently have those RPCs defined in my Actor class, but I would like to move them into their respective implementation. I was thinking of making my classes inherit from UObject and making them a subobject of my actor, would this work? If not, is there any good way to define RPCs outside of an Actor/Component class?
Could you go into more detail as to why you want this?
With specifics
Its unusual to want to do this for RPCs alone
Asking this type of question could generally indicate a potential design pattern issue with the way you are using RPCs or your interpretation of how and when to use them.
Keep in mind, you dont need to keep implementation details in the same .cpp file.
You can split your implementation out into separate .cpp files, so long as the .h contains all the appropriate declarations.
If this is purely a code organizational exercise.
Yeah it's purely for organization. Having the RPCs in different cpp's is what I'm currently doing, just wondering if there's a better way.
In general, I'd prefer a lot of things to be data oriented (traditional ECS), but it looks like OOP is the preferred method in UE from what I've seen.
I've heard about Mass, but I haven't really looked into that yet
RPCs and Replication in general need to be handled by an Actor with a Net Owning Connection. So generally approaches to organization outside of AActor and UActorComponent are not appropriate.
Calling RPCs from a Component also incur a slightly higher overhead than just simply doing it through the owning Actor.
What is the overhead? An extra ID or something?
Yeah to identify the component
Ah
So you are pretty much stuck with separate .cpps
Curious though, for this to be a problem, you need to be declaring/defining a lot of/large RPC functions
Is this the case?
No, just being super picky and trying to get ahead of a potential problem if possible.
Hahaha, you're probably right
Take a look at the ACharacter class, it is probably the heaviest user of RPCs you can find in the source code.
Just kinda poking around and seeing what I can do, since I'm new to using the engine.
It in conjunction with the UCharacterMovementComponent may help you see that you can still be organized within the same files with a lot of RPCs
Yeah, the Character class is sort of what spawned this question
I'm implementing my own movement netcode since I'm pretty particular on how I want it to work. Took a look at how UE works out of the box and noticed that the character class is huge
Yep
Its extremely complex.
But it is a fully featured AAA quality battle tested character movement class.
Also built for a specific genre of game as well mind you.
So if you need something different then you maybe able to get away with making your own.
Choose the right tool for the job
Yeah, I think the complexity actually scared me away from using it since I'm not 100% on how it all works. I'd like to have a full understanding of how everything works since it's sort of the cornerstone of how the rest of what I'm doing is designed.
I guess while I have you here, how well do you know the movement system? Really the end goal of what I'm looking to do is implement something similar to Overwatch's netcode design
Which part of their design lol?
Which I'm sure it handles prediction and reconciliation well, I'm just not sure on how to expand on what's there
The CMC and Character class handle prediction and authoritative corrections
What exactly do you need to expand on?
Well on example is rollback hit detection
I thought you might say that.
Hahaha
That really doesnt have much to do with the Character
Only that you probably want to have some sort of buffer that can "rewind" the Character.
Yeah, does UE have that built-in?
Other than that, its mostly how you go about implementing your Hit stuff
No
As its pretty game specific
True
The UT Source Code on the Epics Github page has rollback from what I can remember.
Really all I know about CMC is that deals with prediction and corrections and also supports root motion
Which is pretty much all it should be doing anyway.
Rollback is more about the hit than whats being hit.
You will typically only want to deal with rollback for hero actors, actors like the Players character and anything else that maybe dynamic and important for hitreg.
Yeah makes sense, is there anything else that CMC does that I didn't mention
Rollback can also be as simply as just buffering the Capsule location and performing the hit test against that.
It all depends on how accurate you need it
Not really.
Unless you start talking about its movement capabilities.
Yeah
But those arent really related to prediction etc
Id recommend taking a look at the UT Source Code if you havent already.
Its old, but is a great reference for these sorts of things.
They also fully predict projectiles as well.
If you also want to add further complexity, make sure you get a handle on GAS.
Its not for the feint of heart.
It seems like another intimidating mountain to climb
There are a lot of tools available and yes, some can be daunting to use at first.
I guess it really comes down to, does the benefit of learning GAS out weigh just implementing your own solution?
It does in all cases, at worst you come away understanding WHY you don't need it, which is not a waste.
Since you will have a better understanding of what you need and how to build it.
Ok cool, thanks for all the info. I was pretty dead set on just implementing my own solutions since I'd be 100% guaranteed to understand the in's and outs, but this conversation changed my mind quite a bit.
Back to hitting the books I guess ๐คทโโ๏ธ
I feel most of the time when it comes to UE, reinventing the wheel can be a big mistake.
Unless you understand why you want to
Utilize what already exists first, especially when you are learning, since you will have a framework around you that can keep you centered.
Thatโs good advice for programming in general
Learn those tools, you can come away from that knowing of at least one way something can be built.
โStand on the shoulders of giantsโ as David Malan says
Which enables you to identify potential improvements if it was done another way.
Starting from scratch on your own, you will likely often find that what you are doing has already been done and likely in a better way.
Which is like pushing a rock up a hill and finding out there is already a rock at the top when you get there.
Which sucks.
Yeah, I'm really bad at not reinventing the wheel ๐
I'm used to dealing with engine-level stuff, which always leaves me with the attitude of "well I know what I want, I might as well just do it myself instead of wasting the time learning this new tool/resource", 95% of the time that attitude backfires
Yep.
Even if the system itself isnt available, there is almost always plenty of resources online on how to do something.
Like Rollback for example.
It doesnt exist in a neat little package/plugin.
But its a very well known concept and resources for understanding it exist everywhere.
When playing in editor for some reason player controllers are never local for clients, what am i doing wrong?
Player controller only replicates to owning player, that's normal. But do you mean by player controllers are never local for clients exactly?
The player controller creates a widget on beginplay. the widget itself has some code that needs the widgets owner (which should be the clientโs controller) but it always returns the listen servers controller. i probably overlooked something crucial
furthermore, checking on client if the controller is a local controller returns false, which doesnt make sense to me.
are you checking the authority?
you could wrap the widget creation on authority check
so that it only gets constructed on clients (not ure if it's 100% necessary)
ive tried that as well yes
I've never used checks for local controller, only authority checks
or netmode checks
what do the authority checks return?
it creates the widget but the controller is still the same controller as the listen server. it's like all clients and the listen server have the same controller
hold on i think i done goofed....
ofcourse each the client is gonna have the same name for their controllers cause they define the name themselves, not the server assigned name (since only the client controller exists on client)
well dont mind me im just dumb xD
still doesnt explain why the playerstate is invalid but at least i know its not because of a supposed controller issue
in the CMC, when the server gets an "somewhat" old movement from a client... does it rewind the other client's CMC to simulate? ๐ค
or does it compare the "old" movement with the "actual" state of the universe? ๐ค
In a multiplayer game (or not), do you guys/gals put the blueprint nodes for applying damage in the projectiles event graph or on the character blueprint?
I feel like the projectile bp provides for cleaner code.
it depends on how your weapon works, Physical projectile or Line Trace?
if it's a physical projectile then it should be in the projectile blueprint
Physical projectile. thx!
Hey, noob question here. I have player spawning logic and some other stuff on my player controller, but in multiplayer it doesnโt fire off consistently so clients just donโt spawn in. I tried also calling an event from the gamemode when handling a new starting player, but sometimes it works, sometimes it spawns two characters. Any ideas? Thanks in advance.
The spawn logic should be on the game mode
Oh, thatโs good to know ๐
when doing an AttachActorToActor, does this need to be done in both server and clients? or just the server? I'm currently using a multicast to do it in both, but I'm not sure if that's what's breaking something
Hello how would I replicate a launch character so if I was in single player and used it it would be the same as if I was in client in used it I know if I check xy override it will be the same in both but is there a way to make it work without xy override? ๐
May need to use onRepnotify to push it to all clients regardless of when they joined
yeah, besides that, I'm just not sure if AActor handles the replication of "attachment" on it's own though
Pretty sure it does.
Although I'm now testing in standalone and still seeing the same behaviour, I'm trying to debug why when I attach a character to a vehicle, vehicle moves forward 100 units, and then detach, the character apperas 200 units ahead
I only attach my weapon on the server and its fine on the clients.
ok that's good to know then
I'd have to double check though. Been like 7 months since I wrote it.
Cedric says it does. Good enough for me.
Funnily enough - he replied to you about this ๐
lol
ok so this behaviour im seeing is definetly not a multiplayer/replication thing
grrr
I think im going to ignore attach actor alltogether, and just add a "sitting" movement mode to the character movement component
gah, I fixed it, needed to use Teleport(), that forces the CMC to reset the based movement so that you don't carry over the delta in position between the character was attached to detached
Hello i'm using GAS and i wonder how can I "send" a client variable to server in this scenario :
I fill the payload in the widget i'm creating client side and i'm sending event from there. Client receives it and resync with server so I can make gameplay actions via the server. However the variable (which is a playerState) only exists on the client and i'm trying to reach the server with that playerState variable. But I couldn't do it (tried RPCs, another WaitNetSync, etc)
The widget is like a targeting list (which is basically listing all players in the lobby) that you select a player from and whenever you confirm, it sends a gameplay event with the playerState representing the selected Player.
Yeah its received locally only
You would split that code to Server and Client. Let Client wait for the GameplayEvent and add the Widget. Let Server wait for the TargetData.
Oh I see
When the GameplayEvent comes back from the Widget, send the TargetData
Custom Task or any in-built feature can handle that ?
You should be able to use TargetData :P
WaitTargetData takes in an Actor. You can make your own. It can handle spawning the Widget and sending the TargetData to the Server
have a look at existing examples in the source code
Ok thank you !
I'll need to convert the widget in some kind of GameplayAbilityTargetActor and it should be okay
Hi. Does any one have some link or any article with example of a client-server application that implemented by using Entity Component System (ECS)? Or some example with using the ECS on a UE Client?
Also what are you thinking about built-in ECS of UE called MassEntity? Is it still in test mode or no? And also can MassEntity be used for some sort of MMO games to spawn entities (Characters\NPCs\Monsters) and keep them in the ECS system to get maximum performance while operating them in runtime? Thank You.
This seemingly innocuous node completely disables replication of movement for my pawns in a dedicated server setup. The pawns still move on the client and server but their movement doesn't show up on the other remote clients. And all it's doing is adding an item to a replicated array that has nothing to do with movement.
It's part of a "take all items" function. When I take 5 or more items at once this happens. 4 or less, everything is fine.
I profiled the network bandwidth and that function was hitting 25kbytes of data but very, very fast.
Is there some way to know when or why this is going to happen by replicating a lot of data?
Anybody know this?
๐ ๐
Changing this to Run on Owning Client totally fixed the issue somehow
LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_LootContainer_Indestructible_C_UAID_3814287443F2A67F01_1188285487. Function Server_TransferSlots will not be processed.
This function works when the player is transferring from the container to their own inventory. When trying to transfer the item back to the container inventory the log shows this because the player doesn't own the container inventory?
I feel dirty. I made the weird replication bug go away by throttling my replication data burden with a Timer delegate event :/
So it runs a 0.01 second timer for each item in the array lmao.. ugh
Why though
if I tried to add the array elements in a for loop it overloaded replication and bricked my character movement somehow?
not even really throwing that much data around either
ya? I was sending the entire inventory system component which contained the array, should try that then eh
I need to try that
At one point it was kinda funny because when I would hit "loot all" the entire pawn would vanish without a trace
dirty
u need a FFastArraySerializer
and WithNetDeltaSerializer all the bits
Saw that serializer earlier aye
I think the real problem is the actual data that you are attempting to move. 25kB for moving something like 5 items seems way too high, that'd be like sending over 1200 integers for each item. What does your inventory structure look like?
It's mainly an array of structs with about 45 different properties that define each item
Turns out what I was doing earlier was actually replicating more like 16-60 of these at once
So I built my own serializer in blueprints
Works pretty good tbh
I still need to simulate higher ping and test
Still seems way too high. 25KB of data for 60 items = 416 bytes per item, which is something like 100 integers, more than double the number of fields that you state your structures are. Why I asked about what the structures contain is if they contain strings, text or names - those can all end up costing a heck of a lot more than any basic numeric properties normally.
Oh, yeah man. Tons of stuff like that. Enums. Strings. Icons.
Enums are fine, those are only a byte.
You should not be replicating static data
So only replicate the RNG parts of the items
I have an array of structs inside the item struct
Called item affixes
Which is like 160 affixes long lel
... i may need to rethink things
So you're storing values even if they're 0?
Some. If the item doesn't use that affix then no
Given that you are doing fully randomized items, likely from an integer, this is all you should ever need to send. The very basics of the data that originally constructed the item. The client can reconstruct a randomly generated name, or look up how much a randomly generated stat is super fast. And since most of these values should come from the same randomly generated key, that one key is all you should need to send for the client to see the same values as a server.
That one key then usually then ends up being even smaller than a single replicated item name. So you get all of the stats with a fraction of the data sent.
hey guys,
Is there are any info, reference project or even a good read on crouching and proning on a networked game?
I am currently having issues with crouching and proning implementation on a network
while they do work on their own, when clicked to prone from crouch state, or crouch to prone state, the data does not seem to be relayed to server and simulated proxies correctly and gets all messed up
any help is appreciated ๐
How would I go about syncing changes in a chest I am interacting with?
e.g. Player 1 Opens a chest,its empty.
Player 2 opens this chest and adds an Item to that chest
Now player 1&2 obviously need to get a "update inventory visuals" function triggered..and thats my question...how? ๐
BP andy ๐ฆ
have an array in BP with contents, RepNotify
OnRep, regenerate the entire chest content
that I do already, unfortunately i have to solve another issue first before i can do the chest stuff (player client inventory aint working no more) for now: stand by ๐ ill respond with a tag once the playerInv issue is solved ๐
Is there a โgold standardโ c++ tutorial/course in inventory systems that does it the โright wayโ? I.e. UObjects etc? Some of the YouTube videos are clearly not doing it right.
Why do inventories need UObjects to be considered "the right way"?
You might find one or two, but I'd still be skeptical. Implementation just comes down to what you need. If you need a massive world inventory system, you probably need to consider some form of POD system with structs.
I personally went UObjects on mine just because I like the simplicity for handling. I get a single pointer I can throw around in UI and have an object for delegates etc. But mine is also super abstract in a plugin. Has very basic handling for creating a UObject that supports stacking and the core code required to handle that. Everything else is inherited and extended at the project level.
Having said that, there are performance implications to UObject inventories. Namely that they need an object instantiated for them. And that is fine for several thousands of items. But if you start getting into massive persistent open world stuff, you either need to consider a basic POD system without objects, or do some optimization to allow an inventory to be condensed down to data when not in use. Which isn't all that hard if you already having a basic saving system for your objects that breaks them down into structs, but might not play as easily with an MMO backend for example.
And even with all of that information. "The right way" is a loose term. It's hard to fully answer that without knowing your entire requirements for the inventory. Every game is different, and some people might optimize away whole sections that another game might consider essential.
Depends entirely on the game IMO.
If I want to change collisions on an actor, should that be done on multicast or only on the server?
Should be a replicated property changed on server and all clients from an OnRep
Multicasting state = bad
Why is multicasting bad?
He didn't say it was. He said multicasting state is bad.
Multicasts are once. There's no saved data, no updates. If there is a light on by default and server says a light is off via a multicast. Now a new client joins the game. All other clients see the light as off, but this new client sees the light as on.
And for my game, I use a struct to represent the item in the inventory and an instanced struct to store any runtime information so when I spawn the actor again, I have the right data saved.
So, yeah, different ways ๐
Ohh ok
What should I be doing if I want to know when a new player state is replicated? Does game state have any broadcast I can use whenever a player state is replicated?
What does POD stand for?
Plain Old Data
This is great. I need to rethink my inventory struct. Right now it has 3 levels of arrays of structs in a single item.
Need to think about how to generate items from a seed but some of their stats are deterministic, like where in the world they can drop is determined by theme, etc.
Thinking about this stuff. I am using a base item Object for my items. What if my inventory is just a reference list to the item instances? Then if I want to move items from e.g. a container to the player all I'm doing is changing the owner and sending the object reference in replication?
damn I didn't even see that yet, thank you
Am not looking forward to changing my struct... every time I do that the game crashes several times lol
Idk, I like the struct based inventory workflow.
And if I recall correctly, Jambax's blog post doesn't use the cool new way of replicating subobjects
Yeah he's old and outdated. Can't keep up with the cool kids.
what's the cool new way of replicating sub objects?
Docs have stuff about it
I've just discovered that returning an Error from GameSession::ApproveLogin just crashes the entire engine after hitting this line:https://github.com/EpicGames/UnrealEngine/blob/5.0/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp#L14216 in UE5.0.3. I guess that's how you can reject players from joining a session too ๐คทโโ๏ธ
Any ideas?
I assumed the rejected player would just land back in it's previous map or doesn't even travel to begin with?
I do, too. Still debating which way to go ultimately.
It should just be send back with the error to the map it came from
Or maybe first project map not sure
New subobject replication + fast array serializer + FInstancedStruct
The holy trinity
UObjects for inventories and structs for item instances
For making a multiplayer FPS, I'm debating if I should implement my first person weapons as separate actors, or as components added to my character. I already have it working in a basic form with weapons as separate actors that get attached to the player. Any idea which method is considered "standard" or which is more commonly implemented? I imagine it varies by game.
I was thinking keeping them as separate actors might cause replication related headaches in the future, but not sure.
I do it as actors
I was thinking it might get weird if I have to manage attaching the weapon to the first person model on autonomous proxies vs the third person model for simulated proxies
k, just wasn't sure how attachment works with replication
If autonomous: attach to this bone, otherwise attach to that bone
Having an issue where my score update works in single player but not in multiplayer. I have a function GetTeam that checks to see if the player who overlaps the goal is on the right team and the cast to is failing which I think is part of the problem but there may be other issues with other casts failing for reasons I havenโt been able to determine. Basically the player character is redefining a team number from game mode which is set in player controller and then accessed in player character. Overlap is tested in player character and passes the score to game mode and that is ultimately supposed to be updated in the player character hud. Works fine in single player and Iโm not sure where the issue is in multiplayer. The score and related variables are set to replicate and the scoring function runs on server
First image is from player controller, second is the player hud, third is overlap logic in player character and last is team assignment logic in game mode
Game Mode doesn't exist on clients.
So any variables, even if they are marked as replicated, or functions you're trying to call while playing as a client won't be accessible.
There's also no point to marking any events in game mode as RPCs as only the server can ever execute the logic - so your OnPostLogin there ends up calling "Run Set Team On Server" but that doesn't need to be an RPC, you can get rid of that event and just immediately call Set Team.
Ideally, you probably want to set team or any other variable that would persist with a player on PlayerState so anyone can see who's team is what and you don't need to use an RPC to do it, just a replicated w/ notify variable using its OnRep function to drive the required logic should suffice, and any team related scoring could be tracked on GameState, however, you likely do not want to call a Run On Server event from your Overlap, instead, use a Has Authority node immediately after the overlap and only use the Authority path - this normally guarantees that the following code is running on the server.
Is there a way to check for when everyone has logged in (where there are a fixed number of players and no in-game joins)?
Or, I imagine there is, but is there a quick solution like a node
@sinful tree Wow thanks! I was using chat gpt 4 to help with my team assignment and it was adamant about using game mode to assign teams, then passing through player controller to player character. Tried running it through several fresh chats and it gave the same response each time
You can use the game mode to assign teams, but the variable itself should likely be stored in PlayerState.
@formal solar if your players are stored in an array couldnโt you check array length?
its ok its to do with the basic setup of my game which I think will be an easy hurdle once I start tackling connection and logins
@sinful tree So constrict a set team function for Team Number in player state and pass that to player character for the overlap, then store the score in gamestate instead of game mode?
Even GPT4 is not very good at providing proper instructions in UE. Hallucinates less than ChatGPT but still
You likely shouldn't be checking all overlaps in your character - your "goal" actor should have its own overlap check.
Your goal can then have an integer variable indicating the team that owns the goal.
In the goal's overlap, you would check if the overlapping actor is a player, and if so, access the playerstate and retrieve the team ID.
You would then check if the Player's TeamID != Goal's TeamID and if true, that means a goal should occur, and yes, that should be registered in the GameState.
@icy jetty Yeah Iโve found it pretty hit or miss but it has at least been useful for learning about certain functions or code Iโm not aware of. Usually I can get it to the right answer by correcting it a couple times. Iโm not solely relying on it though, Iโve got a couple books Iโve read together with the occasional YouTube tutorial
@sinful tree Thanks! Thatโs how I previously had it set but switched it over to the player character after having issues with the casting
Thank you so much!
So no body in this group that has experience with unreal engine Steamcore multiplayer setup which is non region locked ?
Anyone ever had a problem with Client -> Server rpc replication did not register (was called on server) for the first time calling it, but after the 2nd works like a charm?
for some reason the beginplay is only called on the first client, but for the same controller twice. this happens when i play with 2 clients
This channel is primarily a help channel where you post what your problems are and people can try to assist. From my experience, asking extremely general questions like if someone has experience with something isn't likely to get a response, especially so since there may only ever be a handful of people ever looking at the channel at any given time.
If you're looking for someone to just do the work for you, then you're better off reading #instructions and putting up a job posting.
In one part of the map there is person X, in the other part of the map there is person Y. If an object is hidden from person X thanks to Cull Distance, will the actions and activities of person Y interacting with the object work appropriately for person X?
What cull distance are you referring to?
NetRelevancy?
Render Culling?
There are different types of culling, for different purposes.
Its important to be specific.
I mean, just "cull distance" which works by adding Cull Distance Volume at the level. So Distant parts are not rendered (invisible), they are visible as you zoom in.
So visibility (render) culling.
Occlusion culling more specifically.
In which case, yes, the Actor itself and all its components still exist.
They just aren't being rendered for that Client.
If the current object is not visible to the Server (if it's far from the object), but the Client is next to that object, will it work properly for Multiplayer?
Why wouldnt it, given what I said above?
OK.
So, does this process also apply to World Partition, do you know about it?
I've read that World Partitions are compatible with Multiplayer, but I suspect there might be problems.
If World Partition is dividing the Landscape into parts and Cull Distance is closing the visibility of the distant object, do they both work using the same system? So is it just the visibility of the objects?
btw thank you
Only the rendering of the visual components of the object are affected.
thanks
Netculldistance is a different story
When I write "unreal engine Network cull distance" to the Youtube, I can't see any video about netculldistance.
If I use Cull Distance Volume as normal, will I have problems in Multiplayer? I don't really understand why NetCullDistance is needed.
Cull Distance Volumes are for visibility only, they do not affect multiplayer.
Please read the documentation.
Newbie multiplayer question... So if I wanted to create a non-active multiplayer system, what all would be required?
Example:
Player #1 creates an NPC character. It gets uploaded.
Player #2 pulls that NPC into their game.
Player #1 gets in-game credit for Player #2 using their NPC.
The end.
The NPC would essentially have a small text file worth of attributes. Would I just need a DB hosted somewhere to store the file of all player's NPCs and accept updates to it each time a new player creates a NPC / uses another players NPC?
Multiplayer, but more like No Man's Sky (on release), compared to No Man's Sky right now, haha.
So...you can see / use other people's characters, but you arent actively playing with other players.
Another example would be a leaderboard system, but no interactive play outside of that. I'm not sure what the official term would be for that type of multiplayer.
Yes you would need some sort of external DB in order to store that information and allow other Clients to access it.
Are there any recommendations that play exceptionally well with UE5? I'm really inexperienced when it comes to any type of server/db infrastructure, so if there's a recommended guide I could look up, that would be a great starting place.
There is likely a ton of guides on how to manage this. Unfortunately that makes it somewhat difficult to recommend one specifically.
As there is also a lot of different platforms that enable you to do this as well.
Ha, fair enough. I suppose my worry would be when I search multiplayer, I just find a bunch of replication guides...which I think for the most part, I wouldn't need to dive into for my basic use case?
You seem to have a basic plan together and a loose idea of what you need to do, try researching it yourself.
Google is your friend.
Also Youtube helps to.
Dont search "multiplayer".
Search for something more specific, like "How to use an external Database with Unreal Engine"
Good call. I'll look around. Appreciate the help ๐
Learn how to ask the right questions, its a valuable skill.
Its half the battle.
You cannot hope to understand the answer if you first don't understand the question.
I was just telling myself that today ๐ Iโd be able to learn so much faster if only I knew what the right questions were
Can someone help me understand how print is working when playing as listen server/clients? I have an actor, goal, set to on overlap and it has an mswitch node for authority. Itโs getting my team number from game mode and if it ๐ฎ it is set to print the team number and display nameโฆ but when one of say four clients in my test overlaps it prints the results for everyone server, client 1, etc. Why would it not just print the info for the actor who overlapped? Setup is similar to this which @sinful tree helpfully posted earlier
Is there a way to just print the currently active client window when testing in editor?
Because that print is ran on every machine. As Overlap event is ran on every machine.
is there any ordered array like FFastArraySerializer ?
put an index in the item and you can get it to behave that way
yea was thinking of that but maybe need to write my own NetDeltaSerializer ๐ค
im just trying to replicate lots of items without using Actor
so whats the problem?
imagine 100k damagable tree
as long as they are net addressable
and you replicate a weak pointer to the tree
it all just works
(as part of the item)
I dont want 100k replicating actors in the map
its using Foliage system btw, its instanced
that will have indices you can replicate
Also... 100K?
yea just a big jungle
Even fast array is going to hit a brick wall with that
Just how big are these structs?
very small
The point of fast array is to remove/add from anywhere in the array optimally. If you aren't doing that, using it is probably adding more overhead. Just use a static array with a fixed size.
struct { int16 Health, Enum ItemType , FVector Position; }
Mind you, comparisons will probably be the bulk of the cost for 100K so might need it anyway
u mean something like Type Items[1024] ?
grid works though
each instance on server puts its data into a network manager at its grid tile
Yeah, I probably wouldn't use one giant array - split it into sections
I dont know how fast array works, but all those trees dont need any tick or update, they are just there
they need an update to spawn on clients, and also to get damaged on clients
thats what fastarray solves
yea im planning the same, one manager actor for each cell
do note that HISMs tend to shift indices when an instance is removed
and then you're fucked
Would probably split that struct up to. Presumably ItemType and Position never changes after initially set.
i don't think i would
yeah actually you might want one fast array for each item or item group associated with the entity that changes together frequently
You could even pack those "health" values into a uint64 and unpack elsewhere
server - adds instance, adds item to fastarray with an index, marks array dirty
But that won't do anything, you're still using the full 32 bits, and replicating them all
Im also seeing Mass replication to see how they are using fast array or delta net serialize
client post add - adds instance, adds non replicated int to struct for its instance index
I think they don't do anything crazy
@chrome bay yea but Im thinking of adding other properties
but that assumes you don't remove an instance ever
definitely going to have to split it up to deal with 100K either way
No way fast array is going to cope with that, the max changes per-update is 2048 anyway (by default ofc)
is there any good example to show how to implment NetDeltaSerialize ?
...fast array ๐
how do you guys deal with fast array mappings? I mean, if I have 1000 structs let's say, that are linked to an actor/entity, and in the server I want to find the struct to set new values and mark dirty, and I don't want to iterate the entire array each time?
Can't really avoid it sometimes. I use the ReplicationID for the item ID
{
FInventoryID GetInventoryID() const { return FInventoryID(ReplicationID); }
};```
But you can't guarantee the ItemMap is built at any time - especially if you marked it dirty
Hence..
{
if (InID.IsValid())
{
const int32* IndexFast = ItemMap.Find(InID.Get());
if (IndexFast)
{
check(Inventory[*IndexFast].GetInventoryID() == InID);
return *IndexFast;
}
else
{
const int32 IndexSlow = Inventory.IndexOfByKey(InID);
check(IndexSlow == INDEX_NONE || Inventory[IndexSlow].GetInventoryID() == InID);
return IndexSlow;
}
}
return INDEX_NONE;
}
is FFastArraySerializerItem.ReplicationID unique per item for server and clients ?
It's syncd yes
Zlo said add an int Index to your struct .
The int != index
with that ReplicationID no need for that
You're not going to beat a static array IMO
the problem is my struct are not the same type
I use inheritance and v function
I guess static array cant help then
{
UPROP(Replicated) // Initial Only
int32 TileIndexOffset;
UPROP(Replicated) // Initial Only
FVector[1000] WhateverElse;
UPROP(Replicated)
uint16[1000] HealthValues;
};```
summin like that, IDK
Already got the syntax wrong but.. you get my drift
For 100K items you're going to have to be pretty creative
yea I got
The callbacks of FastArray are it's best feature, but you can mimic that with a simple wrapper.
i wrote once something that maintained a map of array indexes for fast lookups
but I have not tested it so it might happen that some corner case invalidates it
Advantage of a static array is that the properties are "unfolded" into the actor, so you don't pay the cost of both a property header and an index
there has to be a way though, otherwise ECS systems wouldn't be able to keep sync with their SOA approach
Downside ofc is all those comparisons, you can't mark an individual item dirty/for comparison
Hoping Iris changes that though
Never done anything for that kind of number of items though tbh
Probably some learnings to be made
I havent started with multiplayer yet but i wanted to quickly what considerations i have to have for using control rig functions in a networked game.
same as any animation or separate considerations ?
Pretty much, yeah.
sorry i asked a double question.
CR most likely just gets the info it needs from the ABP, which just gets info from the character
Animations are a representation of the data.
You send that data to the character
Animations just read from that.
figures. so it resolves client side based on data transfered
Yeah - pretty much.
thanks !
Only thing i can think matters for networking is my animation driven collision tracing. Im using melee line traces. But ill just make sure the traces are networked properly then.

guys can I kindly ask I am doing this RPC wrong ? I am trying set boolean value for certain player here but its not working
I can change this value only with server on client its not working and also when I change it with server then its true or false for everyone ๐ฆ
I am printing it here
I just wanna not to take damage when I have activated shield
hm its working I just used self--> get player state and then cast to dfc player in any damage
I had no idea I can get self (player on my pc) in server call cool
might be better to use a Repnotify... but i dunno, still new to this as well ๐
so try changing your ?sheild to repnotify, then set the ?sheild from your 'serversheild' event and i think it replicate down to all the clients
@real ridge like this - https://docs.unrealengine.com/4.27/en-US/Resources/ContentExamples/Networking/2_3/
Hi, im having an issue with replicating a players rotation correctly.. i have a draw actor that the player can interact with, when they do i have it open the draw and then set their location & rotation to a point just in front of the open draw, the Set Actor Location seems to replicate fine, it puts both server and client player in the correct place when either interact with it, but the Set Actor Rotation doesn't.. it works for the server player but when the client player does it they don't get rotated on their screen, but the server does see them rotated correctly so it appears the client isn't being updated with the new rotation but ive tried rep notifying the rotation, ive tried running the Set Actor Rotation on client if the player isn't locally controlled and neither of those worked.. any ideas? also curious why Set Actor Location seems to work fine but Set Actor Rotation doesn't?
Location doesn't look quite right to me, either.
right side, pawn is standing behind the drawer. left side, pawn is standing in front of it quite a bit
So if your location is wrong and you rotate by some arbitrary amount it isn't going to be right most of the time.
Not sure if this is because you're multicasting a location change for the pawn but the server still thinks the pawn is somewhere else.
I think that might just be the camera angle, your image is before the client even interacts with the draw which is where their location & rotation are set, outside of interacting with the draw actor it is just normal movement component movement which should be replicated by default
Yes, but I'm saying even your normal movement has desync issues with location. I dunno if that compounds with what you're trying to do
The location change isn't multicast? i should of mentioned all this code is running on an OnInteract interface call which gets ran on server when the player presses the interact key
So when either player interacts with the draw the Set Actor Location is setting them to the correct location its just the Set Actor Rotation that isn't for some reason
Ah, okay. Yeah I see you're calling the multicast now but not using it
At least not for the location/rotation
Where are you getting the value for "player spot" ?
Its a scene component on the BP_DrawBase actor
Gotcha
I still think it's problematic that your pawn is in different locations. This doesn't just look like camera angle to me...
lmao the green line in the right image is pointing towards the draw next to it, might be getting confused because 1, i have 100 draws there lol and 2 the white circle widget you see is the interaction indicator widget, the player on the right is within the overlap of those 2 draws but the one on the left is in the overlap of that draw its in front of and the one to its right, which is the left draw out of those 2 draws with the white circle widget on the left image
if that makes any sense
Okay i managed to get it working doing it this way, not sure if this is the 'correct' way or not tho
Still also unsure why SetActorLocation works just fine and replicates on its own but SetActorRotation doesnt
lol no, it doesn't, but it's all good, you seem to have solved it
I had a mechanism where you fire a projectile and it spawns an item where it hits but replaced it with a line trace after issues with multiple projectiles firing in multiplayerโฆ I assumed that there was some issue with the server being able to keep up with the physics but in retrospect I probably just didnโt have my functions set up properly to spawn on server, replicate properly, etc. That being said, do projectiles tend to perform poorly in multiplayer? It wouldnโt be a large number fired at any given moment
I'm trying to avoid sending a large array over the network in an RPC whenever I update it. The only alternative I can think of is using repNotify, as afaik unreal only sends the parts of an array that have changed, so that would minimise the amount of data sent.
But in the case of arrays, the repNotify only gets triggered when actually setting the value of the array, not when adding and removing elements. I was wondering if I set the array to itself + one extra element, which would trigger the repNotify, would that still be optimised over the network? Or would unreal think that its an entirely new array and send the whole thing?
You need a switch has authority when Pressing the F key
From the Server pin, you want to Call MultiCastShield
From The Remote/Client pin You want to call ServerShield
Can someone explained ReplicationCondition OwnerOnly? Why does my value still replicate to the server?
Can someone explained ReplicationCondition OwnerOnly? Why does my value still replicate to the server?
Nothing replicates to the server. It is always from the server. This condition means that it will only replicate to the Owner and not other clients.
For example - the ammo in a rifle. That could be OwnerOnly because other clients don't need to know how many bullets you have. (unless of course you want them too)
@quasi tide Thank you
i was an autonomous proxy the whole time..?

Replication callback should trigger even if you add to the array, unless you're talking BP, I have no idea, could be
But if you got cpp access, you will want to check fast arrays
Hmm, so On Rep can have Input Parametre in C++, how can I do the same in Blueprint?
How to make it so OnRepNotify don't get called on server? I thought that's what OwnerOnlyCondition meant to do 0o?
In BPs, OnReps are just property changed callbacks :D
Since your Server sets it, it might call the OnRep I guess
C++ it shouldn't call either way, cause OnReps actually don't call on servers
Yeah I'm talking in blueprints. I'm fine using c++ but I implemented the struct in BP so was looking to avoid refactoring everything. Also I think that OnReps for c++ only get called on clients which seems to be a pain
A plus you mean
BP structs and Repnotifies are the worst pack I could have ever asked for xD
You can always call the OnRep in you setter functions
That's not a hassle
And you don't always need the OnRep to call on the server
So having the freedom is good
yeah true I guess I just need to create functions to add/remove/set all the variables and include some logic for only the server to call the UI functions
OnReps in BP can get called in a very wack way
Such that they can get called locally on client when the client sets a value
So yeah wouldn't have used them too much
yeah I can imagine. In my case all the data is updated on the server exclusively so it isn't much of an issue. At this point moving the BP struct into c++ I think would be a nightmare because I'm using it all over the place. I guess I will just try profiling the network while setting the onRep array and see how much data it sends
guys why I am getting this red doted thing called twice every time when it is executed in client? I tried debug my pawn but there it is called just once and when I get inside this blueprint its twice, I thougt its because I have 2 people in game so I added 3rd and it was also 2x called problem is that I am setting boolean after it and if its called twice then I will change it to true and then back to false so it has no effect...
any ideas?
its setting this
literally every time I debug its called 2x
What is currently calling your Shoot event?
there is no problem I tried debug it its event dispatcher
created in weapon attaching
but these stuff is all called just 1
I debugged it
So youโre calling an event on the client and then telling it to replicate to server
yes and then I am inside my blueprint for shield making changes
and these changes are always 2x called
u can imagine it better
here is video
it has no sense to be executed 2x
in map I do have 3 players all clients
one client call shield and it is running twice , also event for sound and animations is called 2x on every client weird
Again, you are calling an event
On the client
And saying replicate this event on the server
and?
i dont get it
๐
when I change event shoot to not replicated its called 2x too
even when I put here do once it execute twice lol
and rewrite value
Thatโs not what do once does
It just says you can only run this event once, but if youโre telling both your client and your server to run the same code, you will see it twice
So I did little test now
when I call my event like this via my pawn
it is executed just 1
when I use my dispatcher call it is called 2x inside but dispatcher in pawn is called just once
I am confused
Think of the meaning of the word replicate outside of UE
why I have feeling you are talkng to me in riddles kek
or I am dumb
Sorry I keep getting distracted with work. When you run the game with 2 players and the print nodes come through, does one of them say client and one of them say server?
if I run IsLocallyControlled() on a client connected to a server, it will only return true for the pawn its possesing right?
Does anyone have experience with the network profiler? I'm looking at this packet and am wondering why the top row says it was 3308 bits, while its contents were apparently 48k bits. All the other examples that I have seen make sense, with the contents adding up to the total packet size, but not in this case
Oh dw, figured it out ๐
What was it?
The previous bars before the one I selected were all 7k bits, so it looks like the packets were just split up. So it was just that the last packet that was 3k bits, but it showed the entire 48k bit content inside it
I cleaned up my inventory replication but decided to actually keep the timer function that puts a tiny delay between each item in the transfer process. I like the visual look of the items piling in there one after another instead of all at once heh
Nice
what would be a good approach to send a party invite to another client and have the second client update their ui?
right now im doing this, however the second client never updates their ui.
void UPlayerPartyComponent::Server_SendPartyDataToPlayer_Implementation(APlayerCharacterBase* PlayerCharacter, FPartyData PartyDataNeeded, FGameplayTag UpdateTag)
{
APlayerCharacterGASController* Controller = Cast<APlayerCharacterGASController>(PlayerCharacter->GetController());
if (Controller)
{
UE_LOG(LogTemp, Warning, TEXT("Server_SendPartyDataToPlayer_Implementation: Calling on %s"), *Controller->GetName());
UPlayerPartyComponent* TargetComponent = PlayerCharacter->GetPartyComponent();
TargetComponent->PartyData.PartyMembers = PartyDataNeeded.PartyMembers;
//PartyWidget->UpdatePartyUI(UpdateTag, PlayerCharacter, PartyDataNeeded);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Client_SendPartyDataToPlayer_Implementation: PlayerCharacter's controller is null or not of type APlayerCharacterGASController"));
}
}
well it's commented out! haha
honestly, not sure, I'm all blueprints with widgets
I assume you have either another widget or some other means of ensuring you're getting the correct instance of the character (the other player's character), sending that to the server (via making sure you can send an RPC from the correct place, e.g. it's not getting abandoned for no owner) for the server to send the party request to the other client based on getting that correct instance
well, when I actually invite the second player it updates the PartyData on their client - and the first client actually updates with data from the second client. Its the second client that doesnt update the data
I have the variables on COND_None, if that matters
fist client correctly updates:
second client:
the name is the same, but I know that the instances of the widget belong to the first and second client respectively
Right, they have to
Somewhere you aren't getting the data to the second client's widget though. Sounds like the client at least has the data replicated to it
Yeah, and I have an event dispatcher which calls to update the ui when partydata changes, and It calls on both clients
void UPlayerPartyComponent::OnRep_PartyDataUpdated()
{
UE_LOG(LogTemp, Warning, TEXT("OnRep_PartyDataUpdated: Calling on %s"), *this->GetOwner()->GetName());
for (const FPartyMemberData& PartyMemberData : PartyData.PartyMembers)
{
Server_SendPartyDataToPlayer(PartyMemberData.PartyMember, PartyData, LastUpdateTag);
}
OnPartyUpdated.Broadcast(LastUpdateTag, LastAddedPartyMember, PartyData);
}
so party data changes on client 1 -> onrep calls -> send client 1 data to client 2 via RPC -> update UI on first client
from there client 2 should also call the on_rep method to update the ui
i would think 
it's curious client 2 doesn't even include itself in the party
ah yeah you still have "Create Party" I see
tbh this is normally where I start throwing print strings and breakpoints everywhere lmao
I did a party system using a replicated AInfo that is assigned to a replicated variable on the PlayerState and used a IsNetRelevantFor override to check if the playerstate contains the AInfo so it only gets replicated to party members - then you have a centralized "Party" object in which you can store the members and handle any data between them.
Using a Component means you're likely duplicating data and makes it much harder to keep what the party is in a single place.
Unless it's a component being added on gamestate or something like that.
Assuming the Controller is valid, it will return true client-side, and false server-side
When a player reaches the goal I want to teleport them back to the starting location. Plan to use a teleport in the goal blueprintโฆ does it need to be set to run on server?
Any changes to Player location should be handled by the Server at minimum.
Otherwise it will just cause a correction on the Client.
Hi, I was experimenting with Lyra sample and tried to modify this tutorial: https://docs.unrealengine.com/5.1/en-US/setting-up-dedicated-servers-in-unreal-engine/ to package the project with the default frontend as a starter map, but it seems the clients wont find the dedicated servers, it works only if the entry map is expansion or other playable level, how can I better debug this and am I missing something?
1
When you touch a cube with object Ankh it is supposed to destroy the cube and add to your ammo. Worked fine for one player but for the other the cube did not destroy. I have it set to call custom event destroy on server and then the following... am I doing this wrong?
Yes. You don't want to be able to pass through an actor to destroy on the server.
The "touch" you describe should be happening on the server as well, so no server RPC should be required. Instead, use a Has Authority node and use the Authority path after the "hit" or "overlap" event your using - everything following that path would be executing on the server.
Thanks!
what?
So pretty much each time I get hit it adds my damage into a variable and if its greater or equal then a certain amount before the retriggable delay hits zero and sets it back to zer
but it only works in client for some reason
so the retriggerable delay isn't working?
idk what's not working
is the event not working?
you're not being clear enough to get help
Waitโฆ the touch happens through an overlap event, do you just mean that a has authority should be right after the event like with the goal code you posted? And then all the logic to follow? And then thereโs no need for destroy actor on server? Thereโs also an add ammo function, should that still be run on server?
try to find out more about where the problem is occuring, and then ask, right now it's just too general, it could be a ton of things
Yes. Anything gameplay related should normally be happening on the server, especially so with things that alter counts like ammo. The "Has Authority" node normally is checking if the current instance of the game, has authority over the object you're working on. Eg. If you spawned a replicated actor on the server, then the server would have authority. If you spawned that same actor by having a client do it (eg. Triggering an overlap and using the "Remote" path on Has Authority) then the client would end up having authority over the actor as the server wouldn't know about it.
If you want to destroy the actor, then it's likely that you want to destroy it on the server, especially so if it is replicated.
Mb the problem is it only works in client
๐ ๐
Can you show how you call ApplyDamage?
Launching with 2 players from editor, with Play as Client selected... why would the circled ending fire 5 times on launch? and the final ones come in with the crosshair_ref as None. Edit: changing to run on owing client limits it to 2 runs, but still None
Begin Play fires on server too.
Can also fire on other clients.
If this is on a character, then use a branch before creating the widget and plug in "Is Locally Controlled"
thx. that cleaned up all the errors, and I understand why now. It's not working as expected...but no errors is good. thx again
I have a custom event but the apply damage is not the problem
Im thinking its something with my varibuls
Where is this event being called from?
Well, I mean, put a print string on your AnyDamage, check if it actually is being called properly on the server in the scenario you want.
I have my doubts, as calling apply damage will only ever function on the server, and if you're saying that your damage is not being applied while running as client, but works fine in standalone, that's a sign that how you're getting to the point of calling apply damage isn't correct.
O no its not the damage thats not being applyed to ill try to put it very clear sorry so when I get hit it sets my damage taken and then it adds in into another variable and then when this variable it greater or equal then something it will play and animation but it only works in client?
Hey I need some help. So I have 2 projects which are entirely different.
Project 1: UE 5.1 using Steams Online Subsystem
Project 2: UE 5.2 using EOS
Both projects when I connect to a friends listen server, there's rather bad jitter when moving. Project 1 is nothing but a blueprint derived from character with some add movement nodes, that's it. I've had that exact setup sometime last year with no problem but now it's occurring. I have replicate movement checked, the character is set to replicate, all components are replicated aside from the camera comp, the other person lives about an hour away from me. I tried everything I can think of as well as loads of different solutions from googling to no avail :/
Attached picture shows project 1s character setup
In editor I don't get any jitter, only when I'm in the server
This is my first time working with replication alongside enhanced input, so maybe I'm missing a step there?
what's a good way to get started with learning replication
Take a look at the network compendium
Try to build a networked chat box or something simple like that.
Maybe even try a building a door that you can open/close with multiple clients.
Simple stufff.
what service are you using to establish a connection via unreal doesn't affect how unreal replicates in any way shape or form
start by turning off the replication for your Capsule and Skeletal Mesh
I've done that as well, disabling all but replicates and replicates movement
As well as using smoothsync
And it was just information as I wasn't sure if it was on unreals end initially since in engine I wasn't jittering
Even a simple cube with physics enabled and is set to replicate jitters and even teleports at times
always it will go 2x over client 2x over server if I have listen server and client it goes 2x server call on server and 2x server call on client and 2x client call on client which is weird
Hey guys I have a weird issue. I have an actor that has a property replicated. However, whenever I change the property on the server, it only replicate to the owner client, and not all the clients.
Here is the actor in question:
class MYTHIC_API AWorldItem : public AActor
{
GENERATED_BODY()
public:
AWorldItem() {
this->bReplicates = true;
this->SetReplicates(true);
}
// This only gets replicated to the owning client only for some reason???
UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category = "Item")
AItemInstance* ItemInstance;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override {
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AWorldItem, ItemInstance);
}
void AWorldItem::SetItemInstance(AItemInstance* ItemInst) {
checkf(HasAuthority(), TEXT("AWorldItem::SetItemInstance: Only call this on the server"));
this->ItemInstance = ItemInst;
SetActorEnableCollision(true);
}
}
I run the game with 2 clients, with a separate server in the background, and when I update the value of ItemInstance using the SetItemInstance function, only the owning client gets the value, the other clients dont receive anything. Please help.
Solved it. Had to use bAlwaysRelevant = true; in the constructor of ItemInstance
@thin stratus
Hey man you got a sec to explain to me why the movement is not replicated or w/e is happening ?
First of all, I would really appreciate it if you wouldn't ping me for personal help. If everyone does that I would be non-stopped pinged.
Post your question and wait for an answer. If I have time I will also help. There are a lot of people here that can help you other than me.
And your issue is clearly that you are using something for the Rotation that doesn't utilize the PITCH of the ControlRotation.
Whatever defines your Direction/Rotation, try use "GetBaseAimRotation" (Pawn function) with it instead.
@thin stratus ok sorry ill remember that ! ok ill look at it thansk
@ whoever asked about the SchoolDoor teleport and deleted the question
Need more context. There is a couple of things strange about this.
- Why does the "SchoolDoor" Actor have a replicated Character property?
- Your "Server" labeled RPC is a Multicast. You are calling two multicasts at the moment.
- Why do you Multicast for the Teleport at all?
Biggest question would be what is even calling the Server/Multicast? You can't use ServerRPCs in non-Client owned actors.
Your Door is probably standing in the middle of the level, not owned by the Client that executes the interaction.
You'll need to explain how this is supposed to work in general (what does the player do to teleport).
After that we can suggest you changes to make that work.
uff
They deleted the message
I doubt that's a solution you want.
That removes all optimization that comes from distance culling etc.
That being false is also not the reason that your item doesn't replicate to the second player, unless that second player is far out of reach.
Anybody know why??
Not sure what the issue is, but your Code has WAY too many ServerRPCs in it
That Damage Event you are using is SERVER ONLY
The Code will already not call on the Client. There is no need to ServerRPC
Yes I know this just using them for other things ect so I can put multiply in it but thanks anyway! ๐
๐ ๐
Also if that was you who posted about the Teleport SchoolDoor stuff
Then this was my response before you deleted the question
Thank you I fixed it tho! ๐
๐ ๐
Even then, the "ServerMontage" function would be the one thas needs to Multicast to actually tell everyone else to play the Montage
I assume you are talking about that Knockback anim
Also this is the reason I have a hole bunch of server rps
Most of them are servers then multi
Alright, I guess that's fair if your code is build like that. I can tell you though that I don't have a single ServerRPC that forwards a Montage to the Server.
That's usually very redundant
But either way, can you print in those and check who calls them?
Should make it clearer
With different Printed Strings to differentiate them
To see what actually calls
I did it and it seams like it goes into the damage add and cant make it out
Then that function might already have an issue
My suggestion would be moving the Print Strings into that function to check what is calling and what not. And also to print the Damagen and Knockback Damage value to see why they might fail the condition
Found out the reason I think so it dose work in single player it just adds way less because in multiplayer since I have a multicast its adding it twice I think so umm not sure how I could make it only add the number once in multiplayer and in single
Or wait I dont even have a multi cast idk why the values are dif in multi player and in singleplayer?
Idk what values you exactly mean
Is the Damage value you receive higher?
Then you will want to follow the execution path of your damage backwards until you find where the damage started changing
I can't answer that as I don't know your code
So its setting my knockback damage higher each time I take damage but its sets it higher in client then in server? ๐
๐ ๐
The problem might be the way im applying damage?
Yeah well as I said, you will need to go follow the code backwards and check where the Damage Variable comes from
You probably already know
And then check why it' shigher
Print the Value at that point in your code
The above code where you add up is already too late I guess
I think the problem is when I apply damage it applys twice in the client this is my damage system
sorry if those screen shots cludder ill delete them after ๐
You are using way too many RPCs
Like WAAAAAAY too many
That also causes your issues
Damage should only be handled on the Server
There is no need to ServerRPC or to Multicast
You can Multicast things like the Montage fwiw
You need 1 RPC to tell the Server to perform the Action that later results in applying the Damage
Nothing else
That RPC is redundant. The Trace should already be on the Server if you are doing it correctly.
That's all wrong too, cause you, again, should already be on the Server and only handle the Damage on the Server
That's also redundant. That can be a Multicast if the code before that is, as again said, already on the Server
You can always call the code on Both Client and Server, but then the Client should only do local prediction of effects and not deal damage
And 100% not tell the Server they dealt damage
The basics of how to structure your code seem to be very unclear for you. I would highly recommened rethinking this systems before you create something that falls apart more and more