#multiplayer

1 messages · Page 147 of 1

quasi tide
#

Does it exist on the server already?

#

IE - did the server spawn it

thorny saddle
#
    APCSPreBuildActor* SnappedPreBuild = CurrentSnapAssistActor->GetGhostBuildingActor()->GetSnappedPreBuild();
    if (IsValid(SnappedPreBuild))
    {
        if (SnappedPreBuild->CanBuild())
        {
            Server_SpawnFromPreBuild(SnappedPreBuild);
        }
    }
thorny saddle
thorny saddle
quasi tide
#

Is it set to replicate?

thorny saddle
#
APCSPreBuildActor::APCSPreBuildActor()
{
    PrimaryActorTick.bCanEverTick = false;

    bReplicates = true;
}
#

yes

quasi tide
#

If the client is sending a reference to the server and it exists on the server as well, something is wrong in your logic with spawning it

thorny saddle
#

yes

#

xddd

quasi tide
#

If it can't find the reference, then there is something happening in your setup that isn't working how you think.

thorny saddle
#

i spawned it in both client and server

#

so in client i have 2 of them

#

brb

quasi tide
#

What is CurrentSnapAssistActor? Where does that live? What is GhostBuildingActor? Where does that live? What is SnappedPreBuild? Where does that live?

thorny saddle
#

all of them is in client

#

and in client i choose 1 prebuild\

#

that live in both server and client

#

that spawned by server

#

for build

quasi tide
#

So the server has an exact replica of what the client is doing with their ghost actor? It is also existing on the server and updating on the server and all that?

thorny saddle
quasi tide
#

That's why you can't send that reference. Because the server knows nothing about it

thorny saddle
#

server know about prebuild

#

and this prebuilds are spawned by server

#

client do some stuff(server don't know this) and send choosen prebuild refrence

#

for complete build

#

its ok now

#

thanks

quasi tide
#

It all of a sudden works?

thorny saddle
# quasi tide It all of a sudden works?

no my mistake was this

void UPCSPreBuildPComponent::BeginPlay()
{
    Super::BeginPlay();
    if (!GetOwner()->HasAuthority()) return;
    
    const FTransform& ComponentTransform = GetComponentTransform();

    APCSPreBuildActor* NewPreBuild = GetWorld()->SpawnActorDeferred<APCSPreBuildActor>(
        PreBuildClass, ComponentTransform);

    const IPCSBuildingInterface* OwnerInterface = GetOwner<IPCSBuildingInterface>();

    const uint8 Score = OwnerInterface->GetScore() - 1;
    const bool bHaveInfiniteScore = OwnerInterface->GetInfinite();
    const int CollectionID = OwnerInterface->GetCollectionID();
    

    if (NewPreBuild)
    {
        NewPreBuild->SetInitData(Score, bGiveInfinite && bHaveInfiniteScore, GetOwner<APCSMasterBuildingActor>(), CollectionID, LineHintAssistLocation);
        NewPreBuild->FinishSpawning(ComponentTransform);
    }
}
#

if (!GetOwner()->HasAuthority()) return;

#

this line

#

was empty

#

i add this

#

to spawn it just in server

storm zealot
#

hola friends

I have very weird bug:

Client can't walk on spawned actors ONLY IN PACKAGED VERSION

Simple project with network replication and procedural generated dungeon via replicated seed. (Seed generated on server, replicated in game state, map generated on client by seed. Game is listen server, bug not reproducing in any net mode)

During devlopment, all works properly. Same seed, same dungeon on server and client.
WHEN ITS PACKAGED VERSION - same seed and same dungeon on server and client, nothing unusual. BUT WHEN THE CLIENT STEPS ON GENERATED MESH - he will be corrected by server and change move direction, desyncs client movement, until he walks back.

Meshed generated by simple spawn actor node.

Also, if you just jumping - it will not correct client.

And again - that only in packaged version of the project. Any ideas?

tardy fossil
#

if you jump and land into the center of the generated mesh, does it correct you all the way back to standing on the ungenerated mesh?

storm zealot
#

so this bugging only when client walks on mesh

tardy fossil
#

yeah thats kinda strange, does it happen in the editor if you uncheck "Run under one process" ?

storm zealot
#

No, all is ok when played in editor

#

Only in package

tardy fossil
#

my best guess would be something weird going on with the normals that would make the CharacterMovementComponent think the floor is not walkable

storm zealot
#

How I can check / fix it?

#

p.netShowCorrection tracks corrections in development mode, but character moves correct

tardy fossil
#

you could bind a debug key or action to send a raycast down towards the ground and print out the results of the Is Walkable blueprint node on both server and client and make sure they match

storm zealot
#

Working on it

storm zealot
#

On server and on client, hit is correct

storm zealot
tardy fossil
#

i'd check to see if the ImpactNormal from the raycasts match up on server and client.. and maybe its physical material? if you use one

storm zealot
#

how I can cast ImpactNormal ? Is this a node?

tardy fossil
#

its in the HitResults struct the raycast returns

#

i think you can right click it and click "split struct"

storm zealot
#

Default phys material

#

Both on client and server

#

I thinks something desyncs client and server, but have no idea what

This is just static mesh, in the same exact position...

tardy fossil
#

you are comparing them in the environment where it doesn't work right? ie a packaged game

storm zealot
#

yep, in packaged game

rocky kestrel
#

Any ideas how to prevent basic CheatEngine in online unreal engine game that runs on dedicated server?

graceful flame
rocky kestrel
#

is it plugin or?

graceful flame
#

You apply to be protected on their website.

rocky kestrel
graceful flame
#

Oh wait I think it’s part of EOS now.

rocky kestrel
graceful flame
#

You have to interface with eos using c++ or buy one of the blueprint plugins from the marketplace.

twin juniper
#

Has anyone here shipped a game using the seamless travel method of changing levels? I've got a couple prototypes of it working locally, but I'm noticing there are a lot of complexities that don't seem like they're worth the effort relative to just using a single world with stream levels or world partition with different areas broken up as needed.

rich crag
#

OK guys, I am missing something about multiplayer replication and Im' trying to sus what it is. I have an actor (a boat) that has multiple interactable stations that are child actors. One of these is the helm. When I interact with the helm, it sends a server RPC to check if the character is in range and nothing is occupying the helm, if so, it sets the character as "AuthorizedDriver" on the ship actor (just a variable, as I'm not sure what to do with it yet). I also swap control contexts on the player controller to send RPCs to the ship, but the ship ignores them. I'm certain it's an authority issue, but I'm not smart enough to understand what i'm doing wrong. i can't give ownership of the ship to the character, as I want multiple characters to be able to interact with multiple stations at once (helm, sails, etc). Any help on understanding how to set this up would be amazing. Thanks so much in advance for your effort.

storm zealot
#
thin stratus
#

Being the Mesh

#

You should see a lot of errors in your logs for that

#

I think dynamically spawned actors have that issue if they are spawned non replicated on server and client

#

If you spawn it server side and let the actor replicate it should work

#

But just a random idea

storm zealot
#

Just checked that in other blueprints room generation is not replicated, because its too heavy

So instead they replicate only seed, then every client just generate dungeon by this seed

thin stratus
#

Idk if there is a way to have the Actor "sync up" after being spawned locally first.
They would need to have a matched netGUID I guess

#

Yeah

#

Again you should see warnings or errors about the base movement in your logs

storm zealot
#

those ones?

storm zealot
#

And thats a necro(((

sinful tree
storm zealot
#

On server and client they have different names (f.e. BP_Room_01_4356456 and BP_Room_01_111231324 )

sinful tree
#

Here's an example function I would call after spawning the actor on both the server and client, and I used an index to keep track while it was generating.

void UMyBlueprintLibrary::RegisterGeneratedActorForReplication(AActor* MyActor, int32 Index)
{
    FString displayName = "GeneratedTile_" + FString::FromInt(Index);
    MyActor->Rename(*displayName);
    MyActor->SetActorLabel(*displayName);
    
    TArray<UActorComponent*> ActorComponents = MyActor->GetComponents().Array();
    
    FString compDisplayName;
    for (int32 CompIndex = 0; CompIndex < ActorComponents.Num(); CompIndex++) {
        compDisplayName = "GeneratedTile_" + FString::FromInt(Index) + "_" + FString::FromInt(CompIndex);
        ActorComponents[CompIndex]->Rename(*compDisplayName);
        ActorComponents[CompIndex]->SetNetAddressable();
    }

    MyActor->SetNetAddressable();
}
storm zealot
#

I cant do this in blueprints for sure?)

thin stratus
#

No :P

storm zealot
#

Also, is this will be optimized for generation dungeon? I working on coop game with listen server system

thin stratus
#

Hence people often saying that Multiplayer without C++ has its limits.

thin stratus
storm zealot
sinful tree
thin stratus
storm zealot
#

But that static meshes is already renamed - On server and client they have different names (f.e. BP_Room_01_4356456 and BP_Room_01_111231324 )

#

This code doing the same thing? Or it adds new prefix?

thin stratus
#

Yeah you rename them via a similar function that Datura posted after spawnign them

#

Both locally and on the server

elder sable
#

Hi, i'm using custom replicated uobject, i can replicate properties from C++ but if i inherit this class in BP, i can't replicate properties, anything special to do in BP ?

storm zealot
#

Thanks! Will try. Good reson to touch C++)

#

but im still confused. Why we need to rename actors, if they named differently on client and server? Or this is a reson, and they must be named the same?

sinful tree
#

Here's what it says on SetNetAddressable():

Allows this actor to be net-addressable by full path name, even if the actor was spawned after map load. @note The caller is required to ensure that this actor's name is stable between server/client. Must be called before FinishSpawning
#

Ensuring the name is common between the server and client is what allows it to make the link between them.

storm zealot
#

damn, thank you! This is very interesting. I will try. God, even if it will not work - thank you! That is first good light in this dark hole of multiplayer development in my journey))

storm zealot
#

So if server spawns it (or client that own server) we didnt need it

#

Only after client spawns a room?

sinful tree
#

You'd want to call it after any time you spawn the actor, whether server or client.

storm zealot
#

So I will put my new func there?

sinful tree
#

No, you can't use blueprint to handle the spawning as you'd need to use SpawnActorDeferred().

#

So you'd have to create a function that handles that which you could expose to blueprint 🙂

#

THEN you could insert that function where your current spawnactor is.

storm zealot
#

so I need to replace SpawnActor to new func with spawning actor+ SpawnActorDeferred()+RegisterGeneratedActorForReplication

#

got it, thanks!

#

And that will be default spawn actor func in C++, but with SpawnActorDeferred() ?

#

Im annoyng, Im know)

#

understood

storm zealot
# sinful tree No, you can't use blueprint to handle the spawning as you'd need to use SpawnAct...

okay, my first c++ code and custom bp node

void UMyBlueprintLibrary::MyOwnSpawnActor(Class, SpawnLocAndRotation)  <--- sorry Im javascript monkey and will add type check later
{
    AMyActor* MyActor = World->SpawnActorDeferred<AMyActor>(AMyActor::StaticClass(), SpawnLocAndRotation);
    MyActor->RegisterGeneratedActorForReplication(MyActor, int32);
    MyActor->FinishSpawning(SpawnLocAndRotation);
}
#

that will not work and I need to read more manuals

thin stratus
#

:P C++ doesn't allow leaving types away

storm zealot
#

I know)

cobalt pollen
storm zealot
#

I write in typescript usually, but here Im just didn't know correct types))0

elder sable
#

Look the type of MyActor->FinishSpawning(SpawnLocAndRotation);

storm zealot
#

but the idea is correct? World->SpawnActorDeferred , then RegisterGeneratedActorForReplication (new func for rename by Datura) and finally FinishSpawning

#

what the hell is AMyActor* MyActor, oh crying under the table with JS monkey plush

elder sable
#

Read some c++ basics :p

#

That's just a declaration

split swift
#

i have an fps game that i have been working on that uses a complex weapon pickup system, it uses a bunch of variables to find out what weapon the player is holding, im trying to learn how to network replicate and the code is so spaghetti that i dont even know where to begin. is there such thing as code so bad for replication that its easier to completely rewrite it in a way that works better for replication.

storm zealot
#

Also, what is the easiest way to add cutom bp node to BP-only project?

elder sable
#

blueprintcallable

thin stratus
#

There is no catch all answer to this

#

Either make a C++ Child of the Class your BP is inheriting from

#

And plug it in-between

#

WIth a UFUNCTION(BlueprintCallable) function

#

Or if not relevant to a specific class, make a BlueprintFunctionLibrary (in C++) and add a UFUNCTION(BlueprintCallable) that is static

#

Keep in mind that static functions have no direct access to the UWorld

#

So if you need that you need to pass in a context object

#

I would suggest you look at existing static functions of Libraries in the engine for that

elder sable
#

Does someone know if it's possible to have replicated properties in a blueprint inheriting from a replicated uobject ?

thin stratus
#

Should be totally fine as long as you still add that UObject to an Actors Subobject list imo?

elder sable
#

Mhh, i have replicated properties in my c++ class (inheriting from a uobject), everything is working but in blueprint properties are not replicated (inheriting from the c++ class)

#

So i guess something is missing

formal solar
#

Can I clear intermediate files from online subsystem steam?

#

They are getting saed as gimp files for some reason and it is confusing the compiler

split swift
#

how do i make an attach actor to component network replicable

thin stratus
thin stratus
#

Depends on context

meager spade
elder sable
meager spade
#

To replicate BP properties you need to grab them and tell the lifetime props to replicate them

#

Check UGameplayAbility.cpp at its GetlifetimeReplicatedProps

#

It has some code to grab BP properties

elder sable
#

Hm i can't find GetlifetimeReplicatedProps in GameplayAbility.cpp

meager spade
#

Hmm sec

#

Not on pc

#
    {
        BPClass->GetLifetimeBlueprintReplicationList(OutLifetimeProps);
    }```
elder sable
#

So i should just call this from GetLifetimeReplicatedProps in c++ ?

meager spade
#

yes

elder sable
#

Ok thanks !

split swift
#

im new to replication and i have no idea what im doing here, im trying to replicate an attach actor to component where the target actor is gotten from a BPI Event but whenever the client picks it up i get a message that the server couldent read the target actor. it works fine when the server picks it up though.

thin stratus
#

Weapon being equipped is a State

#

And you can't just connect the Weapon pin to something that went to the Server and back

#

You'd need to pass that through the RPC

#

In theory you should just call the Server RPC, and cut the Multicast.
And pass the Weapon through the Server RPC fwiw and then set a RepNotify/OnRep variable with that Weapon.

#

In the OnRep function you can then attach the actor

#

If you don't know what RepNotify etc. is, re-read the Network Compendium on that topic please.

split swift
meager spade
#

you should not need to replicate attachments though

#

attachments are replicated by default

gusty slate
#

the RepNotify value has to be set by the server for it to work

#

EquipWeapon is that being called by the Client or Server?

#

also what's WeaponSet's type? You probably should use an identifier (WeaponID, WeaponClass, etc) for that, not an object reference

meager spade
#

i have never needed to replicate the attachment

#

actor has a ReplicatedAttachment system

#

i just attach on server, and the weapon is attached on all client

storm zealot
#

@thin stratus @sinful tree Solution is simple, guys
I just set mobility of all generated meshes to "static" and now it works

oh God, 30 hours of debug

REMEMBER KIDS
IF YOUR STATIC MESH HAS MOVABLE MOBILITY, YOU WILL BE REJECTED BY SERVER IF ITS NOT REPLICATED

Gamechanger for generated dungeon in multiplayer

#

nach, I downloaded C++ stuff...((99

thin stratus
#

Well you learned about the other way too I guess

#

Knowledge is also worth it

dark edge
split swift
#

im trying to learn networking and just read documentation for 3 hours and i still cant get a single variable to replicate, does anyone have any good references for network replication

split swift
#

ive finally got somewhere but now i have an actor that wont destroy if the client runs the event but will if the server runs the event i used an RPC to the server and then a multicast but it still wont delete for when client runs it

sinful tree
# split swift ive finally got somewhere but now i have an actor that wont destroy if the clien...

RPCs = Send Data / Execute Instructions
Replication = Value is set on server, and is sent to clients. You can change the replication condition of properties so that only certain clients receive the updates or the updates are only sent at certain times.

You can only call a "Run On Server" RPC from a client if the client owns the actor that you're calling it on.
You can only call a "Run on Client" RPC from the server if the actor is owned by a client.

By default, the Player Controller, a player's controlled Pawn and their PlayerState or any replicated components of these actors are things that are "owned" by a client and can appropriately send and receive the server/client RPCs. You can assign ownership of actors at run time, but that requires you to set that ownership on the server and it isn't necessarily what you need to do to interact with objects.

Multicast RPCs can only be called by the server, and can execute for all clients that have the actor relevant regardless of ownership. An example of an actor not being relevant is if it is far out of range of a client, in which case the server may cull the actor from replicating for that particular client. These are typically used for fire and forget events that aren't mandatory for the game to function, for example playing a sound effect or displaying a particle effect.

So if you want a client to be able to call "Destroy Server" the client would first have to own the "BP_WeaponBase" actor.
A way around this would be to do the "Run On Server" event on a client owned actor, like their player controller, playerstate or pawn. Once running on the server, you can then call to destroy the actor - if it is replicated you shouldn't need to multicast it.

vagrant grail
#

Simple question : How do people make their First Person Character have a hand shown on the screen for them to be able to use it. But when they switch their camera to third person or viewing that character from someone else's perspective shows something totaly different, like the full body for instance.

By that I'm referring for example to minecraft, where in FPS mode you see only 1 hand on your screen, but when you're in TPS or seen from someone else's perspective, they see the full body and the arm isn't placed in front of the player like on the FPS POV, as the arms are placed along the body.

I don't know how to do something like that, any guidance please ? 🙂

vagrant grail
#

using "HasAuthority" node ?

#

Then it will create an issue with the player hosting the game as my game is hosted by a player creating the game. And using "HasAuthority" for him it will return true and will create an issue ?

meager spade
#

@vagrant grailcheck OnlyOwnerSee

#

and OwnerNoSee

#

two options on primitive components (including meshes)

vagrant grail
bright summit
#

I am trying to make a respawn system for players, I get everything to work except one thing. On client when he dies second time, he can't respawn because in player blueprint (CMC) playerstate is null.

I have in playerstate variable which tells if player can respawn or no, and after death I have simple timer which sets this variable.

It seems like after deleting the actor and spawning it again it has no reference to player state, what can I do?

bright summit
#

strange is that cast is not failing but it is still pointing to null class

vital barn
#

I've got two questions:

  1. For learning multiplayer with blueprints, what tutorials do you recommend?
  2. I am stuck with an issue. I have a projectile that when it's Box Collision overlaps with another object, it freezes (to simulate a spear getting stuck)
    There are two exceptions to this freezing, and it's if it's the player or if it's another spear

The issue I am having right now is that for the Server it looks like the spear freezes, while on the client it travels normally. I believe that this is because on the server the spear is actually hitting the player (ignoring the check). What could I be doing wrong?

bright summit
#

you are comparing it to player index 0 which is always the same player, not that one which is throwing it

vital barn
#

Aha! What should I check with instead? 😄

bright summit
#

what blueprint it is?

vital barn
#

I want to make it so that if it hits another player it will trigger, but not if it's you the player.

bright summit
#

I know what you want to do, but I am asking what object the code is?

#

that one on screenshot

vital barn
#

Oh sorry, that's the projectile actor bp

#

I spawn it from the first person blueprint

bright summit
#

so get the "self" reference

vital barn
#

this above is the first person blueprint

bright summit
#

I think you should store in projectile a player object which threw it, then compare it to that stored variable

#

and here set this player

#

as self

prisma belfry
#

Thoughts on this naming conventions for replicated functions/events in both BP and C++:
If anyone has a resource for an alternative I'm curious to see it. Cant seem to find a standard

vital barn
bright summit
vital barn
#

Like this?

bright summit
#

yeah but where did you made this variable?

#

in which blueprint?

vital barn
#

On the First Person Blueprint

bright summit
#

no

#

it should be on project tile

vital barn
#

Ohhh

#

Shit

#

Now I get it

#

Sorry

bright summit
#

then you set it from return value -> throwing client

Because your ret value from spawn actor is your projectile which you spawned

#

I think this is simple to understand

vital barn
#

No I got it now! But it still doesn't work hmm

bright summit
#

I think your condition with overlapped component is useless

#

but I might be wrong

#

I would try to remove it

vital barn
#

I did

#

aha wait

#

When I print ThrowingActor, it shows up empty

bright summit
#

yup, because it is not replicated

#

make it as replicated reliable variable

meager spade
#

@prisma belfry i normally have Server_SomeFunction, NetMulticast_SomeFunction, Client_SomeFunction

solar stirrup
#

I like it that way too

#

Readable

vital barn
prisma belfry
bright summit
prisma belfry
#

Anyone experienced that multiplayer works perfectly when running listenserver and client both on your pc but some things dont replicate when its two pcs on the same lan? any usual suspects?

vital barn
solar stirrup
#

what are you setting it to

vital barn
#

Throwing Client is a Variable (Actor Object Reference) on the projectile
On FirstPersonCharacter BP, where I spawn the projectile, I set the variable to be (self) so that I can get what player threw the spear

#

I tried printing it and on the client it can find it correctly, but not on the server

#

"This is: " is what I print when overlapping

#

I fixed it!!!

#

It was so simple

#

SpawnActor has a field for Owner

#

I just used that one instead

tardy fossil
#

just fyi if your BP_Spear is set to replicated, you might have issues with the spear spawning twice on listen servers for clients when a client calls the server function to call the multicast

bright summit
storm bough
#

Hello. I need data that is not normally replicated (to be specific, ForwardVector of camera). I need to update it every tick (or at least often enough - player will look up or down, even slightly, all the time).
How I can do it without lolmurdering network? I mean, characters walk and change direction in response to player's input all the time. That means variables like character position or rotation are replicated efficiently enough... somehow.

What I was doing before was running code normally (in sense that all instances run it both on client and server), then call client-specific code for local client that gets camera data like ForwardVector, THEN inside I call server code that sets forward vector in replicated variable. I was able to get away with that because it was called only sporadically.

In pseudo-code:

AttackSomethingOrOther() {
  // This code runs everywhere on all characters both on client and server
  // ...
  if (IsLocallyControlled()) { // local player character?
    CL_ResolveWherePlayerLooksAt(); // client-side: UFUNCTION(Client, Reliable, ...
  }
  // ...
}

CL_ResolveWherePlayerLooksAt_Implementation() {
  FVector LocForwardVector = GetFirstPersonCamera()->GetForwardVector(); // this var is not replicated
  SV_SaveWherePlayerLooksAt(LocForwardVector); // server-side: UFUNCTION(Server, Reliable, ...
}

SV_SaveWherePlayerLooksAt_Implementation(FVector LocForwardVector) {
  // to my knowledge, replication of variables works only on server, so you must be ON server to set these vars and see them updated everywhere
  ForwardVector = LocForwardVector; // ForwardVector is UPROPERTY(Replicated, ...
}

Is there better way?

solar stirrup
#

You can use the player's control rotation server-side

quasi tide
#

Main thing is to prefix it with the type of RPC it is

simple crow
#

might be a silly question but.. for replicating array properties.. is it guaranteed that .. lets say on the server I add 20 elements to an array in one function... Those 20 elements are going to replicate back to the client when the replication happens? Its not going to replicate them one at a time or something. I'm basically hoping RepNotify wouldnt be called 20 times or something.

clear island
#

is BeginPlay() of my ACharacter a safe place to cast to my CMC Subclass in both the client and server? or can it be null/delay to initialize?

#

like: Cast<UMyMovementComponent>(GetMovementComponent());

quasi tide
#

Should be fine. BeginPlay runs after the component initialization stuff

clear island
#

I see

#

anyone here experienced at diagnosing client correction error messages? (stuff that gets printed when p.NetShowCorrections = 1 ), I sometimes have these corrections happen, seemingly at random, but only in a packaged build

#

my theory at the moment and according to these logs (someone correct me here if I'm wrong) but it seems the client and server are disagreeing on the walk speed (Cmc->MaxWalkSpeed ?) momentarily according to the logs

#

I say this since the logs show a really big difference in Client vs Server velocity, which I believe is affected by Cmc's MaxWalkSpeed? ( I was just running forward when the issue happened)

copper pendant
#

how to make this:
When new player joins already active chat, server would send this new client all old chat log to his chat window as well?

shy nymph
#

Hey guys, if I have two teams that the player selects from the main menu before joining a game on a dedicated server

Then I find a session hosted by a dedicated server and client travel to that server

what would be the best way to go about communicating to the server what team I previously selected in the menu to have the server spawn the correct pawn?

lets say in the menu I select "play as counter terrorist" and then after client travel the server should spawn me the "counter terrorist character" pawn to posses

#

would it be something in the session interface or should I have a variable in the game instance and after joining send the value to the server via rpc

queen escarp
#

hey can anyone help me with this :/ ? im guessing its related to multiplayer stuff ?

inner cove
#

Hey guys, I face an issue, I use gamemode's restart with seamless travel enabled. Works fine, the only problem that I have is that the WBP UI does not show on the clients after the game restarts, this is the code for it, this runs on a playercontroller. Btw its dedicated server

mystic marsh
simple crow
split swift
#

im trying to make picking up a weapon network replicable, but i have no idea what im doing, i manage to get it to work but i was told that its a bad way of doing it, what would be the good way of doing it?

unkempt tiger
#

is the DemoNetDriver on Epic's agenda these days, or is it not updated?

#

Asking because I'm trying to decide whether or not I should fix a bug I've got in replay playback, or wait for 5.4

hollow eagle
#

check github?

#

but it's unlikely they're touching it until they fix things up for iris

queen escarp
#

hey i have an actor with a static mesh thats replicated the actor is replicated also

#

and im destorying component on player character BP, event on server

#

but nothing happens ??

thin stratus
queen escarp
#

even if i RPC it dosent get destryed :/

pearl saddle
#

For some reason when trying to run code in server, the game mode isn't recognised?

#

Very confused, I understand that the game mode can only be referenced by the server as clients cant access it but it should be recognised since its code is run on the server so if anyone could figure out the problem that would be great thanks

hollow eagle
#

you're not running it on the server though

#

those messages are coming from a client

#

I don't even see the print string causing those messages in your screenshot

pearl saddle
#

I'm executing the code on the server though

hollow eagle
#

the code you posted maybe

#

not the code showing messages in your screenshot

#

nothing you posted contains a print string that prints "cast failed", they all say something else.

pearl saddle
#

thats odd

hollow eagle
#

it's not, the print string is coming from a client from code you haven't posted.

#

it even says "Client 0"

#

in all likelihood this code isn't failing the way you think it is, or isn't being hit at all. The failing code is elsewhere.

pearl saddle
#

When adding to the controller array it prints server: 0

hollow eagle
#

which has nothing to do with the code you posted

#

again, the messages are coming from a client

#

from a print string node that says "cast failed"

#

which none of the code you posted has

pearl saddle
#

oh

#

for some reason the code updated to this

hollow eagle
#

I can't even read half of that the screenshot is so small

pearl saddle
#

i dont remember changing the print output

hollow eagle
#

anyway, this blueprint is probably something that isn't replicated. Running a server rpc on something that isn't replicated won't run it on the server.

pearl saddle
#

this code is in gameinstance i thought gameinstance is replicated

hollow eagle
#

no, not at all

pearl saddle
#

ah

hollow eagle
#

even if it was this still wouldn't work

pearl saddle
#

player controller is replicated though and so is player state?

hollow eagle
#

only the client that owns an actor can call server RPCs on it

hollow eagle
#

those would work

pearl saddle
#

In my head i tried to put this code on game instance thinking it was replicated so I'd be able to reuse this code in another level

crisp shard
#

if there is a randomization factor being applied to my output damage, how can i get the client to predict what that value will be? i tried running same functions on client prior, and although, it works fine, the randomization gives slightly different numbers and it effects the way some client side visuals show up vs how they actually are on the server

#

i could get them after the fact, but this is what im trying to avoid

hollow eagle
#

either don't predict it or it needs to be deterministically random

#

and being deterministic isn't the only complication (that's the easy part), dealing with mispredictions is going to throw all kinds of wrenches into that

#

a question you may want to ask yourself is whether you really want to be showing any kind of exact damage values at all if the server hasn't confirmed it anyway

clear island
#

what could cause a client to receive client corrections when both these booleans are set to true?

pearl saddle
#

Is there no persistent between levels replicated object in Unreal?

hollow eagle
#

no

mystic marsh
pearl saddle
#

dang

crisp shard
#

the health of the enemy basically pitches up a sfx as it gets closer to death, but that first inital hit is going to return "100" everytime because i don't have that dmg calulation until after

lucid badger
#
    DOREPLIFETIME(UAgentAttributeSet, Health);
    DOREPLIFETIME_CONDITION_NOTIFY(UAgentAttributeSet, Health, COND_None, REPNOTIFY_Always);

these are identical in function, right? hmm

#

Like you'd only use the second if you were adding restrictions, but no condition and always notify means... no restrictions hmm

hollow eagle
#

they're not the same

#

the default is REPNOTIFY_OnChanged

thin stratus
#

Always notify means it will run even if the value didn't change

#

Locally that is

fossil spoke
# thin stratus Always notify means it will run even if the value didn't change

To expand on that.

@lucid badger Since the Server doesnt keep track of the value on the Client, if its value changes, it will send it. The Client then has the opportunity to have OnRep called if their local value was different to what the Server sent down.

REPNOTIFY_Always, causes OnRep to be called regardless of that.

lucid badger
#

Got it, thanks guys Okay I didn't think about the case where the client is updated with same value

fossil spoke
#

Clients can change their local value at will.

lucid badger
#

Yeah. I just figured it would always fire even if the value was same

fossil spoke
#

Not by default

lucid badger
#

Yep understood now Okay

nova wasp
clear island
#

or how can I access the "GameNetWorkManager"?

nova wasp
#

you can set it in code but I think the intention is in a config ini

#
[/Script/Engine.GameNetworkManager]
ClientAuthorativePosition=true

in your game ini
@clear island

#

there are other cmc related settings in here

#

"why are those in here AND the cmc?" arguable some are generic to any movement replication I guess

clear island
clear island
#

where are these corrections coming from

nova wasp
#

anything "correction" should be related

#

or just raw repmoves

clear island
#

thats how I'm noticing those

nova wasp
#

you want the thing that sends them, not what receives them

#

afaik

clear island
#

yea I've been trying to track where that is 😄

#

but there' stuff in the playercontroller

#
  • CMC
#
  • Character too I think?
#

its not even minor corrections either, its really noticeable, causing visible rubber banding

#

but only happens in a packaged build for some reason

unkempt tiger
#

is it just me or is this a bit silly how the demo net driver disallows net startup actors from being destroyed during replay checkpoint loading, seemingly regardless of whether or not they were destroyed by the authority in the actual game at that point in time

hollow eagle
#

Without knowing that code too well, no? Seems logical - net startup actors are generally ones in the level, so there's no "create actor" command that comes over the wire (or as part of a demo). So destroying one when rolling back would mean it'd never be recreated, and it sounds like they do have a separate system for that.

#

My understanding of the replay system is that replicated actors that existed at a specific point in time would have a "create" command stored as part of the checkpoint. Net startup actors probably don't do this since they're already in the level and get matched up based on a stable name instead of created on the spot.

unkempt tiger
#

what pains me about it is that a giant part of the set of assumptions that I had about the demo net driver is wrong

#

my assumption was that replay playback was analogous to a client joining a match, and scrubbing the replay was analogous to a client joining the match in a specific time

#

when a netstartup actor had been destroyed on the server before the client would join, the client wouldn't load said actor, even if its a netstartup one

#

because the server would tell him 'whatever used to be here is dead now'

#

that just doesn't happen with replays

hollow eagle
#

Yeah that's not possible because there's no network message for actor creation that the replay system could capture. The creation of the actor comes with the map load.

#

So instead it has to deal with netstartup stuff differently.

unkempt tiger
#

then i'd expect the checkpoint data to hold a list of GUIDs of dead startup actors or something idk

hollow eagle
#

it does seem to do that though

unkempt tiger
#

ikr?

#

but it doesnt seem to work, at all

hollow eagle
#

I mean that there seems to be a bunch of code that does exactly that.

#

If it doesn't work then it sounds like you're doing something wrong.

#

Though it's hard to say what, as I said I'm not super familiar with replays aside from the fact that I know they generally work.

unkempt tiger
#

wouldnt be the first time it turns out to be on me, but with that I am left clueless

hollow eagle
#

look through the uses of QueueNetStartupActorForRollbackViaDeletion, there's a few things that call it that are in blocks dedicated to handling net startup stuff

unkempt tiger
#

and like, it shouldnt get less straightforward than the responsibility of calling Destroy() on the server

#

i'll do that, thanks 👍

crisp shard
#

Should VFX for other clients (sim proxy) be rep notify vs multicasts?

I guess it would depends in some cases but if i had to choose between one or the other, which would be best practice?

fossil spoke
#

You generally would want VFX to be generated from an Unreliable Multicast RPC.

#

Since VFX are typically fire and forget events, tying them to OnReps can have unintended consequences. You have to manage what happens during changing Relevancy for example.

#

The unreliability of the RPC is that way because most of the time triggering VFX is not gameplay imperative.

crisp shard
fossil spoke
#

Is the Player actually going to see them immediately when they join and for the period they may have left to live.

#

The answer is typically no.

crisp shard
fossil spoke
#

Its better in this case to assume unimportance and introduce importance than the other way around.

#

A door opening/closing isnt VFX.

crisp shard
fossil spoke
#

Sure

rocky kestrel
#

I have dedicated server survival game. Server (Game mode) saves all players to array variable of structures. Structure contains health, items, location, etc.. And server checks all controllers every 2 seconds and update variable. Problem is that it have pretty high usage of server and latecy goes way too big when over 60 players same time. What could be alternative way to do it?

fossil spoke
#

I would expect that you would only update a Players data in this way, if and when they perform an action that would change it.

rocky kestrel
fossil spoke
#

What is this data for exactly?

rocky kestrel
fossil spoke
#

I didnt ask what the data is.

#

I asked what you're using it for?

rocky kestrel
fossil spoke
#

Ok

rocky kestrel
#

or when server crashes. Server saves that variable to file every one hour

fossil spoke
#

So why not just perform the save operation when that Player chooses to disconnect?

rocky kestrel
fossil spoke
#

Ok well, if the Server crashes you are unlikely to be able to retain much of anything that happened recently.

rocky kestrel
fossil spoke
#

If its a survival game, why not make it a mechanic? Save when you sleep in a bed or something?

#

Every 2 seconds is just ludicrous

rocky kestrel
fossil spoke
#

What could possibly change within 2 seconds that is that important to retain.

rocky kestrel
#

It is not cool to join back to server and not have that anymore. But I can put that save to OnLogout

#

Thank you!

fossil spoke
#

Good luck

mystic marsh
#

Besides periodic saves, you could also save when something important happens. Checkpoint reached, boss defeated, quest completed, whatever an “important thing” is in your game.

rocky kestrel
#

Thank you!

copper pendant
#

Quick question: When new client join server how to make varible inside server be replicated to this new client?

thin stratus
vagrant grail
# copper pendant Quick question: When new client join server how to make varible inside server be...

Like Cedric said ☝️ But I think in this case what you're looking for is "RepNotify" which like "Replicated" does replicate to new clients, but it will also execute a function on the server and on the client to update stuff in it. This is usually used when your variable is used to behave like a "State" of your actor.

For instance, if you have someone has the default white unreal engine skin, and he goes into a box collision which changes his color to Blue. If people join the game later or were not present in the "Relevancy" range of that Player. They will keep seeing him with the white skin because they were not present when the skin change happened. So in that case you need to use "RepNotify" and in the function generated do the Skin change so people joigning later or when they're in the relevancy range of that player, they see him with the right skin color 🙂

lusty coral
#

Hi,
Has anyone created a two person interactive emote system? Like two person high five or hug?

queen escarp
#

@thin stratus now the same error occured again and i was doing nothing just walking really

thin stratus
queen escarp
#

ok gotcha, wdym hook up VS to it ?

thin stratus
thin stratus
#

If you use c++, then just start with it attached already from vs

lusty coral
thin stratus
queen escarp
#

im using bp only but its converted to a c++ since im using steams subsystem*

#

wdym attached do i run it from vs the project or ?

thin stratus
#

Yeah then you can run it via F5 key from vs

#

Vs will compile and start the editor with it already attached to the new process

queen escarp
#

ok ill try

#

ok and once im running it via VS then i just play untill error and it will get printed in a log somewhere or ?

#

also should i always run the editor/project via VS ? like is there any perks on doing that ? or more costly preformance wise ?

opal pulsar
#

do actor components also need to override GetReplicatedLifetime props and specify each property? If so then on the actor itself do i need to specify the component inside the actors version of that function?

chrome bay
#

The component needs to override it yeah, but unless you have a replicated reference to that component then no it doesn't need to be in the actor

#

It's specifically for the replicated UPROPERTY's of that class only

opal pulsar
#

Alright thank you

#

In what cases would I want a replicated reference to a component on an actor

#

Just curious

crisp shard
chrome bay
vagrant grail
# crisp shard interesting, i never thought about how animation / skin changes should be rep no...

Check this awesome series, you will understand better than with my explainations (he shows the example with the skin I talked about), it's 4 episodes series. https://youtu.be/TEojA3VBXG8

BRY

❗ DISCLAIMER: Re-uploaded due to the original video being somehow magically deleted (I didn't do it..) 😭

👋 Welcome to the Replication Series! This series covers how Unreal Engine handles Replication from the ground up starting with what replication is and how Unreal's Client-Server model works and then moves on into more advanced topics.

📹 ...

▶ Play video
toxic goblet
#

Hi guys, i am curious about is there anyway or program can simulate lag/lost to specify process? I want to test how weak net players look like in other players' view.

#

I have used clumsy, but it seems can only use to all process.

vagrant grail
toxic goblet
vagrant grail
queen escarp
#

@thin stratus ok now i got the error while Vs was attached

#

where should i look :/ M?

toxic goblet
thin stratus
#

You'll see the same callstack that you saw in the logging

#

In there, you would want to go from top to bottom, one by one and check the VARIABLES on the left side

#

And see if you can find what Character has the issue

#

fwiw you can post a screenshot of the 2nd callstack entry from the top

queen escarp
thin stratus
#

As I think that was the PreReplicate one

#

You call to PreReplication

#

And then show me the members tab

#

Eh

#

Variable tab

#

It's on the left already open

#

Think it's called "Autos" in VS

queen escarp
#

hm

#

there is 2x preReplication

#

ACharater
AActor

thin stratus
#

The Character one

queen escarp
#

ye

thin stratus
queen escarp
#

so i doubbleclick that and this sis the info

#

aye

#

i search for "Autos" +

thin stratus
#

"this" being the object instance this crashed on

queen escarp
#

oh ok

thin stratus
#

I just meant the left window

queen escarp
#

ah ok,

#

so its related to "skeleton_BP2

#

right ?

thin stratus
#

Yes

#

Can you scroll that a bit

#

And see ify ou can find the character movement comp

queen escarp
#

characterMovment 3rd from top ?

thin stratus
#

Yeah

#

It's null

#

Which is not good

#

That shouldn't happen

queen escarp
#

alot of red stuff that cant be good obvi ?

thin stratus
#

That's all redundant

queen escarp
#

hm okey

thin stratus
#

nullptr means it's pointing to nothing

#

The properties are just garbage then

#

The main point is that the CMC shouldn't be null

#

Are you somewhere destroying the component ?

queen escarp
#

hm yeah

#

sec ill reopen and look

thin stratus
#

And if not, you might want to redo the Character (BP_Skeleton) as in deletei t and make it again (unless that's a very big code one)

#

Cause this is usually nothing that should happen

#

The CMC is a core part of the Character and usually should share the lifetime with it

queen escarp
#

im destroying it in a RPC*

#

when a enemy dies

#

i think that did it

#

hm okey so its something realated to the NPC wanting to use CMC after its being destroyed i suppose

#

well super thanks as always so far!

thin stratus
#

No worries, yeah don't destroy that

#

And now you also learned a bit about debugging crashes

#

There is more to it, but this usually at least gives some info

queen escarp
#

yeah this was a huge help

#

it atleasts points you towards any direction

flat night
#

hey, what do people to get Steam names and avatars in C++? I tried using the AdvanceSteamSession plugin, cause it worked well in BP, but I cannot build my game when I try to use it. This is my code:

FBPUniqueNetId SteamID; 
    EBlueprintAsyncResultSwitch ResultSwitch = EBlueprintAsyncResultSwitch::OnSuccess;
    UTexture2D* SteamAvatar = UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(SteamID, ResultSwitch, SteamAvatarSize::SteamAvatar_Medium );
    if (SteamAvatar)
    {
        I_Avatar->SetBrushFromTexture(SteamAvatar);
    }

I have added it in the PublicDependencyModuleNames, but it's still not working. Curious what people use to get Steam info? Maybe the actual Steam API?

frail sentinel
#

Good morning everyone. I am having trouble with a race condition and need some assistance. I have a Replicated actor spawned on the server that needs to have its details shown on the HUD. The problem is that the HUD appears to be created before the actor is replicated to all clients. How would I go about ensuring that it is replicated before I create the HUD element for it?

opal pulsar
#

I am confused, I have a actor component that has a variable marked as replicated and a function marked with reliable and server, the client is calling the function and the server is being updated but the client value stays the same, and if I call it from the listen server player then it updates like normal on this listen server but the client is not receiving any updates

#

This is the component that exists on the character BP


    UFUNCTION(BlueprintCallable, Server, Reliable)
    void UpdateReplicatedValue();


protected:

    UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated)
    float myReplicatedValue = 0.f;

And here is the function

void USG_MyReplicationTestComponent::UpdateReplicatedValue_Implementation()
{
    myReplicatedValue = FMath::RandRange(0.f, 100.f);
}
#

Client and Listen call it but only the listen server is being updated in both cases

forest bolt
#

Does anyone here have an opinion about the main anti-cheat solutions available on the market? I'm doing some research and considering adding one to the game I'm working on.

viscid tapir
#

don't forget the UAbilitySystemComponent::InitAbilityActorInfo() to initialize the cached data about the owner/avatar. This is generally done server-side with OnPossessed() and client-side with OnRep_PlayerState or anything else

#

Actually all the replication/prediction is automatically handled in your use case. You just need to have a valid prediction key when committing the ability (i.e restore it via WaitNetSync after the montage being played)

opal pulsar
#

Perhaps I missed it but none of the docs I read mentioned it

tardy fossil
opal pulsar
queen escarp
#

this is madening how is this even possible

#

i have a "Door BP" with a componenet Lock

#

everything is replicated on the actor + parent

#

and this is how im destroying it

#

only for Testing

#

but it dosent work ??

#

on a player character BP its calling it

#

makes no sense ??

tardy fossil
opal pulsar
viscid tapir
#

Yes, actually on the AttributeSet, you declare the FGameplayAttributeData, which is actually the Attribute itself. And then you decorate it with the attribute macro (for the getters/setters) and you add the UPROPERTY(ReplicatedUsing=...) so you mark it for replication with the OnRep function (for the ones that need to be replicated like the health or the mana). In the OnRep function, you call a macro that has been set for you (that actually retrieve the ASC and call a function from there)

#

The prediction key is just an int that is incremented when a new action and its side effects is predicted. So the system can ID every actions with its prediction key and know what to do with the static delegates. You can learn more about how they actually work under the hood with the GameplayPrediction.h file

nocturne quail
#

maybe someone here knows the answer? multiplayer related

why is player invalid at line 5

if(!IsValid(Character)){ ScreenLog("Character Null ptr"); return; } else {PlayerDriver = Character;}
bAttachedToVehicle = false;
OnRep_bAttachedToVehicle()
{
    if(!IsValid(PlayerDriver)){ ScreenLog("PlayerDriver Null ptr"); return; } //LINE::5 <<<
    GetController()->Possess(PlayerDriver);
}

SetOwner(nullptr);
PlayerDriver = nullptr; //commenting this will return in result a valid PlayerDriver ptr, but why this effects in OnRep_bAttachedToVehicle() ?
OnRep_PlayerDriver();
lost inlet
#

what am I even looking at

opal pulsar
#

Question - If I have a bunch of replicated data on my actor/component, should I instead be using a struct and trying to pack as much things that relate together in order to save on bandwidth and also ensure they all arrive together? Are individual Replicated properties all sent out of order and erratic, I have been looking into the CMC and their way of doing it seems to make alot of sense with FCharacterServerMovePackedBits packed stuff

meager spade
#

@lost inlet you know having spaces and tabs makes your code slower right?

#

and new lines.

nocturne quail
# nocturne quail maybe someone here knows the answer? multiplayer related why is player invalid ...

fixed it, now it looks like

if(!IsValid(Character)){ ScreenLog("Character Null ptr"); return; } else {PlayerDriver = Character;}
bAttachedToVehicle = false;
OnRep_bAttachedToVehicle()
{
    if(!IsValid(PlayerDriver)){ ScreenLog("PlayerDriver Null ptr"); return; }
    GetController()->Possess(PlayerDriver);
}

GetWorld()->GetTimerManager().SetTimer(RepNotifyTimerHandle, this, &AArmaChaosVehicleBase::DelayCallRepNotifies, 0.01f, false);
SetOwner(nullptr);
//PlayerDriver = nullptr;
//OnRep_PlayerDriver();

DelayCallRepNotifies()
{
    if(HasAuthority()) {PlayerDriver = nullptr; OnRep_PlayerDriver(); } 
}
#

it was needed a small delay between repnotifies

chrome bay
#

"fixed"

#

That is a very poor fix - just gonna say that now.

#

You've got a race condition, fixing it "well" is an essential part of MP programming in UE

rose pollen
#

I've got a relevancy issue I don't understand while trying to set up a spectator system for players that die in my game. I've never had any other issues with relevancy so I am a bit baffled.

Suppose that there are 3 players, p0, p1, and p2. If p0 dies he starts spectating p1. If p2 was outside of p0's relevancy range when p0 died, and p1 runs over to fight p2, p0, who is spectating p1, will not see p2 on his screen. Everything works fine for both p1 and p2 and p0 can see p1 taking damage.

#

here p1 is on the left, p0 is in the middle and p2 is on the right. The white cube is a debug cube I put on p0's spectator pawn to make sure its location was moving with p1.

#

When p0 dies, my code unposses and destroy's their characters pawn, the creates a spectator pawn, then possesses the spectator pawn. Then the spectator pawn is attached to the player we want to spectate (in this case p1) via "AttachActorToActor"

#

I set my child class of the spectator pawn to have replicates = true, and given that P2 can see p0s spectator pawn cube it seems like it is replicated

#

but I want p0 to use that cubes location for determining what is relevant to him and I can't get that to work

#

I see that wizard cells guide suggests overriding the "SrcLocation" but I seems like we should be able to get it to work via this check

else if (bNetUseOwnerRelevancy && Owner) { return Owner->IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation); }

#

if the "Owner" is correctly set (so the "Owner" of the spectator is the player we are spectating)

solar stirrup
#

GMC added support for custom sync types in its latest v2 beta

#

@fathom aspen I think you'll like that

#

I was able to easily add FInstancedStruct binding support, now I can pass in arbitrary data into the client's moves

fathom aspen
#

Holy moly

#

Instanced structs and GMC, that's a lot of good stuff

solar stirrup
#

Yeah

#

Well technically you can implement support for any type, I just did FInstancedStruct because that just means any USTRUCT is supported now

fathom aspen
#

But yeah I don't quite remember the specifics

rose pollen
fathom aspen
#

Note: Attaching the SpectatorPawn to the spectated pawn to cure this issue won’t help (unless it’s done to the listen-server player), as the SpectatorPawn exists locally, which is generally client-side. The server should be aware of the changing location of the SpectatorPawn to compute relevancy.

#

See i even had a note

#

If u scroll a bit down

#

I wasn't wrong

rose pollen
fathom aspen
#

It's worse

rose pollen
#

this seems like a pretty standard issue that any spectator system would encounter, surprised they don't just handle it in the engine

fathom aspen
#

Since, no player is the server

#

Well the whole system wasn't being worked on for long

quasi tide
fathom aspen
#

It has many issues

#

Hence the article...

fathom aspen
solar stirrup
#

You can write one it's fine

rose pollen
fathom aspen
#

You can do w/e. At the end of the day the core of it, is to setviewtarget etc.

#

It does its best to mirror the same view, and for the most part it looks fine

rose pollen
#

Thank you

fathom aspen
#

SpectatorPawn is just a proxy actor to do stuff

solar stirrup
#

Any delegate I can bind to for when an actor's owner changes? Need it for the rep graph

#

Seems like Iris has a callback for that, which is nice I guess, but I'm still stuck in the past...

quasi tide
#

One day Iris will get more information on it 🙏

solar stirrup
#

i'll just make an interface

#

oh well

nocturne quail
graceful lynx
#

Hey all, is there a way to use preparemapchange and commit map change with servertravel?

torpid lantern
#

Struggling a little bit with getting values from server to client; what is the high-level flow?

Let's say I have a value on the server (cooldownTimeRemaining) - this value is produced in a server function.

Client needs this value.

What does that look like in terms of flow?

Client >> Custom "Run on Server" event >> [server runs func and generates value] -- this is where I am stuck, how do I tell the server to send that value back to the requesting client?

note: in my setup, all actors are simulated proxy

lucid badger
#

Are there any standard techniques for smoothing regeneration of a resource? Think like a stamina bar. I've tried various update rates, and even with consistent rates on both server and client being predicted, there are pretty frequent corrections that look really jarring.

I'm envisioning some kind of abstraction between the actual health/stamina value and what is shown on the bar, where the bar is lerping to the actual replicated value in a way that hides the slight jerking of the corrections... but that still doesn't sound like it would be quite right hmm guess I'll try it and mess around with it

hollow eagle
#

The easy way is to not predict on the client but instead interp from the client's current value to the server's. Every time a new value comes in you just set that as a new interp target, which puts what the client shows slightly behind but with a fast enough interp it doesn't really matter.

lucid badger
#

So lerp without the prediction at all Thinkge and that just ends up looking like a smooth consistent fill rate? In my head I'm still imagining that being potentially jerky still but probably it's too tiny to see hmm

hollow eagle
#

it depends on how fast the interp is and how often changes come in

#

you can also design around not needing it to be smooth at all - like showing a slightly faded bar of where the servers is and the real bar catches up to it over time.

#

you can predict but you need more information than the server's current value - you need to know when that value was set at the very least so you know if you've predicted past it.

lucid badger
hollow eagle
#

You may also need other info like whether the bar should be filling at all.

lucid badger
#

How many updates per second is reasonable? I've got it down to 4 and it still looks reasonably smooth but I'm guessing with the lerping technique even less works fine Thinkge

hollow eagle
#

for prediction If you know for a fact that every second the bar fills 10% then you might not need any info except the server's value, when the server's value was set, and the client's value.

hollow eagle
#

updates may not come in consistently

#

you can't guarantee that nor should you try

lucid badger
#

I mean server side

#

Regen is defined per second but applies X times per second divided by X

hollow eagle
#

that depends on your game

#

it doesn't even have to be done that way, it could be continuous if you calculate the value at the moment of retrieval

#

storing a base value and what time that value was set would let you calculate as if it was continuously adding to it

#

but it really depends on the design of the mechanics you want

#

there's no right answer

lucid badger
#

Sure I was just curious for examples cuz I'm not sure what would be considered too much net traffic

hollow eagle
#

again, not something you really need to worry about

lucid badger
#

Good, that's the answer then catfatNODDERS

hollow eagle
#

setting a replicated value multiple times does not necessarily result in multiple updates being sent

lucid badger
#

Oh right

hollow eagle
#

unless you're forcing net updates an actor will only send updates at a rate defined by a number of settings and also how much other stuff is being sent from elsewhere.

lucid badger
#

Right right right, that didn't occur to me when thinking about this

#

Okay excellent I will fiddle with the lerping Evilge thanks

surreal rampart
#

Hey! I am trying to make a client in my game possess another pawn, but I can't seem to make anyone other than the server possess a pawn.
I know the issue has to do with the player controller and that is not replicated but don't know how to get past that.

#

image for referance

daring gorge
#

is it possible to return a variables value using an interface?
i am having lets say a component with a variable and a class that uses the boolean variable. i made an interface called GetVar returning boolean. implementing the interface in component snd directly sending the boolean var and using interface message to retrieve it. it always returns false, is it the interface or the variable?

solemn dirge
#

Does anyone know where how to implement multiplayer proximity chat, or where I should start looking?

rich crag
daring gorge
rich crag
#

you call the message in the sender. You run the function in the reciever

#

@daring gorge

daring gorge
#

hmm

rich crag
#

@daring gorge in the sender:

daring gorge
#

makes sense now that i think of direct cpp implementation of a basic interface

rich crag
#

int the reciever:

daring gorge
#

so the class that calls the new func

#

test event

#

does that class also need to implement the interface

rich crag
#

test event is just a custom event that i created to trigger the sending

daring gorge
#

yeah, lets suppose its in another class

#

cant i use an object reference and just call the new func directly

rich crag
#

yes

daring gorge
#

so then i dont need to implement the interface in the sender class

lost inlet
# surreal rampart

I'm not sure what you mean by the player controller not being replicated, because it is, but only to the owning client

#

also this is ALWAYS wrong in an MP game

rich crag
daring gorge
#

it returns false always even if i set the value to true. i guess ill debug it with a bunch of print strings and check again later

rich crag
#

interfaces avoid object references

#

thats what they are for

#

abstraction

daring gorge
#

casting avoidance though right

#

not direct?

rich crag
#

you dont need either with an interface

surreal rampart
daring gorge
#

so if multiple classes implement the interface then wouldnt i need to pass in an object reference for a particular object to call the method

lost inlet
rich crag
#

no

#

you just pull the function from the interface @daring gorge

#

on every actor that implements it

#

so whe the sender updates, it automatically runs the function on everything that has the interface

daring gorge
#

oh

#

okay damn isnt that heavy"

rich crag
#

interfaces are good stuff once you get it

daring gorge
#

so i think a more viable use case would be lets say using an interface for kill feed or chat system i guess?

#

something which is more global

rich crag
#

I use interfaces all the time for specific use cases

surreal rampart
rich crag
#

its not necessarily for the global stuff but could be good for it as well

daring gorge
rich crag
#

its just a way to abstract blueprint communication.

daring gorge
#

since i use them to avoid casting

rich crag
lost inlet
surreal rampart
#

Ok thank you so much for the help!

rich crag
#

OK my turn. Anyone know why a rotational value would desync and finally stop working if my actors are moving through the world too quickly? I have a multiplayer ship with a helm actor with a wheel. the logic of the wheel sets a rotational value that gets sent to the boat, the server sets the rotation for multiplayer and the rotation runs locally for predictive purposes. At low speeds, everything is in sync. at 25% its a bit out of sync and values slide randomly against each other. at 50% and above. only the local rotation changes. the server version of the rotation does nothing.

astral anchor
#

Hey, could someone tell my why when in multiplayer, my vehicle (custom movement) insanely twitches, lags, etc? its in sync but its very jittery

solemn dirge
#

hey guys I'm trying to blue print multiplayer proximity chat. Wonder why I cant hear myself when I play on a listen server 2 with clients

heres a screen shot of my voip implementation

solemn dirge
solemn dirge
#

i reccomend watching delgoodies tutorial on the character movement component

solemn dirge
# astral anchor u mean?

the proble mis that the movement component in unreal only have native server integreation for walking, jumping, swimming, and flyings

rotund badger
astral anchor
#

i use easy-fm component

#

which was written in c++

cinder goblet
#

Anyone know why movement for a pawn would work for Player 1, but player 2 can only rotate the camera? QE should rotate, WASD should move but on P2 it does nothing.

rotund badger
astral anchor
sweet sage
#

On unreal multiplayer game can i Possess (OnLogin) a character that is already on world instead of spawning another?

rich crag
sweet sage
#

Where do i do that?

#

OnLogin? PreLogin?

rich crag
#

well, I'm guessing you would store a reference to the charcter on the server that was connected to the login account, and that reference would be retrieved on login and used for possess

sweet sage
#

How do i stop unreal of spawning another?

#

(It spawns by default)

rich crag
#

yeah im trying to sus that out. thinking...

#

I'm not sure if you can prevent it, however, you can destroy it when you possess the other.

#

@sweet sage

#

which is what i would probably do

#

😄

sweet sage
#

Not good

meager spade
#

@sweet sage you need to do it when the controller is ready for the pawn

#

there is functions in the gamemode

meager spade
#

RestartPlayer is a good start

#

comes from HandleStartingNewPlayer

#

calls RestartPlayerAtPlayerStart

#

has some stuff here

#

notabe the bottom chunk here

#

is when the players pawn will get created

#

you will need to like override this

#

and add your custom logic

#

SpawnDefualtPawn is also overrisable

#

so you could just override that

#

and return the pawn you want them to have, instead of spawning a new one

#

so many options

rich crag
#

^^ that guy knows way more. listen to him LUL

#

I'm still trying to get any clue on why a rotational value would desync worse based on actor speed.

rocky kestrel
#

If I set replicated variable on Server RPC Reliable Is it enough to save for all players on server? Even if other players joins to server after it is set?

pliant haven
#

How do you replicate the actual sprinting animation? Default in CMC the walk animation plays on both client & server. When I flip the cycle state to Sprint its only replicate Server -> Client vice versa.

dark edge
dark edge
dark edge
# pliant haven

that's for the max speed, what do you want to do for the actual animation?

pliant haven
#

Ohhhh

#

I just want it to go from walking to sprinting

#

It works just doesnt replicate to anyone else

dark edge
#

when the actual speed you're going is high enough, or when the button is pushed?

pliant haven
#

When the button is pressed

dark edge
#

read that Safe_bWantsToSprint in combination with making sure your speed is high enough

pliant haven
dark edge
#

If you're standing still but bWantToSprint, you surely don't want to play the sprint animation right?

#

First off, figure out what boolean, if any, is synced between all machines

dark edge
# pliant haven

This looks goofy, why does Safe_bWantsToSprint depend on IsSprinting?

#

wanting to sprint and sprinting are different things

pliant haven
#

It doesn't Im new to c++ so I just be trying stuff lol

dark edge
#

yeah it's a mess

pliant haven
#

I thought you needed a replicated variable to drive a animation across proxys

dark edge
# pliant haven

Why are you doing all that instead of just reading IsSprinting?

#

what is the purpose of the Safe_bWantsToSprint

#

Anyway, I'd just use the actual speed to determine which anim to play

#

Since that should be synced if you've otherwise done everything correctly

pliant haven
#

it works if I use IsCrouching

dark edge
#

Yes because Is Crouching is a built-in variable being kept in sync through the CMC

#

you need to do the same for your sprinting if you want to do it that way

#

I'd be very suprised if your sprinting speed change even works right now without rubberbanding, have you tested with lag simulation on?

pliant haven
#

Yea i was getting confused when doing it I wasnt sure what is and isnt needed, but Ill try again.

It works without rubberbanding with 500 ping

dark edge
#

if it is just use that

pliant haven
#

Its not I created that bool myself its not part of original CMC. I removed all the stuff related to it from my code & am gonna try and follow how the cmc does it for IsCrouching

dark edge
#

I mean assuming your speed change works just use that

#

If speed < SmallNumber -> Idle
If speed < WalkSpeed -> Walk
else Sprint

pliant haven
#

What use the speed to drive the animation instead of the bool?

dark edge
#

yes

#

for now, until you figure out how to get a nice synced bool like Crouch

pliant haven
#

I tried this but didn't work. I mean my only goal at this point is to replicate that bool so ill work on that.

dark edge
#

your pawn certainly has a Walk and Sprint speed parameters right?

#

Just check is CurrentSpeedYouAreGoing > Walk, if so, you're sprinting

pliant haven
dark edge
#

and i'm assuming you have a non-sprinting max speed to return to when you stop sprinting right?

pliant haven
#

Its just overriding the walk movement mode so it just defaults to CMC MaxWalkSpeed when I release shift

dark edge
#

but you do have access to those 2 variables on all machines right?

pliant haven
dark edge
# pliant haven

k so in anim check if it's going faster than maxwalkspeed (assuming that doesn't change at runtime) and you're in business

pliant haven
#

Im pretty sure I just need to replicate IsSprinting variable when I use IsWalking it works too, but defaults to the Run anims

dark edge
#

however you want to do it

pliant haven
#

Well half way there its replicating client -> server

pliant haven
fallow kettle
#

Hey devs!!... I am having some trouble with the physics replication on UE... if you see the clip... the movements of the spheres on the client side is very glitchy when the mesh count increases... how can I solve that

also... I have been playing with NetEmulation commands for a while now... and I wanted to ask when applying packet delays in that... is it expected to apply only when the server instance does it... or should it happen from both the ends

sharp furnace
#

G'day all, I'm trying to trigger a WBP (Using Lyra Framework) for a player based on specific conditions within a Game State Component. For example, this should be activated when there is only one player remaining from a particular team, and only activate on that player.
I can get the SinglePlayer version working seamlessly, however i cannot get the content to display in MP unless i call a Multicast RPC function
My thoughts were, this should only be called on the Client using Run on Client RPC?

sweet sage
#

Does anyone knows where unreal unload current map when changing server?

#

I want to connect to another server (ipaddress) but keep current server loaded. I will spawn on same position anyway

chrome bay
#

The two times I've done it they've been physics objects. My suggestion would be spawn them before throwing (and replicate), have the throwing client "launch" it locally, use the engines physics interpolation to blend them together. Fine control of the physics material settings and perhaps some contact modification to tune their trajectories and response to hitting things.

#

But yeah detonation would be replicated by server, or a gameplay cue, however you prefer

#

It would, but if you have any gameplay-relevant physics objects you can't NOT simulate them server-side anyway

#

And by gameplay relevant I mean basically anything that has physics and collision

#

The biggest area you'll see server load, usually, is by far character movement and replication prioritisation. Physics is a small fish in the pond

#

10 vehicles is nothing

#

I'm doing 100 without issue

#

I mean if you want 60 vehicles, you need to spec server hardware to cope with it. They aren't crazy expensive but obviously aren't cheap either - but if you're making a game with 60 vehicles it's reasonable to spend a lot of the servers time coping with them.

lusty coral
#

Has anyone tried to implement a head bang kind of thing as a emote thing with the crowd?

chrome bay
#

The other issue is how you deal with anything that isn't client controlled, what then

#

Client-owned chaos vehicles are client-authoritative out of the box IIRC

#

CMC is much more expensive usually yeah. Disabling primitive overlaps also gives a big chunk of performance back usually

#

The main thing you'll be up against with a high player/bject count is the CPU time the server spends deciding what to replicate. Unfortunately the engine isn't very efficient at that currently. Iris should improve it a fair bit but that comes with a loooot of integration time atm.

#

The engine is building that currently

#

Still experimental (and chaos vehicles are due a huge overhaul to come with)

#

Physics prediction is insanely hard

#

Not strictly, the server basically accepts whatever inputs the client gives it, and sends that out immediately to other clients. The prediction model adds some latency but allows the server to fully simulate the vehicle first

#

Server-auth physics is almost always a hueristic of some nature. Perfect is nigh on impossible

#

I would just heed caution when it comes to saying anything networking + physics is easy 😄

#

Many have been down this road 😄

#

I've been in this pit of despair since pre-UE4 days

#

Any solutions are usually highly game specific

flat night
#

what do you guys use to get Steam avatars and names in C++? The AdvanceSessionsLibrary or?

chrome bay
#

I have no idea why people choose to use SmoothSync for physics vehicles. This stuff exists in the engine already

#

all physics objects inclusive of vehicles use physics based interpolation when they are replicated from the server. It's adjustable in project settings.

nova wasp
#

as long as you have a known pair of states you can interpolate them

#

the issue is how you make up for not having the pair of states on time or in a constant rate

chrome bay
#

Chaos has no GPU acceleration

#

would be impossible to run it on servers otherwise

rocky kestrel
#

What is correct way to get controller in RPC? This is in Player controller blueprint. That function is called from pawn when I want to save player for server.

#

Or should I just use that replicated SteamID in gamemode to loop all controllers (set in OnLogin) to check steamID == SteamID and forget inoutting controller.

twin juniper
#

I am trying to look for an event that is called when the PlayerState ready on server. Just like this one, but PlayerState.

plucky prawn
plucky prawn
chrome bay
plucky prawn
#

I am confusion about what that means. If my server had a gpu why would players need to rent a server 😐

dark edge
#

That's basically the physics replication system that's been in the engine forever

#

and 50m is nuts

rich crag
#

Hey friends. Still banging my head against the wall. Trying to figure out why the rotational value set by input and using repnotify for player sync is desyncing with actor speed... at low speeds, all inputs and values properly replicate. as the speed increases, the desync gets worse until the server stops reporting a value change completely. Im using a server RPC to set the rotational value from input.

#

this is all local testing so server and client are on the same system

umbral tangle
#

if I am not mistaken, replication priority falls with distance, could that be the issue?

rich crag
#

wait what?

#

now thats new

umbral tangle
#

I believe that if the pawns of two clients are close to each other, updates will be provided more frequently compared to two pawns that are further apart

rich crag
#

OH yeah ok replication to the player falls with distance between actors

#

but my character should be colocated with the helm, as well as the ship. there should be no distance change there

umbral tangle
rich crag
#

I likely have not. so a-reading I will go. Thanks!

hexed flower
#

Hello there !
I am a bit confused about the CharacterMovementComponent's prediction architecture in cpp.
I'm developing a system that computes a Location & Rotation each frame for a character to attain a target in a set amount of time (Like a homing dash). I used to add the computed Location & rotation delta each frame to my AActor* but it does not work in an online setup and was very rubberbandish.
I learned recently about FSavedMove and MoveAutonomous and added the computed Location & Rotation to a custom FCharacterNetworkMoveData, for it to be sent to the server. But I don't really know what to do with it once received by the server.

So I'm wondering if Unreal has a built in solution to pass fixed Position and Rotation instead of velocity and acceleration, and if not, where should I look to achieve it ?

#

Thank you @uneven dock I'll look into it

cobalt pollen
crisp shard
#

is there any major performance hits when "replicating" a float variable for example? basic Q, but just curious on how much replicating a simple variable can cause problems?

solemn dirge
#

the only performance hits i could imagine would be if you were replicating 10000 on tick lmao

crisp shard
solemn dirge
#

what is teh purpose of it?

#

if it is unchanging, you might be able to just drop it into a class and call it a day

#

alternative, you could just replicate it whenever it updates, depending on how frequently it updates

crisp shard
# solemn dirge what is teh purpose of it?

it's the health of a hit actor, so when attacking/hitting something w health, it gets the health from that actor and uses that variable for effecting the pitch of SFX. so the closer to death of that hit actor it will pitch the SFX up until death

solar stirrup
#

Replicate as little as you can but don't go for premature optimization

#

I'm guessing it's a health variable for actors?

solemn dirge
#

shouldnt be a problem replicating actor health lol, replicate on hit to adjust all clients understanding of that specific actors health

crisp shard
crisp shard
solar stirrup
#

The server doesn't send a replicated property to clients every time it updates

#

It does so on an interval

#

Just don't use RPCs for that and you're fine :^)

crisp shard
#

ahhh interesting, that makes sense as to why sometimes the actual health the health i got back are slightly different sometimes

#

so i should NOT do this then lmaooo

dark edge
crisp shard
dark edge
#

just..... get its health

#

why is a run on server event involved here

crisp shard
#

for the client that is

dark edge
#

how many of these things you'll be hitting are around?

#

1, 10, 100, 1000?

crisp shard
dark edge
#

ya

crisp shard
#

i mean, could be 10, could be 100, probalby not 1000

#

could be 1

#

lol

#

it would depend on the context of what's happening

dark edge
#

Any particular reason health isn't just a replicated variable on the things you're hitting?

crisp shard
#

hence why i did this

#

the character has a health varaible in a struct

dark edge
#

What do you mean by THE character? Are characters the things you're hitting?

crisp shard
#

i didn't want to replicate the struct

dark edge
#

I mean you kinda have to replicate the health if you want access to it clientside. Why don't you want to replicate the struct?

crisp shard
#

i just didn't want it to be something that causes issues

#

i suppose the struct is all just float variables anyway

dark edge
#

Things have health.
You presumably want the current health of thinys to be in sync with the server's version of things.
You want to play a sound based on health when you hit something.

Simplest version is just to do a clientside hit and play the sound, no networking directly involved at all.

#

Whether or not the hits are predicted or whatever is another matter, but on the client you should have access to some version of the health, use that

crisp shard
dark edge
#

it's not predicting or you're just reading health before the damage application? Do you want to drive the sound by the hp before or after the hit?

crisp shard
dark edge
#

assuming the client has all the info, just do the math and play sound based on post-hit hp value

crisp shard
#

i'd like that sfx that is effected by the health variable to be in realtime, but i'd have to do damage on that client

dark edge
#

You're in the realm of predicting hits and effects at this point

crisp shard
dark edge
#

sync seeds up or use random from stream or whatever

#

if you want to predict it correctly it's a lot of work, that's what's ahead of you unless you just want to wait on the round trip to server to play the sound

crisp shard
stoic lake
#

is there a way to get custom information like a password from a session before joining it? (Without using advanced sessions or another plugin)

crisp shard
#

sync seeds up? or use random from stream? never heard of either

dark edge
#

that way you can roll the same random number on server and client

#

I've never used it but something like that is the ticket

crisp shard
dark edge
#

so what do you do on a mispredict?

crisp shard
#

i've actually been trying to figure this out lol

#

for example, when a client hits but server doesnt

#

i'd like to have a "miss" thing happen

dark edge
#

welcome to multiplayer lol

crisp shard
#

lmfao i love it

dark edge
#

Hit...... oh wait nvm MISS

crisp shard
#

dmg numbers don't show when client misses, but i'd like to go even further by making that number show "0" or "miss" and how would i start to think about doing that?

dark edge
#

do you mean a miss as in a predictable miss or one where the server doesn't agree?

#

like hit chance?

crisp shard
#

\

dark edge
#

Then there's nothing to do if you want hits to be predicted

#

the hit already happened clientside, can't really take it back

crisp shard
#

ok , well thats good to know then, and makes sense. is there another way of doing it where this can be mediated?

#

like going back and forth from server to client back to server?

#

client to server to client to server

dark edge
#

I think most systems just favor the shooter in some way if it is a shooter (making mispredictions rare)

#

some only show hits when validated

crisp shard
#

kinda seems opposite to what you'd want

dark edge
#

Client says hit -> server says "yeah probably hit" -> it's all good

crisp shard
#

maybe im misinterpreting

dark edge
#

server rules out and nullifies obvious misses

#

but it's a fact of life that if you have predicted movement or predicted anything really, the 3 game worlds (owning client, server, other client) fundamentally do NOT agree

#

so the choice is between a shooter saying "hey that's bullshit I hit that guy!" or the shootee saying "hey that's bullshit I was around the corner!"

crisp shard
#

for sure, i like how you put that. it's all an illusion in some ways. just about making the illusion seem very real

dark edge
#

It feels better to hit when the hit happens on your screen than it feels bad to be hit when it didn't happen on your screen. You pay more attention to your own actions then the actions of others, so your own actions need to be reflected in the game state the most accurately

#

I'd start with a hit being a hit if the attacking client says so, then incorporate the synced randomness, then the geometric hit validation (did the thing actually hit in 3d space)

crisp shard
# dark edge It feels better to hit when the hit happens on your screen than it feels bad to ...

yea i'd agree here for sure. especially if im doing hit FX on client prior to server.

im bascially doing the same overlap event (sword swing for example) on client and server, and if the client hits, it runs the same exact fucntions on server, but perhaps i can just send the info im gettting from the client, straight to the server? and then use that info only if the client says hit, then check the server w that info?

#

cuase im bascially doing 2 seperate overlap events (one on client and one on server) and there are defintley times where client and server are not matched up due to character location/etc just not being fully in sync (testing under latent envorment)

solemn dirge
#

Guys im trying to get working proximity chat in my game, and cant tell if its working. Any suggestions on how to debug?

This is my current blueprint

rain condor
#

I have an inventory with arrays. When i drop an item to world, this is removed only vissualy but it's still occupying a space

split swift
#

i have a system where you can pickup and drop weapons but whenever someone picks up a weapon that has been dropped by a player, the pickup target isnt reading for the destroy actor

rain condor
#

Unlink destroy actor.. it works?

split swift
rain condor
#

?

#

Disconnect destroy actor on sv

split swift
rain condor
#

i'm only trying

#

Show me drop func

thin stratus
split swift
thin stratus
#

No clue who that is

#

Question remains

split swift
#

what would i do instead

thin stratus
#

A replicated Actor can only be destroyed by the Server and that automatically causes it to destroy locally

#

Also does your Equip Weapon call ultimately RPC to the Server?

split swift
#

yes

thin stratus
#

Destroy Actor On Server is also such as strange thing to do

#

You should RPC when your Press E

#

And then get the Overlaps on the Server

#

And then you don't need any other RPC

#

Also your Pickup param might be null if your weapon isn't actually a replicated Actor

split swift
thin stratus
#

You'd need to show your code

cobalt pollen
#

y'all I implemented AI navigation on a moving mesh for my multiplayer game (I used the sea of thieves method where I have static versions of the ships with AI actors pathfinding on them and then translate that to movement on the moving ship) and now after trying it I'm realizing the movement doesn't add much to the game (takes away from managing the AI characters) and am probably going to scrap it 😂 😭

thin stratus
#

And alos confirm the weapon is replicated

split swift
split swift
thin stratus
split swift
thin stratus
#

Your changed code

#

You said you call an RPC now on E

split swift
thin stratus
#

And what part isn't working now? Did you remove the other RPCs?

#

The code should be:

E -> RPC -> Interact -> Equip -> Destroy

#

And are you getting any errors?

#

(after stopping to play)