#multiplayer

1 messages · Page 146 of 1

torpid lantern
#

Super stuck on this one, but maybe I have a fundamental misunderstanding of client/server object refs.

Here's my attempt at a proof of concept, but it's failing - the temp var that I want to store a ref to the serveractor appears to be a ref to the **client **actor, which returns none after the actor leaves net cull distance.

In this poc: I press 1 and that sends an server event which uses an interface; which goes to the UnitBP (on the server?), which stores a replicated ref (ServerUnitRef) to itself

I press 2 and the game grabs the ServerUnitRef and saves it to TEMPServerRefStorage on the player controller

[I walk the actor out of cull distance, and they are removed from screen]

I press 3 and my expectation is the TEMPServerRefStorage still has a ref to the server object and should be able to get its location.

All prints are firing data, but #3 returns 0,0,0 when the client actor is out of cull distance.

My backup plan is to store a GUID on the actor and then use a "get all actors of class", then filter by GUID - but that feels super heavy for what I need (the location of a single actor who is outside cull distance).

prisma belfry
#

Hey yall

I have a game where you fight with melee weapons. I want some accurate collision detection so i use a plugin for tracing along the weapons movement^
Problem is that dedicated servers dont run animations so they dont actually move the weapon and the traces dont move at all
So I see 3 options:

  • Client authorative detection, seems like a bad idea for obvious reasons
  • Enable animations when not rendered (if i could find the damn setting), generally not adviced, it will also affect clients and i use some expensive als animation blueprints
  • Bake the sockets relative location during the animation and replay it as a sort array of vector positions, but this tedious and it makes it impossible to do some dynamic aim adjustment stuff i wanted

Thoughts?

sinful tree
lost inlet
#

RPCs work on replicated components, you just would need to make sure the client owns the owning actor

#

PS is an odd choice unless other clients need to know the complete inventory

#

But the PS is owned by relevant player controller

#

Well the PS is owned by the player controller, so that player should be able to call RPCs on a component that is owned by that PS

#

The output log does show failed RPCs

cobalt pollen
#

So to allow navigation on my moving ships I setup a proxy/ghost ship on the server side with ai characters mirrored there and it works. I can move the ship around and the ai proxy characters can use navigation move commands. I'm currently setting the relative transform of the "real" character on the ship to match the relative transform of the proxy character (just a character with a capsule) on the proxy ship. I'm doing this on the real characters tick... this might be fine but any ideas if there's a better way to sync up the movement of an actor to another one? Especially that take advantage of any magic netcode in charactermovementcomponent?

hollow eagle
#

The expense of CMC has nothing to do with being autonomous.

#

The expense is in the spaghetti that is its movement calculations.

#

I don't know why you're talking about netserialize

#

it has nothing to do with this.

#

It would not.

#

I don't know why you keep mentioning random parts of the networking framework without understanding what they are.

#

NetSerialize is not the same as generic property replication

#

it is a specific method to serialize things in a custom way.

#

CMC is already based on both property replication and RPCs.

#

Maybe, it depends on what you are doing and where the expensive bits are.

#

There's no hypothetical answer to this.

#

You profile and find out.

#

I don't know why you're talking about network profiling

#

it's not what I'm talking about.

#

The cost of CMC is not primarily with its networking.

#

interpolation yes, position and movement no

#

there are already callbacks for when actor movement is replicated, storing that off and interpolating is up to you if not using CMC.

#

it depends on what you are doing

clear island
#

yea they really arent

#

animation will hit you first long before that

#

then after, CMC floor checks

#

and then maybe delta property comparison for replicated stuff

#

well the server has to track bone positions on the skeletal meshes

#

because you need that info to acurately detect hits from line traces for example

#

also from what I've heard, transform updates are slow in UE

#

as in, more than other engines

#

the technical reasons I could not say, but its been mentioned on #cpp a few times I believe

#

its really depends on what your game is doing

#

but most of the time if you want to detect stuff like hits against the mesh you wll need up to date information about the pose the mesh is in, which is usually driven by animation, so thats why the server needs that info

#

100 player cap on "default" UE is definitely not happening

hollow eagle
#

ehh, it is

#

that's what fortnite is

#

not for a solo project though

clear island
#

yea

hollow eagle
#

that's a team of engineers. They're not twisting the engine in weird ways, all the tech they use is available.

clear island
#

yea what I mean by default is: not using rep graph, iris, ABA, etc..

hollow eagle
#

hey even epic isn't using iris yet

#

it isn't something enabled by default

#

and it requires configuration

#

you cannot use repgraph with iris

clear island
hollow eagle
#

and you should absolutely not use iris if you haven't worked with unreal multiplayer before

clear island
#

ah actually I think its the push model

#

I believe they're using that

hollow eagle
hollow eagle
#

all the more reason to not use iris

#

iris does not change the basics of how you interact with replication

clear island
#

mostly CMC and animation yes, although once you optimize most out of those 2, then yea networking is probably next

hollow eagle
#

iris does introduce complications in terms of setup, configuration, zero documentation existing aside from a single high level overview page, and bugs that basically no one will be able to help you with unless you have access to UDN.

clear island
#

yea I'm currently using push model too

clear island
hollow eagle
#

yeah, but at least that's stable. Or more so than iris.

clear island
#

yea

#

I'm not touching iris either, for now I just settle with push model, the network stuff is currently not even my top offender when it comes to performance

#

I wouldnt replace the CMC if I were you, thats an ungodly amount of wheels to reinvent there

#

just subclass it and make changes where necessary

#

from what I've heard the GMC is not necessarily lighter, it just has more features

#

also navmesh will probably hit you too when it comes to performance if you're thinking about having AI

#

I dont have GMC so I'm not the best autority on its internals but I believe I've seen it discussed here in that manner

#

it depends, usually moving pawns should not be set to affect navmesh generation because navmesh gen is expensive, but then you need to look into RVO and theres many edge cases

#

I'm just using the default features, selectively enabling/disabling "Can ever affect navigation" in a combination with RVO

#

theres actually good official docs on this

lucid badger
#

So i'm switching my items over to data table rows. Before they were BP Classes subclassing the ItemData class. That was just temporary when I had like 6 items lol.

But when they were BP classes, I could call Construct Object of Class and the Class identity was part of the object itself, meaning when the object was replicated on client side, it started with knowledge of what type of item it was implicitly.

Now that I am using data table, I'm guessing there's absolutely zero way to get the same functionality? I have to have a RowName on the object and replicate it, and do setup for the item in OnRep_RowName?

vagrant grail
#

I'm watching a multiplayer tutorial on how to do sessions, and the tutorial guy wrote his code using variables to save the value of his UI elements (input box and checkbox), while in my case I directly inputted the value of those UI Elements into the "Create Session" node, is what I'm doing bad / wrong and could lead to issues compared to his setup ?

There are some differences in my setup compared to his as I use a slider to get the the value for "MaxPlayers" while he's using an input box.

copper pendant
#

🤔 .. any idea how to fix it? i dont understand this error

hollow eagle
#

quite frankly you need to stop looking at random lists of features and start actually making something. The decisions you are making are based on nothing but your own wild guesses.

#

And the only way to fix that is to forever sit around asking questions and never actually build anything, or to get experience and figure these things out as you go.

plucky prawn
copper pendant
plucky prawn
#

dont use index

copper pendant
# plucky prawn dont use index

im trying to understand how to make this: Client presses button in his widget and this event is get send to the Server and Server is replicating this event to all other Clients (Any Client->Server->All Clients)

plucky prawn
#

use GetOwningPlayer on the client with an RPC through the player controller

#

then the server would iterate over all player controllers and do a new RPC

copper pendant
plucky prawn
#

if its going from client -> server you want Run on Server

#

otherwise if its going from server -> client you want Run on Owning Client

copper pendant
plucky prawn
#

🤷 this doesnt make sense and i dont see the callsite for UpLoadButton

plucky prawn
#

is it supposed to be an RPC?

#

because right now UpLoadButton is called on the client

copper pendant
# plucky prawn is it supposed to be an RPC?

changed it to be multicast rpc event still nothing...
oh.. this multiplayer stuff is so confusing🥴

i managed to make: when server change map its changing on the client with ReplicatedActor before that (Server->Client) 👍
but it didnt worked when Client tried to change map (Client->Sever)🥲

Now i tried to remake it with PlayerController hoping that it would just works both ways (Client<->Server) but it get even worse cus now its not even sending button events from (Server->Client)😢

plucky prawn
#

The client needs to send an rpc to the server through its player controller (or other actor it owns but let's focus on the player controller) for any action it wants to execute on the server. The server should verify the action then in your case iterate over all of the other player controllers and execute a client rpc on them. Don't use multicast for this

copper pendant
copper pendant
plucky prawn
#

i dont have unreal open at the moment. i would highly recommend you look at the networking compendium in the channel pins

copper pendant
#

Thank you, i would look in to pins and this man tutors

cedar lagoon
#

Hi what is the correct way to add a mapping context to for a player controller using the Enhanced one.
I have a pawn on server, i then as a Client send an RPC to possess that Pawn which does, then in my code (pawn) I do:

void ACustomPawn::PossessedBy(AController* NewController)
{
    Super::PossessedBy(NewController);

    if (const APlayerController* PlayerController = Cast<APlayerController>(NewController))
    {
        if (PlayerController->IsLocalPlayerController())
        {
            UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer());
            Subsystem->AddMappingContext(InputMapping, 1);
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Added mapping context"));
        }
        else
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Not local player"));
        }
    }
}

And of course there is something wrong with the IsLocalPlayerController() because it alaways goes to the "Not local player" which makes sense Ikr, but i'm lost using the enhanced input system with mumtiplayer setup

#

Yeah I might add that this does work for a Listen server but only for host, if playing as a Client it does not work

tardy fossil
twin juniper
#

RPCs can only return void, right?

tardy fossil
#

also virtual void Restart(); is what you want if you wanna do stuff on a client on possession

tardy fossil
cedar lagoon
rain condor
#

Simple question. shooting traceline has to be replicated only on the server and vfxFireEvents on multicast?

inner cove
# rain condor Simple question. shooting traceline has to be replicated only on the server and ...

Yeah line trace should run on server but can also run on owning client for client-side prediction for stuff like hit marker (hit marker is not really client-side prediction, but depending on your project's requirements you might have things that client-side prediction can be applied) to feel instant instead of waiting for the server's response to know if they client hit anyone, this will be very noticable with high ping

silent valley
#

Is it possible to speed up the sending of unreliable RPCs?

I am seeing a case in PIE where server triggers GC and sends one of my game RPCs in the same frame.
The GC rpc is received 2 frames later on client.
The game RPC is received 29 frames after that?

#

The ASC sends the GC rpc as unreliable

#

ok, seems calling ForceNetUpdate(); on the actor with the RPC makes the unreliable RPC send immediately 👍

inner cove
#

Maybe increasing the Frequency helps?

#

Nvm thats probably only for replicated variables

chrome bay
#

Is it a multicast?

#

Unreliable Multicasts get buffered and sent similar to properties IIRC

silent valley
#

it was multicast, yeah. ForceNetUpdate() seems to do the trick though 👍

solar stirrup
#

It asks the engine to consider the actor for replication asap, but if your network conditions are pretty bad (i.e. saturated bandwidth and such) the engine can still push back replication

forest reef
#

If I move my gun barrel around with an animation but then try to call the location of said barrel on the server. Would the server know where the barrel is or does it ignore the location in an animation? It almost seems like its getting the location from my default pose.

solar stirrup
#

I don't think animations are generally played on the server

#

So you'd have to pass in the relative position of the gun, probably with some light server-side validation to avoid cheaters

forest reef
#

yeah im thinking thats why my barrel tip is in the wrong spot. maybe the client has to send that location over when calling the server function? Then I just need to validate it to stop hacking?

#

oh you beat me too it lol

solar stirrup
#

haha

#

but yeah exactly

thin stratus
#

@forest reef SkeletalMeshComponents have a setting to only process Bone and Pose updates when being rendered.

#

If you have something that requires the Update to also happen when not rendered (ListenServer not looking or DedicatedServer), you'd need to set that setting to always update the poses and bones.

#

Guns being moved by Aim Offsets and similar are a good example for stuff that would need this, otherwise Server ends up with a different Location.

forest reef
#

I'll have to check that out next time I get a working example going! Thank you

forest reef
#

@thin stratus so something like ```cpp
BaseCharacterSMC->VisibilityBasedAnimTickOption = EVisibilityBasedAnimTickOption::AlwaysTickPoseAndRefreshBones;

thin stratus
#

Yop

#

Usually done on the BP or in the Constructor I guess

forest reef
#

oh yeah, oddly i found the cpp code before i could find the option in the BP

tardy quarry
#

Looking for some advice with respect to working with the replication graph. I understand that it can save a decent amount of CPU server-side when you're working with a lot of actors AND connections, but is it worth spending the time diving into it if I'm only planning on 16 players or less? (Bonus question, with UE5 and Iris in it's experimental phase is it worth bypassing replication graph all together in favor of Iris?)

latent heart
#

Iris is a pain unless you're willing to devote a lot of time to it. So I hear.

#

But a few people are using it successfully!

slate basin
#

hey, is there something like route gamepad to second window for VR HMD?

vagrant grail
#

Simple question : If an actor (let's say a simple cube for example) doesn't have the "Replicates" property on the actor set to true, if I create a variable in that actor and set it to replicate, would it replicate that variable?

keen hound
#

trying to redo the random character system I had, it's spawning the character but not possesing them. any help?

#

Okay it's possessing them but it's not allowing input

vagrant grail
# hollow eagle no

Thanks, another question : If I have a big map like a battle royal, and someone on the other side of the map breaks an object (like in Fortnite), the destruction of the object will instantly be replicated to all players to update their instance of the game, or will the game rather use the repNotify part and wait for the player to be in the range of that object (so the Squared Distance property) to give him the updated state of that object and destroy it ?

Because to me the second option would be better in terms of performance to avoid people receiving updated states all along during the game which could create lag, but the thing is when the object is destroyed, it doesn't have its "sphere collision" detecting when a player is in range of the object to send him the new state of the object as the object itself is already destroyed, so I'm kinda confused 🤔

hollow eagle
#

if an actor isn't relevant it won't replicate

vagrant grail
hollow eagle
#

if the actor exists on that client then destruction will be sent, if it doesn't then it doesn't matter because the client doesn't know about the actor in the first place.

#

an actor that isn't relevant does not exist on the client

vagrant grail
# hollow eagle an actor that isn't relevant does not exist on the client

Ohhhhhh that's why then, it makes sense now. Because in my mind, I thought it still spawns the objects even if they're not relevant at first but will destroy them on the client when he becomes relevant to the obect if that object is already destroyed on the server. But it makes sense in terms of performance of why it's like this. Thanks 🙏

past flicker
#

Is anybody using state machines? I looked through the marketplace and the plugins are really lacking on the network side. Some have replication but with pretty big drawbacks, and none have prediction support.

spice gorge
#

I'm using the PhysicsControl setup to attach an object to a player actor (The reason for doing this and not just attach actor to actor is because I want to attach the same object to two actors). Now I did this in a project last year and it worked. This current project is setup differently however so I can't just copy and paste the code directly.
The issue I'm having is that clients don't recognize other clients or the server when they get attached to an object. Example: If the server picks up an object the connected client observes it move into position and then just continually fall to the ground then pop up again.
If the client attaches to an object they see themselves ok and the server sees everything as intended.

I've been trying to debug this and figure out what steps aren't replicating. The code is run through an Ability in GAS and the attach code is a Task. I thought that those things were replicated as default so I guess there's something specific I'm missing and I'm not sure what.
Is there a component I might need to flag and replicate or force each connected client to call a function locally to replicate state?

past flicker
pure oar
#

i want to switch teams in a 2vs2 game in a 4-player lobby, with Team A and Team B, but I couldn't find any resources, and I couldn't switch teams because I couldn't retrieve the Steam usernames correctly. If anyone has a source, could they share it?

spice gorge
oblique arrow
#

Guys will spawning weapon and assign it to the Weapon variable should replicate this variable to the client?

past flicker
# spice gorge I'm fearing not. I suspect that marking the compnents as Replicates won't do any...

What may have happened in your previous attempt is you had replication so frequent that it just looked like the constraint was working because position was updating so fast. As far as your "noob" strategy goes network physics is complicated, so unless this PhysicsControl is deterministic your clients will just desync. If you want PhysicsControl replicated you're gonna have to replicate it in all the ways Epic didn't, probably for good reason (it's hard).

spice gorge
# past flicker What may have happened in your previous attempt is you had replication so freque...

That could well be the case. Looking at the old build (checker box) it looks pretty stable. I'm wiggling the character here to rotate the box. In the current project you can see that the client just wants to settle the physics to the ground. I'd expect that in the old build even with a high replication frequency there'd still be noticeable jitter.
The intention here isn't to use the physics part, the box should stay ridged, it's the only solution I could find for attaching multiple actors together.

past flicker
spice gorge
# past flicker Why not AActor::AttachToActor?

Because I have two players being able to attach to the box at the same time. I believe AttachToActor parents it, which only works with one, unless I made the box the parent and each player the child. I don't know what Unreal would do in that situation.

past flicker
#

Oh no. That definitely sounds like a physics interaction. Party Animals is the only game I'm aware of that has done something like that over network recently.

spice gorge
#

In the previous prototype, the advantage I got from using the PhysicsControl component was the force vector, which I can use to change the movement input vector. This did put more stress on the Physics system in the multiplayer setup. It worked well as players would only be able to move if they were both syncronizing their movement as pulling in opposite directions would cause the force of the physics control to neutralize their movement vector.

#

My intention with this prototype was to get it setup the same basic way (hooked up via PhysicsControl) but just use the players movement vectors against each other and ignore the box part. Though I can't get to the point where the attachment works 🙂

past flicker
#

Actor has EPhysicsReplicationMode but I'm not aware of how it works and a lot of it is marked WIP. My guess is you're on the hook for a lot of custom code to support this.

spice gorge
queen escarp
spice gorge
#

Ummm. So it looks like I did it. The boxes in the current project were set to simulate physics by default, but in the old project they weren't, instead physics sim was switched on during the creation of the Physics control part. So I just replicated this setup and it all seems to work now. There's no jittering on the client.

queen escarp
#

hey guys this is a common problem i have with all my projects, the damn "rubberbanding" or whatever its like that by default when i start a new project even

#

any tips on what i can do to make it betteR?

spice gorge
# spice gorge Ummm. So it looks like I did it. The boxes in the current project were set to si...

I think I understand more of what was going on here now. Prior to my fix I added code to log when the physics connection happens and noted that the server got two events, self and client, but clients would only get themselves. So clearly they weren't seeing the networked state.
Switching sim physics on the box now shows two events on the clients. So I guess the clients were failing previously when trying to establish a physics control connection.
I'm sure this is all still bad in terms of performance and good code, but it helps prove the target concept out.

past flicker
spice gorge
#

I'm guessing the default physics state wasn't replicating or something was going wrong. As physics was on players could walk into the boxes and push them around and that all replicated, but maybe it was just replicating movement and position and not really physics because it wasn't correctly on.

#

Adding that did magic thing.

past flicker
#

I'm still stuck at Unreal having fully replicated physics out of the box. I don't see anything online about this. Can someone more knowledgeable chime in? Unreal just has automagically replicated physics? Since when?

spice gorge
#

I think I'm probably getting things in a setup where each client is doing something that looks like there's replication going on but they're all just doing their own thing.
I though Iris was supposed to be the Unreal solution to Networked physics, and I'm certainly not using that here.

thin stratus
#

Not sure Iris would allow Networked Physics any more than what we currently have

past flicker
#

Have you tried turning on network emulation? Set it to bad and we'll see what's up.

thin stratus
#

Physics Replication is not really a thing in UE

#

At least not to a point that it can be used for Gameplay

#

The max you could achieve is have something server auth bounce around that you smooth locally

#

But Client controlled is pro bably not a thing

#

The CMC for example boots you out of you enable physics on the character

spice gorge
#

Ah, I'm misremembering Iris, I thought it was adding some level of physics, but I see not.

thin stratus
#

Not sure, afaik Iris just replaces the overall replication stuff of UE with something fresher

hollow eagle
#

All unreal does is replicate basic movement properties, there's no true physics replication.
There's an experimental physics replication mode in chaos but it is nowhere near stable and it's off by default.

thin stratus
#

Something that ties in ReplicationGraph etc.

#

Chaos has some phys rep stuff, afaik, yes, but also not for gameplay in that regard

hollow eagle
#

It is afaik

#

it's fully predicted physics

#

it just isn't finished

thin stratus
#

Yeah that's what I meant ,sorry

#

Should have added "in its current state"

hollow eagle
#

ye

past flicker
#

Alright dagger, so this is confirming what I thought. I don't know what you've achieved here, but it probably isn't gameplay ready multiplayer physics.

thin stratus
#

It depends on what the goal is

#

Just enabling PhysicsSim is not gonna achieve much

hollow eagle
#

I mean, basic movement replication is "good enough" for some things. And horrible for others.

#

basic interpolation and no prediction may even work well enough for some

thin stratus
#

I don't think bone location is synced or?

hollow eagle
#

oh is this about ragdolls

thin stratus
#

Idk

past flicker
#

I think the main goal is dagger wants two actors to attach to and share another actor.

#

Like a tug of war over a box

thin stratus
#

Sounds a lot like these physics brawlers

#

Gang Beasts etc.

#

Human Fall Flat

#

Bla

#

But none of those are done in UE iirc

#

They are probably Unity

#

Or custom

hollow eagle
#

unity doesn't have physics replication either afaik, it's all going to require a bunch of custom work regardless

#

it doesn't require a different physics engine but it does require replicating physics state data and reconciling it with predicted physics yourself.

past flicker
#

Unity has Netcode for entities which seems to have some physics stuff. Party Animals is the most recent game with this and is Unity.

spice gorge
#

Well the goal was just to prove out a gameplay concept. The final "how it's actually done" is something to be figured out if the prototype proves itself.
I ended up using Physics Control because it let me attach two players to an object (Two people carry a box). I don't really care for the simulated physics part as the intention is to make things more deterministic. This seemed like a quick way to prototype the idea out for a LAN multiplayer setup.

dark edge
#

it's not predicted but it's there

past flicker
#

The plot thickens. I don't know what to believe now.

spice gorge
past flicker
#

How poorly documented is this engine when some of the most knowledgeable people on this discord can't agree if UE has physics replication?

spice gorge
#

I feel like I walked in here with two cans of gasoline today 😄

#

But were they replicated cans of gasoline?

past flicker
#

I guess we'll find out if the client catches fire.

dark edge
#

btw that typo has been there FOREVER

#

physic(sic) error correction

#

It actually works pretty well if you don't need prediction

hollow eagle
dark edge
#

I mean what else do you need replicated besides the physics state?

hollow eagle
#

it's not the full state first of all, and there's no real reconciliation to handle prediction on clients.

dark edge
#

Clients see what happens on the server due to physics, that's physics replication. Not great for a game that needs prediction but that's pretty much it

#

It sends enough state to be smooth and consistent, just the default settings are crazy strict

hollow eagle
#

it's really not that smooth or consistent

dark edge
#

Good enough for a space game or something of the sort but I wouldn't want to make an F1 game with it

past flicker
#

I'm pretty sure those Unity games don't have prediction either. I've felt noticeable lag just controlling the character in Party Animals.

hollow eagle
#

it's barely good enough for throwing a single physics object around without clients wildly mispredicting

#

proper replication and prediction requires a degree of determinism that unreal doesn't do by default.

#

and is experimental, and didn't even exist before chaos.

dark edge
#

I haven't tried stuff on a super small scale but I tuned it to behave great with my vehicle system, ramming each other at full speed felt butter smooth.

#

just had to loosen up the error margins a lot to make it behave at the scale of vehicles

hollow eagle
#

with how much ping and packet loss, though

#

I also question whether the various vehicle systems in the physics engine follow a different code path for replication anyway.

dark edge
#

oh idk i made my own

#

@past flickerhttps://github.com/EpicGames/UnrealEngine/blob/072300df18a94f18077ca20a14224b5d99fee872/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysicsReplication.cpp#L358 if you want to peruse the code. It's simple but works good enough if you don't need prediction. IDK if I'd try do a Gang Beasts with it but it all depends on what you're trying to do.

past flicker
#

Thanks for confirming that. I'm not even using physics for gameplay, but maybe it would be nice to have a ragdoll land roughly the same place on all clients? IDK.

livid jetty
#

Does UE5 have complete solution for server authoritative networking including non-humanoid characters?
I mean client prediction, server reconciliation, interpolation, lag compensation.
Or i need to implement it myself ?

wanton bear
#

what are the drawbacks of running a dedicated server locally vs playing as listen?

#

i did my logic as clients only and im starting to wonder if that was a bad decision for a coop game

solar stirrup
#

You'd have to implement it yourself

livid jetty
solar stirrup
#

CharacterMovementComponent

#

Lag compensation no - you'd have to implement yourself

#

missed that one

dark edge
#

If you're testing and the game is intended to use dedicated servers then do that

livid jetty
#

This looks like replication, not the rest i mentioned

#

Prediction is mentioned, i guess reconciliation and interpolation might be there

hollow eagle
#

all of the above is in there

#

characters have full prediction, reconciliation, and interpolation.

livid jetty
#

nice

#

thanks

twin juniper
#

Naming question: I have a function in PlayerCharacter that is called on both PossessedBy and OnRep_PlayerState, so that the PlayerState would exist.
What should i call it for the sake of clarify? I currently use "WhenPlayerStateAvailable" but it feel vague.

vagrant grail
#

Guys I was following this tutorial, and when trying to press the "Leave Session" button like him, it froze the engine for like 5 to 10 sec, then crashed unreal. Does anyone know how to solve this issue please ?

The tutorial (with timestamp) : https://youtu.be/7OdruBNGOM8?t=1916

I will try to relaunch the engine to try again and see if it crashes again.

👨‍🏫 My Patreon link:
https://www.patreon.com/kekdot
Download Project Files | Premium Tutorials | Courses

💦 Get our Game on Steam | Kekdot Center:
https://store.steampowered.com/app/1487180/Kekdot_Center/


In this tutorial we talk about Network and Traveling errors. We install the correct nodes in the game instance to be handled, and also co...

▶ Play video
twin juniper
#

Idk why my action FInputActionValue is always 0 when i sent it to the server. I literally bind it as a normal bind function.
Anyone knows?

#

Is this even the right approach to move the character though?

#

Because, you know, if i let the player move client-side, they may teleport and stuff

hollow eagle
#

it is not, because FInputActionValue is not at all intended to be sent over the network

#

just send a vector if that's what you need

twin juniper
hollow eagle
#

Nowhere? It depends on what the thing is.

#

There's nothing that's going to give you a list of types.

#

If it isn't a basic type and there's no evidence of it being used for networking at all then it's probably not used for that.
Or you read the source of the type and see if it is even remotely setup for replication.

#

In this case the underlying value isn't a UPROPERTY and there's no evidence of custom network serialization. So nothing useful will be sent by it.

twin juniper
#

How do i read the source and know that the type can be use for networking? Wdym the underlying value isn't a UPROPERTY too? God this is confusing

#

Do i really need to know that too, or just try to send basic type and that's fine?

twin juniper
#

Ok imma go checkout Lyra now because i have no idea what i am doing

crisp shard
#

im having trouble getting other** clients to see an attack VFX.

i have client side VFX firing fine but when i do the multicast, it fires but i don't see anything and im not sure why.

is there anything wrong with this flow of logic?

cursive steeple
crisp shard
#

that's why i have that check, so the player firing doesn't expericne the multicast

#

there is a client side evenet before this that is working for the player firing. but i want that effect to be played for all other players and the event does in fact fire but i don't see any visuals/hear anything

crisp shard
#

this is the event that calls the multicasat btw , so you can see where those varaibles are coming from

cursive steeple
crisp shard
#

if that's what you mean

cursive steeple
cursive steeple
crisp shard
#

it's getting the same location as the client so it does seem to work

#

well, it gives the same location

#

so, it should be in the right place, but it isn't seen by the other clients for some reason

cursive steeple
#

Alright then since it's a preexisting comp, it's an exception, thanks for the confirmation

#

There's still the part where you branch on the locally controlled pawn, which obviously stops other clients from spawning the effect, right? Or that was just disconnected/checked for debug or?

crisp shard
cursive steeple
#

Nvm my bad im tired, ignored the negation

#

Yeah

crisp shard
#

it legitmatley fires and is getting the correct location/etc im not sure why i can't see or hear anything from other clietns

cursive steeple
crisp shard
#

thanks yea, not sure why it's not working. it's firing, and the locations are the same, and im doing legitamtely the same kind of logic on another bp and it works fine. but i just can't see this VFX on other clients. not sure if doing it on the characters would be better, but i really don't think it would matter, as i would do the same logic

thin stratus
#

Or does it not even reach other clients

scarlet radish
#

I'm spawning an actor using a blueprint (authority switch), the actor only spawns on the server and doesn't spawn on any clients, what am I missing here?

lost inlet
#

the actor is not replicated then

scarlet radish
#

I have bReplicates = true;

#

Is there anything else I need?

#

They replicate correctly if I spawn them in the editor, just not at runtime

chrome bay
#

relevancy perhaps? How far away is the client from where you put it

#

default relevancy distance is 150M

scarlet radish
#

Stood on top

chrome bay
#

is it actually spawning though?

scarlet radish
#

It's spawned on the server (top left)

chrome bay
#

Can't see anything on either screen

scarlet radish
#

All the items are all over the floor at the top

chrome bay
#

oh right, yeah

#

Are they blueprints of your C++ class? I'd check the BP has replicates checked

scarlet radish
#

Better view

#

Purely c++

#

Things spawned in the editor are replicated (the little apple)

chrome bay
#

are they physics objects or something?

#

IDK, something is off

scarlet radish
#

They have physics yea

#

ikr

chrome bay
#

I suspect then, they are spawning on the client then immediatelly getting yeeted by collision

#

Do you have replicated movement turned on?

scarlet radish
#

yes

chrome bay
#

Cus if not, the two sims will diverge

#

No idea then.. I'd start breakpointing

scarlet radish
#

I always get stuck on shit like this

#

Random bugs no one has ever heard of lol

chrome bay
#

It'll be something obvious

scarlet radish
#

It always is

#

This is the blueprint I spawn them with

chrome bay
#

What does ConstructItem do?

scarlet radish
#

NewObject<UItem) I believe

#

Just creates the object

chrome bay
#

Cus atm the only part of that which is actually replicated is the spawning of that actor

scarlet radish
#

OOHHH

#

It's being spawned, but the properties are replicated, so I cannot see it

#

Because the model hasn't loaded

chrome bay
#

ye

#

ConstructItem looks a bit odd tbh

scarlet radish
#

Every dropped item has an item on it

chrome bay
#

Problem is, that won't replicate

#

Certainly not out of the box

#

Can't a dropped item just store a reference to the class of item? Why does it have to have an instance of it?

scarlet radish
#

Because it has properties specific to that item

#

Durability, stack size

chrome bay
#

That's fine but that all lives in the item class

#

Also are those items data assets? You don't usually make isntances of data assets

#

The point of them is they are static data

#

You jsut use them directly

#

context will not be given

queen escarp
#

hey im trying to destryo session when the "host leaves"

chrome bay
#

well now you ruined my joke

queen escarp
#

it works but it also destroys it when clients leave ./&?

scarlet radish
queen escarp
#

"is server" condition is what i want instead?

chrome bay
#

So whoever logs out first will kill the session

queen escarp
#

yeah but i dont a check at the end =

#

switch on authority

chrome bay
#

SwitchOnAuthority will always be true in the Game Mode

#

It only exists server-side

queen escarp
#

yeah and this wont work either

chrome bay
#

That will also always be true

queen escarp
#

maybe i should check for active player controllers instead ?

chrome bay
#

Use IsLocalController instead

#

Probably not where I would manage sessions tbh but if it's Blueprint only then meh

queen escarp
#

AYE

frozen rune
#

When I download a megascan, it can be like 20 Gigabytes, will it be that big when I upload it on steam, or will it compress?

chrome bay
#

It'll be cooked and compressed when you package

#

Megascans includes all the source data IIRC so you can export it all

#

Also 20GB for one asset lol no thanks

scarlet radish
#

Can you replicate UObjects??

#
    UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite, Instanced)
    TObjectPtr<UItem> Item = nullptr;

I have this, but it's not replicating the actual item.

chrome bay
#

Not just by doing that no, they need to be replicated through an actor

scarlet radish
#

That is on my actor

#
void ADroppedItem::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);
    DOREPLIFETIME(ADroppedItem, Item);
}
#

And that

chrome bay
#

Also Instanced has it's own problems RE replication

#

The key distinction is that marking an object property replicates the value of the property, not the object it references.

#

Instanced replicated objects had problems with GC last time I checked. Might be resolved in newer engine versions but IDK

scarlet radish
#

I notice you use inline functions in your guide

#

For GetLifetimeReplicatedProps etc

#

When do you use inline vs on the cpp file

frozen rune
scarlet radish
chrome bay
#

Also it is old

scarlet radish
#

Understood

chrome bay
#

You can skip things like ReplicateSubobjects() and use the replicated subobject list now for instance

scarlet radish
#

I'm replicating my object using AddReplicatedSubObject(Item); and still don't see it replicated 😦

oblique arrow
#

Guys this variables will replicate to a client? im spawning actor on the server and asigning it to this variable and i need to use it on my client

chrome bay
#

Assuming the actor class replicates yes

oblique arrow
chrome bay
#

Either the weapon class or the actor storing them isn't replicated

#

Client_BindWeaponDelegate looks hugely unsafe

#

No garauntee that weapon actor will be valid by the time the RPC is called on the client

scarlet radish
#

Any ideas? i#'ve just been staring at this for 2 hours now..

    UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite, Instanced)
    TObjectPtr<UItem> Item = nullptr;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override
    {
        Super::GetLifetimeReplicatedProps(OutLifetimeProps);
        DOREPLIFETIME(ADroppedItem, Item);
    }
AddReplicatedSubObject(Item);
#

Why is Item not being replicated

scarlet radish
#
bReplicateUsingRegisteredSubObjectList = true;
twin juniper
#

Show the part that the item is not replicated

scarlet radish
steep wolf
#

follow jambax tutorials for replicated uobjects

#

you require special function overrides

#

uobjects by themselves dont replicate by default

scarlet radish
#

I've followed it

#

I've also followed the 5.1 replication changes docs

scarlet radish
#

Okay I'm a step closer

#

How does replication work with data assets?

#

I have a data asset which contains information about my Item

#
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
    TObjectPtr<UItemTypeAsset> ItemType = nullptr;

#

Assertion failed: Object->IsSupportedForNetworking()

crisp shard
thin stratus
#

Shouldn#t it say what you put into the prints

#

And also print that on everyone?

crisp shard
# thin stratus Only Server?

It’s a multicast so when those fire im not sure if what the print says but I’m pretty sure it just does both (depending on who is receiving the event). The client fires false (as designed) but the other clients aren’t getting that multicast event. Unless I’m missing something obvious

#

For the record. Player fires gun, fire server event, that fires a multicast event that checks the local player controller, which should only fire for the other clients and not the owner/player firing

queen escarp
#

hey, how would i make an object "server side to rpc sound and effects :/ ?

thin stratus
#

Server RPC works, and Multicast calls everywhere?

crisp shard
crisp shard
#

Server as in multicast

#

It just doesn’t say “multicast” on the prints tho

thin stratus
# queen escarp

You can't easily do that without being on the Server in teh first place. For the ServerRPC you need to have the local client own the Actor.
To own the Actor, the Server needs to set it as the Owner. I'm sure you know Ownership by now.

If you need this to happen when a Client interacts with the Actor then you need to RPC elsewhere.

thin stratus
#

It only prints the Player + the Message

#

E..g Server: Bla

#

And Client1: Foo

crisp shard
#

Right yea, just making sure

#

Is the logic I’m thinking correct?

thin stratus
#

So with 2 Clients and Server

#

It prints 2 times True

#

And 1 time False

#

False for the Local Player and True for the SimProxy and Server

crisp shard
#

Yes exactly

#

But that other client does not see the VFX

thin stratus
#

Can you please debug print teh Location on everyone, as well as DebugDraw a Sphere at the location

#

You might be not seeing it cause it sits at 0,0,0 caue that component there isn't valid

#

Or something along the lines

crisp shard
thin stratus
#

Can you still draw the sphere

#

Sanity

crisp shard
#

Show*

thin stratus
#

Yeah the Sphere should show where the VFX would play

#

@crisp shard

crisp shard
queen escarp
#

@thin stratus

#

so basicly this would work right ?

#

the same logic if i just set the owner ?

#

but i need to set the owner "server side" *

thin stratus
#

@queen escarp If "Event: Use" calls Server side, yes

#

But if that already calls ServerSide, then you can just Multicast from there, right?

#

I hope you see the "problem" in this

crisp shard
queen escarp
#

yeah yeah

crisp shard
#

it makes me feel like the VFX are like not replicated somehow but i know they work just v confused

thin stratus
crisp shard
#

even tho it's firing lmao

#

i am testing w latency emuluation at all times

thin stratus
#

RPCs can be dropped if you test with PackageLoss

#

PackageLoss is something I would only really test with if I want to know if my game softlocks locally

#

Cause lost packages aren't really "fixable"

#

It just shouldn't break the game entirely

#

Ping should not cause it to drop though

crisp shard
#

interesting. so when i test w packetloss i shouldn't expect my game to run like that?

thin stratus
#

But given you see the prints, and even the debug draw, I'm not sure if that's the issue

crisp shard
#

i've been going insane testing w packet loss lolol

thin stratus
#

PackageLoss is a very bad thing

thin stratus
#

Even small percent, like 1-3, are already causing issues

#

It just shouldn't cause a lockup

crisp shard
#

yea i have it at 1

thin stratus
#

If the game works well afterwards, it#s fine

crisp shard
#

yea ok dope that makes me feel way better about things lol

thin stratus
#

But you NEVER get the VFX

#

So that's not the problem

crisp shard
#

but yes, the VFX

#

lol

thin stratus
#

Can you play anything else there?

#

Anything to confirm that the VFX is not the issue?

#

as stupid as it sounds

crisp shard
#

well the same exact event is being called on the owning client so that VFX is working itself it just doesn't seem to spawn on other client

#

should i send the flow of logic real quick?

#

i should mention, this worked completely fine when i did everything via multicast, but i implemented client side prediction (sorta)

thin stratus
#

I assume you call a ServerRPC on a Client-owned Weapon

queen escarp
#

@thin stratus when setting owner dosent it require me to set the controller as the owner somehow not the chracter right ?

thin stratus
#

And then in that ServerRPC do a Multicast

crisp shard
thin stratus
#

The thing is

#

If you put a Print into the VFX function

#

And that prints on everyone but hte local client

#

But you don't see the VFX on the Sim Clients, then something is odd

thin stratus
#

Ownership is a chain usually that gets checked recursively up to the UConnection

crisp shard
thin stratus
#

It's theoretically also better to use the Character, so Relevancy can take over for stuff like Weapons if the Owner of the Weapon is the Character

#

I would assume, without testing it, that using the PlayerController as an owner for a Weapon and setting the Weapon to use OwnerRelevancy, might not replicate teh Weapon to other clients anymore

#

But yeah, it's fine to use the Character as owner

#

It's just not so common to set an Owner on an Actor that is in the Level that multiple people can use at the same time

#

Caus then it break

thin stratus
#

Play a different VFX. Or do anything else locally that yo ucan use to confirm that it's generally workign

crisp shard
thin stratus
#

Yeah then not sure atm. I would double check all the RPCs, all the Locations, Print and Breakpoint.

queen escarp
#

if im playing as listen server is it my upload speed or download speed that affects the server ping

#

its the upload right ? has to be

#

internet *

halcyon sparrow
#

Hello! I am having this weird bug on a replication shooting event where once a client shoots (and I call Server_Shoot) Even if the Server event is empty the client is kicked out of the session and opens a new level. Does anyone have any ideia on that? or is that somewhere I can post a video of it?
Using UE5.2

mystic estuary
mystic estuary
queen escarp
#

aye okey, and what would ideally be a required speed to be able to host "lag free" *

#

100/100 250/250 500/500 1000/1000 ?

mystic estuary
#

It solemnly depends on your game. A chess server requires less Internet speed than Fornite.

queen escarp
#

ofc but lets say a PubG game with 5 players

#

for instance*

mystic estuary
#

Honestly, I'm clueless about the actual servers. However, someone like Cedric will be able to answer that in a better way 😛

queen escarp
#

ah okey, il just wait for an answer from him then 🙂

#

my contract is running out next month and i got 100/100 today, wich is slow but im not sure if its worth the extra money for more speed,

#

100/100 works "fine" for everything u need tbh,

halcyon sparrow
mystic estuary
#

I know that you can replicate objects using subobject list, but I don't know what a subobject is

crisp shard
scarlet radish
#

If I'm using static data assets, how do I replicate those across the network?

thin stratus
#

They replicate on their own via the Path

queen escarp
#

Cedric

#

got any thoughts on the internet speed thingi ?

thin stratus
scarlet radish
crisp shard
#

"self" when i equip

thin stratus
#

What are your Replication Relevancy settings for that Weapon?

thin stratus
thin stratus
crisp shard
scarlet radish
#
class FACTORYSURVIVALGAME_API UItemTypeAsset : public UPrimaryDataAsset
thin stratus
#

Which is a bit weird

halcyon sparrow
crisp shard
scarlet radish
#

It might not be the data asset, its failing here

chrome bay
#

Why does it feel like you're still making instances of data assets?

#

An asset implicitly has a stable name

scarlet radish
#

I don't think its the asset actually

#

It's the UObject

#

I incorrectly assumed it was the asset

thin stratus
#

Not sure why the second case happens though

#

or if it still happens

scarlet radish
#

Overriding

virtual bool IsSupportedForNetworking() const override
    {
        return true;
    }

Fixes it, but I feel like its not the correct solution. How can I make sure my UItem is stable?

chrome bay
#

It won't be, but doesn't have to be

scarlet radish
#

So I have to override that function on everything?

chrome bay
#

The only thing you need to do is add IsSupportedForNetworking(), spawn the item on the server, and add it as a replicated subobject. That's it

#

And I suggest making sure the "outer" of the object is the actor also

scarlet radish
#

Okay thanks

#

How does AddReplicatedSubObject work with Arrays?

#

Do I need to itereate through the array?

thin stratus
#

You'd probably add it when you create it

#

I don't see the need to loop the array if when you add/create the object you could also add it to the sublist

scarlet radish
#

I'm currently using a struct to represent each inventory slot, would this need to become a UObject if I wanted to replicate it?

thin stratus
#

No, a Struct replicates fine

#

I don't quite get what we are at by now

#

Are you instancing UObjects and trying to replicate them or not?

#

Cause the DataAsset shouldn't need this

scarlet radish
#

Sorry, I should have mentioned, that seems to be working now.

#

I'm currently trying to replicate an inventory

thin stratus
#

So different problem?

#

Structs replicate fine

scarlet radish
#

Do I need to AddReplicatedSubObject ?

thin stratus
#

The properties of the struct follow the same rules though

#

If you have UObjects in that struct that aren't assets, yes

#

The struct itself and any network support asset and type don't need that

upbeat basin
#

Is setting character to use controller yaw and camera to use control rotation the only way to replicate base aim rotation to other clients?

#

Also, why does giving controller yaw input snaps the character mesh back to it's default rotation value on simulated proxies while it keeps the custom rotation value on server and owning client?

wanton bear
#

In game state, on begin play ive got a branch checking if its the server, then setting a repnotify variable. shouldn't this work as i'm not making a RPC? doesn't seem to.

upbeat basin
wanton bear
scarlet radish
#

I have this on a component and it isn't being replicated, am I missing something?

UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
    TArray<FInventorySlot> Slots;
upbeat basin
wanton bear
upbeat basin
#

Where do you read the value on clients?

wanton bear
#

i assume this must be an intentional way that game state works

#

im printing on the notify and it only prints for the server

upbeat basin
#

Are you setting it to it's default value?

#

That wouldn't trigger the OnRep on blueprints

upbeat basin
umbral tangle
#

blueprint of shame; how I handle the playerstate not being replicated yet on a player-controlled pawn... anyone have any greate ideas on how to handle it in a better way? afaik I can't a RepNotify on the PlayerState variable, which is what I'd ideally want to have I guess

wanton bear
upbeat basin
scarlet radish
#

What's the solution here then?

thin stratus
#

Cause C++ will have proper OnReps for the build in replicated pointers

#

In BPs, you can try to move the call to PlayerState itself, cause then you know it's valid

#

But that depends on the logic

umbral tangle
thin stratus
#

Just keep in mind that C++ OnReps are proper OnReps

#

Meaning they call Client side only

umbral tangle
upbeat basin
#

I do remember I was setting the struct element again to make it replicated to clients but I'm not sure now

queen escarp
#

Cedric why is this not working on the client :/ its changing the ownership correctly

#

its not printing'*

#

the startEvent / ServerEvent are RPC*

#

done on an actor*

#

or anyopne*

thin stratus
#

Why are they RPCs

#

You are already on the Server in EventUse

#

If you aren't then you can't set the owner

#

Owner is only settable on the Server

#

You must RPC in a Client Owned Actor before calling Use

#

There is no cheeky way around this

queen escarp
#

gah mkeyy

haughty ingot
#

Does anyone know how to renable property replication when a property has been marked as "DISABLE_REPLICATED_PROPERTY"

mystic estuary
haughty ingot
#

Thank you

nimble sky
#

anyone able to help me understand what i should be adding to my game I have steam advanced sessions plugin i have a UI I can simulate a connection and all is fine but if i want a Dedicated server like so that way a user can choose host local so ppl can play together and if i want to have Dedicated servers that I pay for where players can connect to what do i need to be following im getting lost on the information any help would be awesome

upbeat basin
#

I'm trying to give some relative rotation to the character mesh on runtime. However on simulated proxies, as soon as owning client gives rotation input, mesh rotates back to it's default relative rotation value. Is there a way to disable this behavior? Only solution I could figure out is setting the rotation of the mesh on tick but, well I would prefer one without using the tick

bitter swift
#

In general, if the server Multicasts a function on a replicated Actor, and that actor hasn't been initialized yet on a client due to packet loss, what happens then if the client receives the RPC multicast?

For instance, let's say I have a replicated variable called CurrentWeapon in my character. The weapon is an AActor and it contains multicast functions. What happens if the server multicasts to a client who didn't update CurrentWeapon yet due to packet loss? In this case, CurrentWeapon might be nullptr for the client.

hollow eagle
#

RPCs targeted at objects that do not exist on a client will be dropped.

#

or not even sent in the first place.

bitter swift
#

Perfect, in that case I don't need to worry about crashes or otherwise

scarlet radish
#

How do I replicate an array that isn't mutated (its children are)

scarlet radish
#
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
TArray<FInventorySlot> Slots;
#
Slots[Index].Item = xxx;
#

etc

#

I don't think the UE knows the array was mutated, I need to somehow manage this manually

#

Or take a different approach

solar stirrup
#

Push Model

#

But normally it should detect it

scarlet radish
#

I tried that but it didn't work

solar stirrup
#

What does your struct look like

scarlet radish
#
USTRUCT(BlueprintType)
struct FACTORYSURVIVALGAME_API FInventorySlot
{
    GENERATED_BODY()

public:
    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    TEnumAsByte<ESlotType> SlotType;

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    TObjectPtr<UItem> Item;
};
solar stirrup
#

Is your item a replicated subobject

#

Also you don't wanna use TEnumAsByte for your own enums

#

use enum class instead

#
UENUM(BLueprintType)
enum class ESlotType : uint8
{
  Your,
  Values,
  Here
};
scarlet radish
#

Someone said you don't need to mark structs for replication

solar stirrup
#

UObjects do not replicate by default

scarlet radish
#

How do I replicate the UObject on the struct?

sinful tree
#

If the object itself is replicated through the replicated subobject list of some actor, then the reference in the structure would be valid I imagine.

scarlet radish
#

Feel like I'm nearly there

#

Should my Inventory slot be a UObject instead of a struct?

scarlet radish
#

Anyone ?

thin stratus
rancid wren
#

I lose control of my pawn after a seamless travel, I am lost on where to fix it.

#

could i get some help with this?

fossil spoke
#

@rancid wren Most actors are destroyed during travel, including Pawns.

rancid wren
#

i've marked it and it does load to the next level

fossil spoke
#

What do you mean you marked it?

#

Also the PlayerController has likely lost possession of it.

#

You may need to repossess the Pawn

#

After travel

rancid wren
#

I'd take a look into the possessing

nova wasp
#

my assumption is something that ISN'T being travelled is cleaning stuff up and knocking your stuff out of place

steep wolf
#

do i ever have to do anything for data asset replication

#

for example softload

#

or is it fine to just replicate dataasset*

fossil spoke
#

@steep wolf Any package that is referenced from disk is safe to pass across the network as it will be directly resolved.

steep wolf
#

so for example, if i have a UPROPERTY(Replicated) UMyDataAsset* containing some asset references within it, they will automatically non-blocking softload on client if i change it on the server?

chrome bay
#

Any hard references will be loaded when the asset is loaded, always

#

Replicated references to objects will only be async loaded if net.AllowAsyncLoading is true. Default is false because it obviously adds latency to the networking system

steep wolf
#

hmm thanks

queen escarp
#

hm since clients cant access the game mode

#

where would i store player deaths ?, for instance my game has 4 players if all die then game over =

#

where would i best do that logic ?

#

game state* ?

chrome bay
#

If you need clients to know the number of deaths then typically yeah

queen escarp
#

hm

#

well if i only want the server to know then how would i do that since clients cant get game mode ?

scarlet radish
chrome bay
queen escarp
#

well when the player dies i have to send the information to the game mode :/ ?

#

but i cant do that since i cant access the gamemode right

chrome bay
#

But player death should be entirely determined by the Server anyway

queen escarp
#

well yeah, but still i need to send that information to the gamemode :/ ?

chrome bay
#

Yeah, but you're doing that on the Server - so it has access to the gamemode

queen escarp
#

oh thats true

chrome bay
#

Clients don't tell the Server when they died, otherwise they could do that at anytime

#

Or worse, do it for other players

thin stratus
#

You are asking a question that has no clear answer

#

This is completely up to you and how you design your inventory

#

Either you use a Struct or a UObject. Or something else. Up to what you need.

scarlet radish
#

If they both work in this scenario

#

Like what differences are there

thin stratus
#

UObject allows for Inheritance fwiw

scarlet radish
#

I've found so far, that I cannot use them [structs] as pointers, which is causing me problems rn

thin stratus
#

Cause the Struct, even if you inherit, would object slice

#

You could use FInstancedStruct to wrap the struct I guess, but at that point one could use an Object

scarlet radish
#

Also I cannot use structs as data assets which is a shame

thin stratus
#

Sure but your Struct can have a DataAsset pointer

scarlet radish
#

If I use FInstancedStruct it makes net replication easier than UObjects?

#

That's the end goal after all

thin stratus
#

Never used it for replicating an Inventory. Jambax added those iirc.

#

I think most people in the end use a FastArraySerializer for their Inventory

#

And UObject is probably preferred if you need Items with different properties and function overrides.
While that is also possible with Structs, again they object slice iirc

scarlet radish
#

"Object slice" ?

thin stratus
#

So if you want to be on the save side of features, a fast array with UObjects is probably gonna be a good call.
But you also only really need Structs or UObjects if your Items have a state.
If they are just plain data that never changes and each slot has only that one item, then you could just have an array of DataAssets fwiw.

chrome bay
#

FInstancedStruct would be pretty expensive for inventory tbh

#

a) it replicates atomically and b) it's really more suited to RPCs than properties

thin stratus
# scarlet radish "Object slice" ?
struct FItemStruct
{
    int32 SomeInt = 0;
};

struct FItemStructChild : public FItemStruct
{
  bool bSomeBool = false;
};

If you have an array TArray<FItemStruct>, you wouldn't be able to put FItemStructChild into it

#

You'd lose the bool

#

So if you need inhertiance like that for your items, UObject it is

scarlet radish
#

Okay so I don't need UObject here, the only problem with structs, is I cannot have the null value when an inventory slot is empty.

#

FInstancedStruct doesn't even exist for me

#

And I cannot use pointers apparently

thin stratus
#

Not sure what you mean

#

You are also never really providing any code

scarlet radish
#

I tried making an "Empty" item, but I'm not sure what combination of & and * I need

static const FItem* Empty;
thin stratus
#

Yeah no

chrome bay
#

Part of the problem here is confusing the item data with the item slot

thin stratus
#

You won't be using pure C++ with UE

chrome bay
#

My slots look like this, in a nutshell:

{
    UDataAsset* ItemDefinition;
    uint32 StackCount;
    UObject* ItemInstance;
};```
thin stratus
#

Naked pointers are pretty shite

#

If at all you'd use a TSharedPtr<FItem> but even that is wrong for the array

#

Just TArray<FItem>

#

And if you need to know if Items[Index] is empty, add a boolean to FItem

scarlet radish
#

So far I have

UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FInventorySlot> Slots;
thin stratus
#

Or if you have an ItemDefinition like Jambax, put that to null

scarlet radish
#
USTRUCT(BlueprintType)
struct FACTORYSURVIVALGAME_API FInventorySlot
{
    GENERATED_BODY()

public:
    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    TEnumAsByte<ESlotType> SlotType;

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    FItem Item;
};
thin stratus
#

Yeah and what's the problem with that?

scarlet radish
#

For example, I cannot do this

FItem UInventory::GetItem(const int32 Index)
{
    if (Index < InventoryData.Slots.Num())
    {
        return InventoryData.Slots[Index].Item;
    }

    return /* nullptr ? NULL ? FItem::Empty*/;
}
thin stratus
#
bool UInventory::GetItem(const int32 Index, FItem& OutItem) const
{
  if (InventoryData.Slots.IsValidIndex(Index))
  {
    OutItem = InventoryData.Slots[Index];
    return true;
  }

  return false;
}
scarlet radish
#

Hmm I could do it that way

#

How could this work? this is used as a predicate

bool CanItemFitInSlot(const FItem Item, const FInventorySlot Slot)
{
    return (Slot.SlotType == ALL || Item.ItemType->SlotTypes.Contains(Slot.SlotType))
        && Slot.Item == FItem::Empty;
}
thin stratus
#

Doesn't give you a ref though, but for a ref you'd need to ensure the entry is valid anyway

#

Your FItem need something to identify it as empty

#

A boolean, a pointer to a DataAsset

#

Something that you can set to later check if it's valid

chrome bay
#

Could returns pointers instead and return null

scarlet radish
#

I can't use struct pointers right?

chrome bay
#

So long as you don't expose to Blueprint you can

thin stratus
#

Struct Pointers are fine. What I meant earlier is that you shouldn't do new FItem()

#

At least not without using a SharedPtr

#
FItem* UInventory::GetItem(const int32 Index)
{
    if (Index < InventoryData.Slots.Num())
    {
        return &InventoryData.Slots[Index].Item;
    }

    return nullptr;
}
#

You can do this fwiw

#

But again, not usable in BPs

scarlet radish
#

How about something like

// FItem.h
bool IsEmpty() const
{
  return ItemType == nullptr;
}
#

ItemType being

UPROPERTY(EditAnywhere, BlueprintReadWrite)
TObjectPtr<UItemTypeAsset> ItemType = nullptr;

thin stratus
#

Yeah I mean that's what I suggested 2-3 times now

scarlet radish
thin stratus
#

Yus

scarlet radish
#

I wasn't implying it was my idea, was just showing relevant code to double check we were on the same page

chrome bay
#

If this is how it's going, why can't the inventory slots just be a TArray<FItem> instead of needing a wrapper type?

#

Just index into it using the enum

scarlet radish
#

Because inventory slots have the slot type too

#

HEAD, PRIMARY, OFFHAND, CHEST etc

chrome bay
#

But those slots always exist right? They just might be empty

#

Or can you have more than one etc. of each type

scarlet radish
#

You could have more than one, an inventory could take any shape

#

2 days and we made it

#

Okay great, so my next issue now, is.......

I have an Equipment component, that updates when the Inventory changes (via events)

But Equipment is a client side component, Inventory is a server side component, so it doesn't receive the neccessary events.

#

I feel like I could fire the event from the OnRep function, but I need to know the index that was updated

scarlet radish
thin stratus
#

cause you get per element callbacks

#

Not necessary but helpful

meager spade
#

@chrome bay are your item instance replicated?

#

i highly recommend FAS for the callbacks on client side

lilac lance
#

does SetActorLocation Replicate in c++ or do you need to set up an RPC for that?

solar stirrup
#

I think you need bReplicateMovement enabled for that

#

not entirely sure

lilac lance
solar stirrup
#

Actor needs to be replicated

#

And it needs to be movable

hollow brook
#

I am dealing with the following issue:

  • On a server, I generate tiles. All the tiles are stored in a TArray: TArray<FMyTileStruct> Tiles which is pretty huge (30k+)
  • When a tile is generated, an Actor that replicates is spawned (Tile Mesh is spawned on Server & Clients)
  • I have a mechanic of Building for clients, which works as usual, you pick a building to build, camera zooms out and you are presented with a trasparent preview of the building position
  • The color is Red or Green depending on if you can build on that tile or not
  • This is resolved via checking the TArray of Tiles, if the Tile at that position is "free" (so no collisions checks etc)

On server, this works fine, but on client, I would need to replicate the Tiles array from Server to Client, which is not a great idea as the Tiles array is pretty huge (would need to chunk it). Also I am not a fan of it replicating realtime. So I was thinking about using a Server RPC call from Client that would work like "Is this tile free?". However, with this approach, there would be a slight network lag, for example if you would move the building preview to a new tile, you would first need to wait for the Client RPC from Server to tell the Client if that tile is free, which could break the game fluidity.

What would be the usual/standard solution to solving these kind of issues with replication/lag/prediction?

#

I guess you misunderstood my issue. The issue is, when a Client would want to know, which tile is free or occupied, he would need to send and then wait for RPC telling him the outcome, which would result in a slight lag, as the information presented (green building preview = good, red = occupied) is realtime.

chrome bay
hollow brook
#

I am not using Fast Array. So with that, the entire Array would replicate to clients and I would not need to do the RPCs, if I understand correctly. I'll look into that, thanks for the tip!

chrome bay
#

But it's either usually an actor instance or some existing subobject that stores additional data per-item etc.

solar stirrup
#

Ever since FInstancedStruct released and was made net serializable, my items instances stopped being replicated subobjects heh

#

The only replicated UObject I have is inventories, since that way I can move inventories around actors without copying the inventory array and having to replicate the whole thing again

#

(also has the bonus of the new replication condition for subobjects, I can hide inventories from players as needed)

thin stratus
#

If I have a replicated property on an Actor that a freshly spawn, do I have any function where I could set that variable before it initially replicates?

solar stirrup
#

probably PostInitProperties()

#

afaik that'll call before initial replication

thin stratus
#

Talking about a Struct with "ProjectileData" that is replicated and fed into the Actor when spawned.
One of the values in that Struct can be set from the Actors SpawnLocation.

#

Hm

solar stirrup
#

Replication is always one of the last things done unless i'm mistaken

#

So you can set it after spawning the actor

cobalt pollen
thin stratus
#

The equivalent is a Deferred spawn but that's not what I mean

cobalt pollen
#

Not sure how that interacts with replication

thin stratus
#

The actor already has the variable exposed

solar stirrup
#

Yeah don't need to defer, pretty sure the game loop always runs before replication so if you spawn it and then set data, they're guaranteed to be there when they get replicated to clients

#

(assuming no prop is a replicated UObject obviously)

cobalt pollen
#

Just grasping at anything because it's rare to see you asking the question instead of answering 😅

thin stratus
#

The problem is that the Actor calculates a Direction from StartLocation to TargetLocation.
When first spawned, that StartLocation is basically the spawn location/actor location.
The problem comes when it respawns after not being relevant for a few seconds.
Cause then it will recalculate the direction but on the Client the StartLocation is now the one where it "respawned".

I want to have a value that remains the initial spawn location that the Server spawned it at, but I need to make sure that it's set before begin play calls

#

And yes, I could just replicate the Direction itself, but StartLocation is used for a lot of things

solar stirrup
#

If you set it after spawning the actor, clients are guaranteed to have it when BeginPlay() calls for them

#

It's one of my favorite guarantees, replicated properties (POD) are guaranteed to be replicated when the actor spawns on a client

thin stratus
#

"After Spawning" being PostInitProperties or similar I guess?

solar stirrup
#

Pretty much any time between spawning and replication occurring

thin stratus
#

Does Properties call before Component?

solar stirrup
#

Could be SpawnActor<>() -> MyActor->SetStuff()

thin stratus
#

(PostInitXYZ)

#

Let's try it I guess

#
void ACustomProjectile::PostInitProperties()
{
    Super::PostInitProperties();

    if (HasAuthority())
    {
        ProjectileData.StartLocation = GetActorLocation();
    }
}
solar stirrup
#

There's also OnActorSpawned

#

nvm it's a delegate

thin stratus
#

Was just about to say

#

I will try this first

#

If it works I'm fine with it

solar stirrup
#

this should work

#

pretty sure the engine would init props before replication

#

makes no sense if it didn't heh

thin stratus
#

It's a weird case, cause the project got NetRelevancy setups later on

#

So now some stuff that wasn't an issue if the Actor is relevant from start to end becomes issues

#

.>

solar stirrup
#

oof

meager spade
#

so i don't replicate instance and fastarray entry

thin stratus
# solar stirrup oof

PostInitProperties doesn't seem to work, but that more due to GetActorLocation seemingly returning 0,0,0

#

With the assumption that I need to wait for the Components to be init

#

So will try PostInitializeComponents

solar stirrup
#

ah possibly yeah

#

since it's the root component that gives location

#

the actor lifecycle doc doesn't say when post init props calls >:/

thin stratus
#

:/

thin stratus
#

Works with PostInitComps

#

Cheers

burnt hinge
#

How can i set the right character ref when i have a multi seated vehicle?

sinful tree
burnt hinge
#

it would be easy if i didnt use animations. just teleporting

crude comet
#

Hello everyone! Does anyone know why morph target names (FName) do not exist on the server? I used two different methods (one from USkeletalMeshComponent and the other from USkeletalMesh), none of them are sufficient.
GetMorphTargetCurves and GetMorphTargetIndexMap. On the development build TMap was empty. Are there any other methods to retrieve name on the server? I do not want to RPC names from the client or something like that. It seems that I'm missing some checkbox or something which will allow me to get these names straight on the server side.

lucid badger
#

Every single time that I spawn an actor or an object and set a value that is replicated I have to use the on-rep not begin play because in the beginplay the value is not yet repped

#

Like 100% of the time

solar stirrup
#

What kind of value are we talking about

lucid badger
#

Anything. Pointers, ints, structs, floats, bools

#

That's what I've replicated so far off the top of my head

solar stirrup
#

POD is guaranteed to be there

lucid badger
#

What's pod

solar stirrup
#

plain old data

lucid badger
#

Well that's not my experience Shrugeg

solar stirrup
#

Pointers are special - you replicate a reference to a UObject, the UObject isn't guaranteed to be available on the client

#

It's weird because that's definitely a guarantee

#

Another guarantee is that, on a frame when an actor is replicated, all of it’s changed properties will be sent at once, and the client should receive and apply these changes within a single frame (with the exception of unmapped properties). However, there is no guarantee made regarding the order in which properties will be received or the order in which OnReps will be called. Any order is considered an implementation detail that should not be relied upon. If the order of an actor’s property replication is important to your game, you may need to implement OnReps to track which properties have been updated on a frame. After the replicated values have been received and their OnReps called, you can handle the changes in the PostRepNotifies function. You may also need to save certain received values in their respective OnReps until they’re ready to be used.

lucid badger
#

Where/when are you setting the value? If I set something immediately after calling construct or spawn, the object replicates "naked" first

#

And beginplay fires without the value up to date yet

#

What you just quoted doesn't say that they're all guaranteed to be there by the time beginplay fires Thinkge

#

It just says changes all come together if in same frame

solar stirrup
#

im trying to find the actual place where I got that guarantee

#

Okay so it's probably better to do it in PostRepNotifies()

#

instead of BeginPlay()

lucid badger
#

Why not just do it in an on-rep? Thinkge that's where I ended up

solar stirrup
#

Or that

lucid badger
#

If multiple things need to be repped at the same time I just put them in a struct

#

And on-rep ig

solar stirrup
#

But the basic guarantee is that when an actor is replicated to a client (initial replication) all replicated properties will be available clientside (except unmapped props)

#

yeah, just make sure that if you must have everything in your struct arrive at the same time, mark it USTRUCT(Atomic) or override net serialization

#

I do have on reps call before BeginPlay() sometimes so it's annoying, but yet another race condition to keep in mind working with replication i suppose

lucid badger
solar stirrup
#

nah

#

Replication is handled at the end of a frame

#

Your game loop generally fires before that

#

So whatever you do between spawning the actor and the end of your ticks, will (normally) be replicated

#

No need to disable replication, and for deferred spawning. The only time I'd use deferred spawning is if I need properties set before the actor's lifecycle starts

lucid badger
#

I wish we had a separate term for when the existence of the object is replicating

#

Like co-spawning or something

#

Versus properties on it

#

My understanding is that BeginPlay (on client) is called the moment the item "co-spawns"

#

And for me that happens 100% of the time before any uprops have replicated

#

Every uprop is always default value for the class at that moment

#

And it sounds like what you're saying contradicts that Hmmge

solar stirrup
#

Nah so

#

the props are there just probably not set

#

I need to double check but iirc BeginPlay() gets called when the actor is added to the world

#

the world has begun play so it calls begin play

#

You're guaranteed that on the frame your actor got created on the client, they'll have all the (pod/mapped) props

#

OnReps/PostRepNotifies() will work fine for that

lucid badger
#

What exactly is POD? Just primitive types? int bool float?

solar stirrup
#

yep

#

numerics, strings, structsm anything that isn't a UObject* generally will be there

lucid badger
#

Yeah that's not my experience Shrugeg

#

That's why I had to move everything to onrep

#

Gotta wait for the properties to show up

solar stirrup
#

UObjects require mapping, so while the reference to it might have replicated, it might not exist on the client yet and you'll be waiting for the UObject itself to replicate and be mapped to your prop

lucid badger
#

Because they're not ready yet

solar stirrup
#

Yep you do wanna use OnRep

lucid badger
#

Like FGuids

#

Are not valid

#

At the moment of co-spawning

solar stirrup
#

It's just that on the frame your actor begins play, the props will be there. Maybe not on begin play, but they're right behind that.

lucid badger
#

Oh

#

Okay I think I was just getting confused by the semantics

solar stirrup
#

Yeah nah like, I wish BeginPlay() got called after props got deserialized

lucid badger
#

By there I just meant like, ready to go

#

You mean like network traffic wise

#

They have arrived but are not yet ready

solar stirrup
#

I meant that I wish the engine only called BeginPlay() once the replicated props were set

lucid badger
#

Yeah that'd be lovely

#

Cramming every value into a struct and repping that seems to work fine though so Shrugeg

#

btw hwat's Atomic I never seen or used that hmm

solar stirrup
#

Right now it can call BeginPlay() even though the replicated properties are right about to be set on your actor - they are there, they will be set on the same frame as the BeginPlay(), but yeah

#

Atomic makes your struct always replicate all properties at the same time

lucid badger
#

now I got you

solar stirrup
#

No delta replication

#

Let's say you have FMyStruct with int32 A and int32 B

lucid badger
solar stirrup
#

You set A to 5, and replicate that

#

next frame your set B to 10 and replicate that

#

However, the packed with the update of A got dropped

#

Your client only receives B's update - your struct is (temporarily) desynced

#

With Atomic, if you set A to 5, the engine will send A & B to the client

#

If you drop the packet, you drop the whole struct update

lucid badger
#

Oh hum

#

Yeah that makes sense. I didn't know it was only diffing

solar stirrup
#

Saves bandwidth especially on large structs

lucid badger
#

But I can't picture a situation where I am replicating changes to a struct where I'd be okay with some changes being dropped hmm

solar stirrup
#

let's say player scoreboard stats

#

kills, deaths etc

#

it's fine if the kill/deaths/points get desynced temporarily most of the time

lucid badger
#

So it'll just get fixed on an upcoming frame? Without requiring another change?

solar stirrup
#

yeah replication is "eventually consistent"

#

the server sends update after update and the client will "eventually" be synced

lucid badger
#

I can't remember the specifics now but i Had a situation where a value was getting desynced and would only correct when the value changed again on the server

#

Like the client changing their value to a wrong value didn't get the server to correct it until the server changed its value

solar stirrup
#

If the client modifies the local value, it's on them

lucid badger
#

Ah

solar stirrup
#

They'll be desync'd until the server sends another update, it won't if it doesn't know it needs to

#

Which happened in your case

lucid badger
#

But when it's the other direction it can tell

#

And eventually get it right

solar stirrup
#

Yeah iirc clients send acknowledgements of property updates they receive

#

If they don't receive a property update, the server will send it again

lucid badger
#

NOTED good stuff thanks

solar stirrup
#

Or of course if the server's value gets updated again

lucid badger
#

That Atomic thing was probably going to cause some truly nightmarish bugs when I started testing with latency Okay Although I guess I'm usually changing the whole struct at once in my current uses hmm but still

solar stirrup
#

Latency isn't the issue

#

It's packet loss

#

If you modify both A & B in a non-atomic struct, it'll send both props in one update

lucid badger
#

sure

solar stirrup
#

So you're rarely gonna notice a bug if ever

#

If you modify A but wanna make sure your struct stays synced, then yeah make it Atomic

lucid badger
#

Yeah I'm not taking any chances. If the struct is meant to sync as a unit then I'm putting Atomic just as a best practice Shrugeg

solar stirrup
#

Weigh the pros and cons when you do that, if your struct is huge you're gonna be sending a big chunk for every potentially minor property update

lucid badger
#

That's what I mean. For the structs where the whole struct represents a set of data that changes all at once, i.e. where the Atomic addition wouldn't change what's getting sent because it should be getting all changed together anyways

#

I don't have any structs yet where I'd be changing singular values in a frame

#

But to protect if I accidentally do that without thinking

#

Boom, atomic

solar stirrup
weak copper
#

Someone should remake Front Lines Fuel of War... and let me be part of it.

#

please 🥰

quasi tide
#

See I would - but that game was extremely boring to me.

weak copper
#

first game with full drones in multiplayer ... RC bomb car RC attack helicopter and RC mini gun tank... the multiplayer was way ahead of the curve before BF3 and COD and i believe it was 32 player?

#

and fight the chinese ...

rocky kestrel
#

Hello! I have online game that worked well with 20 players on server but on playtest with 60 players servers started lag (delayed movement, shots, etc) what things could help and is there any way to simulate 60 players on server on backaged build?

fossil spoke
#

Identify areas that are causing performance bottlenecks

#

Optimize those areas

#

Profile again and start the process over until you reach your target performance metrics

dusty river
#

Blueprint: Is there some general way for a client to execute some logic, then tell the server to multicast it to everyone but the client who called it?

#

Would it be absurd to pass the player controller who called the RPC as a condition to check when performing the multicast function?

twin juniper
#

Where should i put my inventory in an average multiplayer game, PlayerState or PlayerController?

quasi tide
twin juniper
#

If something like PUBG then PlayerController right?

quasi tide
#

That'll be fine. Or the Pawn.

thorny saddle
#

what is the best way for pass actor from client to server?

quasi tide
#

What do you mean? If it exists on both, then just do a server rpc with the actor reference

#

If it doesn't, then you need to tell the server to spawn it and have them match up with NetAddressable shenanigans (if I recall correctly)

thorny saddle
#

something like this ?

#

NetAddressable what is this ?

quasi tide
#

Yes, something like that.

thorny saddle
#

im in ue4

quasi tide
#

Okay

thorny saddle
#

its won't work btw

#

server can not find the refrence