#multiplayer
1 messages Β· Page 675 of 1
positions
but
the ones that are far away are less important
so they could be updated less
you are saying replicated TArrays don't have the same order?
it seems like they do in my tests
Have you cranked up packet loss?
It's packet loss that causes out of order data
I've just been learning replication (as it relates to UE4) this past week, let me see if I can find where it says in the docs that order is not guaranteed
Ah, then order won't matter to you
ok
Line 149, 150 of NetSerialization.h, in regards to Fast TArray Replication The downside is that you will need to have game code mark items in the array as dirty, and well as the *order* of the list is not guaranteed to be identical between client and server in all cases.
It might only be FFastArraySerializer that does not guarantee the order
I've been cramming so much UE4 info the past couple months, I get a little confused on what I learned where or when.
ok
it might not matter depending on how i do this
right now
if I create an array of 4000+ elements
the client explodes when the game starts
for reasons I don't understand
ie use FVector_NetQunatize
yeah
Quantize*
I use that currently
yeah
then use FastArray and only mark elements that changed to only replicate them
during gameplay, initial replication will be the big hit
not really sure there is a brilliant solution for sending mass amounts of data
unless you do frame sliced RPC's
and do it based on priority (so units closer/more relevant get updates quicker)
I might make a smaller array of like 500-1000 that lists the indices to update
that is the other choice
TArray order is preserved btw. But packet loss might mean that it takes a bit longer to match the server perfectly.
I.e. you might occasionally be in a state on the client that isn't the correct order, but it should resolve itself
@slow pond why would you create a 4000 element array?
Hey!
First of all, I am familiar with Unreal Engine Single Player Game development, and I am new to multiplayer game development (Just started learning).
I am creating a mini shooting game for android where 4 to 5 players play together and shoot monsters.
I have completed the prototype on the pc and I am ready to test on android but don't know how to do it.
Can anyone tell me how to move forward from here,
The first thing I want to do is test it with my friends over the internet so that I have an idea of how it fills, what I need to improve, and stuff.
Hi there, got a question. I have a 3d ui element showing the healthbar of a tower in my game. The tower replicates fine but the health on the bar dose not, how would i apply this to both clients
When you say 3D UI Element, you're using a widget to display the health?
Yea
How are you feeding the health value into the widget?
Via an event setting the percentage, ive tried running it as server
You can't really do it that way as widgets don't replicate. The health value should be replicated on the tower itself. The widget can be bound to it, or if you set the health variable as W/Notify you can use the OnRep function to update the widget.
So instead of updating the percentage directly bind it to a float for example and update that float?
Yep.
how would i access the value within the widget?
Seems like multicasting the event works
Don't do it that way... It's not the proper way to notify clients of changes to state.
The tower itself has the health value. If you're changing the health value there, that's all that should be required.
You can do this on begin play of your tower, though you'd need to cast to your widget class, and put a reference object variable within the widget itself (I just left mine in this example as NewVar_0)
like that and set the variable from there?
This should be the begin play of the tower.
Ah can i then access its variables in the widget?
You normally want the UI replaceable without altering the game logic.
As the UI gets thrown out and different designs get tested or improved
Thanks
^ then that would be the bind in the widget.
You don't want to have to rewrite your entire game when you replace UI, so you inject refereces UI needs into UI and let it take care of itself from that point on
Ah ok thanks for clearing that up
That worked thanks π
Would i use that for any bits of hud that needs replicated i.e. Amount of points for the team?
Hi! I am researching the replication system, and I saw that we can set a determined tick rate for the network to send updates (by using NetUpdateFrequency and MinNetUpdateFrequency), I wanted to know if this tickrate is dependent on game framerate (FPS) or it is independent :)
independent, you can render in higher tickrate than updating actual data
awesome! so in case I need a stable frequency like every 100 milliseconds, I can trust it to keep it going despite the frametrate
Network tick always happens at the end of the game tick
So replicated properties will still be checked at most at the framerate of the Server, for example.
NetUpdateFrequency is the maximum frequency that property will be checked at, assuming you reach a framerate higher than 100.
TL;DR networking updates are applied in lockstep with the game thread.
And you'll never achieve a stable frequency outside of editor anyway, so you shouldn't build any system dependant on that.
What would be an appropriate or idiomatic way of sending the contents of a storage container to a client only when they open it?
Would I need to go via the player controller and tell it to update the container in question with a client call ?
Depends. You can separate the inventory of the container into it's own actor, and only make it relevant to players who are interacting with it.
That sounds like an interesting approach
One actor to handle the physical/visual interaction but another for the content seems a good way to solve it to me
Well, actually I am researching the fesibility to make some kind of lockstep system as Rts games do, so the updates should be relatively slow
It's doable to an extent but not inherently
UE replication is "lossy" by design, so it's very hard to make lockstep really work.
And the game-level networking and game thread are interlocked
lossy means that we expect to loss packages?
yep
Clients can easily get into states that never existed server-side for e.g. Clients can easily miss packets and never receive a given state etc.
All you are guaranteed to receive with replication is the eventual state, not all states leading up to it.
I see
The idea was to send commands (player inputs) instead of replicating certain costly/bandwidth intensive data such as unit positions, with a relatively low frequency.
As the inputs are very small, I read that some rts re-send the previous frame inputs (redundantly) so that if a packet is lost, we can reas from the next ones
Sending input only can really only work for fully deterministic lockstep sims
And Unreal is very much neither of those things.
So it will to some extent feel like pushing rope up a hill
Hear it from the almighty Tim Sweeney himself. Old post but still holds true:
https://forums.unrealengine.com/t/please-add-deterministic-lockstep-networking-for-rts-style-games/19255/9
Yep, that is also something we are researching on. We have custom deterministic pathfinding and I was also interested in the new Chaos physics, since they support a fixed tick update.
However, we are aware of the limitations of UE4 in this sense, so probably we will either use the default replication if we manage to optimize it enough, or make a complete custom solution and use UE4 mostly for rendering.
We aimed to support roughly up to 3-4k units simultaneosly, which is quite a lot for standard replication
For something like that you'll almost certainly need something bespoke
Another alternative we though of was to send inputs, but still sync the positions of the units with a very low freqiency to save bandwidth
In any case we will see, time to experiment a bit :)
@winged badger To track positions for 4000 units that are not actors
I'm at a cross roads with how I want to design the coupling between my mission subsystem and the mission component that lives on the player controller. I'm starting to write it in such a way that the sub system calls methods on the mission component to push data such as accepted missions, their current status, etc.
But I am thinking maybe it would make more sense if I created a bridge like class (non-BP, not a UObject) that the mission component gets from the mission subsystem and then the bridge would fire off events. Basically I would be going the other way around - the mission subsystem wouldn't know or care about the mission component
the mission component would depend upon the mission subsystem. The reasoning for this is that if I make the sub system required to push all mission state changes, now the mission system has to hold on to the player controller instance or the mission component instance.
So now, if the player disconnects and gets a new player controller assigned, now I have to make sure I update the mission component instance in the sub system. While that is certainly easy enough to do, it almost seems like a violation with Separation of Concerns
The mission subsystem is supposed to handle mission / objective states, loading the mission assets. It seems more clean to have the mission component just query the subsystem and wire up events during its begin play
fast array it is then, have a read at NetSerialziation.h header, all the network serialization documentation is actually in it
@crystal crag if the component is there just to handle the user interface
first you should cconsider putting it on HUD
and second, your subsystem can just broadcast mission status changes with adequate payload
The main thing stopping me from having the subsystem just have a delegate, is then all players will get mission updates that the component will have to discard unless it was meant for them
So it seems wasteful
So if I had the component just grab a hold of that bridge class instance and bind to it, then the subsystem would broadcast the payload to that bridge, which then only the player and the party members would get the payload
And then the component could request the bridge instance, and if I wanted other consumers subscribe for a given player, then they could also grab that bridge instance, and the mission subsystem wouldn't have to care who the consumers were
This is the most complex task I've handled with unreal, so I'm struggling with what design I like. I just keep staring at the monitor, hoping the design will magically pop into my brain and I can start coding it ><
wasteful is not really an issue here
having listeners ignore the broadcast that is not for them will consume maybe a microsecond during an entire hour of gameplay
but i am at a loss at what bridge instance has to do with a mission or the subsytem driving it
Hey guys, I'm having problems with networking and animations. So, I have an FPS character who has two meshes with following setup:
InnerMesh = CreateDefaultSubobject<USkeletalMeshComponent>("FPPMesh");
InnerMesh->SetupAttachment(RootComponent);
InnerMesh->SetOnlyOwnerSee(true);
InnerMesh->SetCastShadow(false);
`GetMesh()->SetOwnerNoSee(true);`
`GetMesh()->bCastHiddenShadow = true;`
`GetMesh()->SetIsReplicated(true);`
and I have else two classes: weapon component and rifle weapon. Basically every time the weapon shoots it runs ReduceAmmo method. When the ammo = 0 it fires Reload method of component, which is server RPC. Reload runs Multicast PlayReloadAnim method. If the current player pawn is controlled, it plays anim montage on InnerMesh anim script instance. Else it plays montage on the actual character, which is basically 3rd person mesh. And ** that's where the problem comes in**. If I run action reload it works just fine (pressing key) including listen server. But, if my ammo is empty it doesn't work on listen server. Anim montages play on 3rd person, but not 1st. However, if I run it on client it will work fine in both cases.
Please, help me understand what's the problem.
would need some more information or possibly code to help you with that
Furthermore, anim montage doesn't play in standalone correctly when Reload method was fired from ReduceAmmo
oh yeah, and reduceammo is a server function, not rpc
what can I do for you exactly?
from the moment when player fires?
well anything you think is relevant to the above issue
i think you have gated something incorrectly
possibly in your reload stuff
I play anim montages first person with my character's client RPC, which basically does
const float Length = InnerMesh->AnimScriptInstance->Montage_Play(MontageToPlay);
UE_LOG(LogTemp, Display, TEXT("Anim montage playing for: %.2f secs"), Length);
and the length is never 0.00
ok, sorry
what?
reduce ammo is protected. Reload is public
{
if (!HasAuthority() || !WeaponComponent) return;
if (Bullets == 0)
{
UE_LOG(LogTPPWeapon, Warning, TEXT("Clip is empty"));
return;
}
Bullets--;
ForceNetUpdate();
Client_InvokeAmmoChanged(Bullets);
if (Bullets == 0)
{
WeaponComponent->Reload();
StopFire();
}
}```
```void UWeaponComponent::Reload_Implementation()
{
if (!TPPWeapon)
{
UE_LOG(LogWeaponComponent, Warning, TEXT("Weapon's pointer is null"));
return;
}
if (bReloadAnimInProgress || !MyPawn || MyPawn->IsPendingKill() || !CanReload() || !ReloadMontageFPP) return;
MyPawn->SetCanRun(false);
bReloadAnimInProgress = true;
PlayReloadAnim();
}```
```void UWeaponComponent::PlayReloadAnim_Implementation()
{
if (IsRunningDedicatedServer() || !MyPawn) return;
if (!ReloadMontageFPP || !ReloadMontageTPP)
{
UE_LOG(LogWeaponComponent, Warning, TEXT("One of reload montage assets wasn't set"));
return;
}
if (!MyPawn->IsLocallyControlled())
{
MyPawn->PlayAnimMontage(ReloadMontageTPP);
}
else
{
MyPawn->PlayAnimMontageFPP(ReloadMontageFPP);
OnAmmoChanged.Execute(0);
}
}```
idk if i should paste here playanimmontagefpp
should have used three ` for cleaner
oh, i didn't know about this, thanks
oh yeah, and I have animnotify which resets bReloadAnimInProgress and does actual reloading
but since it doesn't play on listen server, the notify callback isn't called
hmm, did you try logging all the steps or using break points to determine where its failing? struggling to get a feel for how this works (seems quite clonky relying on an animnotify), i tend to just set the ammo when montage is completed.
I did, I know that montage doesn't play when it should.
I know I probably should've set timer rather than using animnotify, but the issue isn't it, so whatever
so where is it failing on the server?
set some breakpoints and debug where its failing
MyPawn->PlayAnimMontageFPP
maybe I don't understand you clearly. What do you mean by failing?
does it enter that function?
yes, it does
can i see that function
yeah, 1 sec
{
if (!InnerMesh || !InnerMesh->AnimScriptInstance || !MontageToPlay) {
UE_LOG(LogPlayerCharacter, Warning, TEXT("In 'PlayAnimMontageFPP' some nullptr occured"));
return;
}
const float Length = InnerMesh->AnimScriptInstance->Montage_Play(MontageToPlay);
UE_LOG(LogTemp, Display, TEXT("Anim montage playing for: %.2f secs"), Length);
}```
as I said, log never returns 0, which is a sign that everything worked correctly, I guess
this is client rpc
PlayAnimMontageFPP is a client RPC?
right
you should really name these functions better π
my bad
ClientPlayAnimMontageFPP
yeah if its running that and returning a value
but animation is not playing.. maybe its to do with the visibility options on the mesh?
tried setting the visibility based option to always tick bones and refresh?
maybe, but I don't see how it could
no
on the skeletal meshes
there is an option for that
otherwise you will need to more debugging to find out what is happening, using breakpoints and stepping through the code
well, I tried, but when I do step in it takes me to some .gen files and then everything crushes
do I have to do smth like this ?
{
bool const bFirstPerson = IsFirstPerson();
Mesh1P->VisibilityBasedAnimTickOption = !bFirstPerson ? EVisibilityBasedAnimTickOption::OnlyTickPoseWhenRendered : EVisibilityBasedAnimTickOption::AlwaysTickPoseAndRefreshBones;
Mesh1P->SetOwnerNoSee(!bFirstPerson);
GetMesh()->VisibilityBasedAnimTickOption = bFirstPerson ? EVisibilityBasedAnimTickOption::OnlyTickPoseWhenRendered : EVisibilityBasedAnimTickOption::AlwaysTickPoseAndRefreshBones;
GetMesh()->SetOwnerNoSee(bFirstPerson);
}```
it's from ShooterGame template
can try it?
yeah, why not
I find that I am not using BeginPlay much for components other than wiring up to a system onready delegate of some kind, to then go and do more initialization. Is this a design smell? Is this more common in multiplayer games?
For example, my inventory system, upon a player joining, fires off an HTTPS request to get their inventory for the character. The inventory component is created before the HTTPS response is returned, so in the inventory component's beginplay, it just (on authority only) sets a timer to check if the player's inventory is ready every 0.5 seconds
then once it is, then I trigger a call that has the inventory component finish it's initialization logic
I could tackle this problem partially with beacons and preloading all of the player's data ahead of time, but that is a challenge for another day.
or maybe that's how all games generally do it and I am just doing it wrong
a timer?!?
why doesnt the request trigger the inventory component to update when the data is recieved.. π€
but normally tho, players inventory is done before they even load into a gam
upgrading my project from ue4 to ue5, the only plugin that didn't work is advanced sessions plugin. i stripped the advanced sessions plugin from the project to pass builds, and am trying to figure out how to re-add multiplayer. someone on the forum said this (see screen shot). can anyone explain what this means?
I believe you need to edit the Build.cs file that is contained in the source folder of the plugin's folder.
AdvancedSteamSessions/Source/AdvancedSteamSessions/AdvancedSteamSessions.Build.cs
There is a line in there that reads:
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
and you'd probably want to remove
|| (Target.Platform == UnrealTargetPlatform.Win32)
Then you need to recompile.
thanks dude
Anyone have a nice C++ unreal multiplayer repo I could look at ?
If you're looking for sample code, the Epic ShooterGame example is decent. I think you can get it from the epic marketplace for free
I'm trying to make a multiplayer game ..with listen server ..can any one help ..I've further questions ..
1 . Is Listen server is only limited to LAN ?
2. Is there any player limit on listen server ? Also Is this any nessasary that all players must be on same Wifi ?
3.Can there be Opensource alternative for Listen server or Dedicated ..?
4. How do I create this multiplayer ? Is it only through Widget with Host and Connect button ?
Any tutorial link is appriciated ..an Advice will be Loved ...
Thanks for help
cuz after pakaging I'm just stuck that how to connect both diffrent system
@everyone
No listen servers are not limited to LAN, I would recommend watching and finding some resources on multiplayer and sessions
Hello,
yesterday i was playing the new battlefield and noticed soemthing that got me an idea to try out.
In games likes Battlefield you always see your own team as blue and the enemy as red. In Hearthstone you see the playfield always from the bottom, but for all players it is the same, like you would sit on the same side of a table. What would be really weird for a card game.
So i was wondering how would you do something like that. That the playfield always look the same for each player.
Right now ma games works like this.
Each Player says to the server please spawn me 5 cubes and replicate that to the other player. Player 1 has his cubes on the left side, player 2 on the right side.
My idea now would be instead of telling the server to spawn my cubes and replicate that. I would only tell the Server i have spawned 5 cubes but don't replicate them only tell the other server that i spawned 5 cubes. When the server tells me that the other did that, i tell see server, ok please show me 5 cubes on the other side of the playfield.
Makes that sense? Would you do it another way?
If you think about it, you can control where your cameras are for your players. So the "left" side for player 1 and 2 would be opposite. All that requires is you have your server spawn the cubes where they need to be for either player (to the left of player 1, to the left of player 2)
In terms of visual apperance, that is something that you can control on the client side. You can have a replicated w/ notify variable on your actors such as "team ID" and in the Onrep function, if the "team ID" == your team (stored in the playerstate or playercontroller), then apply a texture that is blue to the actors, otherwise apply a red texture.
Using the example below, you can see CameraActor and CameraActor2 - let these represent player1 and player 2 respectively. From their own view points, you can see that "their side" is always on the left.
@sinful tree
Im trying to understand what you just said, and i hope i understand you correct.
The Camera thing i understand, i would just turn the camera 180 degrees in my game for player 2.
The thing with the "replicated w/ notify variable" i have my problems. If i understand it correct i would at a variable to my actor like you said "Team ID". When the server spawns the actor for player 1 i assign to that variable "Player 1" or something.
But how would i check the Team ID? Can i just create a Costum Client Side Event that gets the Team ID from the Player 1 and checks if they are equal?
You got it. The team ID you'd probably store on the player state. Here's an example I have, though I know using "GetPlayerController" in multiplayer isn't necessarily the best to do....
Anyone know what would cause
OnComponentHit
on a character's
CapsuleComponent
to not be fired for players that are clients?
It only fires for the server player when playing as listen server
Where are you binding it?
In BeginPlay on a UActorComponent on the character
Capsule->OnComponentHit.AddDynamic(this, &UCharacterFallDamage::OnHit);
Is the actor component a default subobject?
Yep
No if checks on the binding?
Not sure what you mean sorry
If you have any sort of if statement checks, or early returns that could stop the binding.
if (GetNetMode() < NM_Client) for instance.
Or authority, or anything similar.
I have a two for checking the owning actor and the capsule component aren't null, but i have logs and breakpoints inside and they're not being executed
That's odd. So I assume that the capsule component is not valid in this other component on it's beginplay?
This is the entire BeginPlay. Note the log at the bottom, which is being logged
void UCharacterFallDamage::BeginPlay()
{
Super::BeginPlay();
GET_OWNER_GUARDED(Owner);
OwningCharacter = Cast<AMMCharacter>(Owner);
if (OwningCharacter == nullptr)
{
UE_LOG(LogFallDamage, Warning, TEXT("UCharacterFallDamage must be added to an AMMCharacter"));
}
auto Capsule = Cast<UCapsuleComponent>(
OwningCharacter->GetComponentByClass(UCapsuleComponent::StaticClass())
);
if (Capsule == nullptr)
{
UE_LOG(LogFallDamage, Warning, TEXT("UCharacterFallDamage requires a capsule component attached to the owning actor"));
}
Capsule->OnComponentHit.AddDynamic(this, &UCharacterFallDamage::OnHit);
UE_LOG(
LogFallDamage, Warning,
TEXT("UCharacterFallDamage::BeginPlay called on %s"),
Owner->HasAuthority()
? TEXT("Authority")
: TEXT("Non-authority")
);
}
well it would crash if the capsule component was null
would also crash if OwningCharacter was null
whats does OnHit look like?
Also to be clear, the Non-Authority, is logging?
i am also wondering why you are using OnHit on the capsule for falling damage..
rather than binding to the Landed delegate on the Character
Both are
Its not exactly "fall" damage, its any impact as we're adding new mechanics to the game in the very near future. I need to rename the component
yeah but should you not do different things based on if it was from falling via impact from say a thrown rock?
anyway digressing
At this stage, no since the velocity is the important thing
So further testing, now i found that actually its the OnTakeAnyDamage that isn't being fired
yeah but that is server only
We have weapons that call the ApplyDamage on the server and they work fine
ApplyDamage is server only
(well it should be, you should never deal damage on the client)
if you want clients to receive that message, you would need to either client rpc from the server or multicast if its all clients
Yeah the OnHit is being called on both and i have a HasAuthority check and only calling the ApplyDamage if the owning actor has authority
right so clients wont have OnTakeAnyDamage called
Correct
But its not being called (on the server) at all if the player that falls is a client
even though OnHit is calling ApplyDamage from the server anyway
Probably character shenanigans. There should be functions on the CMC and character for hitting things while moving. Check if they work instead of the bare bones capsule event
Hello! I am following an online networking tutorial and have set up a basic moving platform that replicates its position. It works correctly in editor, but if I launch a server through command line and connect the platform does not move. Any idea why?
Have you tested in PIE with dedicated server?
How so? like launching as Client?
Yeah. Or at least test with listen server as well so you can see what the server sees
Everything is fine in PIE as client and as listen server
K what about pie with dedicated
so I am spawning my server via the command "D:\EpicGames\UE_4.26\Engine\Binaries\Win64\UE4Editor.exe" "G:\UnrealProjects\PuzzlePlatforms\PuzzlePlatforms.uproject" /Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap?listen -server -log
and connecting with the command "D:\EpicGames\UE_4.26\Engine\Binaries\Win64\UE4Editor.exe" "G:\UnrealProjects\PuzzlePlatforms\PuzzlePlatforms.uproject" 192.168.50.114 -game -log
When I connect, all the platforms are now moving in a straight line and not reversing as they are scripted to
I'll test again with the editor closed
I seem to have spawned under the map.
oh, I was launching the wrong thing.
Same result.
@dark edge Is that what you mean about PIE with Dedicated?
No I mean you can launch a dedicated server and client from the editor
Has anybody else run into the issue of servertravel only working when using the default server port? (7777) When I server travel on other ports, the client ends up dropping the server IP address in the map travel, and ends up opening up the map locally rather than on the dedicated server -- any suggestions?
i.e. server travel to map while connected over the default port:
LogNet: Browse: 192.53.121.254/Game/Maps/RoyalGarden/RoyalGardenExpanded
server travel while connected to a different port:
LogNet: Browse: :7778/Game/Maps/RoyalGarden/RoyalGardenExpanded
notice that the port gets added automatically but the IP address is removed
well I've figured it out. If anyone's curious, this bug appears to only happen if you launch multiple instances of a dedicated server and have Unreal automatically resolve the ports (i.e. if you start two servers, the first one will take 7777 and then the second will take 7778 since a process is already bound to the first port)
if you manually give it the PORT=7778 flag, relative servertravel works properly
Hello guys, would someone have an answer for that?
https://answers.unrealengine.com/questions/1056937/actions-from-2-blueprints-in-multiplayer.html
Thank you
Anyone what source file the CreateSession node is in?
I tried finding it with Rider search with no luck
Even tried doing a general search on thigs that inherit from UK2Node
Ah. That's why I couldn't find it
It's not a UK2Node π€¦ββοΈ
It's just a UBlueprintAsyncActionBase. Pain
can i use advanced session and the steam onlinesubsystem and steam advanced sessions and join without port forwarding? https://www.youtube.com/watch?v=EDNF2DNLhPc&t=902s&ab_channel=DevAddict this is the tutorial i used and im confused if my friend can join from another network without me or him having to portforward
Check out my Unreal Engine 4 courses:
βΊSouls-Like Action RPG with Multiplayer: https://devaddict.teachable.com/p/souls-like-action-rpg-game-with-multiplayer
βΊMultiplayer First Person Shooter with Dedicated Servers: https://devaddict.teachable.com/p/multiplayer-fps-inspired-by-cs-go
βΊMultiplayer Top-Down Dungeon...
Yes
will i have to open any ports at all?
No
like on the firewall?
You haven't needed to open ports for a game in the past decade because games use NAT punch instead, and UE4 + Steam does precisely that
Firewall is a completely different matter, that's an OS thing, not a network thing
AFAIK Steam disables firewall for games it installs, otherwise it's up to you
Ahh, my friend tried without advanced session (the default create and join session that ue4 gives you) and it didn't work before, but i changed to advanced sessions
Advanced sessions doesn't do it, the Steam online susbystem does
Yes in the tutorial he doesn't enable the plugin "Steam onlinesubsystem" but he types this stuff into the defaultengine.ini is that correct?
`[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
[OnlineSubsystem]
DefaultPlatformService=Steam
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"`
this is exactly what i typed
Am i missing something?
That's correct, just need to create sessions then
AFAIK that's either C++ or Advanced Sessions
Yep i used advanced sessions
so im guessing that the default sessions wasn't working with steam and that's why my friend couldn't join
Hi i have a strange issue. When i package development build, my game runs fine. But once I package to shipping build, the game rubberbands alot more, i have tried to set a higher bandwidth limit like here https://answers.unrealengine.com/questions/392972/bandwidth-limit-is-10000-kbs-irrespective-of-setti.html?sort=oldest but the issue is still there
The game is intended to run on LAN
has anyone encountered similar rubberbanding for shipping build before?
Did you test the game with packet lag in editpr
yes i did, and it only delay the response but no rubberbanding
strange thing is development package works fine
its only shipping that has issue and I can't think of what can cause it :/
One thing is that my game runs physics capped at 120fps, so I'm not sure if it may be because Shipping Build somehow does not comply with the 120fps cap
i have some problems with pixel streming in azure cloud. thank all
here is a way to fix network rubberbanding not sure if this will help you though: https://youtu.be/nHfSGuMKIkc
Add this to your DefaultEngine.ini for a huge performance boost!
[/Script/Engine.Player]
ConfiguredInternetSpeed=500000
ConfiguredLanSpeed=500000
[/Script/Engine.GameNetworkManager]
TotalNetBandwidth=500000
MaxDynamicBandwidth=80000
MinDynamicBandwidth=20000
[/Script/OnlineSubsystemUtils.IpNetDriver]
MaxClientRate=800000
MaxInternetClientRate...
just trying to help here
oh this should probably be in other channel mb
I have added these but im not sure if its cus shipping build ignores it or something, let me try again
Does anyone have a tutorial for client side pawn possession/dispossession via character controller?
also the guy obviously demonstrating in development mode (see his debug text). I have no problem whatsoever in development package, it only occurs in shipping
do it on an owning client event/client rpc?
Wait a minute
you said the fps is capped to 120 right?
that is not normal in packaged build
vsync should be off
which makes my issue much harder to debug :'(
i set it in settings
Oh
This seems like an unreal engine bug, i think you should report it
but again ue4 physics is terrible for networking so im really testing the waters here :/ its just weird that development builds works and not shipping
Yeah
that's what i mean it's weird that its different, it shouldn't be
but UE5 already use chaos so i doubt they will deal with UE4 physics hehe
ue4 physics can be weird in multiplayer
ye what a pity
Hi, do u happen to know an optimal physics replication settings? There are so many numbers and im not sure if the default is best
You can't really replicate physics.
It might be possible with Chaos later on in 5, but PhysX is not deterministic
There is no way to get solid results in a general case, you can only work around some important objects with huge amounts of interpolation
Hey folks, is dedicated server state in UE5 is okayish right now? Have small project, which I cant convert to UE5, but its relatively fast to migrate most of components to UE5. Just curious about dedicated server stability in UE5
"Stability" in UE5 is just not really a thing right now and no one operates any dedi on it
So maybe it works as well as UE4, at best
With the large changes with LWC and world partition I kinda doubt it
I would expect servers to work better and better with Epic moving Fortnite to 5
Whats LWC btw?
hello
Any idea on how to setup a simple multiplayer for VR in unreal? like 2 VRs with 2 PCs ?
Is there any really significant reason CMC updates visual offset via relative transforms instead of world location?
General multiplayer implementations don't really change for VR. You still do most things the same way. VR is nothing more than a different control set and view style. For example, your question can be read the same as "How to implement multiplayer for gamepads instead of keyboard/mouse." There will be minor handling differences, but the networking is largely the same.
Thanks so much, i expected the same thing as i thought about it, ok what about using it wireless ?
2 or 3 vr quests
It can be done easy wirelessly right? maybe Iβd have to package first
Just to clarify. Do you mean one VR headset per PC, or multiple VR headsets per PC? I was under the impression it was one per PC from your first question?
There is a very big difference of handling with local versus online controls which is why I ask. If it's one per PC, then it's fine however they connect. If it's multiple per pc, then that likely depends on the PC and how it connects. I'm not even that familiar with how to handle that with multiple gamepads. Local coop stuff isn't that popular anymore outside of consoles, and even then it's kind of an afterthought most times.
don't think you can normally work two headsets with one pc, usually tested with one and as client mode / server launched separately
or without vr just locally
The most I know about local coop is that the engine checks every frame if it should do split screen or not regardless of coop style games. π
Yea yea i meant one per PC
it works fine in development build as i said, the key is fixed timestep. Generally it runs smoothly, only shipping build gave me issue
i suspect shipping build does something weird to the timesteps because when my vehicle drive in open area theres no problem in shipping build either, but the moment i get near dense forest then the rubberbanding happens
but the fps still seems smooth, way higher than what I had set as minimum for smoothing
so i believe it may be really a bug
for development build it works fine no matter where I am
Hey, so I tried assigning InnerMesh->VisibilityBasedAnimTickOption = EVisibilityBasedAnimTickOption::OnlyTickPoseWhenRendered; and calling
{
InnerMesh->VisibilityBasedAnimTickOption = IsLocallyControlled() ? EVisibilityBasedAnimTickOption::AlwaysTickPoseAndRefreshBones : EVisibilityBasedAnimTickOption::OnlyTickPoseWhenRendered;
GetMesh()->VisibilityBasedAnimTickOption = IsLocallyControlled() ? EVisibilityBasedAnimTickOption::OnlyTickPoseWhenRendered : EVisibilityBasedAnimTickOption::AlwaysTickPoseAndRefreshBones;
}```
method in BeginPlay and when my character dies. Also I set `GetMesh()` to not replicate. All like in ShooterGame. Though, nothing changed. It still works on clients and when I reload from key event, but not from weapon directly on listen server and standalone.
I'd highly appreciate if you or anyone could help me. And I don't know what I should exactly see when debugging.
I managed to solve my networking issue, mostly. Hot Reload was messing up my builds so i had to regenerate the intermediate folder
π Hey guys! I just watched the "Network Multiplayer Fundamentals" live, and I felt like "I need more."
I think I just got the basic concept of how Multiplayer works in Unreal Engine. But I wanted some more "Real Examples."
Is there any live, talk, or even a course that can give me that? 
I still cant accept external connections but all of my actors are behaving properly
I would also like to know. The Udemy tutorial i am doing is just now getting into replicated functions.
Witch one?
Why?
A lot of it is filled with really basic gameplay programming, its poorly paced, and the host makes frequent errors he then has to correct.
πΆ good to know...
I am going to keep progressing with it. Maybe it gets more interesting later
Its very hard to find a good one on this topic
just let me know
refund till you can
till you can refund
The physics replication settings are used to tune the error function driving physics corrections. Basically they determine how close the physics state has to be to be considered "close enough". You'll never get perfectly in-sync physics, instead, the default replication system uses State Synchronization to keep the simulations mostly in sync.
Introduction Hi, Iβm Glenn Fiedler and welcome to Networked Physics.
In the previous article we discussed techniques for compressing snapshots.
In this article we round out our discussion of networked physics strategies with state synchronization, the third and final strategy in this article series.
State Synchronization What is state synchroniz...
That's basically how it's done in the default implementation. If you're capable of doing other implementations, you wouldn't be asking any questions here lol.
@cerulean juniper @left marsh I would recommend Tom Looman's course. It has more of a focus on C++, but it also does have BP's. It also shows how easyβ’οΈ it is to just dive into C++. Overall - probably the best gateway to Unreal imo.
The C++ course mastery?
I'm already confident in my C++ skills. Does his focus on multiplayer?
Tom Looman does have multiplayer stuff but I don't know about that particular course
These look great. Thanks!
This one, yes.
It is pretty darn good. Covers all that you need to know to get the ball rollin' with MP
i know how it works but I just wonder if people have experience with tuning the settings cus it surely can have a big effect from my countless tests
the physics that is running for me is deterministic enough when running 2 standalones it will produce the same simulation in a small scene. But ofc when running in big world floating point precisions start to hit
I don't think anyone can help you here much, as the general knowledge is that UE4 physics aren't deterministic and don't have a fixed timestamp.
All movement replication would require you to locally keep track of the whole physics scene to be able to replay moves on correction. Without that you will get rubber banding and all of that. On top of that, vehicles with physics are usually done client auth.
If you need this all to work you'll need a lot more coding than just changing a few default variables
u can fix the timestep by using supstep with max deltatime. and using smoothed framerate or cap max framerate. i.e with max 1/120 ms substep and u cap framerate at 120 then when the fps drops the substep deltatime will be fixed at 1/120
this i believe is why dark souls cap their game at 60fps
to have a stable networking outcome
my problem now is that physics run very fine in development build, but in shipping build it all go rubber
thats why i suspect theres some settings thats not carried over to shipping :/
How would I make sure client that creates an actor would be the only one able to call certain events?
For example: my 2 characters are both creating actors and itβs just messing up everything
I could handle it in playercontroller, but surely there must be another way right?
My characters are replicated
They both need weapons to spawn, and be able to use them (animation and projectiles, damage replicate)
Problem is with them being able to use the weapons
well a UFUNCTION(Server) can only be called by the owning client anyway
The projectiles animation and damage works
But if I call the spawn on beginplay
Wonβt they both have created them locally?
well that depends
Wow I just fixed shipping build physics by forcing fps cap on 60! so happy π been struggling with this since yesterday -.-
uh that doesn't sound like the best solution, unless you mean you enabled substepping
Let me get my project open to clarify
i use substep to force fixed timestep. And cap fps to ensure it does not go more than the deltatime
this is a common solution in Dark Souls
due to UE4's physics its the only way for somewhat deterministic physica
yeah but relying on a fixed framerate is what I'm kinda uneasy about in general
its not fixed framerate, its framerate capping
very different
since physics substepping is likely doing most of the work for reasonably okay physics
no dude its capping 60 max not fixed
if people go below it will run more substeps at fixed dt
it's effectively fixed if you're consistently hitting the performance target
actually going below is very good
did you try it with t.maxfps 20?
current deltatime is 1/120 so as long as everyone fps is below that it all will sync
I'm afraid the reason it doesn't work in shipping is that it just accidentally works in development because you get exactly the right performance level
yes
you're going to struggle to use the editor
the point is for fixed timestep the fps cannot be more than substep limit thats all
:triangular_flag_on_post: Tio Esquilo#2037 received strike 1. As a result, they were muted for 10 minutes.
huh?
that's not at you
i think ure missing the point
but now the message got deleted
so what if your players want to get the game to run on their fancy 144Hz monitor and they remove the fps cap in their INI?
too bad for them this is the cost of networked physics
Sorry about that, for confusing the convo removing that message.
theres trade off
Dark Souls limit at 60fps and sells fine
i doubt 144hz pple will have much to complain
I think the only thing I'm thinking of is that there must be a way to get the desired outcome without limiting FPS
yes there is with Chaos
yeah because modders fixed it for unlocked framerates
but since UE5 isnt stable yet and my game is still UE4 :/
If I needed networked physics I would use 5.0 branch with Chaos and try to get actual deterministic physics networking online, if you can get it to a plugin you'll make literal bank
okay actually, I think I may have a different issue than replication
Chaos has fixed timestep independent of the fps so u can decouple it entirely
so I'll try fix that first π
not stable enough for production
Release-5.0 stream exists so hopefully a preview before the end of the year
but im just happy my shipping build works as intended atm
but i cant wait for Chaos tho
its amazing from my UE5 tests
just cant rely on UE5 yet :/
Maybe not now, but when is your game releasing ? Next 3 months ? Next 6 months ? It will be essentially done by then
well is your game shipping? you could always make a branch/stream to do UE5 experiments in
this week for some clients
Alright then, just don't be too surprised if some players experience massive rubberbanding
it will run on Local network anyway so i worry not too much, but shipping was rubberbanding even on LAN due to the fps issue
its for an exhibition
like a simulation
so i've calculated my tradeoffs already :(
oh on LAN might be okay and it's a controlled environment
:)
yes
this game wouldnt be ready for consumer at all
it has many horrible unoptimized parts Im very aware of lol
Ive done the risk analysis
well for your client when they have to foot the bill for hardware, don't be too hard on them
dw they all were quoted to use rtx 3080 or rtx 3090
they are the military
hardware is np
aha it is
but for military
its like they build this vehicle battlefield game where commander will deploy vehicles and players will take on roles to drive those
so there are tanks, light strikes, frigates, helicopters and jets
all run on physics
networked
and I had to dev it all solo, even had to rig the vehicles -.-
yeah, I can see how that could be problematic
surprisingly it all turn out fine
the tank i even used niagara to simulate the threads
okay different question, since it seems I might have messed up earlier in creating this... π
should you be using the character to handle it's input or playercontroller
I changed it to playercontroller since that made my rotation input (tick based) easier to manage
but now I'm getting reference issues on the controller
idk how to properly debug multiplayer yet...
you can actually use either for that, I think controller might have the slight edge since if you respawn but pressed move forward before spawning, you have to repress the key if you go the pawn route
though why would you be processing rotation in a tick?
combination of mouse/gamepad look rotation in topdown
depending on current input device
the tank playing with commander shipping build, no more rubber π
maybe i should cap it at 120fps to match the substep deltatime
@keen surge we just calculate the DesiredHeroRotation inside the playercontroller, then the Hero's movement component, pulls this and rotates the character
yes I'm using SetControlRotation and it works just fine
but I'm wondering why I'm getting reference issues...
what reference issues?
it's probably all good then
PC complaining about accessing none as playerRef
I'm trying to figure out on what client or server it's going wrong but as I said I'm no good with debugging multiplayer
well player controller only exists on owning client and server
might be good with a more verbatim error, but in a multiplayer environment, your pawn might not be set right away - even if you instantly spawn on join
controller is always spawned before pawn, and can tick before pawn is even possessed
so if you handle input on the PC, you have to bear in mind that the pawn you get might not be valid or might be something like the spectator pawn
so maybe show the crashing code?
it's not really crashing that's the weird bit π
it looks fine, but yet it gives errors
and I'm just setting it at beginplay like so
at the branch it's telling me playerRef is None
but only a few times when I join a client
host only is fine
at least ur Blueprint looks clean and commented
Oh BP, but in MP the player pawn can and will be null
i hate messy blueprints XD
might also change it to C++ for some parts when needed, but I like how easy BPs are to iterate
Your main issue is trying to get the Pawn on BeginPlay
You can have input events firing before the client has acknowledged possession
Cause BeginPlay of the Controller doesn't mean it's valid
u should use OnPossessed to get the player
And yeah thatβs bad in MP
right, so how would you do it in MP?
and then replicate the playerref
There are events for this. Character has an OnPossessed event for example
Movement input should also be done in the Character if possible
PlayerController is more for Character independent input, like menus
that way PlayerRef will be available eventually, also put a "IsValid" check on the PlayerRef as well everytime u fetch it
never use object pointers without IsValid checks unless ure 100% sure
Or validated get
ye or this
yeah my issue with that was rotation through character
I can just have it in playercontroller without any struggle
No sure what the issue would be here
The code you are showing should work fine in the Character
And if you can use C++, have a look at the framework classes, cause they have tons of functions that BPs don't have
e.g. OnRep functions for Pawn in the Controller
see, BP has an issue though, and its one of the things i dislike, there is not many of the client side callbacks for the OnReps
so, only movement input, or just all character specific input?
I mean idm changing everything to C++
I've just not worked with it much and last time gave me a headache haha
in c++ you can use SetPawn function to cache a ref to the player.
I was trying physics stuff, and for some reason it wen't all spooky
this gets called from OnRep_Pawn and Possess
With multiplayer aware stuff, itβs always easier in code
alright time to rewrite it π
I barely trust BP beyond basic value replication
even i struggle with basic stuff
i have had onreps not fire, until i deleted and remade the property.
inside BP's
yeah I found BPs really useful with how fast they were to iterate on
physics usually go spooky in multiplayer
but I've only started on MP yesterday
the only way to make physics behave in UE4 is to cap the fps
no..
and use substep
was afraid it wouldn't work but it's no big deal
look @ rocket league, and other physics based multiplayer games
or rather, harder to make it work than just coding
basically how i made my vehicle physics to work over network is from here
Rocket League use Bullet Physics
i dont think changing physics engine is a small task for any individual, it can be done, I did look into it as well
but the cost was too high
for my current project
Almost every well behaved networked physics game made in UE4 use different physics engine/solver
to use standard UE4 physics the fps capping is the only way
That's not really true, Fortnite doesn't
FOrtnite uses Chaos
fornite has been using chaos for a while
it didn't
its the game that invented all the Unreal tech
It may do now, though I haven't seen any source for that, but it didn't before
its first cars were not chaos
Yeah because they have actually functional networked vehicles
also Fornite doesnt have "physics simulation"
Yeah it does
fortnite use movement components
these components have very specific ways of simulating their movements deterministically
it cannot be applied in general
The cars use physics
no they use their own components
those components have their own physics solver
Alright, I give up, good luck
just like how their projectile components solve its own motion
it does not rely on the physics engine
as i said, if you want networked physics in UE4 right now without capping fps you need to implement ur own physics engine/solver (like the components above).
Only in Unreal5 Chaos have deterministic overall simulation
I use tight enough settings to get my physics driven movement close enough to not matter. It's a matter of tuning really. There's no one perfect solution.
Even the water vehicles in fornite have their own floating components to resolve the physics by sampling the gerstnerwave generators that syncs with the GPU shader
Why so you guys keep conflating determinism with networked physics. It helps but is not a necessary thing.
this is very true
Deterministic helps with extrapolating physics much better and prevent error
Keep it deterministic enough to not devolve chaotically between state updates and you're in good shape. Prediction is the real pain point. If you're ok with ping delay it'll work just fine as is.
with state sync it will be ensured that things will somewhat behave correctly
only need for 100% deterministic is when using lockstep
but that's far fetched...
I don't play Fortnite but gotta ask, how does it handle vehicle vs vehicle collision? 2 clients can't be correct.
that's very cool, i think these days many things are becoming more client authoritative, because it opens up for more user experience. The cost is to build a better cheat detection and stuff
i think it does both client and server
i have no idea, i just know that from UDN posts and information i see floating around
like it does prediction on client
not got to vehicles yet, that is next years task
Physics prediction on client is perfectly normal but for collision it gotta be server
i do notice if you hit another vehicle driving towards you, you kinda clip in and then bounce back
Im working on a vehicle construction and combat game and we're lucky it's slow paced enough to not need prediction. Predicting arbitrary-performing vehicles sounds like hell.
so i assume server just does the corrections
Yeah that sounds par for the course.
i think prediction can be good, because you will only need to predict the next few hundred ms or so
but prediction has the ugly rubberbanding effect on collision :/
thats exactly the rubberband i mentioned
it predicts on client and corrects on server
I'd rather have good collision and everyone agreeing on the world state. Our speeds can be high but it's not a twitchy game.
for my game i also did not do prediction (i tried), but it turned ugly fast
same
Can't do Rocket League without prediction but they had a hell of a time doing it. And that's for a game where all vehicles are pretty much the same.
most vehicles will need accelerate and stuff so with input lag it's no problem, cus everything takes time to change
only for fast moving player capsules then prediction is crucial
They also used much better physics engine
there was a point in time I wanted to jump over to Unity for their physics XD
but now that Chaos is here there's no reason to
btw do u have video of ur game, I'm excited to see glimpses π
@keen thorn Old but this is a prototype video
https://youtu.be/WAZWfSwHFXk
woa looks cool
this would be cool in steampunk style
i like the gyro balancer
π
somehow reminds me of scrap mechanic
That's debateable tbh
Not only that, but probably even a false statement :D
Hi, thank you for your help with this.
But i'm having some trouble.
Your example, is it a normal function or a repnotify/OnRep function? (That ist could be a repnotify just name to me now π
)
I used it as a normal function in my cube actor. But i think it isn't working for me because one of my actors ist the servern so can i even do things localy if he is the server?
Right now only the second player is doing it. But for some resons in didn't figured out yet. All my cubes are blue.
If the ID is controlling a State, then it should be a RepNotify
If no state depends on it, then it can be a normal variable
subjective statements cant be false, only those that judge such statements can be so :D
But that wasn't subjective :D
"much better" is inherently subjective
Anyway, they basically used whatever UE3 shipped with and improved it afaik
there's even debate in physics if Objective reality really exist hmm...
And given it's UE3 and not 4, it's even harder to compare this
I remember UE used havok for a while before going PhysX right
But yeah, Physics and MP, straight out of the box, is a bit of a shitshow
it is a never ending story indeed
PhysX is a really good physics engine, UE's implementation of it has always been the problem.
Authority driven maybe not, but if you are the one controlling the physics actor, it's not so nice
PhysX is really good especially the latest PhysX 5.0 used in Omniverse i think
but like @thin stratus says, physics sim is all beauty until networking comes into play
Yeah James is very well aware of this haha
IIRC Epic actually bought the company that was originally creating Chaos, then continued dev as their own
Last time I had to do "physics" I fell back to fully calculating what I needed
(which was hover physics of a flying donut shaped drone)
Where our client implemented it with normal physics ;_;
I believe u, I did deterministic lockstep and had to constraint all physics to be spheres only
would be too much pain otherwise
I gave up and went client auth
Haha, I gave up on normal movement on Bang-On Balls and went Client auth there too
When Epic told me that Fortnite was Client auth, I suddenly realised it's probably not going to be an issue for me if it's not for the biggest game in the world at the time
cool did not know this, which company was it?
I can't remember tbh, just remember seeing that info floating around somewhere
You can do a lot of Client Auth as long as you don't trust it all :D
Racing Games for example I would probably always do Client Auth
I'm interested to see how Chaos integrates with network prediction, but if you look at the implementation currently it's just another unscalable solution.
Can't imagine F1 2021 Server Auth
but collision between players gotta be resolved server auth right
Yep
maybe the normal movements can be client
but in a predictive model it's impossible
"You didn't hit the sausage curb, but let me tell you, you will with this nice 2mm correction!"
All clients simulating in different relative timescales and with lossy gamestate
The only way to really do it is deterministic lockstep, but that's impossible unless your entire architecture is deterministic too
Which UE's isn't
Especially when you consider replication
I don't know how F1 games are done exactly, but I assume they are Client Auth and the collision between 2 cars (given the rubber banding when you really crash) is done Server Auth
I came to the same conclusion, for network physics, do client auth for the lesser pain
tbh with even the lowest grade of anti-cheat you can make it acceptable
I would actually, even with Lockstep, be a bit scared of saving moves
Like, do you save the whole physX scene too?
F*ck that?
yeah it's impossible to reach any sane scale
Works for rocket league where you have 9 physics objects max
Yeah okay
Less so for a game with stack of barrels
Lockstep will run quite well if you mix it with state sync (very possible cus i did).
key is to find the sweet spot
There really is no one-size-fits-all solution to this problem tbh
If I would want to create something that is very physics heavy and multiplayer, I would probably not use either of the two bigger engines available
Just have to roll with whatever works best
Idk but I feel like it's more fighting than needed
and the simulation need to be as deterministic as possible, like the next few hundred ms or so
tbh making the sim deterministic is relatively straightforward
but keeping the inputs to it deterministic when all the input is coming from different relative timescales is the hard part
True lockstep means shit loads of input lag too
Games like Gangbeasts, where you have these wonky characters that can hold each other and lots of physics going on. Or Human Fall Flat, idk ,scares me, but haven't really spent much time check how to achieve this with UE4 anyway
yes this is where lockstep shines, and to correct for divergences some state sync is needed in between
yeah. an old RTS/FPS I play uses that same approach
Like, even in Bang-On Balls, we currently have this issue where Clients are Client Auth, dash into another Client or AI, and the response is just laggy
Cause they can't predict the hit
;_;
But they have very simple physics sims, unlike todays games with crazy vehicle sims
Hell even convincing vehicle sims are an entire career path
because lockstep guarantee order on input, but like u said it has few frames lag which is why it should only be used for vehicles and not Sonic
And BeatNUps?
That sounds like a good usecase for those
Iirc they even show the input delay at the top
conclusion is as @thin stratus said, networked physics is a shitshow XD
always a tradeoff, cannot have perfect...
*Networking is a shit show
*Game development is a shit show
I kinda hope that UE5 helps with interactions between Characters
yet you wrote the amazing compedium that got me into UE4 multiplayer dev 3 years ago
I don't know what they all change with their prediction plugin
XD
Networked physics in particular is a particularly fresh sort of hell
But I'm so annoyed that I can't have 2 Clients interact with each other without it looking laggy
I wouldn't worry about it, nobody else has solved it either π
Apart from letting them run through each other
Yeah but BangOn Balls literally has banging into each other as a feature
u gotta reinvent physics for this i think
I prototyped a game two years ago that had bouncing ball-shaped vehicles in multiplayer and it worked quite well with simulated physics, I'm hoping Chaos can have UE5 come out with a good physical version of that
you have put urself in a pinch here, having responsive input + deterministic collision outcomes for all clients...
what is the best way to determine, when a client has sent an RPC on their timeline? I've been thinking about having the client send the timestamp alongside the rest of the RPC, but that obviously might be insecure
are there any better ways?
so when I receive it on the server
i want to know the GameTimeSeconds() at the time the client sent it on their end
All you can do is send the timestamp
But it's likely not much value because that timestamp is only relevant to that local clients' game instance
I.e, the servers' GameTimeSeconds will not be in sync with it
yeah, but doing that is for the most part, impossible
For perfect sync, at least
Can work for some things but you have to live with inaccuracy and some occasionally assumption, such as internet traffic being symmetrical in speed
im okay with the timers being offset by latency, I just want to be able to reference specific points in time for both instances
in part to overcome connection issues
latency isn't the issue so much as network traffic/ping not being true RTT
and true RTT is impossible to calculate
network traffic is non-symmetrical. It could be 50 ping to the server, but 150 back
basically my idea for an approach is to timestamp every update
and not worry about when the packets arrive, but have clients sort it out just by that data
RPC's are always received in a fixed order
even unreliable ones?
Well, they're always processed in a fixed order anyway
Unreliable bunches are still processed in order, but there may be gaps.
so PC->PlayerState->Ping is only an estimate of latency then right?
not something that i should rely on?
Yes
Ping in itself is fundamentally estimated
The very essence of it is that it changes for each packet
so what im getting here is that ideally, i get a timestamp from a client, but check it against some average latency to verify it, right?
so that you cant put in some bullshit values
That's sort of what CMC does. It receives a timestamp for each character movement packet, and tallies up the delta times between them and tracks it versus real time.
An you use some kind of heuristic to track values that go too far outside of some tolerance over time, to keep them "reasonably" in sync
For example, to prevent speedhacking
if a packet has a way too old timestamp i should just drop it right?
But the point is that it's impossible to be accurate, it's an estimate
hi i do something in my game in multiplayer, all players can interact with butons and mores
but i have a problem only input text can't be inteacted by client (only server host)
that normal ?
CMC tracks processed timestamps and rejects older ones.
But you also have to reset that timestamp periodically, to avoid floating point error accumulation
I've actually been thinking of making a custom time stamp
that doesnt use FP, but rather fixed frame counts
going to have the same issue fundamentally
one int for seconds, one byte for frames
everything is simulating at different framerates, and "because physics" not even at the same real framerate relative to each other
I intend to have the gameplay logic run at a fixed framerate on both ends
and running it on timers
What I'm saying is, timers do not run at the same interval between computers
And over time, the error between them builds up
right, so i need to synchronize periodically
Keeping two separate machines in perfect time sync is impossible
that should be doable
Either way you can look at CMC's timestamp and error accumulation stuff
But it's not all that straightforward generally
I am well aware :v
but I wanna try and build it myself, to get a better understanding
and to have some more control
Im also trying to implement a networking model that doesnt rely primarily on UE4's prioritized replication
I want to have all the gamestate stuff be updated in one blob
Well, that's easy to do but don't know why you'd want that
more consistent and synced gamestate
but also much more expensive
i know its more bandwidth costly
but im okay with that
ill probably not run everything in that blob
just players
Easy enough to do. Just dump all replicated properties in a single struct and write a NetSerialize() function for it
and let UE4 do the rest
Could you please point is there any default network-friendly way to pass FTransform as RPC argument?
I don't think there's a built-in optimized type but you can send a rotator + net quantized vector, assuming no scale
i mean i can't interact
but detected
and only client can't
host can
Thank you! Just checking if I missed something that UE already had
If I have an automatic weapon that fires at say 600rpm. It's top down and the player can shoot wherever their mouse is pointing. What if anything could/should I do to minimize bandwidth? Firing a Start/Stop fire instead of an rpc for each shot seems difficult when the server has no idea where the players mouse cursor is.
Start/stop it is
The server should indeed know the aim
RPC for each shot simply cannot work
But I would need to RPC the aim location instead then would I not, and it would require very frequent updates to ensure that it actually fires where the player is aiming?
I mean the player could in theory change their aiming drastically during one frame with a mouse cursor
Yes, but consider this : you only need one unreliable RPC per frame for aiming, and it's okay if 10% of packets make it to the server, the aim will have to be interpolated but inaccuracy is likely no big deal
Firing however is a 100% thing, has to be reliable if only to not have conflicting ammo count
That makes sense
Not to mention you can't just not fire because of bad network, and because of game feel you'll fire locally anyway before the server even knows
So you're essentially telling the server how it is
So unreliable rpc on tick for aim (something the engine does out of the box for controller rotation) + reliable start/stop
People here recommended Tom Looman course, right?
We send a reliable RPC for every shot, and that's for weapons with fire rates of double that in many cases (0.05 sec delay)
You can't unfortunately rely on the aim of the server - it's sent independently (if you're using a character), and not at a high enough rate to be in-sync with the clients' actual aim.
if you can guarantee that, then start-stop is a valid option ofc
My aiming is disconnected from the controller. The player can essentially shoot in any direction at any time
Unreal Tournament went to enormous lengths to tie it's weapon usage in with character movement, the result is a very clunky hard to extend system. It works and uses less bandwidth, but is quite horrible in it's implementation
and not really a direction either, they aim and fire at a location and then there are calculations to figure out what the direction is based on what their mouse was over
Personally I assume you want to replicate aim no matter what, if only to show to other players where you're aiming at, so I recommend the start/stop approach because you're solving two problems at once
It really depends I guess. For our case it didn't work out (competitive shooter), just wasn't accurate enough
But on the flipside pretty much all bandwidth to the server is character movement + these weapon RPC's
And that's it really
Regular RPC's anyway
I'm going to try both but I have a feeling it might not be accurate enough simply because you can change directions so quickly
Essentially that's the issue we had. CMC updates are deliberately compressed for e.g. and sent at the lowest rate you can get away with, they're also unreliable so may not even always arrive.
Unreal Tournament got around that by forcing CMC to send an update when a weapon fires, and also having a fixed tick loop between weapons and CMC to make sure everything updates in order
But it does couple those things together quite tightly which I didn't like much
My aim vector is just the location of the actor to the mouse cursor pretty much, so the cmc is not really involved
it is technically because it rotates whenever your aim differs by more than 90 degrees from it's forward direction
can someone explain to me the difference between prediction and extrapolation cause from the explanations I've heard they sound like the same thing except prediction seems to be tied to client whenever it's explained
i.e. prediction seems to imply client-side prediction with known inputs
extrapolation seems to imply unknown inputs
Extrapolation applies to remote stuff in my mind
Other players are "extrapolated" from your clients perspective
Seems like semantics though
I might be totally wrong
If I am passing some values in a structure through a run on server event the structed become null after the value is passed to that event
Please help.
Does anyone know what the base network cost is to replicate a uobject?
Extrapolation means to make a guess about the future of some state based on the current state you know. You might guess that the player will continue in a straight line even if you're not getting any more updates for instance. It's something clients will typically do when they are not receiving updates from the server.
Prediction (ClientSide Prediction) is something the client will do where it assumes that commands it's sending to the server will be accepted and displays the result to the player immediately to give an illusion of no latency.
I can see it being confusing since prediction means to make guesses about the future, and extrapolation is also making a guess about the future π
Hi! I am doing a small test/POC in order to reduce movement replication costs/bandwidth.
Basically, I have a very low replication rate (1 per second for now), and I want to try "filling the gaps" by sending movement orders via RPCs.
This orders would then be taken by a Controller that performs the movement Client side. The problem is that AIControllers only exist in the server. I want to use those because I need to use pathfinding. Do AController instances exist on clients? Can I extend AController to use Navigation/Pathfinding in the same way AIController does?
The cost will depend a lot on what's in the UObject, how often it is replicated (Frequency) and the distance it's replicated. If you're curious about what specifically UE replicates for an empty object I don't know. π
thanks for the explanation that helps clarify π
So I have a bunch of character bps made and I need to pass info like stamina and hunger into a widget but I dont want to have to cast to each of those characters, how can I get those values into the widget without a cast?
It is multiplayer and I havent found a good way of doing this yet.
I don't think that's multiplayer specific. Presumably you have replicated the value to the client where the UI lives somehow already. The character BPs could have an event dispatch that you bind when initializing the UI, and the UI just displays the new value whenever you trigger the dispatch in the character bp.
You'd need to cast them once in the initialization of the UI to access the event. You could also get a reference to the UI directly in the character and update the value on the UI from the character whenever it changes, but I would not recommend it.
The values are replicated yeah, but I had the UI created on the controller. I needed to get the variables from the characters to pass in the stamina and things but I could give that a shot, but the UI doesnt really come into contact with the characters other than through the controller, and yeah that last part is what I am thinking I have to do as the UI just doesnt communicate with the characters otherwise
UI should live on the controller
Don't reference UI directly like that. Put in bindings, pass the character to the widget, and let the widget bind it's own events. If for any reason you have to recode your character class because you deleted a UserWidget, you've done something wrong.
what I would do is I would add an Initialize function on the UI widget, that takes the controller and/or the character being controlled, then bind the event there. Whenever a new pawn is possessed by the controller, you initialize the widget again.
HUD is a good class to mediate between gameplay and widgets
The character should not really know about the UI, this way all it does is pushes an event and it doesn't care who is listening.
You might use the same event to do some effects like flashing the screen red when you take damage for instance
Yeah I didnt want the UI to require like everything, its really just 2 or 3 variables from the characters I need but I was wanting to avoid casting to like 20 different characters, but I am gonna try out some of the stuff you guys suggested first
Why would you need to cast to 20 different characters?
I made 1 controller but I have a bunch of different character classes
Right
and you have 1 UI
so that would imply there's some data that is the same for all the characters
put that in a baseclass and work with that
Baseclass, stats component, or if you're a masochist put it into an interface and cry.
AMyBaseClass : AActor
Health
Stamina
AMy19thClass : MyBaseClass
ThingsOnlycClass19CaresAbout
Yep, or use a component, may or may not be preferable depending on your situation. For anything complex I'd probably go with a component.
Damn, someone else had mentioned doing a baseclass previously
I need to get on that now, might make things a lot easier
Yeah usually your character classes share some basic functionality that just doesn't make sense to duplicate across each character class type.
I was just curious what the network packet size is when it replicates. I know it depends upon what is inside of the ubject / replicated properties, but I was just curious about the base network packet size
or maybe I can't get an answer to that because uobject in of itself doesn't replicate anything, so it really is like replicating a struct in that sense
Yeah and it's gonna get batched with other things and compressed, so the size of those bytes specifically would depend on how it might compress with other things I'd assume.
So throwing out caring about the details of replication frequency and all of the other stuff (that is important to consider, just not within the scope of my question), really replicating a UObject with a float takes up no more size than a struct with a float.
Without anything marked as replicated inside it, I don't think it replicates. Once you have a replicated property there is presumably some header information that comes with the object outside of your replicates values.
Well I know uobject itself doesn't replicate on its own. I guess I just thought that when you make a uobject replicate, then there would be some data injected into the network packets about that uobject that would not be present when replicating a struct
Maybe, I wouldn't know. UObjects afaik have a "connection" so you can refer to the same object, so that Id would need to be passed as well.
For a struct you'd need a byte stream + knowing what struct to cast those bytes back to
Yeah that's more of what I am interested in
I'm not sure how useful it is, to my knowledge UE handles most of the batching and optimizing of that traffic.
You could probably attempt to batch some stuff yourself if you're manually updating things by sending a struct with an array instead of an array of structs.
I'd definitely profile the need to do that first π
The only purpose of my question is to determine how much of a network cost difference I would see if I replicated a uobject with a float versus a struct with a float, so I can make better design decisions moving forward
Structs are good for basic data, but when it comes to replicating things such as item data and missions, those all have different properties
Are you intending on manually writing the replication stuff for a base UObject, or are you talking about actual actors and actor components?
UObjects don't have any replication built in, that starts with Actors in the inheritance chain
so you either stick all possible properties that all of them could hold into one struct, or you replicate uobjects with inheritance, making each uobject type hold only properties related to that type of item or that type of objective
the struct route I have always hated
I ask because if it's actually an actor it will have things like a transform and other data as well
I just went through the trouble of adding replication to a base UObject myself to test it out
and replicating a custom UObject through an actor component
There are some other approaches that might be enough depending on what you need to store
/**
* RaevinNetworkObject
*/
UCLASS()
class RAEVIN_API URaevinNetworkObject : public UObject
{
GENERATED_BODY()
public:
URaevinNetworkObject();
virtual bool IsSupportedForNetworking() const override;
virtual bool ReplicateSubobjects(class AActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags); // note no override because this is the FIRST declaration of this function.
virtual bool ReplicateSubobjects(class UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags); // note no override because this is the FIRST declaration of this function.
virtual int32 GetFunctionCallspace(UFunction* Function, FFrame* Stack) override;
virtual bool CallRemoteFunction(UFunction* Function, void* Parameters, struct FOutParmRec* OutParms, FFrame* Stack) override;
UWorld* GetWorld() const override;
};
Yep π
That's my base uobject that will support networking
That's pretty much what I'm trying out right now as well
you have some other approaches depending on what kind of data that needs to be stored for each instance.
You can have a struct that inherits from another struct, and have them in different tables, then if you're in C++ you can combine them all into one array and down-cast them.
I've never seen a struct inheriting from another struct... that's an interesting idea
That allows you to refer to a particular type with just the name, and you don't need to store irrelevant data for every object.
It's not really supported by BP afaik :p
But the code that manages that functionality can live in Cpp, and you can expose type safe versions to BP.
That much isn't as much of a concern I suppose. I guess though unless there is a much higher network cost overall for using a uobject, then I would just use a custom uobject if struct inheritance isn't support by BP
I think the network cost will be vastly eclipsed by usage patterns as opposed to UObject/Struct storage π
because then I still have to write some kind of wrapper to have BP support the custom data types. Not too hard, but if a custom uobject isn't a lot in overhead, why bother doing it is what I am thinking
Such as how often the data is updated / pushed via replication you mean?
I'm testing UObjects for my inventory because I want to store a fair bit of instance data, and want the items to be able to "do things". I have not even bothered thinking about the cost of replication, I'll look at it if I notice issues, and try to send the information more rarely.
It's better to not send anything at all than to send something cheap that you can avoid sending in the first place
Yes
Ok, that makes sense
With Structs I don't think you can expose pointers to UFUNCTIONs for instance, so you'd not be able to use polymorphism with an RPC, which would mean either sending a big struct with a bunch more data than you need, or have a lot of specialized functions that you dispatch to manually after casting to the correct struct. Regardless, you'd be sending the whole struct not just the changed values.
With UObjects I'd be concerned about restricting when and where they get replicated and to whom, as well as the potential costs of running that manual replication code for a lot of items. Again, it's not something I'd bother with until it becomes a problem.
But if you don't have a lot of per-instance data, like for a quest you probably don't. I'd just send the the quest id and the stage
This is a bad idea. What you should do instead is replicate movement diffs
or interpolate farther into the past
so you can replicate 1 per second
like interpolate 3-4 seconds into the past
either that or replicate movement diffs instead
one you start using rpcs on top you lose all kinds of benefits you get from diffing deltas
@waxen umbraThanks for your well thoughout replies. This has been very enlightening
especially the struct piece
*thought out
I understand the concept, but wouldn't that create a lot of delay?
yes
the alternative is to send position diffs instead of positions
position diffs will be smaller when the replication system packs them
unless you are going like 4000 units per second in the x and y
it is up to 2000 per second π
It is an RTS game, I know that the usual is using Lockstep and a different networking system but I wanted to make some tests in Unreal just in case we can skip the troubles of lockstep
I am replicating 4000 units right now
still working on the system
on a lan my interpolation delay is only like 0.5 seconds
still working on the system though
Introduction Hi, Iβm Glenn Fiedler and welcome to Networked Physics.
In the previous article we sent snapshots of the entire simulation 10 times per-second over the network and interpolated between them to reconstruct a view of the simulation on the other side.
The problem with a low snapshot rate like 10HZ is that interpolation between snapshot...
this madman is replicating like 1000 cubes at 10 ticks/sec
I am not saying rip off his code, though maybe you could
I am saying look at some of his ideas
the replications auto bit pack
but some of his other ideas with indices and position diffs
unreal does not do
Interesting. 0.5 delay on lan is a bit too much still for the kind of game we are going for, but this is definitely an interesting approach
he doesn't do interpolation delay either
well
another idea
I am exploring
is what if the interpolation delay was higher the farther from the camera you were
like
units way off would have a higher delay
and as you move closer
you have them move a little extra fast
to catch up
then you could send very little data for far off units
so then the closer guys could have almost no delay
Delay is only relevant when it's noticed. If I remember right the delay in Gaffers system is basically because of the jitter buffer. His rule of thumb is that the system should be able to miss two packages in a row and still have two values to interpolate between.
If you have a sendrate of 10 packets per second, thats one package every .1 second, and you want to be able to miss two in a row you have 4 packets in the buffer (delay of 0.4s)
yeah, he runs with very minimal delay
well, thats still 400ms of induced delay, but it's nothing strange, it's only relevant when noticed.
What he's using that for is transform data, not commands if I remember right
Well, most RTS have lockstep systems which inherently have delay, so delay in itself doesn't worry me
you'd still send commands (shooting, etc) immediately.
lockstep systems only have input delay though
Yep
So you'd take a shoot command, send it instantly, the server would check if you hit it with your current snapshot, and then send the result immediately
it is, the main issue is to write a custom deterministic simulation which mostly implies not using Unreal's stuff
For the record I think I remember reading about several new RTS games that don't use lockstep, and even fighting games that don't.
Yes, I do too. But all those rts games have very low unit counts
Fair enough, I thought I'd just mention it π
I could see snapshot compression working for an RTS as well, but RTS games are really outside of the types of games I usually think about and work on π
It is a good point :)
I have been studying the subject for a long time, honestly I think that the best solution is still lockstep, but I wanted to explore some "easy" solutions if there are any
the problem with lockstep is
how do you debug desyncs
even if you were to know which frame the desync happens on
which would be difficult
yes, it is a challenge
now you have to figure out which one of the thousands of units caused it
the game doesn't even crash
when it happens
nightmare fuel
what I saw done, is to implement a hash/checksum per frame, which you can use to play/replay the current frame, and check for desyncs locally in debug builds
that sucks, and is also only step one
I can think of breaking the checksum into smaller ones to have a better idea of the area that caused the problem
And then, a matter of time and seeing what is causing the desync, most causes are obvious, if the code is fully deterministic
the problem for me is to have completely deterministic code, specially in Unreal, because it can be very difficult to know how things are working under the hood
I did read the article, while it is amazing, I don't quite see how can I emulate his improvements using Unreal's network or replication - starting with, I bet Unreal is using its own performance optimization tricks
it doesn't do position diffs
if you are sending indices it doesn't do diffs of those
I looked at the sourcecode yesterday
To start with, replication works at class level right? So how can I send diffs instead of the whole position?
yeah, that seems a good candidate for optimization