#multiplayer

1 messages · Page 163 of 1

dark edge
#

So it's like this:
Character:
Button press -> run on server event
run on server event -> select what to do (let's say it's to mine)
Serverside char sets repnotify CurrentActiveResourceNode or CurrentActiveRock or whatever
Onrep -> show the minigame UI for CurrentActiveRock

Minigame:
??? -> Won -> call MyCharacter.MiningSucceeded

Character:
MiningSucceeded -> run on server event MineRock(CurrentActiveRock)
MineRock -> pop the rock

serene furnace
#

I tryed making a few safety still, even Aiming is somehow a bit offset and random so that people needs to aim for real x)

dark edge
#

Basically what the server sees is that it said "yup you're mining this rock", then later the client said "yup i succeeded, pop the rock"

#

this is 100% cheatable but I'd start here

#

if you wanted to make cheating not a thing you'd have to have the state of the minigame be serverside too, that'd be spawning an actor representing the minigame and doing networking during minigame play

serene furnace
#

yeah but the "rock mined" is set by the server ^^

dark edge
#

yes

#

read my pseudocode, the serverside version of the character chose the rock

serene furnace
#

there is no existing ways to prevent cheating anyway x)

dark edge
#

Set it up such that you can just skip the minigame for now and directly call the RPC to pop the rock once CurrentActiveRock onrep fires, later put the minigame in between

serene furnace
#

but yeah what you said is pretty much the only option I could think of if I'm not going for "Actors calls server event" version

dark edge
#

you need to do that

#

how would hte server know anything then? It wouldn't know the rock is being mined, and it wouldn't know the mining succeeded

serene furnace
#

it was working for just one player, not letting other people mine at the same time x)

basically widget said "Hey we succed to mini game lets call the actor to spawn a rock"

#

but somehow between one client to another, the ownership of the first client was changed when a second client interacted even tho, both said "owner is the server"

dark edge
#

don't bring ownership into this

serene furnace
#

yeah thats making things way too messy at the end of the day lol

dark edge
#

your interface with the game world is your pawn, use it. It'd be best to make it way more general but for now make RunOnServer events like:

WantToMineTheClosestRock
and
OKIMinedThisRockNowPopIt

#

that's what the server sees

serene furnace
#

yeah i'm going for that RN and remaking it into pawn

dark edge
#

you could just as easily do it like:
WantToMineThisSpecificRock
or
WantToInteractWithSomething (the most general and what you'd eventually end up with)

serene furnace
#

I already have a "im interacting with what ever item is close to me" function, yeah

#

it's not on a beginning point of dev ^^

I'm on it for a couple years now lol

dark edge
#

yup, so interacting with a rock, the rock tells InteractingPawn "hey, I'm a rock, set RockImTryingToMine to me"

#

the onrep fires, the widget shows up

#

later, if you succeed, the widget tells the char to tell serverside char "yup I mined RockImTryingToMine, pop it now"

#

If you wanted it to be cheat resistant you'd do it like:
"hey InteractingCharacter, here's a MinigameActor I just spawned for you to deal with"

serene furnace
#

well thats what I'm doing, the server fires a Client side event to open the widget

dark edge
#

that MinigameActor could have its ownership set to the player so it can directly RPC through it

serene furnace
dark edge
#

you can make the replication condition owner only

#

but it's just better to have events that respond to state be driven by repnotify

#

the state is "I'm interacting with this rock"

serene furnace
#

why is it "better"

I mean rep notify only fires when the condition changes, then it means I would have one more function per minigame instead of one big Event graph with all minigames

dark edge
#

OnRep_CurrentRock -> if CurrentRock.IsValid -> true -> show CurrentRock.MinigameWidget
-> false -> hide any MinigameWidgets

#

Now if CurrentRock gets set to null like when the char gets killed, or walks away, or the rock gets mined, it'll Just Work™️

serene furnace
#

thats what I'm doing with owning client tho ?

if you get out of collision sphere of the rock, the menu closes

#

and you can only interacting if you are overlapping with the sphere

dark edge
#

I mean you do you but RepNotify is the most robust way to do something like this. That way your code can just be like a state machine.

serene furnace
#

well since the widget is closing if you leave the collision sphere of the item, and the item is not movable in anyway, and handled only by server

I guess it's overall even more protected than I thought lol

#

and then the only way to get a ref to the proper rock to mine is to directly interact with it withing this sphere x)
Packet injection will probably be the worst for my project

People triggering event like "hey I minned properly" from outside 🥲

#

even packet encoding wont save you, they would just inject encoded packets until they find the right one lol

serene furnace
#

well yeah I was stupid, using the " get owned player pawn" from the widget gives a super fast way to get the pawn and something that can call server event.

And then from the interact event set a variable "item im interacting with" on the server gives me a safe way to get "what ever item i'm currently interacting with"
to keep track on "who is mining what"

And from there trigger a server event that spawn item on mining sucessfull and set transform to make everyone see that the rock goes smaller and smaller

#

I guess it was a good way to see how the engine is handling the ability to call a server event and such

rough dock
#

should a match timer be in the gamemode then replicated to the game state or should it just already be in the gamestate

#

having trouble with match flow since it can only be set in the gamemode and stuff

peak mirage
#

Could you please elaborate this a little more? Official document does say how to enable Iris, but not tell how to use them, for example, how to tell the system a property is marked dirty.

obtuse field
#

In FSocket if I want to send the data, I put all the data in one Send function, and it will chunk it for me, right?

sinful tree
fallen sparrow
#

Hey guys, Client crashes with a fatal error on execution of servertravel.

Any Ideas?

#

It works in editor but in packaged builds it crashes. UE 5.2.1 blueprint project with Advanced Sessions and Steam sessions.

plush shoal
#

@thin stratus I have gotten logs

obtuse field
#

And package it as DebugGame

obtuse field
fallen sparrow
#

Thanks for the response man, I've never debugged a packaged product before so this'll be new

obtuse field
plush shoal
#

I don't have a print string but I'll be able to tell anyway

#

It appears to be line 1972 on the client @obtuse field

#

You see it loop back to the default level because of the playfab request

#

[2024.03.18-01.50.31:319][ 42]LogSteamSocketsAPI: Verbose: SteamSockets API: Log [#1335973175 P2P SDR steamid:76561198357159093 vport 7777] closed by peer (5010): Relay received unexpected noconnection packet

#

seems to be the failure

#

Seems to be on Steams end

#

It appears that maybe there's some misconfigurations in my .ini file

#

(Based on a community fourm I found describing the error code even though its in a different context)

#

This might potentially be the issue

#

it seems there was a duplicate line along with extra netcode at the top

#

I'll let you know if the clean up of engine.ini fixed it

obtuse field
#

How can I get connected cliens from FSocket server?

obtuse field
#

I see that there is a function HasPendingConnection, but it doesn't return the meaningful data about the connection

gloomy tiger
#

Nested FFastArraySerializer won't trigger their PostReplicatedAdd by design, right?

chrome bay
#

You can't nest FFastArraySerializer at all. It'll replicate like a regular property

#

Only object-level UPROPERTY's can use delta serialization

gloomy tiger
#

But yeah, that makes sense. Thank you.

static lava
#

During movement with prediction where you do: Server Tells you you have been slowed(or rootmostionsource movement like knockback is applied) to the client-> client applies slow effect(prediction)->calls back server to know it started prediction and server can also apply

#

How do you make sure it cannot be cheated? Like say server sends you a slow effect

#

And you don't call server back, should there be a failsafe timer that slows you on server anyways after a given time like 500-600ms?

#

Is there a more elegant solution or this should do it?

#

As cheating on private servers is still an issue even in non hardcore games that still have competitive elements like Survival games

chrome bay
mental pendant
#

If I call a Server RPC on the Pawn from my AnimInstance, is that going to be called multiple times for each client replicating the pawn?

gloomy tiger
#

I currently have this design:

struct FMyTrait {
  UPROPERTY()
  FGameplayTag Id;

  UPROPERTY()
  float Value;
}

struct FMyEntity {
  UPROPERTY()  
  FGuid Id;

  UPROPERTY()
  TArray<FMyTrait> Traits;
}

class UMyActorComponent : UActorComponent {
  UPROPERTY(Replicated)
  TArray<FMyEntity> Entities;
}

To summarize the problem with this design: whenever I change a single FMyTrait of FMyEntity, all the other traits would be replicated as well, whereas I'd like just the changed one to go over the network.

That said, do you have any suggestions on how to improve this design so it is more network-efficient?

#

Or rather, I just came to the realisation I don't know the following for a fact - are TArray<...>s delta-serialized by default? In the sense - if I add something into a replicated TArray<...>, will that single value be transmitted over the network or its default is atomic?

gloomy tiger
mental pendant
gloomy tiger
mental pendant
gloomy tiger
mental pendant
gloomy tiger
#

Oh, wait

#

Nah, ignore me. *Server* RPC.

mental pendant
#

I want the client to decide when to trigger the next step (because that's smoother for the player) but still let the server call, and multicast, the function. Like, inserting a new mag after the animation for ejecting it has finished, this is something I wanna trigger from the client (so the animation is smooth) but then it's the server telling everyone to insert a new mag

gloomy tiger
#

🤔

#

But I feel you don't need that RPC neither, because the server knows when the animation has started and it also knows when it has finished (not sure about Dedicated Servers, though.)

#

I mean - these are not questions you are asking, am just spitting out randomly

mental pendant
#

yeah that's where my doubt started, I don't get how AnimInstance works with replication.. like, if the server gets an AnimNotify, is the client in control of the pawn receiving it at the same time? Since it's a UObject is not replicated afaik

#

hence why I am using a Server RPC 👀 I want the controlling client to trigger the new animation when it sees the old one finishing

gloomy tiger
#

I believe the only RPC you want is StartReloading(), for example

#

Because the rest is fairly predictable

#

If you're listen server, then the server knows which animation is running, hence the AnimNotify will trigger there as well

mental pendant
#

ideally yes, I am probably mixing up state changes with cosmetics at intermediate steps of the ability

gloomy tiger
#

Are you going with listen server or dedicated?

mental pendant
#

listen

gloomy tiger
#

So yea, probably the single RPC you need for this entire pipeline is a StartReloading

#

You start the animation locally
And you start the animation remotely

The server, which is also a client, sees the animation, hence the AnimNotify is available to it. So the server naturally knows when the magazine has to be filled up.

mental pendant
#

I see, I was just thinking in case of lag this would cause weirdness on the client-side, but that's the client's fault I mean 👀

#

thank you this really helps!

gloomy tiger
solar stirrup
#

afaik only the fast array serializer supports delta replication, array wise

obtuse field
#

Is there a way to know if TCP server accepted connection on the client, without sending additional TCP call?

vagrant grail
#

Do we agree that saving players joigning the game in an array and get the 0th element will always return the host of the game in a listen server context ?

gloomy tiger
#

I may be mistaken, but it seems this is only true for remove operations? 🤔

lament flax
#

i got a replicated actor

from the server i want to call an event on the client

the server fires the event, but for some reasons it get executed on server (instead of client)
its not a debug bug since it only prints "Server :..." in the output log

any ideas ?

#

first time i got this bug

#

looks like this is the source of it

warm lintel
lament flax
#

on the breakpoint hit :

#

(i have only 1 client rn)

#

when doing multicast it is called on server and client

warm lintel
#

far as I know at least

chrome bay
#

correcto

#

Can't call a Server RPC on something you're not the "Net Owner" of. And only one player at a time can be a Net Owner of an actor

lament flax
#

oh

#

so i am forced to use multicast and filter with a authority switch ?

chrome bay
#

You can't call a multicast from a client

#

If many clients can interact with one actor at a time, you need to route the call via something you are the net owner of. This is a common thing for interaction systems for example, where you might put a component on your pawn or controller, with an RPC that takes a "target" actor parameter.

lament flax
#

the issue is to get to client side

fathom aspen
lament flax
#

ig i'll add a reroute to the player character

chrome bay
#

You're calling a Client RPC on the Server? Should be fine then - but only the Client who is the net owner of the actor will receive it

solar stirrup
chrome bay
#

If there is no net owner, it'll run on the Server itself

lament flax
chrome bay
#

What type are you calling the RPC on?

lament flax
#

actor

#

already placed in level before start

chrome bay
#

Ah, right yeah, so it has no net owner then

#

It belongs to the level, so no player owns it

lament flax
#

ill change the logic

the player character is owned by the client right ?

chrome bay
#

it is

#

This sounds like bad design already though

lament flax
#

okay, ill call a event from server on it to make it switch to client

chrome bay
#

If the actor is in the level, surely it's relevant to all clients?

lament flax
chrome bay
#

The actor pre-exists in the level, so surely every player can see it and/or whatever changes are made to it are relevant for everyone?

lament flax
#

the goal of executing this event to server side is to call a interface event on the HUD

#

the HUD is null when the server has the player controller ref (which is normal)

#

rn the 2 possible fixes i have in mind is :

  • calling a multicast on this actor, filter to get the "owning" client, then switch to client to call the event on the HUD
  • calling from server a event on the player character, then switch to client to call the event on the HUD
rich crag
#

can someone tell me why, when i cast to a child bp and it's replicated, i end up with two copies? As a standalone blueprint, it doesn't have the issue, but part of another blueprint, it does.

#

I had this problem with ladders on my ship and now having the same with doors in houses

queen escarp
#

if im sending positive value then it works but if i send a negative value it dosent work ??

frail barn
#

i need to create a team-based range-restricted visibility system
pawns of a same team is visible to each other, but invisible to another team pawns outside of a vision's range
i have 4 arrays for this, "all pawns in a team" for both teams, and "foes in a visibility range" for both teams
to make it work, all pawns is set to hidden in game, and some pawns need to be set visible by some criteria
so, the main question is:
how to say at the server side to every client separately - "unhide for yourself pawns from this array"?

hardy turtle
#

hi guys! is there anybody who can help me solve a little issue i have?
I know i can start a lobby by opening a level with the option listen

is there any way i can change that option on the current gamemode? what i would like to achieve would be having a main menu that turns into a listen server to have friends connect to it (as it became the actual lobby) and then start a game

Thank you!

queen escarp
#

i dont get it wtf is goinmg on 😮

obtuse field
#

I have such code, and for some reason, client is not receiving the data from the stream. Bytes Read is equeal to 0

if(IsRunningDedicatedServer())
{
TArray<uint8> Bytes;
        FMemoryWriter MemoryWriter(Bytes);

        TMap<int32, FInstanceBuildingData> PlacedInstances;

        TArray<int32> TestArr;
        TestArr.Add(14);
        TestArr.Add(15);
        TestArr.Add(16);
            
        MemoryWriter << TestArr;

        int32 BytesSend;

        UKismetSystemLibrary::PrintString(GetWorld(), "IS IT SENT??? " + FString::FromInt(Bytes.Num()) + " " + FString::FromInt(MemoryWriter.TotalSize()));
            
        TCPChunkDistributor->Send(Bytes.GetData(), MemoryWriter.TotalSize(), BytesSend);
        
        //TCPChunkDistributor->Recv(Data, BufferSize, BytesRead);
    }
    else
    {
        uint8 Data[4096];
        int32 BytesRead;
        
        ESocketConnectionState SocketConnectionState = TCPChunkDistributor->GetConnectionState();

        if(SocketConnectionState == SCS_Connected)
        {
            UKismetSystemLibrary::PrintString(GetWorld(), "CONNECTED");


            TCPChunkDistributor->Recv(Data, 4096, BytesRead);
        }
        else if(SocketConnectionState == SCS_NotConnected)
        {
            UKismetSystemLibrary::PrintString(GetWorld(), "NOT CONNECTED");
        }
        else if(SocketConnectionState == SCS_ConnectionError)
        {
            UKismetSystemLibrary::PrintString(GetWorld(), "CONNECTION ERROR");
        }

        UKismetSystemLibrary::PrintString(GetWorld(), "READ DATA: " + FString::FromInt(BytesRead));
    }
#

It says that it is connected btw

eternal canyon
obtuse field
#

How can I debug this?

queen escarp
#

@eternal canyon wdym ?

snow trail
queen escarp
#

No i mean

#

Sec ill show u

dark edge
#

the specific game mechanic

lament flax
dark edge
#

uh

#

You want to be able to walk up to a chest, press a button, and see the inventory right?

lament flax
#

yeah thats what i have working rn

dark edge
#

ok so what's the problem?

lament flax
#

the problem was that the actor is own by the server so the owning client was the server itself and not the player interacting with it

dark edge
#

thats fine

#

do the interaction rpc through something the player owns, usually the pawn

#

Pawn:
Input -> run on server event
run on server event -> figure out what to try interact with -> call Interact on it

#

done

queen escarp
#

@eternal canyon @snow trail they are both coming from the same event same conditions the + works and adds fine but the - dose nothing

lament flax
#

what ive done is that the server gets the actor and call the event inside

dark edge
#

the server what

#

just saying the server doesn't help

#

the serverside version of what actor?

lament flax
lament flax
dark edge
#

Just looking in inventories can be completely local, no need to have networking involved at all assuming the inventories are replicated

lament flax
#

btw can this step be passed ? does the server owning the chest knowns who owns the player as client ?

dark edge
#

no

#

none of that

lament flax
#

a player lagging could duplicate stuff

dark edge
#

ok first off, do you want to replicate your inventories or not?

lament flax
#

they are

queen escarp
#

adriel

#

any ideas in my case ?

magic vessel
#

Small question here, I'm trying to work on prevent cheating (such as packet sniffing) but I have no experience with this. What tools do hackers usually use to cheat that I can use to verify my tactics are working (or at least so I can tell my community that there have been efforts undertaken to limit cheating)

fallen sparrow
#

Hey Hive, I got the debug going and I caught the exception

#

Client Crash on ServerTravel

#

So I guess I'm wondering what's next, I never mess with the code or engine level stuff. I've messed with C++ in the past so I'm at least familiar with some of the syntax.

dark edge
#

What is the game mechanic you're trying to do?

frail barn
queen escarp
#

@dark edge well this is a char component thats why in using owning, its basicly a slow system

#

But i got it working kinda

dark edge
#

trivially cheatable, I can just set it to be 10,000 and zoom everywhere

dark edge
queen escarp
#

How would u change the speed from the local files u mean or?

dark edge
#

the server should say what speed you have

#

not a client

#

what changes the speed?

#

a debuff?

quaint frost
#

hi everyone! does anyone use replay system in case of showing epic moments directly in session? i see how it works and don’t see easy solution, so maybe someone have experience with this?

queen escarp
#

Yeah upon start the server dose set the speed

#

Yeah a debuff

dark edge
#

just do it all serverside

thin stratus
#

I linked this once

#

But I never implemented any of that

quaint frost
#

thank you! this is what I’m looking for, start point!

lament flax
#

if i code my game to have all players being clients, and my server to be a dedicated
but later on change, and have 1 player host (listen server (client & server)) and the other players being clients

would this mean i will have to redev some stuff ? or should i be fine ?

solar stirrup
#

Depends on how you handled your code

#

There's some pitfalls when a client is also the server

#

Better to handle it right off the bat if possible

lament flax
#

so its not possible (or very hard) to dev to make both working ?

solar stirrup
#

Not impossible, not hard at all

lament flax
#

what should be different then

solar stirrup
#

Just some edge cases you have to keep in mind

rich crag
#

Can someone please explain this???!! Conditions: have a replicated door (or interactable) that is a child blueprint of another blueprint. Cast to that child blueprint. Be in a map using world partition. - Under these conditions, I get a duplicate child that exists only on the (each) client. In the case of a door, a door opens, yet another door is there, but does not stop you from walking through (which is what tells me that it's on the client - you can walk through it because the server says it's open). Under any other conditions - the blueprint is standalone in an open world, the blueprint is a child of another blueprint but in non partitioned world, or you do not cast to the child blueprint, there is no duplicate. This is most unfortunate because I'm having problems getting non cast methods to properly replicate.

short arrow
#

but you should consider it if you haven't before

solar stirrup
# lament flax what should be different then
  • Rep notifies don't execute on the server (if you're using C++). Meaning a client that's also the server won't execute them automatically. You have to call them manually if you want them to run on the server.
  • Your server is also a client, so you want to be careful not to run cosmetics from other clients on the server as well.
  • Any code that you want to run when you don't have authority (for clients only) won't run on the listen server host (since they always have authority). Another thing you gotta be wary of (stuff like Switch Has Authority in blueprints, or HasAuthority() in C++). This is generally solved by checking if a pawn is locally controlled or an actor is locally owned instead of checking for authority.
#

Probably plenty more I can't think of right now

lament flax
solar stirrup
#

Shouldn't be costly at all

#

As always, profile before optimizing for no reason

lament flax
#

i've been doing as many authority/controlled pawn check as possible, so if i change the net mode, i'll probably have to redo stuff, but not most of it

#

and im in BP so rep notifies doesn't change behavior

#

also, im curious why doing "set members" in struct or changing arrays with "add","remove","clear" doesnt trigger repnotifies

#

i have to do stupid stuff like this to trigger it

solar stirrup
#

Blueprint rep notifies are a bit annoying since they get called in the setter of the variable or when it gets replicated

#

Any other modification won't call the rep notify

#

I'd recommend calling your rep notify function manually instead of setting

#

@lament flax

lament flax
#

how can i call them in BP ?

solar stirrup
#

Isn't it in the function list?

#

Not sure if you can call it manually actually, but try

#

If you can't, just have your rep notify function call another function that does the processing you want

lament flax
#

not callable

#

i think i already tried

solar stirrup
#

That way when you want to call it manually, you just call the function the notify calls

#

Cleaner imo

lament flax
#

yeah i did this trick, using a useless bool var

#

somewhere elses

lament flax
rich crag
#

on the parent. It does not matter if the child is spatially loaded.

indigo brook
#

If you guys were to relearn how to make a multiplayer game, what advice would you give yourself?

fallen sparrow
#

do it from the start in C++

indigo brook
#

That's fair, there's more things to control with there for sure

fallen sparrow
#

Its not so much about the control, its that there are quite a few engine hickups that without it you are just SOL

indigo brook
#

I'm on my multiplayer learning journey and I gotta say, I think I'm asking the wrong quesions to myself when creating. I don't fully understand the rules and I'm feeling a bit lost haha.

mental pendant
#

What is the proper way to check if a Pawn is on the server? I am running an HasAuthority() check inside my pawn's BeginPlay() where I do some initialization, but it's getting called on both client and server. I only want to do this initialization on the server

fallen sparrow
#

Like my issue currently lol. ServerTravel causes a fatal error on the client side related to a null pointer somewhere in the Chaos physics. So I'm starting my journey of fiddleing for better or worse to get it to work.

indigo brook
#

That's great news!

#

I'm trying to f*** around with skeletal mesh cosmetics changing but I can't seem to grasp the replication side of things. I get close, but it feels dirty

fallen sparrow
fallen sparrow
indigo brook
#

Aye, truer words were never spoken!

#

Server is the god, and everything has to pass by the server, but my issue is when you are the client trying to get info from your own PC or the clients Game Instance to the other players

fallen sparrow
#

What kind of data are you wanting to go where

mental pendant
indigo brook
#

If it's a listen server then on the wall it goes!

mental pendant
#

on the widget

indigo brook
# fallen sparrow What kind of data are you wanting to go where

Example, I spawn a third person character into the lobby map. I have 1-5 players. Each player that spawns in has to also pass along their cosmetic (head, torso, legs) struct. Then that has to basically show the right parts on their custom character. It's something that's been done for over a decade in multiplayer games but I can't figure it out haha

fallen sparrow
#

A guess a hypothetical Chriss, if you want to have other clients see your players new skeletal mesh, you'll have to Server RPC the mesh change on the client and then multi that client change to all the others

#

ClientChangeMesh->ServerChangeMesh->Multi everyone change mesh

solar stirrup
#

You don't want to use a multicast RPC for this but a replicated property

#

Since this is a stateful change

indigo brook
#

@solar stirrup I've been using repnotify for that for sure

#

I seem to get things to work okay, but it's like wack a mole, I fix one issue and another pops up. Example, my character can change items fine on server, but then the client, when changing items via widget and struct, it crumples the body parts at root location haha

fallen sparrow
#

scaling issue?

indigo brook
#

Naw, it's a body part issue. So in the struct, I SetMembers of the head, or Set Member of torso. However, on the client, it zeros out all the other struct slots, thus, no Mesh (body) and the parts just go to root. However, the struct works fine, same system on server. It's the weirdest thing

#

Wack a mole all day

#

Or character clothes spawn fine in the lobby but not the game. Or vice versa, clothes don't spawn in lobby but do in game haha

fallen sparrow
#

I know that replicating structs introduces some problems lol

indigo brook
#

Right?!

fallen sparrow
#

Ive never been able to pass a struct directly in replication but passing replicated varriables into a struct works just fine

#

In my project items are structs. When the player encounters a pickup, the pickup calls the server to set the varriables in the object struct and deletes itself, if I try passing a struct to struct nothing is set

indigo brook
#

Yeah, the struct only houses skel mesh slots, originally it was integers but you'd think it wouldn't be an issue

fallen sparrow
#

Passing skeletal mesh assets as a struct could be an issue I feel like, have you thought about instead of passing a mesh, passing an integer for a switch that predetermines skeletal mesh assets on the client?

indigo brook
#

Yeah, I could do that. Are you sure structs have these kind of issues with multiplayer usually? If you way it does I might try that technique

fallen sparrow
#

Well my struct does have a skeletal mesh so im not sure

#

I'll post a picture

solar stirrup
#

Sounds like you're doing something wrong Thonk

indigo brook
#

This is what I have for my structs, the S_CharCustomization is just skel mesh slots

#

I'm experimenting, so this dosn't work right now (which is expected)

solar stirrup
#

What's the type of Body Parts/Head Parts etc

#

(also why not replicate the entire struct instead of each member individually?)

indigo brook
#

I messed around with replicating the struct too. Again, I've been playing try this, try that game today haha. It's one of those things were you try 1000 things, forget which works in one build but not the other

#

Hence why I feel lost, I don't fully understand the rules, but I'm throwing speghetti at the wall to see what sticks hah

indigo brook
fallen sparrow
#

well im a faily acomplished spaghetti thrower lol

solar stirrup
#

Those should work

indigo brook
#

Right! haha

solar stirrup
#

Assuming they're assets on the disk

indigo brook
#

Indeed they are

solar stirrup
#

What's the issue

indigo brook
indigo brook
# solar stirrup What's the issue

The main issue is that I need to learn how to do network communication. I understand the basics, but there's some techniques I don't know how to accomplish

fallen sparrow
#

Here's how I do my weapon struct

indigo brook
#

Like how do I pass a clients game instance info to the server and the server then distrubutes that info to the other clients (their custom characters look like what the clients set up)

solar stirrup
#

Game instances are not replicated

indigo brook
fallen sparrow
#

The GameMode is persistent on the server

solar stirrup
#

If you mean you saved the player's character customization info in the GameInstance, you can just then call a Server RPC on an actor the player owns (PlayerController, PlayerState, Pawn if currently possessed)

#

Don't use the gamemode for this, not really the place for that

solar stirrup
# indigo brook

This looks okay however, you would only want to call the Server RPC on the client (so the client sends the server their desired character look after loading it)

indigo brook
solar stirrup
#

For simplicity's sake since you're beginning, I would recommend doing this on the PlayerController

#

Each client only has access to their own, the server has access to them all

indigo brook
fallen sparrow
#

PCs are persistent as well

solar stirrup
#

Your weapon definitions should be in something like a Data Asset or Data Table

indigo brook
#

@solar stirrup Aye, I spawn the player in the PC

solar stirrup
#

A lot of the info you're replicating doesn't need to be replicated, it's static info that should be loaded from a data asset or something

indigo brook
#

I wish I could take better pics of the graphs

fallen sparrow
#

That's true, an optimization effort for the future for sure

solar stirrup
solar stirrup
fallen sparrow
#

Well I'm currently hard stopped at the client fatal erroring and exception to do with the Chaos phisics during a servertravel call, so I doubt if I'll ever get to that point

indigo brook
#

Alrighty guys thanks for answering, I wish I had more energy to continue haha I was working on this all day and am burnt out for now. I appreciate the assistance guys, you rock

solar stirrup
#

good luck to both of you

fallen sparrow
#

Yeah np man, hope you get it figured out

indigo brook
#

@solar stirrup I don't want to be that guy, but you seem to have a good solid grip of networking system, would you be able to (not all the time) review and correct my work? Aka, can I friend you?

#

I'm looking for Networking Sensi's

solar stirrup
#

Sure, I'll answer whenever I have time ^^

indigo brook
#

I'll be sure not to spam, just need some correcting.

#

Thanks @fallen sparrow for answering as well, I hope you get your Chaos physics server travel issue fixed too!

frigid elk
#

What is a really good resource for me to learn how to stop my client from rubber banding like crazy

#

smoothsync does not work for me so far btw so i could be destorying the connection another way

reef bison
#

I am seeing a very odd behavior with my inventory. when an item is added to the inventory I do a broadcast to the UI so it can be updated, this works when playing as a listening server but if I have 1 client and 1 listening server, whenever the client pick ups an item the server also gets one (in the UI) because the broadcast is also running there

I narrowed down the issue to a broadcast call that I added because of the server but I have no idea how to only run this code if the inventory is from the server. I thought it would just be a matter of doing a check for authority on GetOwnerRole but for some its always returning the component from the server?

my steps to recreate the issue:

  1. I open two games: client and listen server and their inventories. both are listening for the broadcast so the UI can be updated
  2. the client picks up an item. this is triggered by the OverlapBegin function in the drop actor, all the code onwards is running on the server (because of if (!HasAuthority()) return)
  3. I get the actor that collided with the drop, then the controller and then the inventory manager component
  4. I call the function to add the item to the inventory. this all bubbles down through some stuff until it hits the broadcast where I am trying to do the check. this is the code I have:
if (OwnerComponent && OwnerComponent->GetOwnerRole() == ROLE_Authority)
{
    UE_LOG(LogTemp, Warning, TEXT("Owner: %s"), *OwnerComponent.GetFullName());
    BroadcastAddedMessage(NewEntry);    
}
  1. even through all of this happened from the inventory component of the client player, the OwnerComponent is pointing to the server's inventory component. why? ablobdizzy
#

ok maybe my question is too big ThinkDerp I added some logs in the drop actor and I seeing the weird behavior so I will simplify it:

void ATerraWorldItemDrop::OverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
    UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
    if (!HasAuthority() || bHasBeenCollected) return;

    // Server-side code
    const ATerraCharacter* Character = Cast<ATerraCharacter>(OtherActor);
    if (!Character) return;

    UE_LOG(LogTemp, Warning, TEXT("Character controller: %s"), *Character->Controller.GetFullName());
}

why is the controller always from the server if the character that collided with the drop is from the client?

fossil spoke
#

HasAuthority() && IsLocallyControlled() == Listen Server host controller.
HasAuthority() && !IsLocallyControlled() == Server side but looking at a Client owned controller.

#

The Server always has authority over all Actors, so its not a sufficient check on its own in this case.

reef bison
#

I just noticed that I understood the logs wrong. what I was logging was the actor component from the client but instanced on the server, which makes sense

#

I just need to find a way to get a reference to the pawn to try this now NkoHmm

hoary spear
#

Cond_OwnerOnly?

reef bison
#

the IsLocallyControlled check worked, thanks!

reef bison
#

I am not sure if that would help because the code to add an item in the inventory always runs in the server

fossil spoke
reef bison
#

in the subject of replication, I know that unreal networking model is authoritative but is there a way to invert this for a few properties? e.g. the items in the inventory have a position and I dont want the user to notice the delay when reorganizing the items, is it possible to let the client "own" the inventory authority and replicate it back to the server?

fossil spoke
#

But what you probably want to do, is have the Client "predict" (perform the move operation locally) that the Server will tell them they did a valid move. If they didnt do a valid move, the Server would tell the Client and the Client would effectively rollback that move so that it remains in sync with the Server.

reef bison
#

I thought about doing that but it sounds like a lot of work to implement it 😅

fossil spoke
#

It is.

#

Welcome to having to deal with Latency.

reef bison
#

for the record the game I am developing is similar to terraria so I am prioritizing a better experience for players with high ping than having it being anti-cheat

reef bison
#

btw thanks for the GenericItemization repo, I was peeking at the sample the other day to figure out how to build a part of my UI ablobsmilehappy

fossil spoke
fossil spoke
#

But the general idea is that you get the Client to run the same code that the Server would run, but allow the Server to still be authoritative over the final result.

#

It can get complicated.

hoary spear
#

Which for me feels like a natural place to call it

reef bison
#

but I understand this is a long shot since unreal is all about authoritative networking, I might need to implement this myself

hoary spear
#

Question is can you trust the client to that degree?

reef bison
#

either way I appreciate the help so far, I will continue with the server inventory and think about changing it later on if the delay is too annoying

reef bison
#

it would be awesome if I could do everything on the server but it's a trade-off for high latency players

hoary spear
#

I run it all on the servrr and cant say the delay have bothered me that much. How often is a player starring at their inventory while picking something up

#

Feels like a partially self-constructed problem

#

I do async loading aswell so im bound to have delays 😅

fossil spoke
reef bison
#

I will keep an eye on it but its good to know that you dont have issues with it

fossil spoke
reef bison
#

do you happen to have any resource explaining how to do that with unreal so I can study it more?

#

I think predicting the moves of the inventory isn't hard, what I have no idea how to do is the client/server version of the property because it needs to be changed by the client and then corrected by the server

fossil spoke
#

Unfortunately there isnt really a resource for it because it typically requires a feature specific implementation.

#

Just google client side prediction and see what you find

hoary spear
#

Prediction is definetly an option ofcourse^ eminent for other stuff

reef bison
#

got it, thank you! 🙏

dark parcel
#

Eg, request to insert item in X slot. Client commit the visual change (icons , text info, w.e) and then server rpc the request

#

What client change don't effect gameplay , only the visual aspect. So it may have health potion in the quick bar , but that won't be ready to use until server validate the move is valid

#

If the server comes back the correct data will be sync anyway

#

Sort of thought about it in a min, probably want to give deep thought depending on your project need

mystic estuary
#

It really depends on what exactly you are trying to do, but sometimes even a simple sound will make it to cover that ping. Character getting hurt, item being used, button being clicked, etc. It's so low effort, yet very efficient

reef bison
#

yeah I am anticipating too much a problem that I am not sure I really have at the moment

reef bison
#

actually I can just do an early update as soon as I do the RPC then the server will correct it with the callback NkoHmm

dark parcel
hoary spear
#

Just remember that it is prediction, not necessarily the ground truth

#

Only the server has the truth

reef bison
#

I got the equipment window working on the client and the server pepeHappy

#

my will to throw everything in the client is fading a bit, this is not that hard once I understand how it works

hoary spear
#

usually just gotta give it some thought

#

flow diagrams is my secret sauce to this

vagrant grail
#

Guys, why isn't the "Game Instance" in this graph ? Is the Game Instance server or client or both ?

thin stratus
vagrant grail
thin stratus
#

Usually you don't want to put such information there

vagrant grail
thin stratus
#

Lobby is already connected players?

#

And they select their role there?

vagrant grail
vagrant grail
# thin stratus And they select their role there?

no, there's no role selection there for anyone but just the host setting up the game by pressing buttons to say wich roles will be available when the game start (like in this screenshot, the host of the game has game settings menu where he can press those images to turn on / off the roles for when the game starts. The greyish images are the disabled roles and colored ones will be the one enabled).

So I'm looking for how properly to save those roles somewhere to use them in the next level to distribute those roles to people.

People suggested me the GameInstance to do that as it keeps data between levels, so that's why I'm kinda confused of you telling me it's not the right place to put such information 😄

#

The roles will be distributed randomly to people in the next level

thin stratus
#

But that's in the lobby

#

You have a bunch of ways to do that. The host is always a ListenServer?

vagrant grail
thin stratus
#

The host selecting the roles

vagrant grail
#

Then he will press a "START" button when everyone and everything is ready

#

to go to the next level

thin stratus
#

Then I would start with turning the selection into a string and pass it via the options string

#

You Server Travel for that

#

There you can add ?rolelist=

vagrant grail
#

where do I save the string first ?

thin stratus
#

And the string could be just roleA,roleB,roleC

#

Up to you but you pass it via the server travel command

#

The game mode has a variable called optionsstring

#

Which will have the data then

#

You just have to reconstruct it

vagrant grail
#

where should I use that "serverTravel" node ? GameMode ?

thin stratus
#

?rolelist=roleA,roleB

thin stratus
#

Otherwise you wouldn't be able to travel to the other level

#

Idk where you do that

vagrant grail
#

I'm trying to focus finishing the lobby part first with all the settings

thin stratus
#

Yeah then for example the GameMode

#

LobbyGameMode fwiw

maiden flame
#

Sorry to inject, but why not use the GameInstance?
All the information will be set by the server, so they can just load everything from their own GameInstance after changing levels/starting the match (without worrying about security as they already have authority).
This way you can re-use variables directly (or at least transmit them to the GameMode or something), rather than having to deconstruct and reconstruct them as a string.

maiden flame
#

I read that, so I'm just asking why not 😉

vagrant grail
#

The issue I have is that for some reason the variable I have in the game instance filled with enabled roles is always empty for some reason that I don't understand

dark parcel
#

tho for something like a Game Setting, passing it as an option thru argument totally make sense?

vagrant grail
#

This is my data table

dark parcel
#

might be too early, but it's purely a guess at this point

vagrant grail
dark parcel
#

up 2 you. You can do it when you click the host button if you like

#

what ever your project requires

#

why not just use get Data Table row?

#

Also the property name should be Name?

#

not Row Name?

#

like where is Row Name?

#

actually I don't know

#

never used the node

vagrant grail
vagrant grail
dark parcel
#

there's a way to get all the rows

short arrow
#

Get data table row names -> for each loop -> get data table row

vagrant grail
dark parcel
vagrant grail
short arrow
#

I also noticed you are passing those values into a replicated variable in the game instance

#

game instance isn't replicated IIRC

vagrant grail
#

argh

short arrow
#

if there's something you're trying to replicate in game instance, dollars to donate you should probably be doing it in either the game state or you should be making a new manager class to handle whatever it is you might be trying to do in there

#

the easiest way is to just replicate it in the gamestate

#

it'll work everytime, but that doesn't mean it's always where you'll want the logic, I just don't know what you're actually trying to replicate and why

vagrant grail
#

I'm so confused, I hate Epic for having 68495 different classes

hoary spear
#

Get yourself an overview

maiden flame
#

Moxie, he needs to transfer the information from the lobby level to the actual match level.
Either the GameInstance or transferring it as a Game Setting are valid options IMO.

hoary spear
#

Or travelstring

vagrant grail
hoary spear
#

depending on what this is and how much

hoary spear
vagrant grail
maiden flame
short arrow
#

Also it's a data table, its replicated by proxy @vagrant grail

maiden flame
#

Yeah, he has to move it from the instance to the GameState or something like that after changing levels. So all clients can see the roles available 🙂

vagrant grail
# hoary spear depending on what this is and how much

To simplify what I need with that is having the selected roles by the host save and trasfer to the gameplay level as I will need to replicate that to everyone if 1 setting is enabled (enabled in the gamesettings by the host), which is "Hidden Composition".

  • If set to true, Everyone in the game won't be able to know how many roles are still alive except 1 role being the exception who will be able to see how many of those roles are still alive and ingame.
  • If set to false, people will be able to see those roles on the right side on a UI Widget, and each time a role dies, it gets removed from that widget.
vagrant grail
hoary spear
#

cedric already suggested travelURL

vagrant grail
short arrow
#

In lobby store all information in game instance on server -> change levels -> Server RPC information from game state to clients, or transfer logic from game instance to game state and then replicate it

hoary spear
#

what else are we talking about here 😄

vagrant grail
hoary spear
#

Ok so:

  • Host Configures the game with the avaliable roles in lobby
  • Starts the game , moving everyone to playlevel
  • everyone gets assigned a random role from the avaliable ones
vagrant grail
#

The concept of the game is like the "Werewolves of Hollow Miller" or whatever the name in english is

hoary spear
#

fixed

hoary spear
#

anything else?

#

all clients can see all "alive" roles ?

vagrant grail
#

Depends if the setting "Hidden Composition" is checked or not (I don't have that settings created yet in the game setting image above).
If it's set to true, nobody will see "alive" roles, so they have to guess except 1 role being the "Mad Man" who will be able to have that list shown to him.
If it's set to false, everyone will see "alive" roles, and the "Mad Man" doesn't have that exception anymore so he becomes like a simple Villager

hoary spear
#

almost sounds like a custom replication condition

#

if you truly wanna hide it from the clients (so they cant cheat it so easily)

#

or ofcourse just a replicated bool letting the ui show it or not

vagrant grail
#

I never used "custom replication conditions"

lament flax
#

can i get this somewhere in game ? such as in the game state or game mode ?

hoary spear
#

the data is very shortlived, per game anyways so storing it anywhere permanent seems unnessesary

maiden flame
lament flax
maiden flame
#

Hm, well, the default Players array changes automatically depending on the amount of connections.
Did you try using it?

hoary spear
#

it representes the players currently connected / in the game

#

if you really want to use your int, you can update the int in code, by using said player array

maiden flame
#

^

lament flax
#

the player currently connect is one of the 2 values i am comparing

#

"total player count" can be seen as the "goal nb of player before we start the game"

hoary spear
#

logic sounds flawed if so

#

Target vs Actual is what we're talking about

lament flax
#

then, i'll ask the question i another way

how does multiplayer games knows when all player joined the game before starting ?

hoary spear
#

target is set as a server rule for joining players, while actual is the length of the rray

#

so before hosting , the host would configure "public connections" , which gets used during session creation

#

there's also the GetMaxPlayers method, which is this very same amount

vagrant grail
hoary spear
#

for which part?

vagrant grail
hoary spear
#

gameinstance is not replicated, so you'd need to RPC it yourself if you pick that route

#

gamestate is, but will change during server travel

#

so you'd need to handle that in some way aswell

#

you can route it through the gameinstance tho

#

All server sidie:

  • Host tell Gameinstance which roles are enabled
  • opens level
  • GameState grabs enabled roles in the GameInstance, and sets a replicated variable in GameState.
vagrant grail
hoary spear
#

Not easily in bp only

lament flax
#

My repnotify function is only getting called on server

Its in the game state, its set to replicate

dark parcel
#

should read it then

#

there are times when you want to skip owner

lament flax
#

well, the point of a repnotify function is to get called on client, now or later on

#

i wanted to replace a multicast with this

maiden flame
#

@vagrant grail For your game, what roles are visible to the players depend on a game setting set by the host, right? You called it something like "Hidden Composition".

If disabled, you could move the roles information from the GameInstance to the GameState, where every client has access to the information of who the roles are assigned to.
(You might handle the random assigning elsewhere, but let's keep the theory simple for now.)

If enabled, there's only one role/player that knows everyone else's role, so instead of moving the information from the GameInstance to the GameState, you can send the role assignment information to the individual player's controller or pawn, which is hidden from other clients.

vagrant grail
maiden flame
#

Ah, but that makes it even easier. You can still apply the same class logic as I mentioned.

vagrant grail
maiden flame
#

Basically, from GameInstance to GameState = Every client may know the roles in the match (but not who it is assigned to).
GameInstance to specific controller/pawn = Only that player knows the activated roles.

#

Server/host handles all the information and sending it from GameInstance to GameState or the specific player who is allowed to know the active roles.

vagrant grail
maiden flame
#

The player associated with the role is something you do manually on the server, and we don't need to share this, only the list of roles we activated in the lobby.

maiden flame
vagrant grail
maiden flame
#

So when the server randomly assigns roles to players, we can check if they got the Mad Man role. If the player has that role assigned, we move information about the active roles from the GameInstance to that player's pawn or controller.

vagrant grail
maiden flame
#

Which part specifically?

vagrant grail
maiden flame
#

Eh, I think you should figure this out, but essentially once we change maps to the actual game level, you could use BeginPlay in the GameMode to retrieve the array of roles from the GameInstance of the server host.

Then use an event like Event OnPostLogin to assign roles from that array to each joining player (coming from the lobby).

Each time we assign a random array element from the role array, we can check if that is the MadMan role. If it is, trigger a RPC on OwningClient inside the player's pawn/controller (accessible by default from the PostLogin event output), which sends the role array from the GameInstance or GameMode (anywhere you have a copy of the list of roles ended up being used).

#

There's some more details, but honestly I might as well write the game for you at that point xP

vagrant grail
#

Thank you so much 😄 Yeah if you want to write the game for me it would be a pleasure so I can focus on doing the level design, UI, etc... 😄

maiden flame
#

You're welcome 😄

rich crag
#

asking again if anyone knows why a child blueprint that you cast to gets duplicated in a world partition map (if the parent blueprint is spatially loaded)? Any other situation works - if the parent is not spatially loaded, if the map is not open world, or if you don't cast. The problem is, as far as I can tell I need to do all 3, unless i place all my doors manually outside of other BP's? I cant even tell if this is a bug or expected behavior.

maiden flame
#

@rich crag It's really difficult to wrap my head around what you are trying to do. It would be best if you create a clear overview of what you want to achieve, and what your proposed solution is (with screenshots of your code). This will make it easier for someone to help you.

quaint frost
#

i found a solution from UT with duplicating world, but i want to implement more efficient way with FLevelCollection...

rich crag
# maiden flame <@423537970096635915> It's really difficult to wrap my head around what you are ...

Easy to explain. I have a parent blueprint (a house). It is just a collection of static meshes, plus a child blueprint (a door). I have replicated the door opening using a cast and RPC from the character. If I set the door down alone, it works as expected. If I add the door to a house in a regular map, it works as expected. If i add the door to a house in an open world map, I get duplicate doors, one on the server and a duplicate on the client that does not open. I say that because the one that opens respects collision while the one that remains closed does not. If I turn off "spatially loaded" on the house, the door does not duplicate, but this permanently loads the house, yes? not desirable. What am i missing

#

current door:

#

but i have done the door multiple ways that work outside of these conditions.

hoary spear
#

Are you calling toggle door?

rich crag
#

yes

hoary spear
#

Not shown if so

rich crag
#

calling toggle door from character with rpc

hoary spear
#

Aight

rich crag
#

on the character:

hoary spear
#

(Toggle door being rpc is redundant)

rich crag
#

but its not. different things happen

#

the first toggle only opens the door on the local client

hoary spear
#

You're already executing logic from the server

rich crag
#

i thought so but thats not how its working

hoary spear
#

once on the server, you stay on the server

#

so serverdoor already executes on server (assuming owning client etc)

#

and toggle door just calls on the server anyways

#

if you were on a client then the RPC would fail, as the client invoking this has no authority over a server owned door

rich crag
#

ok. so I've dumped the original toggle for only the server rpc, still same result.

hoary spear
#

yeah it wasnt part of a problem, just redundant

#

havnt gotten to any spatial loaded things yet so cannt say for sure whats going on in your case

rich crag
#

door on left is working properly, standalone. the one on the right is the same door, just in a simple empty parent blueprint

hoary spear
#

one thing i know

#

is that

#

OnRep will be client (and server) side

#

so you cant invoke server RPC's

#

you want them to be regular, local events

#

and the timeline doesnt need to be repliciated at all

rich crag
#

ok

urban moth
#

is there an example or at least overview how to work with GAS in MP?

hoary spear
#

Lyra / GAS Documentation / GASShooter / ActionRPG

#

several sample projects

#

no real good overview tho

#

GAS Documentation is the best noe imo

#

by tranek

urban moth
#

oh boy.. I thought it .. thanks anyway

rich crag
# hoary spear

I didnt think those things were required (the server rpcs and the timeline replication) but as it was not working, i have been trying everything I can think of

hoary spear
#

as an example

#

I've only recently started using 'em so they'll get better over time I'm sure x)

rich crag
#

its probably a good idea for me to start using them lol

hoary spear
#

did it help turning of RunOnServer?

rich crag
#

no. I had them off originally.

#

switching them back no difference

hoary spear
#

well leave them off i'd say

#

add some print strings and see whats going on

rich crag
#

i will, if it works the same theres no reason to do more server work

#

the print strings say everything is good

hoary spear
#

(the server wouldnt do it, they'd block it as client has no authority (is not owner))

#

what do you mean print string is good? ^^

#

where's the prints being executed

rich crag
#

all of the print strings in the chain report expected results

#

I have added them off and on through the whole logic chain

hoary spear
#

soo..

Client Input -> Server serverdoor -> Server toggleDoor

Server OnRepIsOpen -> Server Open/Close Door ?
Client OnRepIsOpen -> Client Open/Close Door ?

rich crag
#

yes

hoary spear
#

also

#

you're toggling door twice

rich crag
#

this is whats happining in the outliner

hoary spear
hoary spear
rich crag
#

yes i deleted the first toggle

#

no, the door is in a test parent blueprint that is placed

#

it loads the door spatially on top of the placed door

#

:/

#

i wonder if the parent were spawned dynamically

#

because it is showing the placed actor, then adding a spatially loaded actor

hoary spear
#

pretty strange

rich crag
#

driving me batty.

#

I've gone back through every replicated door tutorial i can find lol. they all do the same thing

#

IF in a spatially loaded parent blueprint in open world

thin stratus
quaint frost
#

links yes, but there is sample code link, and it is not available, and i can't find UKillcamPlayback class source code, and it is important part of it

thin stratus
#

@pallid mesa Your Instant Replay post seems to not have all requirements available anymore. Epic sample code seems to be gone.

pallid mesa
#

@thin stratus oh no, did epic remove the original post by Alex K.

#

the article was an addon to the original writeup from Alex, if they have removed it i will have to rewrite the whole thing, might take a while

quaint frost
quaint frost
vagrant grail
#

@thin stratus I think I found a typo in your "Multiplayer Network Compendium". You forgot to add "at" between changes and runtime 🙂

pallid mesa
#

im not @ home

pallid mesa
#

Oh my god, thats a problem

#

Leave it to me, i'll see what I can do, but it'd have to wait, im ooo

quaint frost
#

ok thank you in advance, i'm trying to implement it by myself, but example would be great to check )

quaint frost
#

@pallid mesa maybe you can help me then if you have written this article you should have experience, my DuplicatedLevelCollection is always null

#

and this method Experimental_ShouldPreDuplicateMap never called

pallid mesa
#

are you using world partition?

quaint frost
#

no, i have now single persistant level without sublevels

pallid mesa
#

which engine version are you using?

quaint frost
#

5.0.3

#

no game features are used

pallid mesa
#

👍 even easier

#

although 5.0 is a quite old version

#

so I have to check source code for you

quaint frost
#

we have multiplayer game with CI build system, and there is a problem to update engine, when you have modify engine source 😉

pallid mesa
#

don't worry

#

I will take a look in a bit, im ooo

quaint frost
#

oh it will not work in editor (((

obtuse field
quaint frost
#

call to duplicate levels in UnrealEngine.cpp

#

and removing GIsEditor check will crash the engine, maybe it should't work in editor, and check is valid here 😄

magic vessel
hoary spear
#

Cant really get around that

olive crow
#

AActor::IsNetRelevantFor is only called from server/host to determine if it should be sent to the client right?

lament flax
#

The way i did to attribute roles to my players is by giving two params to the GM : nb of players of team A and of team B (A+B= max players in server)

Then i overrided the function "GetDefaultPawn..." in game mode to feed the correct class to the futur-spawned player

#

When i get back home i can send screenshots if needed

steel lake
#

Hello guys! I was wondering if any of you can help me. I'm trying to use the World's Exec() function to use the open <ip> command from C++, but it is not responding. I tried to connect using the console and it did it correctly.
What I'm doing is:

void MyClass::MyFunctionToConnect()
{
  FString ip;

  //Code to get the ip.

  const FString connectCommand = "open " + ip;
  GetWorld()->Exec(GetWorld(), *connectCommand);
}

I'll appreciate any help 🙂 Also, if this goes in other channel, please let me know and I'll move it.

lament flax
steel lake
steel lake
warm scaffold
#

Sanity check here 🙂
Does the ue 5.3 versus 5.0 have different port forward settings? in ue5.0.3 the port is 7777, is it the same in ue 5.3?

quaint frost
#

thank you so much )

pallid mesa
#

Removed the zip from here, as its now included in my webpage, refreshed the links with new ones.

hardy turtle
#

Hey guys, I'm trying to send this interface event to the player controller from the game state.
If i use a Rep notifier with an integer (that i update from the gamemode) it works, If i do the same thing using a boolean (wich i change every time the event is fired in the gamemode) it won't replicate.

Does anyone have an idea why?
Thank you

quasi tide
lucid badger
#

[2435.76][480]LogClass: Warning: Property InteractableComponent::bReplicates (SourceClass: ActorComponent) was not registered in GetLifetimeReplicatedProps. This property will not be replicated. Use DISABLE_REPLICATED_PROPERTY if not replicating was intentional.

#

Why is the log bothering me about core properties from ActorComponent? Thinkge

hollow eagle
#

probably because you didn't call Super. Or you shadowed an existing variable.

solar stirrup
#

^

lucid badger
#

Err the first one

#

Hmmge frankly I'm surprised that didn't cause anything to actually fail

sinful tree
hardy turtle
#

the rep notify is just triggering the message

rich crag
#

Hi guys, trying again to see if anyone can sus my issue. Open world replicated blueprint - it doesn't matter how it's replicated. World partitioning. blueprint is child blueprint. Parent blueprint is spatially loaded. You get an extra child blueprint on (each) client only - a duplicate. it even shows up in the outliner as a dynamically spawned instance. Only the child blueprint though. And it doesn't matter if the child is spatially loaded or not. I'm trying to get open world doors as child blueprints, and it seems like this is something that would be done all the time, but I'm not seeing this issue except 2 or 3 mentions...

rough dock
#

will repnotify get called when i add or remove an item in an array?

rough dock
fossil spoke
#

Are you using BP or C++?

rough dock
#

bp

dark edge
fossil spoke
#

If I was to take a guess.

#

It sounds like, if I had an "Equip Weapon" Animation

#

But the "Equip Weapon" functionality itself was based on a timer (instead of the Animation itself).

#

He would cache the time of the Animation, so that it can be passed into the timer.

#

That way, the Animation and the Timer completing, would be effectively the same.

#

Thats my guess as to what he is referring to there.

pulsar grove
#

what would be considered excessive server downstream kb/s, is there generally a good target to aim for?

hoary spear
#

Collab whiteboard

obtuse field
#

Unreal's RCPs work in the manner, that they are serialising data to be sent to the function, and then deserialising them and passing to the function on the other side, right? How can other side know where data ends in terms of e.g. instanced structs. With arrays I guess its just writing the sum length of the bits of the members, but then if its nested it has to write it again, and parent array have to take additional length bits into account

vagrant grail
#

@thin stratus typo again : site ? Instead of side ?

hoary spear
#

Not sure the tag is warranted for a typo in a widely used compendium where you get the gist of it in the context...

vagrant grail
obtuse field
thin stratus
obtuse field
thin stratus
#

Yeah FInstancedStruct probably has its own NetSerialize for that. Iirc James also said it shouldn't be used for stuff like Inventories or so. Probably due to the overhead.

obtuse field
thin stratus
#

Rip

obtuse field
#

Somehow I have to save items custom data

thin stratus
#

The usual way is UObjects

#

Jambax posted somewhere how he does arrays

#

FastArraySerializer with UObjects

#

Exact setup depends a bit on the project

#

There is also a post somewhere with some pseudo code but it would be the same stuff he wrote there just as code

#

Inventories work differently, so this isn't a solution exactly for all inventories. Some might not have stacking or need each instance in a stack to be unique. Would need to adjust the info per FastArraySerializer Item to match your requirements.

#

The UObject instances must be replicated via some actor. Usually the outer of the Inventory Component fwiw

obtuse field
#

I will take a look later, ty

fossil spoke
#

Ive noticed some issues with the current implementation of FInstancedStruct that could be improved upon.

#

But they are a cool concept

thin stratus
fossil spoke
#

But realistically Items dont change much beyond their initial creation.

#

Im only curious to see what the implications are for using FInstancedStructs in this way are.

#

Not convinced its an appropriate usage.

#

But im developing a usable system and will profile it in a somewhat realworld usecase. Like an ARPG setting for example

upbeat basin
#

How much does cheaters have control over our games? I always assume any variable can just be changed locally. If we take the simple example of opening/closing a door with a replicated bool with on rep function, where the door's rotation changes locally in the on rep function according to the bool's new value, would it be possible to open the door locally, since it's bound to the OnRep function and not the bool directly? Or wouldn't they be able to just change the rotation of the door? Since it wouldn't be open on the server, they wouldn't be able to walk past it since the server collision would prevent the movement. But they could still see inside if we put something that's supposed to be hidden behind the door. And thinking like this, wouldn't it be just possible to change materials to have wall hacks?

#

Are these inevitable things that could happen without an external/third party cheat protection or are there things that we can do more than server authoritive logics to prevent cheating?

chrome bay
#

Unfortunately delta replication is extremely hard to do because the underlying struct type can change at anytime, which makes it very difficult to store any history state and/or ack receiver packets. Iris might make it possible since delta serialization is somewhat automatic in a sense, but not sure yet.

#

Just a general comment but for me the common design issue I see with inventory systems is people pack all their "item" data into a single "item" struct, which then has to contain all properties for any inventory system concept, like "stack size" or "level" or whatever. It's just a classic inheritance problem where the base has to include data types used only by certain children.

fossil spoke
# chrome bay Just a general comment but for me the common design issue I see with inventory s...

In the plugin ive opted to separate static data from dynamic data in the form of ItemDefinitions and ItemInstances. Instances of Items are generated from Definitions and are what is replicated and they only ever replicate the dynamic data that is specific to the instance that cant be stored anywhere else. Minimizing as much as possible from being replicated. There are still far more optimizations that could be made but as i said earlier ive yet to really do any profiling and earnest optimization.

#

ItemInstances do replicate a handle to the ItemDefinition so that they can access the static data about themselves.

#

But the fact they are serialized in full is hard to escape.

hoary spear
#

I keep a single handle for the static data, which clients fill into the struct themself (for userfriendlyness), but i havnt found a good way to solve custom persistent data without stuffing it into the base struct.. feels like i cant get around that

reef bison
#

I have a UPROPERTY(Replicated) TArray<FExample> Example array in my ACharacter class. I only change the value of this array in the server and it is only read by the server. I removed the Replicated flag and everything seems to be working fine

I want to make sure I got this right: everything still works because since I only interact with this variable in the server, there is no need to replicate this value back to the clients

#

if I ever forget about this and try to access this variable in a code path that runs both on the client and the server, then I would have a divergence in values, right? (the client would always see it as empty)

reef bison
#

thanks bow

hoary spear
#

Just slap a blueprintauthorityonly specifier on it 😄

obtuse field
#

So, I'm trying to send data 2 times in a row over TCP socket

TArray<uint8> Bytes;
    FMemoryWriter MemoryWriter(Bytes);

    TMap<int32, FInstanceBuildingData> PlacedInstances;

    TArray<int32> TestArr;
    TestArr.Add(14);
    TestArr.Add(15);
    TestArr.Add(16);
            
    MemoryWriter << TestArr;

    int32 BytesSend;
    
    if(!Socket->Send(Bytes.GetData(), MemoryWriter.TotalSize(), BytesSend))
    {
        UKismetSystemLibrary::PrintString(GetWorld(), "SEND ERROR");

    }

    TestArr.Empty();
    
    TestArr.Add(30);
    TestArr.Add(31);
    TestArr.Add(32);

    TArray<uint8> Bytes2;
    FMemoryWriter MemoryWriter2(Bytes2);

    MemoryWriter2 << TestArr;

    if(!Socket->Send(Bytes2.GetData(), MemoryWriter2.TotalSize(), BytesSend))
    {
        UKismetSystemLibrary::PrintString(GetWorld(), "SEND ERROR");

    }
#

But only first array is displayed. Although, it how bits for 2 arrays (PENDING DATA, READ DATA)

#

This is how data is read on the client:

                TArray<uint8> Bytes;
        Bytes.SetNum(4096);
        
        int32 BytesRead;
        
        ESocketConnectionState SocketConnectionState = TCPChunkDistributor->GetConnectionState();

        if(SocketConnectionState == SCS_Connected)
        {
            UKismetSystemLibrary::PrintString(GetWorld(), "CONNECTED");


            uint32 DataSize = 0;
            TCPChunkDistributor->HasPendingData(DataSize);

            UKismetSystemLibrary::PrintString(GetWorld(), "PENDING DATA: " + FString::FromInt(DataSize));
            
            if(!TCPChunkDistributor->Recv(Bytes.GetData(), 4096, BytesRead))
            {
                UKismetSystemLibrary::PrintString(GetWorld(), "ERROR");
            }
        }
        if(BytesRead != 0)
        {
            UKismetSystemLibrary::PrintString(GetWorld(), "READ DATA: " + FString::FromInt(BytesRead));
            
            FMemoryReader MemoryReader(Bytes);

            TArray<int32> TestArr;
            MemoryReader << TestArr;

            for (auto Arr : TestArr)
            {
                UKismetSystemLibrary::PrintString(GetWorld(), "ELEM: " + FString::FromInt(Arr));
            }
        }
fossil spoke
#

@obtuse field Did you also mean to ask a question?

obtuse field
obtuse field
#

But, is there an easier way to deal with it, than keeping track of all the data? Isn't there something to e.g. automatically divide these chunks?

fossil spoke
#

Sorry i cant be more helpful. Im about to go to bed 😄

obtuse field
thin stratus
#

Has anyone tried out NPP and run into checkf(false, TEXT("No matching simulation data found for TraceID: %d"), TraceID); when opening a Trace with NP Channel in it?

true cliff
#

Hello. I have a question. I'm making a game with MediaPipe. Is it possible to replicate motion capture pose in local multiplay?

solar stirrup
#

I use instanced structs for items as well

#

In our case item instances have a TMap<FName, FInstancedStruct> so you can get/set data by name

#

however recently changed to it a TMap<UClass*, FInstancedStruct> where the class is a special object type that just returns a UScriptStruct

#

With custom net serialization, I only read/write the UClass* and then the FInstancedStruct's underlying data (skips serializing the UScriptStruct for no reason since we know that it'll be from the UClass)

hoary spear
#

Thats just static data tho, Right?

gloomy tiger
#

Have this on my AGameState:

UPROPERTY(Replicated)
float Value = 0;

void SetValue(APlayerController* Instigator, float NewValue) { Value = NewValue; }

Is there any way to replicate Value to all but the Instigator? Reason I ask is because the Instigator already has its own local version of Value; also, I'd like to keep it as a replicated UPROPERTY() to automatically benefit from replay et al.

chrome bay
#

There's not no, not unless you move it somewhere else

gloomy tiger
#

Aight, thanks.

vagrant grail
#

Is the data in the gamestate getting reset when switching from one level to another or does the data stay ?

rich dune
#

Hey,

on P2P sessions on map change, clients disconnect for some reason. we use seamless travel and the same code works perfectly fine on Dedicated Servers. It even works perfectly fine when I hoste a P2P Session on my Switch Dev Kit and join as client out of the editor and the transistion works fine.

Any ideas whats the issue?

hoary spear
#

So which scenario doesnt work fine ?

vagrant grail
thin stratus
#

You can check my Discord Profile for an option to contact us.

#

--

Man, Network Prediction Insights is totally busted for whatever reason

vagrant grail
thin stratus
#

Hehe, yeah no, initial contact and all of that via email please.

thin stratus
#

sigh

lost inlet
#

I thought NPP itself would get a bit more love than it has with Mover being actively worked on

thin stratus
#

Yeah seems to be an NPP related problem. I can repro that with any kind of Simulation running, even the NPP examples (the flying UFO).

#

Bummer, I was about to modify NPP to add some stuff, but can't validate if it works without the Insights debugging.

lament flax
#

if i spawn a actor on the server, will this be replicated to the clients ?

dark edge
lament flax
#

perfect, ty

vagrant grail
#

How to transfer all the player to a new level please ? I tried to use "Open Level" on the host it moves him but it kicks the other client for some reason 🤔

vagrant grail
solar stirrup
#

Execute Console Command -> ServerTravel YourMap

thin stratus
#

?listen is redundant there

solar stirrup
#

ty

vagrant grail
#

doesn't work 😬

lament flax
#

Maybe you have to give a path ?

#

Maybe call this in server

#

And not client

thin stratus
#

don't think so, but has to be called on the server

dark parcel
#

Mb didn't read the message

thin stratus
#

And the listen part isn't needed

lament flax
#

Why?

#

Just curious

thin stratus
#

Cause it's not

hoary spear
#

Its implied

thin stratus
#

Like ,it's not needed :D

#

Not even that, ?listen is for OpenLevel to start listening for incoming connections

#

ServerTravel doesn't need that

lament flax
#

because its already in "listen mode" ?

#

after first Open

thin stratus
#

Yes

lament flax
#

okay ty for explaining

hoary spear
#

Thats what i ment tho, its implied thay you're a server when you do a servertravel

vagrant grail
lament flax
#

doesn really matter, but maybe you want to create a reusable event to change level

#

in this case you would want to place this event somewhere easy to access

vagrant grail
#

PlayerController then ?

lament flax
#

idk, you decide

#

:)

vagrant grail
#

it doesn't help 😭

lament flax
#

can be anywhere server side

vagrant grail
#

That's why I hate Unreal because there 600 manners to do things 😦

lament flax
#

i would probably place this in game state

thin stratus
#

It really doesn't matter

lament flax
vagrant grail
thin stratus
#

Also that argument goes for a lot of things, not just UE

lament flax
#

true

vagrant grail
thin stratus
#

Being able to do things in a lot of ways

#

Is not a UE "problem"

lament flax
#

btw, whats the diff between game instance and game state
each time i do some research i get more confused

vagrant grail
#

But UE has that problem

thin stratus
#

You call it problem cause you lack knowledge at this point

lament flax
#

UE has that super ability to be used in any way you want

#

all programmer tools have this

lament flax
wary marsh
#

Noob question here. I couldn't think of a better way to ask the question than just to make a video. I'm pretty stumped. it seems like should be a simple thing that I'm just not considering.
Any help would be greatly appreciated.

lament flax
#

when you start you always lack knowledge

vagrant grail
thin stratus
#

GameInstance exists once per Game Process, shouldn't be used for Gameplay fwiw
GameState exists once per "map/world" and allows replication from server to client and should hold the game's current overall state

thin stratus
vagrant grail
thin stratus
#

Cause it means that you can solve it in multiple ways without having to worry if it's the ONE way

#

There is nothing to simplify here

#

The classes that exists in the GameFramework all have their right to exist

#

Where you put your ServerTravel call is completely up to you

vagrant grail
#

But there are so many

thin stratus
#

Yeah and that will always be like that

#

You gotta learn them

vagrant grail
#

snif 😭

#

What I would really like is to have something as simple as 2 contexts, server and client. And you can't code server stuff in a script inside a client context, and can't code client stuff in a script inside a server context, so you can mark a real split between client and server in terms of organisation.

solar stirrup
#

Except that's code duplication hell

hoary spear
solar stirrup
#

You'll just get the hang of it by learning

hoary spear
#

Programming principles exist to guide you

thin stratus
#

as soon as you have ListenServers, you will have duplicated code

vagrant grail
thin stratus
#

Online Tutorials are very often really bad

lament flax
#

thats why you leanr by doing mistakes :)

thin stratus
#

No matter what it#s about and how simple or complex the topic

#

Cause people make tutorials based on wrongly learned knowledge

lament flax
#

when i look back at my first projects, damn everything is bad xD

thin stratus
#

And spread it

vagrant grail
thin stratus
#

¯_(ツ)_/¯

lament flax
solar stirrup
#

Filter those ways to "good" ways and there will be less

#

Even then, flexibility is awesome

#

Projects have different requirements

lament flax
#

a single DT with hundreds of lines

frail barn
#

i have a pawn, which is Hidden in game. how to unhide it for only one specific client, still remain it Hidden for other clients?

lament flax
vagrant grail
lament flax
thin stratus
#

BeginPlay will already call on the Server AND on the owning Client

#

If you filter for "Authority" you wouldn't need the RPC

#

And you will probably get accessed none atm due to getting the GM on the Client (if you use it)

frail barn
lament flax
#

set hidden in game asks for a bool
true : hide it
false: unhide it

#

thats why its called "set hidden" and not "hide"

lament flax
#

are you on client side or server side when you decide to unhide an actor

thin stratus
vagrant grail
thin stratus
#

Third note: "Playing with multiple clients makes the first hosting client not work". You hovered "Play as Client", and if you meant that with "mutliple Clients" then that's not even a Client hosting anymore in that mode. That's a DedicatedServer setup. So if the first client there fails, then it's not even a Server vs Client issue.

thin stratus
#

Not entirely sure why atm. Setting the DefaultPawnClass makes no difference, cause your PlayerController BeginPlay will replace the Character anyway

thin stratus
#

But that shouldn't break anything of course

#

I assume you are using EnhancedInput for the actual movement

#

So I would suggest you check via "showdebug enhancedinput" if the keys are even working at all when you play

#

cause they aren't, then whatever logic you have to set InputMappingContext etc. is probably broken

wary marsh
# thin stratus Another point is that you are getting the GameMode on BeginPlay, and you use it ...

Thanks for the information, I'm absorbing this :D. I will look at the input mapping stuff I am using the enchanced input mapping. But imp pretty sure that its working because it responds to input on the clients. I was looking to see if there was some setting for multiplayer for those but definitely don't see any 😛

I originally wasn't calling the game mode cast on begin play. I moved it there while trying to figure out why it wasn't working correctly

Yea I assumed the Travel to map with "listen" effectively converted the client to the server. But I connected 3 other clients to the same session and all the connected players moved and replicated their montages

thin stratus
#

You are playing Standalone in your video

#

Unless you specifically check "isServer" or so somewhere, multiplayer doesn't at all matter here

wary marsh
# thin stratus You are playing Standalone in your video

im under the impression that "standalone" is more or less the same as being the server all teh time.
But its the same issues if i play as listen server or purely as clients
whomever is considered the server cant move if if i run the event begin play command

thin stratus
#

@wary marsh Standalone is not a Server. It would actually fail IsServer checks.

#

And "purely as clients" if you use Play as Client in the settings, is with a DedicatedServer

#

No one hosts there

#

It's a headless process without graphics that is the server in that mode

#

So if the first client can't control, then it's not a Server vs Client issue

torpid storm
#

What I would add, is that there's a lot of stuff going on in that video. Plenty of different places where things could break. Try to reduce it down to a simpler scenario. Standalone should work if you've been careful to check authority rather than explicit client/server stuff. If not, Listen Server should be okay. No need to test with 2 players.

wary marsh
#

Play as Client works just fine I get 2 clients that work as you'd expect it to.
But then when i click Host game.. the logic is Open Map option-- listen
Then the screen that says client1 wont accept inputs
But the screen that says client 2 (the person who found the session and joined) works as expected

thin stratus
#

Eh

#

If you go through the host game logic of a main menu

#

You should not have it say client

#

That means you started the main menu with PlayAsClients

#

Which means they are already connected

#

If you want to test connection process, you gotta start 2 players with Play as Standalone selected

wary marsh
#

hmm. i see. So if i 2 standalones. then host with one and connect with the other it would be a more proper server client relationship?

thin stratus
#

At least closer to what players would experience

#

Wouldn't explain why your character in standalone can't be controlled

#

But I alreayd told you to check the input debug

wary marsh
#

yea ill move on to that. 😄 thanks for your help!

#

Okay... lol feel like an idiot... but i initialized the enhanced input in the player controller and not just on the pawn.
this seems to have solved the issue.facepalm

#

thanks @thin stratus

lament flax
#

random question

#

when you plan your game to mutliplayer, with the server as a dedicated one
there is a "build" version for the server right ?

#

is there some resources on how to config dedicated servers for unreal ?

torpid storm
#

What do you mean, a build version? There is a versioning system, certainly. There's also some checksums which can detect when things are out of sync. I don't have much experience with either though

lament flax
#

i am taking about a special exe build or whatever for the dedicated server

#

i am not talking about versioning

torpid storm
lament flax
#

we arent understanding each other ^^'

hoary spear
#

versioning in this context is not to be confused with source control.

warm lintel
#

there were some stuff on the community wiki as well IIRC

torpid storm
lament flax
#

sorry, i kinda stoped to the title of the doc

#

i didnt understood the link between building from source and a dedicated server

torpid storm
#

All good 🙂

graceful flame
#

The process to generate a server build is quite simple, you just have to change a single drop down then right click and press build, but this all happens within visual studio which means you need to download the UE source from github and compile it first also using visual studio.

quaint frost
#

@thin stratus thank you for links
@pallid mesa thank you for great article and help with example code
Now i implemented instant replay and it works, have some problems with camera but i think i will solve them myself. @pallid mesa can i contact to you in PM? about replay system i have another level task, want to know your opinion 😉

hardy turtle
#

Hey guys! What am I doing wrong? i really don't understand, i select my character in the menu, it saves on the gameinstance in a data asset, the pawn gets it from there and it should replicate to the others right? it does not for some reason 😅
Hope you can help! Thanks in advance!

thin stratus
#

Using BeginPlay ( which calls on everyone .. ) to set it is not enough and specifically wrong, cause that way you will always have the Server set it to its own value

lament flax
#

you can edit data assets at runtime ?

thin stratus
#

No

thin stratus
#

DataAssets are ReadOnly, at least in 99% of the time

lament flax
hardy turtle
lament flax
#

didnt know you could do that

thin stratus
#

You 100% shouldn't

lament flax
#

i dont see the utility for me tho

thin stratus
#

The changed data will also not replicate

lament flax
#

and sems kinda illegal xD