#multiplayer

1 messages · Page 252 of 1

last furnace
#

it increases at the same rate on both server and client at the same time, is that correct?

dark edge
#

it should be pretty much the same on server and clients at all times

#

minus lag etc

#

there should be no way that the server sees 1 and client sees 0

#

assuming that's correct, then your problem is in the usage of the parameter, nothing to do with networking

last furnace
#

ok so that's fine then, does that mean the alpha needs to be connected to the param in some way?

#

as in this wont work because the alpha isn't involved?

dark edge
#

What's the rule here, the glow color is red when ____________?

#

I'm thinking it should be transparent when alpha is 0 and red when alpha is 1 but idk your design

last furnace
#

ideally depend on the alpha, but I don't know how to lerp a linear colour. Do i have to break and make it into floats and finterp each channel?

#

in this case it should lerp from black to a "Chosen Colour" Variable

dark edge
last furnace
#

my problem was I was looking for an finterp equivalent

#

unfortunately that hasn't fixed the replication problem

last furnace
#

you are welcome to give up on me any time

dark edge
#

show current code

#

show all of whatever applying the alpha does

last furnace
dark edge
# last furnace

if you do:
BeginPlay -> short delay -> timeline -> call that function
does it work correctly everywhere?

last furnace
#

same results as my previous examples. everything before the Outliune works

dark edge
#

so this is the only node that's not doing anything?

rotund sail
#

I set the online platform (ie the susbsytem in the config) to null, to test in editor. Its janky but atleast there isnt the unique_net_id mismatch trouble that using steam will get in editor

last furnace
dark edge
#

first check if that material is valid everywhere

last furnace
dark edge
#

is first person camera a component on this actor?

dark edge
#

does the delay fix it?

last furnace
#

sorry for the naivety, where should i be delaying?

dark edge
last furnace
last furnace
dark edge
#

then start debugging to figure out what's broken

#

did you enable replication on anything that wasn't by default? Also who's machine doesn't do the post process, the host or client?

#

oh u know what

last furnace
dark edge
#

might be a locally controlled thing

#

since post process is GLOBAL

#

What's the idea here, an outline is on what pawn on what machine in what state?

#

do pawns with an alpha of 1 have an outline, and pawns without have no outline? Is that the rule?

#

should YOUR pawn on MY machine have an outline when YOUR pawn is vanished?

last furnace
#

you, a ghost, trigger the vanish ability, and it changes your colour, transparency, and the colour of the outline/cellshading. Everyone should see me the same way i see myself

#

but it doesn't change how others look

dark edge
#

ok, so how does the post process know the difference between your pawn and my pawn on my screen

last furnace
dark edge
#

I think the post process should ALWAYS be there, and you should draw to a stencil when vanished

#

the PPM doesn't fade in and out, your pawn draws to a stencil or not based on vanished state

last furnace
#

ahk, so the issue isn't so much a problem with my replication setup, but more the method of the outline itself

#

will try the stencil method tomorrow. Thanks for bearing through this with me

#

First time delving outside of single player

dark edge
last furnace
#

I went through so many tutorials thinking "surely there's a more streamlined way to do this by now"

rotund sail
#

ye MP is pain. I would try writing down the work flow on paper to see if you can figure it out a bit better. Like
Client clicks button on UI -> Server Calls X Function -> Etc,.

latent heart
#

A server vs client timeline can help too.

#

Make sure that all calls between lines are diagonals.

last furnace
torpid lantern
#

What am I missing here, why is a func trigged from an OnRep called twice?

sinful tree
torpid lantern
#

I hate that this fixed the issue..

#

But thank you.

sinful tree
#

Yeah, that was a definite oddity. When wierd unexpected things happen, restart is definitely best bet XD

soft condor
#

Hi folks. I have an issue with replicating a dynamic skeletalmeshcomp. I have a server rpc in c++ that calls a BlueprintImplementableEvent(https://blueprintue.com/blueprint/0wh-4bk5/) which attaches the dynamic component to the player skeletal mesh. The serverRPC also sets a repnotify value that calls the event as well. This is working fine on the client hosting the server(listen server) but the meshcomp doesn't seem to be replicated on the other connected client even though it is visible on the server. I think My understanding of replication might be a bit flawed here. Since the serverRPC changes the repnotify value shouldn't it replicate to other clients as well? I would appreciate some help thanks. Below is the serverRPC and rep_notify:

{
    PlayerWeaponState = EPlayerWeaponState::Equipped;
    OnPickUp();
    GetCurrentPickupActor()->Destroy();
}

void AhordeGameCharacter::OnRep_PlayerWeaponState()
{
    OnPickUp();
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, TEXT("Working onpickup for client"));
}```
heady python
#

i have 2 teams, and each team can only control their owned units. when a client makes a request to move units, how can i ensure that they only move units on their side. Would sending their PlayerController through the RPC for a team check work since the client only has access to their own PlayerController?

sinful tree
prisma snow
heady python
sinful tree
#

Player Controllers and Pawns have a reference to their playerstate. Playerstate has a reference to their controller and their pawn. The Pawn has a reference to the controller and the playerstate.

heady python
#

I see. so sending PlayerController is what i want. thank you!

#

or getting the playercontroller on the actor im calling it on

sinful tree
#

You shouldn't need to send the player controller at all.

nocturne quail
#

is there a fast method to change the character anim class at runtime?
calling this on a multicast is very slow

GetMesh()->SetAnimInstanceClass(PlayerAnimObject->GetAnimBlueprintGeneratedClass());
#

server method which is calling the multicast is derived from c++ animnotify which is called in editor montage

nocturne quail
#

I am calling it on notify end

#

I want it to be changed straight forward when the method is called

#

according to my guess it is slow because:
the current animation instance needs to be destroyed and a new one to be instantiated from the reflection system since i am calling GetAnimBlueprintGeneratedClass()

prisma snow
#

I would first profile and debug that this suspicion is correct. A 0.5second delay is really high. Might be due to something else

#

If it's indeed slow due to that function this is not the right channel to ask btw

nocturne quail
thin stratus
#

Also, why is that a Multicast? I would argue that's State, so it should be replicated via an OnRep.

#

Also SetAnimInstanceClass most likely has to fully initialize the AnimGraph and all the AnimNodes, cache bones and what not.

nocturne quail
thin stratus
#

That can indeed be a bit expensive. .5 seconds is absolutely wild for a single call though.

#

If it costs a few ms then we would already say it's expensive

#

500ms is way too much

nocturne quail
#

and its 500ms in my local system where i am playing as 2 clients

#

not sure in a real network environment how it will behave

#

i mean to open world clients

thin stratus
#

You need to profile it though.

nocturne quail
#
void AArmaCharacterBase::EquipNotifyHandleFinished(class USkeletalMeshComponent* MeshPlayingMontage)
{
    MultiSetWeaponAnimClass(EquippedWeapon);
}

void AArmaCharacterBase::MultiSetWeaponAnimClass_Implementation(class AWeapon* AttachedWeapon)
{
    if (IsValid(AttachedWeapon))
    {
        if(!IsValid(AttachedWeapon->PlayerAnimObject)) { return; }

        GetMesh()->SetAnimInstanceClass(AttachedWeapon->PlayerAnimObject->GetAnimBlueprintGeneratedClass());

        if (UArmaWAnimInstanceBase* WeaponAnimInstance = Cast<UArmaWAnimInstanceBase>(GetMesh()->GetAnimInstance()))
        {
            WeaponAnimInstance->UpdateCurrentWeaponRef(AttachedWeapon);
        }
    }
}

void AArmaCharacterBase::UnEquipNotifyHandleFinished(class USkeletalMeshComponent* MeshPlayingMontage)
{
    if (HasAuthority())
    {
        MultiResetMainAnimClass();
    }
}

void AArmaCharacterBase::MultiResetMainAnimClass_Implementation()
{
    if (!IsValid(PlayerAnimObject) || !IsValid(PlayerAnimObject->GetAnimBlueprintGeneratedClass())) {
        return;
    }
    GetMesh()->SetAnimInstanceClass(PlayerAnimObject->GetAnimBlueprintGeneratedClass());
}
nocturne quail
thin stratus
#

You usually just pass the UAnimInstance class into it.

nocturne quail
nocturne quail
thin stratus
nocturne quail
nocturne quail
#

I think i can solve it now by calling the end notify little early before the notify actually end's

thin stratus
#

Are you actively creating that component runtime?

#

I'm somewhat sure that doesn't replicated.

soft condor
thin stratus
#

One usually has to create the Component on both sides.

#

And ensure it's stably named so it can actually "connect".

#

I think only Actors will be spawned upon replication.

soft condor
thin stratus
#

If your current pickup actor is replicated, then it could be that it gets destroyed before the OnRep calls.

#

Cause you destroy it directly afterwards

soft condor
thin stratus
#

You can try to either delay the destroy by setting the lifespan, or you can try to call TearOff on it, which cuts the replication ties. But then the client needs to clean it up for itself

#

Which in theory is fine cause I assume the client can just destroy it locally after equipping

soft condor
soft condor
#

Ah I think I see the error of my ways. I assumed that because it was spawned on the server and was marked as replicate that it would automatically do that in the client as well. I ended up spawning the component as an actor instead and then I enclosed the spawning and calling the blueprint event into one function that I call in both the server rpc and the repnotify. The BP event remains the same. It looks something like this now:

{
    if (TObjectPtr<UWorld>World = GetWorld())
    {
        const FVector location = GetActorLocation();
        const FRotator rotation = GetActorRotation();
        FActorSpawnParameters spawnParameters;
        spawnParameters.Owner = this;
        WeaponMeshActor = World->SpawnActor<AWeaponMeshActor>(location, rotation, spawnParameters);
        OnPickUp();
    }
}

void AhordeGameCharacter::Server_HandlePickup_Implementation()
{
    PlayerWeaponState = EPlayerWeaponState::Equipped;
    SpawnAndAttachWeapon();
    GetCurrentPickupActor()->SetLifeSpan(1.5f);
}

void AhordeGameCharacter::OnRep_PlayerWeaponState()
{
    SpawnAndAttachWeapon(); 
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, TEXT("Working onpickup for client"));
}```
soft condor
twin cliff
#

i'm confused about the intended way to do replicated movement with the built in CharacterMovement component - it seems like for other things, setting up an explicit server RPC to trigger them is the way to go (like firing an attack), but the CharacterMovement component has built-in server side movement validation? so I can call the movement functions on the client and as long as replication is enabled the server will still be validating the movement even if I don't explicitly do it through an RPC to the server?

fossil spoke
#

This ensures that the Client has instant feedback on its movements locally (a smooth experience for the player), while allowing the Server to maintain Authority over the Client (to limit their ability to cheat, like teleport or speed hack etc etc).

twin cliff
#

so it sounds like using the component implies server authority as long as replicates = True, and I can manipulate it directly on the client with the replication/validation all getting taken care of. just wanted to double check my understanding

fossil spoke
#

Generally you will provide the CMC with Inputs

#

Like Jump, Crouch, Move Forward etc etc

#

It translates those inputs into "moves"

#

Which it then uses to sync with the server.

thin stratus
#

That's also why proper predicted custom movement is not a thing in Blueprints

primal summit
#

is anyone familiar with this connection error for connecting to a dedicated server?

"PacketHandler parsing packet with zero's in last byte"

nova wasp
#

but changing the ACTUAL replicated property locally is a bit nasty as some things may assume you aren't doing that

#

that's mostly for simple simulated proxy stuff

#

the CMC server simulated move playback is basically a tiny rollback sim, on sim proxies it's just a position + velocity mostly with some metadata for timing and if they are crouching etc

#

making stuff work correctly in the CMC requires actually extending the simulation steps IN the cmc itself

#

you can't just apply stuff in the regular game tick as the CMC has its own inner loop that both sides work together to maintain a similar "good enough" result (considering the saved moves afaik)

#

clients spam rpcs at the server with where they THINK they are in which way they want to go

#

the server tries it and sends back the result, if it's too far you get bonked to where the server says you are

pallid stone
#

So when you've got a timer on a server doing something, like crafting or farm growth, and you want clients to be able to use the time elapsed to show progress bars, what's the best way to do that?

nova wasp
#

My initial hot take is that you should not need to send constant timer updates if it's known when it started and how long it will take

#

then you can just compare with the local time on the client or with a roughly accurate server time (made with some math, there is an example I can show)

#

it depends on accuracy needs though and how bad it is to predict too early or too late

#

the more stuff you can send in the initial packet that describes the state for a while without needing to constantly rely on a stream of new data the better imo

pallid stone
#

So it would be some sort of "start server time", from getservertime?

#

Just a float? And another replicated float for the length?

nova wasp
#

this is just my rough idea of how I would do it, I think there are plenty of other ways that might make more sense

#

a float is okay here but risky if the game server is around for days at a time

#

as it might start to lose accuracy at higher counts

pallid stone
#

We're talking processing time in minutes

nova wasp
#

but that's unlikely to be an issue here yeah lol

#

the offset time is one thing but there would be an absolute time here

#

I am being a bit overkill trying to make this more quantized here... you can probably get away with sending a lot of these

#

I would say it's worth considering if you have a LOT of these that get sent at once to try to make them sort of derive the value from other offsets or to be able to send the timer for multiple at a time

#

but thats something you can make better later I think

#

for example a single actor rep movement + transform is like ~12 floats or something worth of data

#

depending on settings

#

for now I would say just try to make it resilient to people showing up later at the very least (use onreps etc) instead of rpc based

twin cliff
#

is there a way to have the standalone client and dedicated server launch different maps on startup when running through PIE? im testing out a flow of launch standalone at menu -> click button to connect to server, and have only gotten it to work when starting the dedicated server in a separate process

it's a pain though because then i have to wait a lot longer for the dedicated server process to go through the full startup each time

pallid stone
#

When you've got a variable that's replicated, if a client changes it and they don't have authority, then it doesn't change, but what's happening in the back end? Is it sending the variable up over the network to check for changing it, or is it doing checks locally in the engine code to decide if to even both sending up?

polar hedge
#

Does it matter if MARK_PROPERTY_DIRTY_FROM_NAME is called before or after the property change? I thought it had to be called after, but in Lyra it's always called before.

MARK_PROPERTY_DIRTY_FROM_NAME(ThisClass, PawnData, this);
PawnData = InPawnData;
nocturne quail
ancient adder
pallid stone
lament flax
ancient adder
lament flax
#

i heard of push model but not much

#

is it a alternate networking system where instead of pooling the objects you have to manual trigger ?

#

im not finding much on the push model system

muted reef
#

Throw some brainstorms how I can manage my anim BP for different character classes like for different abilities. Say like Marvel Rivals. My mind boggling

ancient adder
# lament flax im not finding much on the push model system

When you register your property for replication in GetLifeTimeProps or something you can set it to be Push based, you just set a bool to true

When you do, the engine will not diff the property unless you mark it dirty with MARK_PROPERTY_DIRTY_FROM_NAME afaik

lament flax
#

okay so this have perf gains in some cases

ancient adder
#

I believe so, but I heard some people saying it doesn't help

timber tundra
#

Hey everyone, does anyone know of a nice way to get the functionnality of a tmap in a replicatable way (TMaps don't support replication ☹️ )

tardy fossil
#

one way to do it is separate the keys and values into 2 arrays when you need to replicate it and rebuild the tmap on the receiver side

timber tundra
#

Yeah, I'm watching a youtube video that does something similar : when the map is modified it gets converted to an array of tpairs that is replicated and gets reconverted to a map on the client side.

#

I think I'll try that.

lament flax
timber tundra
#

Yeah, I'm trying to do method 2 right now. Thanks for the link.

lethal depot
#

I create a custom uobject from an actor component, and replicate it via calling AddReplicatedSubObject
I try to use the object as a parameter in RPC
if I call a multicast RPC just after creation and AddReplicatedSubObject() call, the client does not get a valid ptr (it is nullptr)
If I add a short delay before the RPC call the client gets it properly

is there a way to force init stuff so the object can immediately be used as parameter in RPC-s or is there a way to check if it is ready or not? what exactly do I need to wait for here?

torpid crest
#

Did anyone managed to make custom movement like climbing the ladders work in multiplayer?

sinful tree
# lethal depot I create a custom uobject from an actor component, and replicate it via calling ...

No. You cannot guarantee that the object would start existing before the multicast is received - this happens with every type of replicated object in the engine.

From what I understand, since UObjects are they very base thing that exists in the engine, they don't have anything that can help facilitate knowing when they start existing.

The "easy" way to know when an object exists on a client is to set its reference within an OnRep property somewhere so that when the value of that OnRep is set and the OnRep function triggers you can try to access it and do something with it, but this still pales in comparison to how "Begin Play" works for actors. I'm sure one could duplicate how an AActor ends up calling BeginPlay but it seems rather convoluted, at least to me, as to how one actually gets from the point of constructing the AActor due to replication to the point where Begin Play is called.

lethal depot
#

something like PreNetReceive of the created object would work as well then, right? instead of the OnRep function

#

as we are on the client anyway

#

(the created object has replicated properties too)

#

I don't want to go the OnRep way because I create multiple instances from the object dynamically

nocturne quail
#

Technical multiplayer question.
suppose i have 100 weapons and each weapon has unique set of animations/offsets/locomotions for character.
so which option is best to implementing them?

1: in a single character animation blueprint class
2: let every weapon has its own animation class for character and when equipped, set the animation class to the owner character

#

currently i'm doing option 2, which works perfectly but have 0.06sec delay when switching animation class

latent heart
#

That's probably a hitch on loading the class. The solution is to async load the classes you may need to use.

nocturne quail
cedar tangle
#

Ha! so to develop in the editor as dedi then you need to have the following set:
Run Under One Process = FALSE
Play Net Mode = Play As Client
Other wise it probably wont work as you expect 🙂

#

I did some boiler plate test code, and this would fire on all clients:
Controllers[Choice]->Client_OnScanComplete();
This was related to Run Under One Process being true.
The idea is a message is GEngine Logged on a random connected client. So not supposed to fire on all clients.
I got a feeling that allot of the questions here may be related to this configuration requirement.

feral linden
#

Hi ! I'm trying to make this door blueprint work in multiplayer, but I can't figure it out.
I'm learning as I go so this blueprint might be all wrong already but the door does work as I want it to.
Can't make it replicate tho, I've been told to use repnotify to achieve it but don't know how/where to set it up.

Any guidance would be welcome. 🙂

nocturne quail
feral linden
#

Well, that even I'm not sure. How would I know ? This event is set in my thirdpersoncharacter bp and is a bit of a spaghetti itself.

#

As I said, learning this stuff, sorry.

nocturne quail
nocturne quail
feral linden
#

while running on server, it prints "server", while on client it returns "client"

#

Is that what you were asking ?

lament flax
#

If you want it to be replicated, a good solution is to have the server calling "open door" and "close door" (server RPC). Those functions changes the value of a replicated bool "IsOpen".
Inside the OnRep_IsOpen you call your timeline code

feral linden
#

Thanks for the insight, will check this out in the morning

#

So repnotify isn't the way to go ? Or is it working alongside rpc ?

dark edge
#

in the repnotify, set the relative rotation

#

then everyone should see the door angle the same as the server

feral linden
#

Getting out of bed to see if it can really be that simple lol

#

Ooof yeah ok that does work !

sullen sail
#

I'm really confuse with the RPC process, why is that I can only see the pickup in the server side? I already did an RPC call to pickup a ball when entered the character trigger area:

feral linden
#

@dark edge Got carried à away and forgot to thank you. Thanks 🙂

dark edge
#

delete all those RPCs

#

use a replicated variable to represent state and use repnotify to do things on clients when the state changes. Set that vairable ont the HasAuthority path of that overlap chain and you're done

sullen sail
#

Like this @dark edge ?

dark edge
#

overlaps happen on server as well

#

don't let the client say "I'm holding the ball now" unless you're ok with cheating

#

What might be better though, is for a replicated ball to have a replicated reference Who'sHoldingMe

#

Instead of 10 players saying if they hold the ball or not, you have 1 ball saying WHO is holding it

sullen sail
#

yeah good point

#

so I should transfer that variable to my actorBall, then do the onRep there?

twin cliff
#

does anyone have experience adding grpc to the build system? not super familiar with the build setup and trying to add grpc/protobuf to it in one of the template projects, was wondering if theres a recommended resource or way to do this

thin stratus
twin cliff
#

oops, not exactly sure where the question should go, maybe cpp?

nocturne quail
# latent heart That's probably a hitch on loading the class. The solution is to async load the ...

I managed to sync load the animation class and then set it, but it still have a small glitch when transitioning from previous to new animation

if (!IsValid(Owner) || !ThisEquippedBy(Owner) || !Owner->IsHolding(this))
    return;

FStreamableManager& Streamable = UAssetManager::GetStreamableManager();
FSoftObjectPath AnimPathToLoad(TEXT("/Game/Animations/abp_AKM.abp_AKM_C"));

Streamable.RequestAsyncLoad(AnimPathToLoad, FStreamableDelegate::CreateLambda([this, AnimPathToLoad]()
{
    UObject* LoadedObj = AnimPathToLoad.TryLoad();
    UClass* LoadedAnimClass = Cast<UClass>(LoadedObj ? LoadedObj : AnimPathToLoad.ResolveObject());

    if (LoadedAnimClass)
        Owner->GetMesh()->SetAnimInstanceClass(LoadedAnimClass);
}));

karmic gust
#

I'm running into an issue where I'm generating splines at runtime and the colliders aren't working on the dedicated server. I've verified I'm replicating the the points with rep-notify, I'm doing a build of the mesh on all pieces individually for replication speed. Clients and servers use the same function to generate everything, including collision. I've added ``` PublicDependencyModuleNames.AddRange(new string[] {
"Core",
"CoreUObject",
"Engine",
"InputCore",
"OnlineSubsystem",
"OnlineSubsystemUtils",
"Chaos",
"ChaosSolverEngine"
});

    // Required for splines to generate collision in dedicated server builds
    PublicDefinitions.Add("WITH_RUNTIME_PHYSICS_COOKING=1");``` to my build files to try and get the server to use this, but it doesn't seem to work right, I don't have any other build files and it works in the PIE with dedicated server running all players as connected clients, so it seems to be a build issue specifically, but the wizardry is failing to find a reason it's being stripped out
cerulean barn
#

can someone please explain to me what things need to be ran on the server and what things need to be ran on all clients?

karmic gust
#

@cerulean barn here's a great helper set of info

cerulean barn
#

thank you

prisma snow
#

If something is only relevant to the player, such as some UI displaying damage dealt, then client only

#

and usually client+server is in prediction scenarios and can get tricky because if client and server disagree you need to somehow resolve it

unique forge
#

hi lol

#

im stuck at door replication, most likely said, the door doesnt open at all

static lava
#

how do games such as ark:se/ark:a handle the based movement on things like dinos or the ship/skiff without the jitter it causes given player 1 controls the thing you are standing on thus it always throws off player 2's prediction

nocturne quail
static lava
#

I was thinking about that, but It would be too easy to cheat

#

and even though ark is pretty bug ridden it never had any similiar glich/exploit

nocturne quail
#

this is why in pubg so many speed hackers

#

else nobody will play pubg with jitters

static lava
#

is there no way to smooth out these jitters? Like make them take longer or something

nocturne quail
nocturne quail
#

or make the server correct the location every 15sec example

#

instead of on every frame

static lava
#

yeah but client side prediction is the cause of the jitter as it predicts a different velocity even with built in systems in engine like acceleration or braking force

#

seemingly prediction even ignores those as well even though they are in the same component as the prediction, the CMC

nocturne quail
static lava
#

I will look into it thank you

snow crypt
#

Anyone have any idea why I cant rotate a player thats possessed?
Having issues rn, I have tried absolutly everything and cant seem to get it to work
SetActorRotation, SetControlRotation (Server and Client)

prisma snow
snow crypt
#

If anyone has an idea it would help a ton!

#

Been struggling with this for a hour now

#

ahaha

rustic ore
snow crypt
rustic ore
snow crypt
#

My issue isn't the character freezing, I am trying to rotate the player in a direction when the player sits down. Right now the player dosen't rotate, so trying to figure out how to do that

nocturne quail
rustic ore
snow crypt
rustic ore
snow crypt
#

would that have any visual glitch when unpossessing?

rustic ore
runic flower
#

Out of curiosity, any tips on how to store player stats/data? I heard some use PlayFab Azure but wanted to see what everyone else uses

thin stratus
#

It's the only method you should usually use, yes.

#

I mean, you can always create some other form of connection and send data that way, as long as you know how to do that.

#

But you won't find any "new" method. RPCs aren't doing anything different than leading to bytes being sent across the net.

errant charm
#

Hey guys, trying to do a physics handle pickup
already got the interaction and execution of it down, it just looks super jittery.
if the server has it, it appears super jittery on the client side.. vice versa
tried this rpc but still have the same result? replicated movement and replicates are on all of the actors.

thin stratus
# errant charm Hey guys, trying to do a physics handle pickup already got the interaction and e...

Tick is already running on every instance. Sending the RPC is somewhat redundant. Also you should probably just let this run on authority and replicate the location to everyone. With physics you can more or less forget about prediction anyway.

And what you are mainly lacking is interpolation. Even if you limit the SetLocation call to authority, the replicated location will never be smoothed on its own

#

Also there is a good chance that the first person camera isn't rotated correctly on the server. You should probably fall back to using control rotation.

odd gulch
#

Hello,

While testing networking on Unreal Engine server-side as a listen server (with an average ping between 10 and 50), everything looks perfectly smooth on the clients. However, on the server side — specifically for the host (me) — characters appear to stutter heavily.

How can I fix this issue or at least minimize it? I would really appreciate help from someone who truly understands this. Please, I've been dealing with this for months, and it's been frustrating trying to figure it out with almost no resources or proper documentation on Unreal's networking. If there's someone experienced out there, I’d be grateful if you could get in touch.

Also, kindly, I’d prefer not to receive speculative comments from people who’ve only been experimenting with networking for a couple of days.

livid gale
#

Hey all quick question, I've got a chat system set up and I'm trying to make the owner's name a different color than all of the other current connected players. I've tried setting it on a condition is local player controller which only sets the host's name to that color. what would be the proper way of going about achieving this?

kindred widget
livid gale
#

yeah, I'm using the check is local player controller as the condition. However it's just setting the host's name to the color (green) in this case and the clients to (blue) what I am trying to achieve is the local player only sees their name as green and everyone else in chat as blue.

kindred widget
#

Then you're making the check on the wrong machine.

livid gale
#

Should I be running it as a client event?

kindred widget
#

You have a chat system. It sends a message. Hopefully carrying with it the sender. This should likely be their PlayerState. You should be checking if that playerstate's controller is valid and is a local controller on the machine displaying the widget.

livid gale
#

ah okay, I'll give that a go

thin stratus
static lava
#

Given how many games uses moving platforms driven by other player does the CMC support smooth based movement on platforms that are have unpredictable movement, such as ones whose movement can change any time based on input on a remote player?

#

Like you can run around on dinos, rafts, skiffs in ark without jitter, same for Atlas, Sea of Thieves etc

#

I've been messing with replicated ships which move buttery smooth on controller player(driver) as they of course predict it for themselves, they move smoothly on observing players who don't stand on them, but if a non driver is standing on deck it causes vicious jitter as it tries to predict it constantly, giving new movement input, causes a huge jitter as expected, and even built in braking and acceleration set in the CMC causes micro jitters

#

I assume its doable given how many UE games do it, I'm just unsure if I'm overlooking some setting in the CMC or do I need to go deeper into its C++ and add customization there

#

The Platform and the players are both currently controlled/moved by their own CMCs and not physics as my project wouldn't work well with physics

nova wasp
#

it just sends the relative position

#

if that doesn't work you can just attach directly I guess

#

something like a ship should probably just have the player attach themselves to it imo

static lava
#

I'm currently using based movement afaik, but it still jitters when the boat has a speed change or controller turns the boat/movement direction

#

I'm trying to do it like Sea of thieves where you can run around the ship and do stuff while your coop partner drives

static lava
#

I tested it and according to the cmc it recognises the boat's mesh as a valid base

#

yet for the client standing on deck(not the driver) it boat seems to wildly jitter on turn and acceleration, while for the bystander client who just looks at the ship the opposite happens, the deck client is the one jittering while the boat is smooth, Same goes for the driver, they see the boat moving smoothly given they predicting the movement themselves and only see the passenger(deck) client's pawn jitter

last furnace
#

Hey guys, I have transform bone nodes in my animation blueprint, are these something that can be replicated? everyone in my google searches seems to still have issues.
So say I'm modifying a bone with my control rotation so my head tilts back when I look up. I'm controlling this in my character blueprint and casting from that in my ABP. With this method I can get the server to work, and all clients see the servers bones transforming, but clients can only see their own bones transforming. Is it possible to get everone to see everyones bones transforming or should I give up on this?

Here's an example showing their heads tilting down

  • Clients see their own bones and servers bones transform
  • Server only sees their own
thin stratus
thin stratus
# last furnace Hey guys, I have transform bone nodes in my animation blueprint, are these somet...

There is nothing inherently different for getting this to work vs other stuff.

If clients need to see something, then the server has to replicate it. You can't replicate stuff in the AnimationBP, but you can in the character. ControlRotation doesn't exist on other clients, but you can use GetBaseAimRotation, which uses a replicated pitch value.
If you need more custom stuff then you need to replicate it properly through the character

last furnace
#

So this is my current setup going from the character blueprint to the ABP. Should I be doing any logic in the OnRep functions? If so, I'm having trouble wrapping my head around what would actually go in it.
This setup is based on this thread: https://forums.unrealengine.com/t/replicating-bone-rotation-modify-transform/374171

I'm new to replication so feel free to talk to me like I'm stupid because in terms of this stuff I kinda am

#

forgot to include what's in the ControlProperties function:

#

oh shit, figured it out. This method works if I swap out get rotation with the base aim node, thanks so much @thin stratus

thin stratus
#

All you need to do is use GetBaseAimRotation in your AnimBP

#

Instead of the replicated ControlRotation

#

And replicting ActorRotation is just a waste of bits

last furnace
#

ok yeah this is falling into place, thanks again

static lava
#

basically this is what's happening, I removed all the parts until I was left with only a cube, that I now scaled to be long as I though it might be sme issue with the it slipping out from under the base finder linetrace

#

but as you can see the issue persisty, the passenger sees the platform(base) jitter the driver of the platform and the observer pawn sees the passenger itself jitter and according to both server and client it recognises the long strip as a valid base so it should use relative location yet it jitters

odd gulch
static lava
#

So I can't even say anything

#

I went into the settings and turned on "Base on Attachment Root"

#

it started working smoothly but to be sure it was the thing that fixed it I turned it off again

#

and it still works

#

this is the only change I did and then promptly reverted it and it started working

#

Only took 2 days and doing absolutely nothing in the end to fix it

nova wasp
#

Does the ship move from ticking? based movement assumes it can change ticking prerequisites

static lava
#

it is moved as a character but it now works perfectly

#

even though as I said all I did was enabling the "Base on Attachment Root" compile-> save then disable "Base on Attachment Root" compile-> save

#

before that it jittered after that it fixed so I guess it would've flushed something

nova wasp
#

I would suggest figuring out which one is ticking before the other

thin stratus
#

Could be that it totally breaks again if you switch who controls whom in the middle.

odd gulch
nova wasp
#

@odd gulch p.NetEnableListenServerSmoothing

#

make sure that is on at least

#

I would suggest making sure SmoothClientPosition_UpdateVisuals is doing... something on the listen server

#

make sure NetworkSmoothingMode is on something not none too

#

p.NetVisualizeSimulatedCorrections at 4 or so should show a complex debug draw... not very useful as its a bit difficult to tell what it's supposed to be doing but I would compare that with the typical client smoothed result

odd gulch
static lava
silver totem
#

This is a somewhat basic question, but am I right to think that when replicating any kind of value that’s changing with a velocity I need to also send a timestamp to compensate on client?

#

So like, in an isolated example if you move at a speed of 5cm a frame at 60fps simulation speed and want to replicate to clients, you send current position, speed, direction and a timestamp so clients can compare the latter to determine their latency and compensate by direction* speed* time latency

odd gulch
prisma snow
#

I would start simple and get into complicated stuff if it's needed

silver totem
#

Yeah I should probably just see how it goes with just replication lol, though I suspect it's going to jitter a bit with medium-high latency

#

Wonder how those games that rely on sync and simulate everything else independently do that

copper grove
#

im having an issue with redpoint eos and common plugins where when i create session it auto opens the same level im on, before using common plugins i would call create session then open level with ?listen and that worked fine... how did you solve your issue?

cedar tangle
nocturne quail
cedar tangle
# nocturne quail in cmc there is a variable to allow client auth movement and this solves the jit...

yeah if the client can move the Character Movement Component (think that is what CMC is) then that can cause complication.
Without the server snapping it back then everything would be out of sync. but the problem I have possibly noted (not tested) is that the client can delay the response then teleport to another players location (if the client has it) kill them and return. The only way to detect that is by validating/re-validating the shots, damage health. But it would probably be all out of sync any way. A simple solution would be to watch the time stamps and flag any strange patterns.

nocturne quail
# cedar tangle yeah if the client can move the Character Movement Component (think that is what...

I got a shooter game demo project from someone claiming was working at aaa company , and that project has something similiar to check player patterns for movement and predicting where should be the player at this time according to the movement input, if there is a big difference it detect it as a speed hack
currently breaking my head with this project to learn how this all stuff working, there are no comments for stuff to explain 😄

cedar tangle
# nocturne quail I got a shooter game demo project from someone claiming was working at aaa compa...

Um, is something I forgot in that message above. That may help the next chunk of text make scene.
Event though the server is awaiting a response from the client that is doing some network trickery, it has communication with the other client that got killed. The problem is the server can not validate if the other client that got killed is reporting/relaying the the truth. So how to solve this. next chunk of text on he way.

nocturne quail
cedar tangle
#

The first and most simple way I would do it is to have server based triggers that the players have to pass to be in a location (the player instance on the server passes them). This can be a good way I guess to invalidate the damage. Another way is to calculate distance traveled of each player, not so simple but they wouldn't match.

nocturne quail
#

I'm validating hits on server, so basically a client can see the other client taking damage but if server not validate it the damage will not be dealed

#

so shooter only see visual effects

#

doing the whole gameplay on server is a good idea but the game will be lagging if there is not a stable connection

cedar tangle
#

actually yes that is correct now you put it like that the server would not apply the damage as the client is not responding. Hmmm.

#

If the code is solid 😛

nocturne quail
#

yes server logics are always simple and solid, it not need fancy things

cedar tangle
#

I can see how it is possible tho.

nocturne quail
#

this works the way like clients copies on server deal damage and the result is replicated to local client

cedar tangle
#

Ray cast hit would result in small amounts of damage. A knife attack maybe allot and the really tricky one damage radius.

#

Throw a grenade reconnect, boom.

#

I mean if the grande trajectory code is not simulated on the server. And it can be.

#

@nocturne quail I think server based logic for almost everything is heavy.
And that is one limitation. But I am starting to wonder if the server logic only can be tricked.
I guess it adds more wight to the servers processing demand to counteract some of the more extensive validation checks.

#

and that result in $$$$$

nocturne quail
#

validating simple code stuff is not heavy unless it involves large heavy ticks

#

basically a proper design will not effect server performance

#

for damage system i use linetrace for all hits

#

and so far it has no performance hits

#

for grenades do a linetrace from the center point like shown in image on all directions

cedar tangle
#

I know the UE engine is a beast, like the more I understand it, it shocks me.
but one can never trust a client.
And every possibility needs to be defended.
well depending on if it is a cash grab or not I guess.

#

The problem with the grande is the throw it has to be simulated to know for sure it is at that location.

#

Basically the radius is defined by its landing location.

#

the ray casts both gun knife have origin locations so as long as that is tracked then that is fine.

nocturne quail
#

grenade should have time like 5sec, it will explode after 5sec no matter thrown or not and do line trace from the explosion point

#

put a socket somewhere in weapons to do a linetrace on forward vector of that socket

#

for a pistol it should be the muzzle point example

#

if the scope is attached, do line trace from the attached scope

#

it will again need the bullet socket on the reticle point in scope

cedar tangle
#

Actually that would work, if the distance between the grenade landing and the grande spawn point is validated.

nocturne quail
#

if server did that trace, no need for validation

cedar tangle
#

The server would receive the data from the client.
just delayed.

nocturne quail
#

yeah lots of scenarios in that case

cedar tangle
nocturne quail
#

just don't delay user inputs to server, developed a best design with a perfect movement prediction and lag compensation it will solve lots of issues with server latency

#

replicate custom data as less as you can

cedar tangle
#

Yeah but I have seen player teleport and do strange things in games built with UE, it has to be down to the code of that game.

nocturne quail
#

like if a client is not in range, we don't want to replicate stuff to them for no reason and replicate to them when they comes in range

nocturne quail
cedar tangle
nocturne quail
#

client can't dictate server, server dictate client this is what unreal network model is popular for

cedar tangle
#

Any way, that one is the one I want to experiment with.
I think what I have seen with the teleport is just bad code.

nocturne quail
#

if client change something in their local memory it can't effect the server copy memory running somewhere else

cedar tangle
#

You nailed it with the distance.
What happens is that the sever receives the call to instance and throw a grenade on a delayed response.
Without knowing its spawn origin or simulating the landing position. it could register and apply damage.
because of the packet upstream delay the server has no idea about the manipulated data by the client.

nocturne quail
#

server is not interested in the client data, server has its own copy of the client which will take damage and it will replicate to the local instance which will get killed

cedar tangle
#

It is not that simple

nocturne quail
#

if the local client changed and tricked that data, server will know that client should be killed , why its moving around, kick him

nocturne quail
#

nobody can manipulate that copy

#

the only thing impossible to detect or very hard is aim bot

cedar tangle
#

can even compile the code out.

nocturne quail
#

what?

cedar tangle
#

with a dedicated build the client can have the server logic compiled out , I know as I have done it.
but the issue I can see is the RPC call is fired by the client, and because of that it is actually
possible to trick the server if one has made a mistake in the servers logic.

nocturne quail
cedar tangle
#

um sorry for the wall of text .. I best ff now.

nocturne quail
#

no issues, you increased my knowledge as well discussing this stuff on multiplayer

twin cliff
#

does anyone know if there's a nice way to run multiple dedicated servers locally when running the PIE stuff in-editor? i'm setting up a system where the player gets moved from one server to another as they change instances and was looking for a way to configure this in the editor or elsewhere

thin stratus
#

Just need to reference the editor exe and u project file and plug -server and -log behind it

opaque forge
#

Sorry to revive an old thread, but how & when does Lobby Kit facilitate connecting clients? You said clients need to establish their player count before connection, so how does that work with PIE?

thin stratus
#

Cause I posted pictures of everything.

#

So I assume you don't mean the info I already shared

quasi tide
#

Woah woah woah - why ask that? Instead ask if he would share Salty Panda's Lobby Kit 🙏

thin stratus
#

It's Blueprints. Why would you want that :D

quasi tide
#

Because it is less work for me. Work is bad.

thin stratus
#

You can ask again once I turned it into a plugin

quasi tide
#

UE6 will release before then 😭

thin stratus
#

Probably

#

I do need to brush up the lobby kit eventually. But the marketplace/fab is too saturated anyway to invest time into it

opaque forge
#

I'm just confused about the order of operations

thin stratus
opaque forge
#

So this is before a connection is even attempted

#

Got it

thin stratus
#

I don't think you can add after connecting, but not sure.
The whole thing is meant to be LOCAL players being also registered as normal player upon login/connection.

#

If you are past that point, it would need to magically run through that when the player locally adds a client, which feels like a bad idea (could add 1000 players for fun and see things crash).

#

And the server adding them would not result in the actual player knowing about them.

#

Especially if it#s a listenserver, it would just be a second player on their end.

#

So just based on that I doubt you can spawn them after connecting

opaque forge
#

Multiple local player controllers persist across server connections and/or listen server restarts, right?

thin stratus
#

But there should be ULocalPlayer instances that should survive I guess.

silver totem
#

What kind of clock is usually used for client prediction?

#

When you need to predict future state to compensate for one way delay

cedar tangle
# nocturne quail no issues, you increased my knowledge as well discussing this stuff on multiplay...

I am going to build out allot of my ideas that will be open to test.
I am looking at creating some kind of network logging layer that can be seen side by side the running game.
Also I did not notice the possessing the player with a temporary AI after the player has been killed.
That is interesting. And also yes the mouse-look is an aim-bot magnet as it client side. I have had ideas of other types of
combat systems that are server only to remove the aim-bot effectiveness.
But I haven't built enough experiments of the network code yet to really get a
feel for what is cost effective and not.

kindred widget
#

Why do you possess a dead pawn with an AI controller? And don't do server auth for player's aiming. There's a reason it's client auth and things like EAC exist.

cedar tangle
#

Sorry last message for a while promise. The other things I was looking at was the line of site server to client stream.
So a client would only know of data that would expose valuable data to a 3rd part tool, if the client can see the other player/players/items.
I will experiment a lot with this concept over time.

cedar tangle
kindred widget
#

I'm not sure what that was a response to?

cedar tangle
# kindred widget I'm not sure what that was a response to?

From data prospective. Say the player is destroyed and re-instanced then any data that the sever may
need to reflect on after the event (death) has passed. If I find a situation where I need to do it I will let you know.
Is many ways to go about dealing with a problem and is always a good idea to experiment with a few.

#

Or could turn them into zombies ha.

kindred widget
#

But why an AI controller? The pawn is "dead". Unpossess it, let it visually die off or do whatever it needs to do post death. Then later make a new one for the respawn. What does the AI controller bring?

prisma snow
cedar tangle
cedar tangle
cedar tangle
prisma snow
cedar tangle
#

@prisma snow this is about as much the client can do in my case: 'CanIDoThisControllerOfEverything()', notice no arguments.
hook that up to an aim-bot.

prisma snow
pale yew
pale yew
cedar tangle
#

I come on here as have a question. Development related:
I moved over to visual studio code from visual studio, and I created some blank class files in IDE.
Do I have to re generate the visual studio project files?

kindred widget
# cedar tangle You can validate/check for the aim-bot activity on the server. But not wasting t...

You can't really check that on the server though. Do remember that you have to send all of that data to be verified. And given that most non critical input is not reliable, you'd be doing this passing of data outside of the look events themselves by saving them somewhere on the client and passing them through a reliable RPC later. This can already be tampered with. But even if we pretend it cannot, you've now added an assload of data just for one person's aiming code. Multiplied by intended player count.

And you have to rely on the client passing that data to the server. You cannot rely on the Server's version of what it thinks client is doing because client needs to be able to look around without the contraints of the server. Even if there was zero network lag and you have a client running 120fps and a server running 30, it'll feel bad for your client. Add in latency and unreliability of packets and kaboom. Server does not have an accurate representation of what the client is doing due to so many things being out of sync that it's impossible to manage.

So in the end, this is why local to client anti cheat software like BattleEye and Easy Anti Cheat exist. Cause you just can't do this kind of system on server auth.

prisma snow
# cedar tangle Never trust the client.

There's little point to join a community help server if you're going to ignore all advice. We already exposed that what you are doing makes no sense and is unreasonable, Authaer explained it really well. You ultimately decide what to do, and it's not our responsibility to convince you.

cedar tangle
#

@kindred widget The mouse look can stay on the client. Is how I am treating it.
Because it is open to manipulation, it can not be used as a valid data source for a game mechanic.
Just never trust the clinet it that simple.

#

@kindred widget Also BattleEye and Easy Anti Cheat exist don't trust that, the client will always find a way.

#

@kindred widget the real problem is $$$$$$ and that is what I am experimenting with.

kindred widget
# cedar tangle <@143471961723371520> The mouse look can stay on the client. Is how I am treatin...

It's not that simple, actually. I outlined that above. You have to trust the client at some point. If you server auth everything it's laggy and feels bad for the player and your game will sell like shit because it feels like shit to play. You have to trust the client at some point. Planetside2, Fortnite, CoD, Overwatch, etc etc. literally any FPS/TPS game with competitive gameplay still has client auth look input for this reason.

cedar tangle
#

That is a lot of stuff. Not doing any of that. Very interesting tho.

prisma snow
#

yeah. I think VALVE also had some interesting articles about netcode and prediction

cedar tangle
#

Will be digging into it, thank you for posting.
The player peeks latency is really interesting, I did not know about that.
Is obvious now I think of it.

polar trail
#

I've got a question for all the dedicated server pros in here 🙂 The issue i have is the following: I have set up a dedicated server project which is using OnlineSubsystemSteam. When i build the project with my Unreal Engine Source build, the dedicated server works as expected. It shows up in the steam client's server list, under the internet tab just as well as under the lan tab. Since working with my source build takes ages for everything (compiling / packaging / ...) i also have created a binary build (in some cases also called "installed build") from my source build. When compiling and building the very same dedicated server project with the binary build the server also shows up under the lan tab but no longer under the internet tab. To make this clear again: The project is exactly the same. In source build it works, in binary build it doesn't. I made sure that the binary build also contains the Steamworks SDK files. However there seems to be a difference between what is used by a source build and what is used from a binary build regarding Steam. Can anyone tell me, what i have to change to make the project work from the binary build as well? Maybe something i have to add to the build.cs or my target.cs or the DefaultEngine.ini or ...? I am really going nuts here 😦 What i think can be ruled out are any problems related to firewall settings, since - as stated already - the dedicated server runs fine when it has been built with the source build of the engine. Thx for any help with this issue!

copper grove
nocturne iron
#

I'm building an ARPG in Unreal where players start in a solo game (non-networked) after choosing their character. If a player invites a friend via Steam, I want the game to switch to a listen server and allow the friend to join, without (seemingly) restarting the session.

Is it best practice to only create a session/listen server when the invite is triggered, or should the lobby always be a listen server in the background? Also, any tips on cleanly transitioning from a solo setup to a networked session without making it feel janky for the player?

#

I am leaning towards always listening, but not sure of that is shooting myself in the foot later.

kindred widget
#

AFAIK it always needs to be a listenserver if you don't want to restart the level.

#

There may be ways around that with engine modifications though. 🤷‍♂️

pale yew
quasi tide
#

I'm about to jump into a meeting, will post the code afterwards.

rotund sail
#

Has anyone used playfab or gamelift or other dedicated server backend services? what was your experience with it? would you recommend them?

quasi tide
#
bool UGameplayHelpers::StartListeningForConnectionsInMap(UObject* worldContext, FString levelName)
{
    UWorld* currentWorld = GEngine->GetWorldFromContextObject(worldContext, EGetWorldErrorMode::LogAndReturnNull);
    FURL newUrl = FURL(*levelName);
    return currentWorld->Listen(newUrl);
}

@kindred widget @nocturne iron It's actually pretty simple. I have it in a BPFL so I can do it in BP. But you pretty much just tell the world to start listening. Obviously add any other safeguards that you need or want, but for my purposes, I don't need those.

nocturne iron
quasi tide
#

You'll have to properly shut it down as well by making sure the net drivers are closed out.

nocturne iron
#

Do you have code for that as well? 👀

quasi tide
#

Nah. I didn't implement it because I didn't need it. Closing the session through the sessions stuff worked well enough for me. I might be doing a hard travel in that case. Haven't really touched this project in like 8-ish months.

nocturne iron
#

Thank you :)

idle lion
#

Hi, I am new to unreal, why I don't have "ServerTravel" blueprint?

midnight herald
#

All it does is call UWorld::ServerTravel So if you have a cpp project you can create identical functionality by creating a Blueprint Library function, getting the world, and calling World->ServerTravel

kindred widget
copper grove
copper grove
#

yeah commenting out all the bindings fixed it

pale yew
ashen plume
#

@grand kestrel sorry to bug you again, and of course about rotation smoothing, your example where you said that the listen server is forced to be linear didnt make sense when i look back

grand kestrel
#

It gets forced to exponential

ashen plume
# grand kestrel Ya I corrected that after I said it

ah nw, other than that you mentioned the lack of extrapolation for meshes, i was wondering why the built in interpolation itself wasnt working for listen server, even though everything should point to it working,

#

MoveAutonomous, and TickComponent look like they both do this

grand kestrel
#

It has smoothing it doesn't have extrapolation

#

So the smoothing sucks

ashen plume
#

and the view from clients does have extrapolation?

#

just not the view of the listen server?

grand kestrel
#

Might want to re-read this

#

in the case where IsNetMode(NM_ListenServer) is true

ashen plume
#

even with the lack of extrapolation there is actual smoothing still happening somewhat at least, and not none

grand kestrel
#

Yeah but the result is poor

#

Just have to wait until epic decide to add listen servers for Fornite PES_SadShrug

ashen plume
#

my issue was that there is no smoothing whatsoever at all on the rotation

#

using epic's "best practice" of setting use control rotation yaw to control rotation with input

#

cranked up the settings just to ensure they actually work, and i took a clip that the movement smoothing works and not rotation

#

can see that the mesh does at least have any smoothing on location, just not rotation, that was my original question

#

other devs have got this working, but for me it doesnt work "out-of-the-box" so theres clearly some secret

fallen fossil
#

im working with ue4 sdk, and for some reason, variable won't replicate, even tho RPC works and its owned by local player 🙄

#

and actor replicaiton settings

#

it does not replicate from local to server

#
[A_SpawnerForEachPlayer_C_0] Client 1: Changed mode to: Destroy
[A_SpawnerForEachPlayer_C_0] Server: Mode is is not destroy
[A_SpawnerForEachPlayer_C_0] Server: mode is: FreeFlight
[A_SpawnerForEachPlayer_C_0] Server: Is Owner same as PC: false
[A_SpawnerForEachPlayer_C_0] Client 1: mode is: Destroy
[A_SpawnerForEachPlayer_C_0] Client 1: Is Owner same as PC: true
[A_SpawnerForEachPlayer_C_0] Client 1: mode is: Destroy
[A_SpawnerForEachPlayer_C_0] Client 1: Is Owner same as PC: true
[A_SpawnerForEachPlayer_C_0] Server: Mode is is not destroy
[A_SpawnerForEachPlayer_C_0] Server: mode is: FreeFlight
lament flax
kindred widget
lament flax
#

always from server to clients

proper pagoda
#

Replicated variables won't change from Local to Server - Only the server can set variables; Clients are allowed to send "Server" RPCs

fallen fossil
#

lol i have to be explicit 😭

#

is there some unrela function for variable rpc? or I have to create another event

lament flax
#

just make a server RPC called on a owning client connection

fallen fossil
#

ye, but its just teadious to create for every variable

proper pagoda
#

Usually you want to be quite explicit with which variables the client is allowed to modify

lament flax
#

yeah, its kinda rare to let the client that much power

#

easy to cheat through

fallen fossil
#

at this point, I don't replication(for variable) if im using rpc 🤔 im only sending it up

proper pagoda
#

You set it to replicate -> Send RPC to the server to change the variable -> Server then replicates it to everyone

fallen fossil
#

nah, its only usable by owner, but server has to check stuff

#

yup, it works, thanks guys

proper pagoda
#

so you don't need the other clients to know about it? You could set the replication condition to Owner Only

fallen fossil
#

yes, but I don't replicate anything from server to client 🤔

proper pagoda
#

ahhh my b

fallen fossil
#

no worries 😄

snow kelp
#

What is the best advice/resource when it comes to creating a 5v5 third person shooter with a completely self hosted dedicated server(s) ( with or without use of EOS/Steam) ?

cerulean barn
#

can someone explain to me why this doesn't remove the widget from the clients screen? ive tried doing it directly in the button (doesn't work either)

#

also why does this create the widget twice on the same client?

#

ive been stuck for two days, any help appreciated

dark edge
#

just have bIsDead as a bool

#

set it on server, and in the repnotify, show the UI if locally controlled

#

pretty much all of your code here can be triggered by the state of bIsDead, right?

#

You should default to using repnotify as your approach to damn near anything unless there's an obvious reason to use RPCs for the purpose

#

In your case, just covering the UI stuff, can be like:

OnRep_bIsDead -> if LocallyControlled -> branch on bIsDead -> true -> create DeathHud and add to viewport -> set DeathHudRef
-> false -> is DeathHudRef valid? -> true -> remove it from viewport

#

that's it, now just set bIsDead true and false on server and all that will take place

cerulean barn
#

also still printing creating widget twice on the same client

#

fixed with this check... is this efficient though?

dark edge
#

No rpcs involved at all

#

Onrep fires EVERYWHERE when the variable replicates

cerulean barn
#

not the client?

cerulean barn
#

or on all clients

cerulean barn
#

everything else works tho

cerulean barn
#

why is the onrepIsAlive not being ran on all clients when respawning?

#

when pressing the respawn button and changing isAlive on the player, it only runs the onRepNotify on that client....

#

how come?

quasi tide
#

Because you're only changing it locally.

#

The server has to change it so it can replicate down to all clients.

#

So you have to to a server RPC to request that it gets changed.

cerulean barn
#

@quasi tide

cerulean barn
quasi tide
cerulean barn
#

does onrep not fire everywhere>

quasi tide
#

Not when you only change it on the local client

#

Reread what I said and follow it exactly

cerulean barn
#

whats the point of replicating with notify if its not gonna run on the server/ elsewhere

#

im confused

sinful tree
# cerulean barn what happened to this

This still happens. Replication only happens from Server to Clients. Clients setting values for replicated properties only happens on that client.
If you want to communicate to the server that the client clicked something you need to send an RPC.

quasi tide
#

You are not replicating anything though

#

You are only changing the variable locally

cerulean barn
#

imchanging a replicated variable..

quasi tide
#

LOCALLY

sinful tree
#

On a client.

quasi tide
#

You are only changing it LOCALLY

#

The server is responsible for doing any replication

cerulean barn
#

so setting it here is not locally?

quasi tide
#

The client can only talk to the server through RPCs

cerulean barn
#

so how come when i set it there it runs everywhere

sinful tree
#

Because you're probably setting the health value on the server, which then triggers the onrep which then is trigger the server to set it.

cerulean barn
#

yes im setting the health on the server

#

and im also setting isalive on the server as u can see there

sinful tree
#

This is also kind of bad form - you shouldn't be using OnReps to set replicated values anyway. The server is the only place that replicated properties should be getting set.

#

OnReps can trigger everywhere, if the server is the one that sets the value in the first place.

cerulean barn
#

look how i had it set up earlier

#

this other dude told me to convert to on rep notifys

sinful tree
#

Right, which you've done, but if you need to communicate something to the server, you must send an RPC to the server and have it set the replicated properties.

cerulean barn
#

"OnReps can trigger everywhere, if the server is the one that sets the value in the first place.
"

#

didnt know this specifically

#

so i should just make a server rpc set isAlive on respawn button

cerulean barn
#

or with on reps

quasi tide
#

Not to be rude - but I don't have the time to go through and read all of your posts for the situation.

tidal cloak
#

I'm running into a strange issue using the OnlineSubsystemNull with Unreal Engine 5.4.

Here's the setup:

  • I have two levels: Lobby and Game.
  • The Lobby level is assigned a Lobby_GameMode (derived from GameMode).
  • The Game level is assigned a Game_GameMode (also derived from GameMode).

Issue:
Player 1 creates a session and travels successfully from the Lobby level to the Game level. However, when other players try to find the session, nothing shows up.

What’s strange:
If I change the Game level to use a GameMode derived from GameModeBase instead (while keeping the Lobby's GameMode unchanged), the session becomes discoverable by other players.

I've tried various combinations of GameModes, but it seems the key condition is that the Game level must use a GameMode class derived from GameModeBase, not GameMode.

Why is this happening? I'm not sure.

dark edge
# cerulean barn does onrep not fire everywhere>

@cerulean barnThis setup will work.

On the SERVER set bIsDead when the thing dies, whatever that means. Runs out of hp, whatever
When it replicates out, the OnRep will run on all machines.
In the Onrep function, do what you want to do that depends on bIsDead (show UI, ragdoll, whatever)
That's it

#

no rpcs involved, just set bIsDead from the server and you're done, the thing is dead, whatever that means in your context.

#

Literally this simple

upbeat basin
tidal cloak
#

yeah, i am using matching gamemode and gamestate

upbeat basin
#

That's strange

#

But key condition is that the Game level must use a GameMode class derived from GameModeBase, not GameMode is also wrong

tidal cloak
#

it is wrong, but it works....anyways here's my setup , if it helps

Edit : BP_Gamestate is derived from gamestate

crisp shard
#

What functions would I want to override to fully customize the spawning of my character?

It does like two spawns, 1 is quite quick and it happens during the actual character class loading, then the actual character is spawned. The first doesn’t actually get spawned but it seems to just send me to a random spot then go to the correct location I set or was at previously

#

Assuming the functions I’m looking for are in game mode ^

old knot
#

hi, i'm implementing ping system for teammates, so i spawned a ping actor from player controller via server RPC, then checking for all player controllers to determine if a teammate exist, then set ping actor visible via client RPC, now the problem is that actor spawned entire the game , Although teammates are detected correctly, ping actor is visible for everyone, what shoud i do?

exotic wasp
#

if you still want to do the client rpc to change visibility, you'll still have to make the actor only relevant to players on the same team

merry wyvern
#

For a multiplayer game for a stamina system would you guys use a time line or actual math mechanics, honestly timeline seems like the better opetion for optimization.

chrome mason
#

Hi, I'm running into something strange with mesh replication and was wondering if anyone here knew the root cause. Getting the location of a socket on the player 2 (client) mesh from the server returns the wrong value. However, it only provided the wrong value when player 2 was out of view of player 1 (server)(see video). It seems that the player 2 animation is "stuck" on the server when out of frame. Any insight would be appreciated.

atomic nest
#

My ProjectileMovement uses HomingTarget to track targets. On the client side, the projectile's flight is very shaky due to acceleration. How to improve the stuttering sensation on the client? Does anyone know about NPP? I tried for a long time but it didn't work

thin stratus
#

If not, then that's at least part of the requirements to make it smoother.

thin stratus
#

Drop Down Setting. Change it to always tick pose and update bones or so.

chrome mason
#

we were really banging our head against the wall on that one. at first we thought it was some replication issue but it didnt make sense because it was only when the client was out of view and not rendered.

cerulean barn
#

anyone have tips for an inventory system and replicating things? are the items replicated or just the shots itself? or what the character is holding in hand

#

assign each character an inventory class, and have an array or hashmap of items?

#

im assuming?

thin stratus
#

With C++, peeps usually use FastArrays for Inventories.

#

With replicated UObjects and such

#

In Blueprints you are kinda bound to using the shittiest setup that somewhat still works :D

rotund sail
#

Do state trees support multiplayer? I was having trouble calling an RPC from a state tree task

kindred widget
#

Calling an RPC on what?

#

And what kind of RPC?

#

The short answer is "No." But you can still call an RPC on something else from something that isn't networked. EG a widget is not networked, but a button click can still call an RPC on an actor.

rotund sail
#

Well the task is ai behaviour running on the server afaik

#

Im calling it from a State Tree Task blueprint

#

a multicast rpc, since its presumbley on the server (as the task logs print to there)

kindred widget
#

Yeah that won't work. You'd need to call that on the Pawn or whatever this state tree is affecting for instance.

rotund sail
#

Ah

kindred widget
#

The state tree doesn't exist on the clients. As you noted it's running on the server. So there's nothing on the other machines to receive it.

rotund sail
#

that makes sense

#

interesting

#

Luckily its pretty easy to call stuff on the character bp lol

wind magnet
#

is there any way to make 2 players move around in the same widget, like in a fighting game selector?

#

im trying to find a tutorial for it but i cant find it anywhere or they dont give me the proper answer

dark edge
#

Don't think of it as two players moving around in a widget. Think of it as two players changing some data, and that widget displays that data

#

You're talking about something like super smash Brothers, the widget just has to know which element each player has highlighted, whatever that means.

wind magnet
#

more like DBZ Fighter Z cause im not using the mouse and keboard for my game

dark edge
#

Anyways, yeah it's totally doable.

wind magnet
#

okay okay ty ty! ^^

kindred widget
cerulean barn
kindred widget
#

At least an identifier to the type. Usually an FName to a datatable row, or a pointer to a data asset.

Plus anything else your item needs to function. Stack size, Durability, etc. Anything that isn't static data which you should be pulling from the before mentioned datatable or datatasset.

cerulean barn
#

so the actual actor is one of the components of the struct im assuming

#

quantity, name etc

kindred widget
#

Actor?

cerulean barn
#

object*

#

like the object class itself

#

like a gun etc

kindred widget
#

Not quite. I mean you could keep a pointer to the runtime object maybe. But I wouldn't make the inventory care about that.

cerulean barn
#

an array of structs, and inside the struct is the actual object right?

dark edge
#

Could just be an int ItemID and int Amount like Minecraft

kindred widget
#

It's kind of a disconnected concept that a lot of tutorials confuse. The inventory itself is nothing but data. So is your equipped gear.

Lets say you have a gun for example. In your inventory this is just a struct of data. Ammo count, durability, etc etc. Anything you'd need to create what you'd need if you equipped it.

When you equip it, you just need to place the data into a separate container of equipped items, maybe on the same or separate component meant specially for equipped items.

This is where your inventory handling ends.

When equipped a child class of your basic inventory/equipment should handle spawning said actors, or applying attributes through whatever ability system you use, or granting abilities like shooting and throwing grenades, etc.

#

This same thing applies with a hotbar system like some games have where you don't "equip" the weapon but select it on the hotbar. It should still be the same idea. Simple data and when "Selected", function identical to if it were equipped. You get to keep clean code, not muddle your data handling with gameplay systems, etc.

cerulean barn
#

i dont really understand what ur saying

#

shouldnt an inventory just be an array of objects

#

which you want in ur inventory

#

or better yet a hashmap

#

"name" : WeaponClass

dark edge
#

it can be whatever you want

kindred widget
#

So you make a game. You have 10 people running around. They're looting up a storm, each person has 250 things picked up. Your way has 2500 things spawned for no reason just to exist in an inventory.

dark edge
#

An inventory being an array of class refs is fine

#

might get a little silly if you have a ton of them and they're hard refs as you'd have to load all the data but it'd "work"

cerulean barn
#

side note is casting ur character class in a widget poor practice? i feel like im wasting so much memory

kindred widget
#

Sure, but now we're back to an array of structs, because those class refs need extra data to function.

dark edge
#

all casting does is make the thing be loaded. Your player's character is probably already loaded I'd think, since you are playing the game.

cerulean barn
#

like this for example

dark edge
kindred widget
#

Note his key word there. "make the thing be loaded". It doesn't load or waste memory in the slightest.

dark edge
#

Casting could cause problems when you have random casts to SPECIFIC classes that aren't necessarily common.
Say your widget had some cast to your final boss and all his minions, they would have to be loaded even at the beginning of the game. But if it's just a cast to YourBaseCharacterType, those are gonna be around anyway so it's fine.

cerulean barn
#

okay so whats common practice for an inventory system

#

an array of structs?

kindred widget
#

It depends™️

dark edge
#

I like structs but some people go gung ho on the object method

#

What does your inventory system have to support? Stacking? Prices? atomic trades? Complex logic like Factorio?

#

Or is it just sufficient to store classes and instantiate them when needed (equipping, dropping)

cerulean barn
#

for now i just have two weapons

#

no quantity

dark edge
#

Start with array of BaseWeaponClass

cerulean barn
#

primary and secondary

#

because my hotbar system is pretty weird rn

#

i just have 2 slots

#

primary and secondary

#

and when i switch i just switch the selected slot

#

they aren't really connected

#

okay so attach an array of base weapon class to each character?

dark edge
#

but more generically yes an array of class refs

cerulean barn
#

i already have it working for the 2 slots

#

im trying to make a better system though

#

aren't arrays slow though

dark edge
#

no

#

they are the fastest thing

#

lol

#

why would they be slow

cerulean barn
#

if ur dropping the first item in the array you have to shift it all over

dark edge
#

so

cerulean barn
#

so thats slow lol

dark edge
#

how many items are you talking here

cerulean barn
#

idk

#

lol

dark edge
#

it's probably faster than the hash part of a map lookup

#

up to maybe 100 items or more

cerulean barn
#

deletion in a hash is o(1)

dark edge
#

that's how it SCALES, not how it behaves down at the small end where things are happening

cerulean barn
#

is it easier to code replication in blueprints or in c++

#

replication stuff like this *

dark edge
#

Just do it in BP first

#

then move to C++ once you're comfy or can't do the thing you're trying to do

cerulean barn
#

because im new to all of this and multiple people have told me to start with bp's even though i feel like i would be better off just coding

#

some of this stuff is pretty confusing already

dark edge
#

Have you written a single line of Unreal C++?

cerulean barn
#

nope

#

0

dark edge
#

ok then you answered the question for yourself lol

cerulean barn
#

ive coded c++ though

dark edge
#

When you want to break into the C++ side of it start out with a BPFunctionLibrary and structs and stuff.

cerulean barn
#

okay so quick question

#

so i have an array of objects right

#

for the weapons or whatever i add

dark edge
#

array of classes yes

cerulean barn
#

ye

#

would the functionality of attaching the gun to the hand and third person mesh for others to see be in that weapon class or the inventory?

dark edge
#

spawn actor from class -> attach

#

probably

cerulean barn
#

like scrolling through a hotbar

dark edge
#

I mean there's the simple easy way and then on the other extreme there's the crazy scalable way that takes like 5 files to define a weapon

cerulean barn
#

id rather do the simple way

#

would i have a variable like current slot in the character class and whichever slot it is, it spawns that class then attaches?

dark edge
#

yeah

#

Is there a storage inventory or is it just hotbar + what you have equipped currently?

#

what is the item state of a character, just:
TArray<ItemBaseClass> Hotbar
int CurrentHotbarSlot
ItemBase* EquippedItem
?

#

I take it you don't want ping lag between pressing a hotbar button and the item appearing in your hands correct?

cerulean barn
#

i haven't actually set it up yet

#

im just planning

#

my current system just has an equipped weapon + primary + secondary

#

and when u switch it changes the equipped

dark edge
#

how many entries is a hotbar?

cerulean barn
#

well rn i just have 2 items

#

but i wanna test it with any item

dark edge
#

I mean how many will it be

cerulean barn
#

like a cube for example

#

lets just say 5

#

but i want a backpack / inventory system down the line for sure

dark edge
#

It's probably easiest to have the hotbar items exist as hidden actors, with the active one unhidden

#

it's a lot easier to predictivly unhide an actor than it is to predictively spawn it

cerulean barn
#

and just toggle the animations when setting them visible?

#

like holding a pistol vs rifle animation

dark edge
#

so backpack = array of classes
hotbar = array of objects (adding to hotbar spawns and hides)
Active entry on hotbar is unhidden and set as CurrentItem, it's the thing your inputs go to

#

the item can define their animations

cerulean barn
#

u really dont think i should try coding instead?

dark edge
#

Get it working in BP first, it'd take me 10 minutes

#

Then once it's working start looking at moving it to C++ side of things

dark edge
#

you'll need a c++ base item, C++ base character, etc.

#

I'd probably make an inventorycomponent which represents stored items, you could reuse it for chests and such

cerulean barn
#

but i still get confused with the blueprint side of things, so on event begin play in the character i would initilize an empty array of classes and an empty array of objects, then on each pickup append to hotbar, and once hotbar is full, add to backpack im guessing

cerulean barn
#

whats like an organized way to do it

#

making a inventory class?

dark edge
#

I'd make an inventorycomponent for the backpack / chests etc but just get the thing to work first

#

your cart is very far away from your horse

cerulean barn
#

yeah i should prob just get started and take each problem at a time

#

so since they are not specific classes or specific objects

#

would i just have it a straight up array of classes and objects?

#

thanks for all ur help btw

dark edge
#

You could either make all items have a common base class or just use Actor as your base and have all items have a common interface or component on them

cerulean barn
#

u dont think i should spawn in everything as an object? or just the hotbar items

dark edge
#

depends on your design

#

The only reason you'd want stuff on hotbar to be spawned is so you can instantly switch without waiting on spawning from the server

cerulean barn
#

is that typically how its done for hotbar?

dark edge
#

it's a lot easier to predictively switch your active item than it is to predictively spawn one

cerulean barn
#

right

dark edge
#

there is no typically

#

it all depends on if you're making WoW or Fortnite or Rust

#

and if you have $100M or $0 to work with

cerulean barn
#

my game end goal is gonna be like finals but different game mode

#

but like similar style fps shooter

dark edge
#

yeah you probably don't want ping lag on swapping weaps

cerulean barn
#

maybe just spawn in the weapons only in the hotbar

#

like weapons or lethals

#

and everything else is stored as a class

#

like grenades etc

dark edge
#

just go do the thing and your plan will 100% change as you do it

#

no battle plan survives contact with the enemy

cerulean barn
#

lol

#

yeah ill try and set that up

#

and obviously i spawn everything on the server

#

not the client

#

spawn on the server -> attach on the client

cerulean barn
#

@dark edge (sorry for tag) so everytime im picking up a new object i have to loop through my whole inventory to check if it's already in there? wouldnt a hash map be better because i can just see if the value already exists for the key?

#

this doesn't check if the item exists or not

reef bison
#

it depends on the type of inventory you want

#

having a hashmap as an inventory implies that you can't have "inventory slots" and each item type can only be added once

#

(besides its own properties like stack count)

dark edge
#

can you have 2 of the same weapon?

#

or addunique

#

idk if you can have duplicates though, it's your design

crisp shard
#

How do you control how a character spawns ? I get default behavior I’d like to override

sinful tree
crisp shard
#

Yea I noticed a few but not exactly sure which of them would be the one to use, or if I should be overriding all of them to a degree.

The ones that seem right are:

  • ChoosePlayerStart
  • FindPlayerStart (this one seems semi irrelevant to me but might still be needed for some cases)*
  • HandleStartingNewPlayer

My instinct is to ignore findplayerstart , and override the other two. Main unwanted behavior is, before the character will spawn in to the selected location, it will seemingly spawn into and show what appears to be the center of the map/world and then within a couple of seconds or less will go to the correct spot.

fossil spoke
#

Main unwanted behavior is, before the character will spawn in to the selected location, it will seemingly spawn into and show what appears to be the center of the map/world and then within a couple of seconds or less will go to the correct spot. This is because the PlayerController is the View when there is no Pawn that has a Camera Component possessed by the PC.

#

Generally speaking you typically end up covering this as part of the Loading Screen.

#

We have a 3 second grace period after the level loads before the loading screen comes down.

#

This is helpful for covering up things like texture streaming and other unwanted artifacts.

crisp shard
#

That makes sense. I have a loading screen and it still bleeds a small second of that into view but a small grace period like you mentioned would probably fix that.

The loading screen takes up majority of loading time except the final second or two , I could manually stop the loading screen later on when character is fully ready but I’m curious to know which of those functions are firing to cause that

But tbh, a 3 sec delay would probably solve it

fossil spoke
#

When the PC is spawned, its spawned at world origin. For a few frames there is no Pawn, if there is no Pawn there is no Camera. Therefore the PlayerController is the default view when there is no Camera.

#

So for a few frames, the PC is providing the view to the renderer.

#

There is nothing you can do to chaange this

#

The only thing you can do is cover it up.

crisp shard
fossil spoke
#

If that works for you, sure.

#

In our case we have a Spawn Screen, so the PC gets a Spectator Pawn until the user selects who to spawn as.

quasi tide
#

Could do a server rpc from each client to let the server know they're ready and then when the server gets that, it tells all clients to remove the loading screen.

#

Really depends on what you want your players to experience.

fossil spoke
#

Yeah it all depends on what approach is necessary for your game.

crisp shard
#

Nice , I’m glad to know why that was happening in the first place. Thanks for the replies

crisp shard
gusty sentinel
#

Is it possible to have replicate this full chian? ActorComponent->UObject->Struct->UObject
Without holding a replicable reference to the UObject somewhere further up?

and have that secondary UObject replicate? Everything else is succesfully replicating
I'm having some tricky issues where it's not 😐

exotic wasp
#

the actor component will have to register both UObjects as subobjects

#

you could probably get away with an interface on the first uobject that gets all UObjects under it

#

or just get them manually

#

does it make sense for the struct's uobject to be replicated through the component? is it owned by it?

#

if its something like a weakptr and its owned and registered elsewhere, you dont need to register that one as a subobject

gusty sentinel
#

its basically
InventoryManager(ActorComponent) -> Inventory(UObject) -> FastArraySerializer -> ItemStruct(FastArrayItem)(Struct) -> ItemInstance (UObject)
But the ItemInstance can hold another Nested Inventory(UObject) and have non restricted nesting depth.

#

In this case, other than the nesting. then yes the component ultimately is the owner of all the UObjects in it's chain at a given time. Unless it moves to another root ActorComponent/Inventory

I know the alternative method is to have some kind of independent Manager of all the uobjects and just hold a reference but then that makes network relevancy and some other things more difficult.

I suppose I have to register the 'jump' from uobject->Struct->uobject at the top level?

exotic wasp
#

i dont see why Inventory having a reference to ItemInstance would be an issue

#

it probably makes sense for a manager to be able to query all attached inventories and get all items anyway

gusty sentinel
#

thats fair

exotic wasp
#

as long as ItemInstance doesnt know of manager

#

one way dependency

gusty sentinel
#

I was just hoping to not have a secondary array at a higher level and figure out a way entirely thru functions or other tricks

exotic wasp
#

well

#

you could have a delegate in your ItemStruct or Inventory that gets raised when you add or remove an item that then registers/unregisters the ItemInstance UObject

#

you dont have to hold an array of ItemInstances in InventoryManager as long as you have some other way of tracking owned objects

gusty sentinel
#

hmm.

exotic wasp
#

also nothing wrong IMO with an array of TWeakPtr<UObject> in InventoryManager

gusty sentinel
#

A challenge I see with that, is if I move an item into another separate inventory/manager like a top level item, I'd need to walk every chain to update all the potential nested things in that item.
but that's not too big I suppose

exotic wasp
#

when i rolled an inventory system using uobjects, i made a base actor component that manages replicated sub objects

exotic wasp
gusty sentinel
#

yeah

exotic wasp
#

then you should know what item is being moved

#

and can unregister in old and register in new

gusty sentinel
#

oh for sure, its entirely doable.

#
bool UMyInventoryComponent::ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags){
    bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
    if (Inventory){ bWroteSomething |= Channel->ReplicateSubobject(Inventory, *Bunch, *RepFlags); }
    return bWroteSomething;
}

I'd just need to expand this a bit I suppose to go down into the nested items of the inventory

exotic wasp
#

alternatively, make Inventories an ActorComponent

gusty sentinel
#

A backpack holding a gun, holding a handguard holding an adapter holding a grip holding a laser.
I don't want each level of 'inventory' to be an actorcomponent. otherwise it'll starts to feel messy like I suddenly have many dozens of actor components. I'd rather avoid that.

exotic wasp
#

understandable

exotic wasp
#

it is much easier now

gusty sentinel
#

oh?

exotic wasp
#

you just Add and Remove them as replicated, basically

#

always has to be routed through an Actor

gusty sentinel
#

ah so I can just do the

Inventory = NewObject<UMyInventory>(this, TEXT("Inventory"), RF_Transient);
AddReplicatedSubObject(Inventory);

hmm

exotic wasp
#

something like that, yeah

gusty sentinel
#

ah looks like I need to do this anyway to support iris, other approach doesn't support iris

exotic wasp
#

oh you're using iris?

gusty sentinel
#

not yet, but id like to eventually

gusty sentinel
gaunt crown
#

Quick Q regarding Replication and Net Update Frequency for certain actors.

Let's say for a Chair, you'd interact with it rarely but requires replication for multiplayer too. If I were to set the Net Update Frequency to 4 means every 0.25sec it will automatically update all clients within the Net radius. But I still feel even updating "AUTOMATICALLY" is overkill for just a chair sit action. Wouldn't you just disable automatic net updates for this by setting the Net Update Frequency to 0 to stop all automatic net updates, and just call Force Net Update on the chair when actions are made by the player at that time? Because other than that, why update it?

Just looking for best practices with certain use cases. Cheers guys.

prisma snow
gaunt crown
pseudo wagon
gaunt crown
#

Wait so it handles all that for me?

#

So when I do the execution of a replicated event once, it will go dormant on it's own basically right away when it realises nothing is updating or?

pseudo wagon
# gaunt crown So when I do the execution of a replicated event once, it will go dormant on it'...

More information here: https://dev.epicgames.com/documentation/en-us/unreal-engine/actor-network-dormancy-in-unreal-engine

Basically you set your actor to DORM_DormantAll, that will stop actor from update.
When you need to replicate some variable call FlushNetDormancy

Epic Games Developer

Optimize your multiplayer game by effectively using dormancy in Unreal Engine.

gaunt crown
#

All I am basically doing is, is running an Owning Client event on a chair actor to enable and disable input for when getting off the chair. The rest is handled through Server anyway. So really only one replicated call.

#

Thanks!

gaunt crown
pseudo wagon
chrome bay
gaunt crown
#

How would I do that exactly?

Because upon my Server called Interaction Event executes. I do all the logic for setting the player to the chair and disabling movement etc, and then set owner to be able to just do key inputs on the Chair to allow exiting the chair.

But I need to do the Owning Client call to set Input Enabled after the owner has been set don't I?

@chrome bay

chrome bay
#

Changing the owner and calling a client RPC at the same time is probably going to fail periodically.

#

psuedo-code here

void AChair::OnRep_Owner()
{
    Super::OnRep_Owner();

    if (LastInputOwner && GetOwner() != LastInputOwner)
    {
        LastInputOwner->RemoveInput();
    }

    LastInputOwner = Cast<APlayerController>(GetOwner());
    if (LastInputOwner)
    {
        LastInputOwner->AddInput();
    }
}```
gaunt crown
#

Im doing this in Blueprint just to let you know 😄

chrome bay
#

RIP

gaunt crown
#

LMAO.

#

Should've prolly stated that originally.

chrome bay
#

Not much you can do then really, but tbh, even the ab ove isn't flawless. If it were me, I'd replicate an "Owned Chair" property on the controller and update input as that populates/depopulates. No need to replicate chairs then.

gaunt crown
#

Yeah, keeping it to just the controller / player instead of separating replication across more actors.

#

Hmmm okay.

#

For the chair inputs though. I'd think putting it on the character itself is best, not controller?

chrome bay
#

either one ye

gaunt crown
#

I just realised though. That then means I'd have to start putting in bits of logic about a chair inside of the character. Which then it starts getting a bit messy. Bit annoying but I might have to anyhow.

sonic obsidian
#

I have a question about the push model ive seen some tutorials and in C++ we obv need to mark the property dirty after a change so we need to do this in BP or is it automatic.

latent heart
#

You don't have to mark things dirty to replicate.

#

It's automatic if it's marked as a uproperty and replicated or repusing.

#

Some things do sometimes need to be marked dirty, but that's generally more a rendering thing, not replication. With standard unreal stuffs anyway.

exotic wasp
#

if you are using push model, you do need to mark it dirty

#

i believe this holds true in BP

#

but if you are using proper set/mutable gets anyway it should be transparent

exotic wasp
gaunt crown
#

How would one design it technically?

#

What bits go where, etc.

exotic wasp
#

you could add some sort of input listener to your character that listens for an input and then forwards that to the chair on the server

#

the listener is ideally generic and the character knows nothing about the chair

gusty slate
#

Hello everyone,
Is it possible to replicate a TMap when it's inside a struct?
Essentially I have a double TMap for each of fetching
TMap<FNameQuestName, TMap <ActionTag, ActionCount>>

#

hmm I've actually remembered that I used a custom NetSerialize for a TMap<TSubclassOf, Struct(int, int)>
Would doing this for both TMaps be better than just turning the data structure into arrays?

```bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
{
    bool Temp;
    int Num = 0;
    if (Ar.IsSaving())
    {
        Num = CapacitiesMap.Num();
        Ar << Num;

        for (auto Itr = CapacitiesMap.CreateIterator(); Itr; ++Itr)
        {
            Ar << Itr.Key();
            Itr.Value().NetSerialize(Ar, Map, Temp);
        }
    }
    else if (Ar.IsLoading())
    {
        Ar << Num;

        for (int i = 0; i < Num; i++)
        {
            TSubclassOf<class ACraftingItemCPP> Key;
            FValuableCapacityEntry Value;

            Ar << Key;
            Value.NetSerialize(Ar, Map, Temp);

            CapacitiesMap.Emplace(Key, Value);
        }
    }

    bOutSuccess = true;
    return true;
}```
gusty slate
#

Actually I probably would be better off using a struct key and int value than this nested maps hell

#

and then just netserialize the one map

exotic wasp
gusty slate
#

I'm changing it into a single TMap instead of nested ones with a struct for a key and I'll just NetSerialize a struct with the TMap inside

cerulean barn
#

question, if i am working on an inventory system and i have an array of classes, when attempting to add another item to the inventory, do i have to loop through my whole inventory to see if the item already exists? doesn't this seem slow?

sinful tree
cerulean barn
#

oh

#

but doesn

#

doesn't it deep down still loop through and check if it exists?

#

or is it constant

sinful tree
#

Pretty sure it does loop, but at least the loop is done for you in C++ which will be faster.

cerulean barn
#

still

#

everytime i add an item it takes O(n) time?

sinful tree
#

And besides which, something as small as an inventory is next to nothing in the grand scheme of things.

exotic wasp
#

if you really want an inventory to be unique and fast, use a set

cerulean barn
#

cant i just use a hashmap

sinful tree
#

Sets don't replicate. Tmaps don't either.

cerulean barn
#

do hashmaps replicate

exotic wasp
#

a set is just a hashmap where the item is the key

cerulean barn
#

not sure about ue5 but generally thats not true

#

ue5 sets maybe

sinful tree
#

You're trying to optimize something that doesn't need optimization, unless you're planning on having inventories that have hundreds of thousands of items, it's going to be negligible on performance.

cerulean barn
#

okay just wanted to make sure

#

thank you

exotic wasp
#

you would encounter issues with replicating that much data well before the iteration itself is the issue

cerulean barn
#

is it an issue to replicate inventories?

sinful tree
#

It can be.

exotic wasp
#

not unless they're massive

cerulean barn
#

okay like 20 items max in my game prob

exotic wasp
#

fast array serialization is great but it's annoying

exotic wasp
spark radish
# cerulean barn is it an issue to replicate inventories?

depends on how you make it and use it. if your inventory stores an array of UObjects, then you'll want to look into the ReplicatedSubObjects system. if you're going to transfer replicated UObjects between inventories, then you have to deal with many more nuances with that system.

#

if you're just replicating a set of ID's in the inventory, then it's pretty simple to deal with replication

gusty slate
#

You should probably make an inventory slot Struct that holds data about each slot and have a replicated TArray as your inventory

#

like InventoryIndex, ItemClass/However you ID Items, Quantity

cerulean barn
mortal blaze
#

Hello,

I'm using Steam Advanced Sessions in my project so that players can invite their friends from Steam. I've set everything up correctly (at least it works).
Now, I need to have the list of players joining the game (for example, 4 players) and have either their unique ID, their name, or something else that would allow them to be distinguished in a list.
My last test, which I thought would be the most interesting, was to connect the "get stored recent player list" node with the "person invited" node of the "event onsessioninviteaccepted" node, but I can't run a test afterwards to verify that the list isn't empty.

I'm open to any tests or ideas on the subject.
(Im novice on unreal)
Thank you.

rotund sail
mortal blaze
rotund sail
#

hmm yeah eh

#

thats probably the problem, it should succeed, but im not sure why its failing. hm

#

you said you have it setup so Im assuming you have the net drivers set and the subsystem set in the defaultengine.ini config

mortal blaze
#

yes on the video à watched some month ago, he told to add it on defaultengine.ini:
[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480

; If using Sessions
; bInitServerOnClient=true

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"

[/Script/Engine.WorldPartitionSettings]
bNewMapsEnableWorldPartition=True

#

The only thing I'm not too sure about is that I put this little piece of text in the defaultengine.ini present in the Projectname\config and I don't know if it was somewhere else that it should have been put.

sullen sail
#

Hello everyone,
I have a basketball game setup using Unreal Engine with two players connected to a dedicated server. The basketball is spawned by the GameMode, so it's owned by the server.

Now, when a player shoots, I need to apply an impulse to the ball. The problem is: in the player character class, I don’t have a reference to the ball since it’s owned and spawned by the server (inside the GameMode).

How can my client-side player character send a request to the server to apply an impulse to the ball?
I’m looking for a clean way to trigger this from the client while keeping server authority and replication intact.

dark edge
#

Input -> Run On Server Event
Run on Server Event -> boop the ball

sullen sail
#

Where should I create this event? In the gamemode class?

#

To boop the ball, I would need the actor reference of the ball in the character. But, since characters don't have access to objects owned by the server

dark edge
#

and yes they do

#

if the server spawns a replicated actor, it'll show up on clients

#

If you're on client and call GetActorOfClass(Basketball) you'll get it if it's a replicated actor and you can refer to it in rpcs

sullen sail
#

I see, so I should be doing the GetActorOfClass(Basketball) node in a Run on Server node?

dark edge
#

Just somehow end up with a reference to The Basketball when both The Basketball and The Pawns exist

#

For now you could do this, it'll work:
Pawn:
Input -> Run on Server Event
Run on Server Event -> get actor of class Basketball -> boop it

sullen sail
#

Question on the performance of this, would it be heavy in the server side to do a get all actors of class node?

dark edge
#

No, and I said get actor of class

#

unless you're gonna have many basketballs around

#

It's not the ideal setup, but don't worry about ideals right now, get the thing to work at all first

sullen sail
#

Okay will try this

cerulean barn
#

does anyone know why this doesn't show the gun when switching on the first person mesh? just the third person mesh.. unless i switch guns twice then it shows

rotund urchin
#

with the character movement component theres this issue where when youre moving and you suddently stop or change direction, your character snaps back a bit to his stopping point

#

how do you prevent this happening?

#

im guessing its some prediction happening