#multiplayer

1 messages · Page 594 of 1

kindred widget
#

Where would you use GetPlayerController when dealing with networking code? Most times you should program classes to be relatively independent. If a client owned actor needs to tell the server something, it likely already has easy access to it and doesn't need to pull from the controller. And you should avoid it when doing server code, because it'll always be the listenserver's controller, and there are better places to keep networked coding than the listenserver's controller.

#

Most times you end up with GetGameState or GetGameMode after a server RPC rather than GetPlayerController(0)

hidden thorn
#

I see what you mean

kindred widget
#

The only time I might consider using that would be interfaces. I could see using GetPlayerController(0) in a client version of an actor that the client doesn't own to get the local controller to call a function from it that'll RPC to the server to make the server version interact with that same actor.

#

@toxic lion Also, do yourself a favor if you're sticking with blueprint a lot. Make a Function Library and wrap a lot of common calls. It'll tidy up your blueprints a lot. I do this in every project I create.

toxic lion
#

Thanks! I have a couple simple functions I created previously. as soon as I get a good grasp of getting the correct controller/player I'll create some

#

This works for both clients, but not yet for the server

kindred widget
#

That's odd. On a side note I messed up mine above a little.

#

Ditch my hud call, but check if it's locally controlled and get player controller0

toxic lion
#

from the player BP?

kindred widget
#

If that's your character, yeah.

#

I guess technically you don't really need the controller call in there either.

toxic lion
#

server bails out at the first branch, so it doesn't proceede from there

kindred widget
#

Nothing prints on the server if you put a print before the IsValid?

toxic lion
kindred widget
#

Well, you'll definitely get a print before IsLocallyControlled... You have three characters, yeah?

toxic lion
#

yes, two clients and one server.

#

It may be how I'm spawning them I guess

kindred widget
#

Possibly, how are you spawning them? Because at the moment your server doesn't own a character on BeginPlay apparently.

toxic lion
kindred widget
#

You don't have to ServerRPC that, just run the cast and spawn logic straight off of OnPostLogin. GameMode isn't replicated, only exists on Server.

toxic lion
#

ah that's right. okay

kindred widget
#

But that won't be the problem I don't think.

toxic lion
#

yup. problem persists

kindred widget
#

That's a strange way to call an interface in blueprint.

toxic lion
#

is it?

kindred widget
#

Out of curiosity can you make that a message call the SpawnPlayer call in the GameMode.

toxic lion
kindred widget
#

I wonder if the server's controller never gets login called? You may have to spawn it deliberately for the server player.

#

Cause your logic is perfectly fine. So I have to assume that PostLogin isn't called for the server controller.

toxic lion
#

hmm, let me print that out of I can

#

so far looks like the OnPostLogin is working for all parties

kindred widget
#

Hmm. I wonder if the server's version beginplay calls too soon. Let me check something in C++

toxic lion
#

sure. I would like to note for sure that the server's character does spawn in like 1-2 secs before the clients

kindred widget
#

Well, it's more a matter that the other characters would get sent as a bunch where the logic is happening in realtime on the server, so their controllers/owner would be set at beginplay

ember needle
#

hey all, this should be pretty simple but i'm a little confused. I have a replicated actor put directly in editor, and when I try to call the server from a client on this actor, the server does not receive the call. Is it because objects set in editor do not have an owner? What is the workaround?

kindred widget
#

@toxic lion Not sure how I'd fix it if it was the case, but can you just put like a 2-5 second delay on Beginplay in the character before the IsLocallyControlled check?

#

@ember needle Owner issues. Clients can't contact the server through non client owned actors. Anything with no owner is automatically server owned. There really is no fix. Possibly create a function to interact with it through the Character or Controller.

ember needle
#

gotcha, so it's what i supposed

toxic lion
ember needle
#

thank you.

toxic lion
kindred widget
#

Well, I suppose that solves that mystery. Beginplay on the server's version of their own pawn is called before the server can possess it's own pawn.

#

Not sure if setting the owner to the Controller would solve that? Cause IsLocallyControlled only checks the Pawn's Controller variable.

#

@toxic lion Come to think of it given this train of logic, I wonder if the Possesed events might work better for this?

#

This might be the reason that I very lazily just check the validity of GetPlayerCharacter0 in the HUD class on tick. Client only, no networking requirement, no headache.

toxic lion
kindred widget
#

Does that run okay on the clients?

toxic lion
#

nope 😦

#

let me delay it however

#

fewer errors with delay

ember needle
#

@kindred widget sorry i'm reading with one eye (currently in meeting) but can't you use onposses?

#

that's what I noramally do

#

OnPossess is called on server

#

use that to set the character replicated OnRep variable

#

OnRep you do what you need, you have your character

kindred widget
#

He's just trying to add a widget to screen for the owning client. But his server was spawning it's character and calling beginplay too fast before it could possess it. But if he does it OnPossess, the controller isn't valid yet even when it calls it.

ember needle
#

sorry i tagged you by mistake

#

i meant onposses on the PC

#

not on the character

toxic lion
#

on the PC BP

ember needle
#

onposses is called on server, isn't it?

#

that's why i was suggesting to use a character replicated variable

toxic lion
#

oh i see. okay lets see

ember needle
#

that's what i normally do

toxic lion
#

okay this does spawn the UI on all players/clietns

#

ui doesn't seem to react to the player information however

edgy dagger
#

Is there anyway in unreal that i can launch a and get back to the app with a return on that url with a message. the current Launch url only takes me to OIDC i cant return from it, the web browser widget doesn't support OIDC

toxic lion
#

oh maybe it does. one sec.

#

it works

#

Thanks so much for the help @ember needle & @kindred widget

#

truly appreciated

ember needle
#

no worries

#

glad it worked

hidden thorn
#

Has anyone a good post or some instructions of where would be the best place for certain type of logic to go, I sort of get the idea of GameState PlayerState GameInstance etc, the problem is they are becoming bigger and bigger and I don't like that, I would like to split out the code.

kindred widget
#

You can also make actor components to compartmentalize those classes. That or even create your own game wide server authorative classes just like GameMode or GameState.

hidden thorn
#

I might end up doing the 2nd thing, hmm its just annoying as I hate doing it the way I am doing it but at the same time I wanted to get it done this week (wasted about 3 days though) so might end up finishing it as it is and once done I will move things around.

#

But thanks for the input @kindred widget

fast arrow
#

hello guys. im curious how do i replicate UObject in c++, if i store it in the struct?

torpid girder
#

I am running a dedicated server from pie and a client, i want to pass different config params to the dedicated server than the client, so I went to the advanced run settings, enable run dedicated server, disabled single thread, now when i run in pie i just get a blank screen,

#

is it even possible to run a dedicated server and client?

shut gyro
#

Does anyone know what the difference between a "port" and a "channel" is in terms of Unreal Engine terminology?

versed socket
#

How can I use Subsystems to decouple game logic systems while also keeping the game data in sync? Because Subsystems aren't able to be replicated. Wouldn't I need to create some kind of data storage Actor that exists only to propagate changes to all of the Subsystems, such as the AGameState class? Or is there some way to do this automatically?

hidden thorn
#

Unsure of what you want exactly, any chance you can explain again or give an example.

winged badger
#

if you designed your framework so it needs to replicate subsystem data, you kinda failed

versed socket
#

Isn't the whole point of a subsystem to help you decouple your systems to that they aren't dependent on one another?

#

And don't at least some systems require replication? For example, a movement component requires a replicated position transofrm

#

Maybe I'm just misunderstanding the purpose of a subsystem

meager spade
#

ActorComponents can also decouple

#

and seems like this is what you would need

#

look at GameplayAbilities, its decoupled, but requires you do have a interface and a component on every actor that wants to use it.

kindred widget
#

@dull lance Variables only replicate once per server tick at maximum. So for example, if you set it to false on the client for any length of time before the server both sets it false and then true again enough for it to detect changes and replicate them, the client will remain false. So as far as function bodies, if you set it false, it'd stay false through that function body until the client set it back to true or the server sent a replication update.

unkempt tiger
#

So ugh, what's a reasonable Kbps bandwidth saturation limit I should be setting if I want to roughly replicate real life conditions (supposing I have decent servers and clients with a relatively up to date network (rather than dial up))? that is the limits in DefaultEngine.ini

#

40,000? 400,000? :P

kindred widget
#

@unkempt tiger According to online sources, something like Apex Legends reportedly requires up to 512 Kb/s, so that'd be just over a megabit. 512,000 bits.

#

It has quite a following, and I can't really remember much lag from the game when I played. So I imagine that's not really a bad ask at all.

unkempt tiger
#

That is quite a lot

kindred widget
#

I mean, it can be. I don't see it as being that much personally. Most people have an average of 10 to 20 Mb/s download.

unkempt tiger
#

There is seemingly a very wide range of kbps values between games, I find this confusing

#

Is it that games going for the 30 to 40 kbps ranges have it so low because they're also shipping on mobiles, or other bottlenecked platforms?

#

Is it because they plan on shipping in some country with old networking foundations?

kindred widget
#

Depends on the game. Don't forget that networking performance isn't just about gameplay. Less networking means less bandwidth for servers which means less upkeep cost for hosting.

#

A lot of games also have phone versions. Even more simply don't require that much data because they've been simplified to death.

unkempt tiger
#

I see, that makes sense

#

I suppose that if I launch a game and just open up task manager and see the net usage, it'd give me a rough estimate?

kindred widget
#

Not sure. Possible. Not sure what the overhead and such is on that.

unkempt tiger
#

well it'd probably be an upper limit

#

mayhaps there's a better alternative to check for this if the game is on UE4

kindred widget
#

Curious though. I wonder if you could convert the two velocity vectors into 4 total bytes each instead of 12. I wonder how accurate it'd end up. Might need 6. Would still be half.

unkempt tiger
#

which velocity vectors?

kindred widget
#

Linear and Angular.

unkempt tiger
#

Oh for the prop physics networking

#

In my solution I'm not sending velocities

kindred widget
#

Fair.

unkempt tiger
#

Just launched mordhau (which has fantastic networking btw)

#

Fluctuating between 0.2 Mbps to 0.3, so roughly 200-300 kbps

#

I guess it's fair to assume they have their MaxClientRate set to at least 150000

sand iris
#

Anyone have experience writing automated Functional Tests and running them on Play as Client mode?

The test events in my FunctionalTest BP such as Event Prepare Test, Event Start Test, and Event Tick only get called on the serer but I would also like them to be called on the client.

#

For example, when the following prints on Event Start Test , it adds the "Server" prefix to the printed string, meaning it's only being called on the server:

solar stirrup
#

When you spawn an actor on the server, does its transform get replicated?

#

assuming it's set to replicate, or SetReplicates is set to true at runtime

winged badger
#

it will spawn at the same transform

#

as on the server

#

it doesn't mean that it will keep updating it if you move the Actor later

steel fractal
#

got a quick question, what would be easier to replicate, the first person template, or true first person using the 3rd person blue print

agile lotus
#

Why is OnLogout called during level unloading for streamed levels

lost inlet
#

debug it? that'll tell you why

distant monolith
#

Anyone have a practical starter/beginner tutorial for dedicated servers?

wind oasis
#

Hi, I really don't know why but in my sister's computer the game runs slow twice from me. and Its don't matter if she is the server or the client. Anyone has idea why its happening ? and the clients are faster / slower as the fast frame rate

fiery badge
#

Hey

#

do anyone know how to destroy spawned actor

#

in class

#

i have a shield actor that i am spawning in player class

#

it's working fine

#

but it's not destroying

#

i am trying to destroy it with the destroy actor function

#

i replicated it

#

and try to destroy with multicast, server only but nothing seems to working

#

ok

#

new update

#

when i run game as listen server

#

it's destroying server shield but not client

#

so, what i thing is it's destroying on the server but but not from server

#

dose anyone know how to fix it?

kindred widget
#

@sand iris If your events only get ran on the server, either your clients don't have a version of this actor, or you've specifically routed these events to the server. My guess would be the first since you intentionally want it to print from the client and tick would run on both sides.

#

@steel fractal They're both mostly the same to replicate. Control rotation, and character movement for the most part. The differences of the meshes is all client only animation stuff.

#

@fiery badge You need to be certain you're spawning it only on the server. Do not spawn replicated actors on clients. Then when you want to destroy it, simply destroy it on the server. If you destroy it on the server and it destroys, but it remains on the client then it's likely that you are spawning it on client and server at the same time. Whether it's replicated or not, this would give the impression that it won't get destroyed on the client when you destroy it from the server because even if it's replicated, the versions spawned on the server will stay there when the replicated one from the server is destroyed, because they're not server owned. Alternatively, if it's not replicated and you destroy it on the server... it's not replicated, so nothing else happens but it just gets destroyed on the server.

hidden thorn
#

If I have a PlayerStatus property that realistically only the server will ever care about, it doesn't need to be replicated does it? It will change but only by the server and only the server will check for the status of the player.

#

There will be calls made from the Client to the Server to change the status though.

kindred widget
#

If the client doesn't need to see it for any reason, it probably doesn't need to be replicated. Such as if they don't need to know what the current value is to change it, or there's no Animation or UI involved that they have to handle from it.

hidden thorn
#

That's the case, what will happen is the Player will have an Event attached for when the game status changes (which is replicated) and when that changes I will either make another Server call to change the PlayerStates status which will be used on the server at a later time.

twin juniper
#

can someone learn me the basics of an online game ?

wide stream
#

Hi. I'm having trouble with joining a local session created by a locally running dedicated server - the search result is empty.
I have dedicated sever built according to this guide
https://docs.unrealengine.com/en-US/Gameplay/Networking/HowTo/DedicatedServers/index.html
which creates and starts a session according to this guide
https://unreal.gg-labs.com/wiki-archives/networking/how-to-use-sessions-in-c++#searching-and-finding-a-session

The session is created and started successfully, but the client (PIE instance of the game) is not able to find it.

Here are the session's settings:

How to set up and package a dedicated server for your project.

#

Dedicated server:

void ATPPGameSession::RegisterServer()
{
    IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
    if (OnlineSub)
    {
        IOnlineSessionPtr SessionInt = Online::GetSessionInterface();
        if (SessionInt.IsValid())
        {
            TSharedPtr<class FOnlineSessionSettings> SessionSettings = MakeShareable(new FOnlineSessionSettings());
            SessionSettings->Set(SETTING_MATCHING_TIMEOUT, 120.0f, EOnlineDataAdvertisementType::ViaPingOnly);
            SessionSettings->Set(SETTING_SESSION_TEMPLATE_NAME, FString("GameSession"), EOnlineDataAdvertisementType::ViaPingOnly);
            SessionSettings->Set(SETTING_MAPNAME, GetWorld()->GetMapName(), EOnlineDataAdvertisementType::ViaPingOnly);
            SessionSettings->bIsDedicated = true;
            SessionSettings->bIsLANMatch = true;
            SessionSettings->bUsesPresence = false;
            SessionSettings->bAllowJoinViaPresence= false;
            SessionSettings->bAllowJoinViaPresenceFriendsOnly = false;
            SessionSettings->bShouldAdvertise = true;
            SessionSettings->NumPrivateConnections = 10;
            SessionSettings->NumPublicConnections = 10;
            MaxPlayers = 20;
            
            OnCreateSessionCompleteDelegateHandle = SessionInt->AddOnCreateSessionCompleteDelegate_Handle(OnCreateSessionCompleteDelegate);
            SessionInt->CreateSession(0, NAME_GameSession, *SessionSettings);
        }
    }
}
#

PIE Client:

    IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();

    if (OnlineSub)
    {
        IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();

        if (Sessions.IsValid())
        {
            SessionSearch = MakeShareable(new FOnlineSessionSearch());

            SessionSearch->bIsLanQuery = true;
            SessionSearch->MaxSearchResults = 20;
            SessionSearch->PingBucketSize = 50;

            TSharedRef<FOnlineSessionSearch> SearchSettingsRef = SessionSearch.ToSharedRef();

            OnFindSessionsCompleteDelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(OnFindSessionsCompleteDelegate);

            Sessions->FindSessions(0, SearchSettingsRef);
        }
    }
    else
    {
        OnFindSessionsComplete(false);
    }
steel fractal
#

@kindred widget thank you, was wondering if I should switch but you helped my decision to stay

solar stirrup
meager fable
#

and the server keeps correcting its location on the client

#

how can it be different if the starting location and velocity are the same on both?

kindred widget
#

@meager fable Replicating fast moving objects is tricky and not normally done. Take for instance your multicast. Your server is going to play that first of course. Lets say you have a client that runs the same code 100ms later. Not factoring in other complications and processing etc, your server's projectile is already 200units ahead of the client. And continually updating that replication against the client is likely to end up in them fighting over where the projectile should be on the client.

#

How concerned with cheating are you?

meager fable
#

this will be coop not pvp so not that much

kindred widget
#

Consider just spawning it on the client as an authority. The bullet doesn't even need to be replicated itself, just the gun shooting it. Let the client tell the server that it spawned one and maybe rpc from the client the spawn location/direction to play effects for other clients. Don't bother RPCing from any of the other bullets that are just visuals. Just let the client version decide what it hits and RPC that to the server. Other clients will get a decent enough third person visual, and it'll feel a lot better for your client that did the shot.

meager fable
#

okay, will play around with it, thanks for your advice

#

I've currently disabled movement replication without changing any code

#

and the fireball hits a different place on the server than on a client

vague saddle
#

Hey guys, does anyone have any experience setting up a dedicated server for a high number of connections?

hidden thorn
#

Does anyone know why when I assign a Gamemode that inherits from AGameMode my character can't move anymore, it seems its only the client !! If I inherit from AGameModeBase everything works fine.

loud onyx
#

In the Net Profile tool my player controller class says it's 100% waste, and I'm not replicating any properties on it, I have everything on a player state. I'm wondering if I reduce the update frequency of the controller, will this affect input/movement at all? Is it safe to reduce that, or perhaps not worth it?

fiery badge
#

Hey

#

Can anyone explain what is unreal Engine online system is

kindred widget
#

@hidden thorn I've never made a project from GameMode, but I remember something about it having a "StartMatch" or something similar call, could that be causing it?

hidden thorn
#

I am also unsure, haven't tried it yet, I just went back to using AGameMode and I will give it another go at some other time.

sand iris
#

if I have a FunctionalTest BP and I'm using Play as Client mode (which means that the server own the FunctionalTest instance) how can I call a function/event on the server from the client?

I tried using a multicast event and also a "Run on Server" event but multicast was only called on the client and "Run on Server" was not called at all

#

This is the event I want to run on the server, which I'm trying to call from the client:

#

I think this issue is unique to using a BP that inherits from the FunctionalTest class

dark niche
#

@hidden thorn your gamestate needs to derive from AGameState also for AGamaMode to work

hidden thorn
#

It does

kindred widget
#

@sand iris By default, only the player controller or a possessed pawn can RPC to a server. Clients cannot RPC in any way except for ServerRPCs. So if you want a client to network, it has to be through one of those two actors, or an actor who's owner variable has been set to one of those two on the server.

sand iris
#

I see, thanks!

torpid girder
#

Hi, I've been researching how to run a client and dedicated server from pie as separate processes, but all I get is a blank screen and nothing starts

slender yarrow
#

netmode: Play as client, then play as standalone client

#

Does anyone know if UGameplayStatics::ApplyPointDamage need to be called from a server ran function? I thought it automatically ran on the server but I am calling it and not getting any response from the actor

eternal canyon
#

depends

slender yarrow
#

this was the problem. I just fixed

eternal canyon
#

if its in a client event u have to use run on server

#

if ur not

#

then it should be fine

slender yarrow
#

it only auto runs on server from blueprints

young yoke
#

I'm having an issue with player movement replication (the rotation works fine). This is when testing in single process with multiple players. This used to work before I converted the project to a different (VRF) skeletal mesh and anim BP. I tried replicating more variables in the ABP, but it has not helped.

Second issue: It seems that the player movement doesn't work unless the PIE window is un-focused then refocused. Replicated physics actors also get no movement replication unless the window is not in focus (i.e. holding alt+tab will have the physics actor move, but then stops when the PIE window is re-focused). This wasn't an issue with my previous player pawn setup, but nothing major has changed other than the SKM and ABP

rustic hound
#

if I have an online server set up but it wants me to input a port value, is it fine if I set it to unreal's default port (7777/17777)?

#

im worried that if I set it to the same port, would there be any conflicts?
or is it the other way around? If they have separate ports, would the online connection not go through?

halcyon totem
#

is this a bad idea? Will this cause massive lag? The VR character movement is done on tick, and I have made it multicast and then ran this code. is this bad to do or is it ok?

summer tide
#

In seamless travel from lobby to gameplay map, all my characters will persist?

winged badger
#

not unless you make them persist

#

for that c++ is required

#

not much, but a little bit

summer tide
#

not possible in BP

#

Is that using GetseemlessTravelACtorList?

#

Where would that function go in c++? @winged badger

winged badger
#

is is, but one in PC

#

would need to be overriden

#

and its GetPawn() would have to be added to the array

still path
#

Does anyone know why, after joining a game session, the server map fails to load for the client? Logs show the session was joined but nothing seems to happen. Re-clicking the join button fails to join.

rustic hound
#

@still path check if the server map is opened as a listen server

#

and check for spelling

summer tide
quasi tide
#

Does anyone have an idea on why my AI still moves on the client, even though it is no longer moving on the Server?

Upon death, I detach the controller from the AI to stop it from moving. This works as expected on the server, however, on the client side, the AI is still moving 🤔

rustic hound
#

have you replicated the AI's death status to the client?

#

try using print strings to check

#

if the client doesnt also print out a message when the AI dies, that means its not dying on the client side

quasi tide
#

The animation plays, but if I remove the controller from the server side, and movement is replicated, how is it moving?

#

That is the part that I'm not understanding.

rustic hound
#

is it moving in a rubber-bandish way?

quasi tide
#

No - just a straight line.

rustic hound
#

not sure if this is how it works

#

but it might be that since its no longer moving on the server side, it doesnt attempt to update the AI's position anymore

#

which also means that it doesnt lock its position

#

and since the controller isnt removed from the client side, it keeps running

#

i believe thats how replicated movement works - by only updating the location when a change is made*

#

i suggest you replicate the removal of the controller to the client as well, that might fix it

quasi tide
#

From my understanding, the zombie doesn't actually exist on the client side, it's being controlled by the server, no?

rustic hound
#

sorry, what do you mean by doesnt exist on the client side?

quasi tide
#

The AI isn't actually running on the client, only the server.

rustic hound
#

oh, so its movement is hidden behind a "switch has authority" ?

quasi tide
#

No? The character movement component handles the movement.

rustic hound
#

I may be wrong here but i think that means the AI is actually running on both the client and the server

#

since the controller hasnt been removed in the client side, it will keep running for the client

#

but if the controller is reenabled on the server side and the AI starts moving again, I think the zombie would then rubberband back to the location it has on the server side

quasi tide
#

But the client does not have any authority over the AI. Even so, I've tried that theory out as well, and it still doesn't prevent the AI from moving on the client.

rustic hound
#

hmm

#

oh mb, didnt realize the AI controller only ever exists on the server side

cinder lily
#

So I'm doing multiplayer tests, want to make sure that when a player is looking at an object (which highlights it with a post-process stencil effect) only that player sees the outline. Initially the problem was, it only showed up serverside, so nobody except Player 1 (the listen server) could see it, and Player 2 couldn't outline at all.

I now have it showing up properly on clients, but every outline shows up for everyone. Is there a quick trick to making post-process effects specific to each player's screen?

This is in blueprints, not C++

winged badger
#

@cinder lily no, if you want a Pawn you really should override the GetSeamlessTravelActorList in PlayerController

#

apologies Korica, this was meant to ping @summer tide

#

idea for your stencils is that its always local only btw

#

no networking at all

#

just prevent the code for running if its not for the owning client

#

as for selections remaining the idea is this

#
// figure out which actor should be selected
void SetSelectedActor(AActor* InActor)
{
  if (InActor != SelectedActor)
  {
    if (SelectedActor)
    {
      // remove highlights from actor that was previously selected
      SelectedActor->Unhighlight();
    }
    SelectedActor = InACtor;
    // this is new Selected actor so it gets highlighter
    if (SelectedActor)
    {
      SelectedActor->Highlight():
    }
}
#

so the same function that triggers the highlighting of actors, removes the highlight from the previous one @cinder lily

safe marsh
#

hey, is it possible to test a multiplayer VR game using PIE clients?

#

for example, client A and B both sync their projects via git, launch into VR and connect via directIP

#

can client A run a dedicated+client or a listen server and B connect to it over WAN?

marble gazelle
gusty slate
#

Hello, just a reminder to my brain RepNotify should trigger on both clients and server yes?

kindred widget
#

@gusty slate Blueprint or C++?

gusty slate
#

BP

kindred widget
#

Should trigger on both then, yeah.

gusty slate
#

Hmm alright thank you. If the value doesn't change from what it currently is, does it notify?

kindred widget
#

Nope. In a very simplified version of what happens, the server will evaluate replicated properties often based on the netupdatefrequency setting and it's own tick rate. If the value has changed from what it was the last time it replicated, it'll replicate it. If it hasn't changed, it'll ignore it.

gusty slate
#

Amazing explanation thank you 👍

winged badger
#

the BP RepNotify isn't a RepNotify to begin with

#

its a hack

#

that made a PropertyChangeTracker act as a replication callback

#

you can set your RepNotify variable locally on client, and OnRep will get called

#

its also the reason why it gets called on Server (while it really shouldn't)

gusty slate
#

Hmm interesting, I do find it convenient that it gets called on the server tbh, it makes it that on a listen server all actors handle the effect of that variable change through the same call

kindred widget
#

It's not that hard to get the same functionality even without it calling itself on the server. It's just an extra line when you set a new value. Where as in blueprint, you have to write checks in your OnRep to not do things on the server version of it if you don't want the server OnRep to do something, that is the not convenient part.

gusty slate
#

I haven't stumbled on that situation yet but I understand what you mean

#

although it is the same thing really, either check to not apply on server or call functionality after value change

#

but yeah 🤷‍♂️

winged badger
#
void SetSomeValue(Type InValue);
void OnRep_SomeValue()
{
  SetSomeValue(Value);
}
``` works just fine
#

when OnReps aren't called on server

meager fable
#

I started using network profiler and under all RPC`s tab I'm only getting multicasts and client side rpcs. Why are there no Server side RPC profiled?

silent valley
#

So, using Steam and dedicated servers - my player count returned in the FOnlineSessionSearchResult is always 0.
Works ok with NULL subsystem.
Do I need to do an extra step to update the player count somehow?

#

i.e. result.Session.SessionSettings.NumPublicConnections == 0

empty axle
#

@meager fable you need to start profiling server side

meager fable
#

How do I achieve that? I run a listen server on my pc

empty axle
#

Or actually on client side. If in your profiling there are only multicasts and client calls that means it is already server side.
Just call the 'netprofile' command on some client window not on the listen server window

meager fable
#

oh okay, thanks

silent valley
meager fable
#

Does non-RPC code affect RPCs? EG if I have a ton of terribly optimised tick code in my game and run a listen server will more rpcs get delayed or canceled?

kindred widget
#

No personal experience on the matter, but I assume that it would at least be less snappy. Server having a better tick rate means it'll network faster as well.

chrome bay
#

for sure

#

It's all running on one thread

manic willow
#

Hello, people. A friend recommended this group to me. I work on this blueprints-only project and so there is this client-side delay upon logging to a listen server. I managed to narrow it down some point but cannot find the exact reason why it's happening. Is there someone with more XP than me who can have chat with me about it?

silent valley
#

Anyone got any tips for making Voice Chat work?
My colleague and I can hear each other a little bit but it seems the recording volume is VERY low and it records the first 0.2s and then it cuts off.

#

or do people use Vivox instead of the built in system?

silent valley
#

I mean I have it working using this kind of thing - but it just doesn't really work

#

can't hear my colleague very well

#

voice constantly cutting out

peak sentinel
#

I heard UE's built-in voice chat is not working very well but I never experienced before, but I just know my friends followed that link and not having any problems

#

Sorry if I couldnt helpful

silent valley
#

ok no problem, thanks for looking 🙏

shut gyro
#

@silent valley I have had the same problem with the default implementation of voice. You can try increasing the following and see if it works for you:

[/Script/OnlineSubsystemUtils.IpNetDriver]
MaxClientRate=2000000
MaxInternetClientRate=2000000

which means more voice packets have less of a chance of being dropped, but its still kind of unfeasible imo.

#

I just implemented vivox yesterday into my project at a basic level - free for all voice chat - and they have nice free edition support for up to 5000 concurrent users.

silent valley
#

ah.. that would explain it.
I actually also started evaluating Vivox 🙂

shut gyro
#

ShooterGame already lays it out all for you with Vivox

silent valley
#

👌

#

checking out the sample now 👀

chrome bay
#

Vivox is fine until you realise you're at their mercy when it comes to server downtime.. but tbh that seems to be a running theme with any MP game these days.

shut gyro
#

Yea. I’ve gotten used to it especially with EOS which has a lot of what I need with the payment of occasional downtime of the plugin

#

Which seems to be when big games get released for free like gta 5 xD

chrome bay
#

We've just had some very unlucky timings with Vivox when their servers go down for maintenance right as we push our update, which is frustrating for all involved

#

Plus I'm just not in general a fan of having 3rd-party dependencies but I'm out of touch with what online gaming is about these days 😄

silent valley
#

I would prefer no dependency but I just don't think the UE4 solution is going to cut it for production

#

we're aiming for 100+ players per server too

chrome bay
#

yeah, it's nice to not have game traffic bogged down with voip

shut gyro
#

I’m just waiting till Epic releases their own voice party solution via EOS, it’s planned on their trello board

#

Vivox is a nice intermediate till then.

urban cargo
#

Hey not sure if my issue should be in multiplayer or here so I'm having an issue where if the player1 for example gets a weapon its added to his view and the weapon is also added the the others people view and i want to disable the other view for player1 and so on (i don't get why disable for others or only owner see isn't working maybe im using it wrong idk
i think its more connect to blueprints than actual networking stuff

slim mist
#

Hi all, given the situation of an NPC being killed and having its audio component being played on both networked players on a listen server, would I execute AudioComponent->Play() on the NPC Actor's Server_Die or Multicast_Die function?

limber gyro
#

try it on server die first

#

if it works good

#

i am not sure how sound works with replication

kindred widget
#

Are you destroying them, or doing something like making the mesh simulate ragdoll?

slim mist
#

not worrying about ragdoll or destruction, just a sound

kindred widget
#

I was just going to make mention that you could spawn sound at location based on which of those you do. I think all clients would call EndPlay if it's destroyed on the server. Alternatively if you were ragdolling you'd probably have some form of replicated value to set it up, which could call the same PlaySoundAtLocation on each client.

slim mist
#

I'm doing attached sounds

limber gyro
#

i am a bit confused by particle replication maybe one of you can help, i have 2 bullet actors a regular 1 with a mesh that gets destroyed on hit/overlap and another one that has a raycast on the tick. The one on the raycast on tick the particles only spawn if i multicast, the other one doesnt need a multicast i can just spawn the particles normaly and it works, why does that happen?

#

they are both replicated

kindred widget
#

Hard to say without seeing it. Possible your one with the hit/overlap is also playing on client. Where the tick isn't?

slim mist
#

Question about client/server ownership. A player possesses a pawn - the player owns the pawn. The player also has a reference to a weapon actor and triggers its fire function. Does the player or server own the weapon actor?

limber gyro
#

@kindred widget thats an option

#

@slim mist depends if the server spawned it or not

kindred widget
#

The AActor* Owner variable inside of an Actor determines who owns an actor. This is automatically set for Pawns when a controller possesses them. For anything else you have to set the Owner variable on the server.

#

This is true even if the controller or pawn spawn the weapon. It's owner value will be null until it's set unless you pass it into the spawn parameters. So technically the server owns the weapon until that variable is set to the server version of someone's Controller, or something the Controller already owns.

slim mist
#

gotchya! that makes sense 🙂

#

thank you

#

this helps a ton

summer tide
#

@winged badger So I assume GetSeamlessTravelActorList will be in the parent controller class for the lobby Player Controller, since I'm using blueprint.

winged badger
#

it will be in APlayerController in c++

summer tide
#

Yea but for Lobby Player Controller or Gameplay Player controller.

#

I have those two controller in BP.

winged badger
#

neither

#

i mean

#

departing controller c++ base

#

has to implement it

#

and whatever is designated for controller on travel map as well

slim mist
#

Is there a free starter project that demonstrates good practices with respect to replication?

kindred widget
#

Not the starter projects, but if you can follow C++, Shootergame is a good place to go.

slim mist
#

great

#

perfect

#

thank you!

#

This'll probably fill in all the knowledge gaps I have for the moment 😆

kindred widget
#

Learn tab in the Epic Games Launcher, if you're not sure where to find it.

ember needle
#

@slim mist it often makes sense to set the ownership of a gun to the player that owns it. In this way, you can use replication functions inside of the gun itself, otherwise you need to go through the PC or the character.

#

obviously the ownership needs to be set by the server, and in general it's part of the "player took the gun" routine that anyway goes through the server

#

my $0.02

slim mist
#

thanks @ember needle 🙂

kindred widget
#

@slim mist Not sure about Github. I always download it from the Learn Tab.

quasi tide
#

Hot diggity dog - after hours upon hours of bashing my head against the wall...it's working...it's finally working. I successfully have my FPS networked-ish. Clearly doing some bad things, but it's nice to actually see it working. (It's a PvE, so I don't care so much about cheating). I also don't get to work on this that often.

#

For hit detection, I'm pretty much just doing the line trace on the client side, and if there is a hit, I just tell the server that I hit something by sending the FHitResult struct. Then letting the server do all the calculations. I plan on making a custom struct to see if I can send even less info. But this is working for now. I know it opens the game to some pretty easy cheating, but again, it's a PvE, with no plans of leaderboards or anything like that. So, I don't really care if people want to cheat in their own game. If that's what they think is fun, so be it.

still path
#

@rustic hound what would be the best way of accomplishing that? Opening the level on the client side (solo or hosting a game) works fine, just doesnt like to open when joining a server.

leaden narwhal
#

Guys Is Making Multiplayer In Unreal Engine Easy Or Hard ???

quasi tide
#

How do ya'll normally test MP? Under one process or not?

slim mist
#

thanks @kindred widget 🙂

#

God I am so spoiled with this engine

kindred widget
#

Haha. I feel you. I've been at this a whole year and I doubt I'd have learned half this much in Unity or CryEngine.

shadow schooner
#

hellooo again people

#

so I am trying to do something like color selecting that you can select the color of your player

#

and while I see the material on mine client

#

it doesnt appear to anyone else

#

here is a blueprint

#

the blueprint is called on playercontroller

#

any ideas why this isnt working?

hidden thorn
#

@leaden narwhal I guess it depends who you ask, I tried to make a multiplayer game in Unity and ...... I found it harder than in UE4, also I picked up the concepts in UE4 far quicker than in Unity.

summer tide
winged badger
#

if you add Super call, yes

kindred widget
#

@shadow schooner This should generally be done with replication. You're only seeing it on one client because clients can only RPC to Server. They cannot Client/Multicast. If you Server RPC from the client to then multicast this would work. But I'd recommend RPCing to the server to set a replicated property instead, and using the OnRep to change the color in each client. That way the state will persist.

slim mist
#

reading through ShooterGame's implementations, especially with weapon...mind. blown.

#

WOW

summer tide
#

@winged badger Then what I need to do in Bp. Would it take the lobby character that I customized and spawn in gameplay? Or Do I still have to spawn the player? manually?

slim mist
#

SO LUCKY I get to see a battle-tested implementation

#

here I am playing with lincoln logs trying to figure it out on my own

winged badger
#

you should not spawn the player if you're persisting it

#

its relationship with the PC and PS will persist

#

and it will not call BeginPlay once it arrives, since it already did in lobby

shadow schooner
summer tide
#

Do I have to change their location to the PlayerStart?

shadow schooner
#

so it should replicate through the server

kindred widget
#

@shadow schooner In that case, Mesh likely isn't replicated. Don't replicate it though. Get the local client version.

summer tide
#

@winged badger Trying to understand . Then how would I transfer the character once the gameplay level is loaded?

shadow schooner
kindred widget
#

What do you have at the moment?

shadow schooner
#

wdym

kindred widget
#

Your code, what do you have at the moment?

shadow schooner
#

i have it on global game controller

kindred widget
#

What does that mean? Server's Player Controller? Or is GlobalGameController a class name?

shadow schooner
#

you remember the other day with the lights?

#

its the same controller

kindred widget
#

How are you calling the multicast?

shadow schooner
#

through an actor (the player)

kindred widget
#

If the multicast is in the player controller, what specific function calls that multicast, and from what specific actor? And have you changed the multicast in any way since you last posted it?

shadow schooner
#

that is inside the actor that I now made the whole actor replicated and still doesnt work

#

the actor = playable

#

thats the errors

kindred widget
#

In this screen. If you click on Mesh2P, is that checkbox on the right that says ComponentReplicates checked?

shadow schooner
#

i am 100% blind

#

let me check if this works out

kindred widget
#

You can't send a pointer over the network if it points to a non replicated object. And component replication isn't advised. That's why you should get the local client's version instead of replicating that component and sending it over the network.

#

Well, I wouldn't say isn't advised, but in this case, it's very easy just to affect the client's version without replicating it.

shadow schooner
#

eh

#

I checked on replicated

#

and it still doesnt work

empty axle
#

And that multicast will also not work as you can call them only on the server

kindred widget
#

Are you pressing that button from the server's screen?

shadow schooner
#

on boths screen

#

nothing

shadow schooner
kindred widget
#

@shadow schooner I really strongly advise just going this route.

shadow schooner
kindred widget
#

Clients cannot contact each other. Clients can only singularly talk to the Server. So you tell a client to ask the server to set a replicated integer. When that integer replicates to any client, that client can set the texture on that actor that replicated it like the second image.

shadow schooner
#

wait I think I understand it but

#

this isnt supposed to change colors of everyone?

kindred widget
#

If you have three clients and a server player. That's four players total. If client 2 presses P with what I just posted. Only their character will change materials, but it will happen on all machines.

#

That's 16 total characters, 4 characters on each machine. But only one character on each machine changes colors from the press of P

#

If you want every character to change colors, you would need to RPC to the server, Get all of the player's characters, and make all of them replicate this.

#

So are you wanting every single character to change colors, or just the client that presses the button?

shadow schooner
#

how did you do that w/notify?

kindred widget
shadow schooner
#

whats the diffrence?

kindred widget
#

Replicated just replicates the value to all clients. RepNotify creates a function that gets called when that value is replicated.

#

Kind of a heads up to clients that the value changed.

shadow schooner
#

oh nicee

#

let me check if that works

#

@kindred widget someone must give you a rank promote or something

#

you are amazing it worked and I understand know how and why it worked

kindred widget
#

Eww. Responsibility. Get it off.

shadow schooner
#

ahahahaha

kindred widget
#

That's good though. Just remember that when you replicate any actor, that means that the server is spawning an instance of it on all clients. Always remember to consider that each instance of something spawned and replicated from the server is connected to it's client instance, but only the server can make it do things on all clients. Kind of like with the character point. Four players on a Listenserver setup means 16 characters total, 4 on each client, with only one of them being able to send ServerRPCs per machine, and only one machine being able to tell the other machines what their version should do. Bit to wrap the head around at first but it gets easier.

slim mist
#

Dumb question: Player is on Map A in Server A. Player switches to Server B in Map A. Why do games have the player reload the assets of Map A instead of just changing object states which I assume would require no loading?

shadow schooner
quasi tide
#

According to the docs, rep notify is supposed to be better than RPC's and you should favor them over RPC's.

shadow schooner
#

seems fair as it has a whole on change style function

slim mist
#

Hey all, what purpose would setting the owner of a weapon's bullet serve? This is an excerpt from Epic's ShooterGame.

void AShooterWeapon_Projectile::ServerFireProjectile_Implementation(FVector Origin, FVector_NetQuantizeNormal ShootDir)
{
    FTransform SpawnTM(ShootDir.Rotation(), Origin);
    AShooterProjectile* Projectile = Cast<AShooterProjectile>(UGameplayStatics::BeginDeferredActorSpawnFromClass(this, ProjectileConfig.ProjectileClass, SpawnTM));
    if (Projectile)
    {
        Projectile->SetInstigator(GetInstigator());
        Projectile->SetOwner(this);
        Projectile->InitVelocity(ShootDir);

        UGameplayStatics::FinishSpawningActor(Projectile, SpawnTM);
    }
}
summer tide
#

Is there a way to store skeleton meshes in gameinstance from lobby and then assign them to characters in gameplay?

slim mist
#

I believe your skeletal mesh would be a pawn which you then have the playercontroller posses

summer tide
#

My character has the default mesh then have some skeleton meshes as children. For example, head, chest, arms, legs, etc.

#

When I customize the chars, I assign some SK meshes to them for either male or female.

floral crow
#

Hey guys, on a shipping build the clients never try to connect to the Server (this works perfectly on non-shipping builds). Something worth noting is that the clients think they are running in stand alone mode. Why could this be? We're using the default NetDriver

meager spade
#

clients will be standalone till they join a server no

#

?

slim mist
#

Will MyPawn->IsLocallyControlled() ever return true when ran on a server?

meager spade
#

not dedicated server

#

listen server, yes

#

dedicated server can never be controlled locally

#

in response to you other question, the owner allows for network RPC's to be used on the bullet, use owners relvancy, etc.

still path
#

Will the join session node automatically load the correct map for the server or do I need to run an open level node to get that part done?

slim mist
#

thank you so much @meager spade 😄

#

I think that may be an answer to my next question...

#

I traced the execution flow from AShooterCharacter::OnStartFiring all the way to AShooterWeapon::ServerFireProjectile, and it appears that there are three instances where an RPC call to the server is made, which I think would result in 3 projectiles being shot for 1 input from the player. Obviously, the server only ends up calling ServerFireProjectile once. Where did I go wrong?

#

I don't understand why RPC calls are made to the server after AShooterWeapon::StartFire, which is when it makes its first call to the server...and the server then calls StartFire. I'd assume the server would run the rest of the execution without needing more calls further down the execution line

floral crow
#

Does anyone know how to set the net driver to the demo one? I was expecting a Project Setting or something like that but nope... I'm googling, but just in case anyone knew already

meager spade
#

normally its in your config

#

we do nothing special for shipping builds

floral crow
#

DefaultEngine.ini it looks

tired zodiac
#

Does anyone know what / if it's possible to get a character with multiple skeletal meshes to replicate? - i have tried in a clean project and adding a 2nd skeletal mesh to the character breaks replication animations. (In blueprints)

faint lotus
#

I tried making a change, but I probably formatted it wrong. The only related instructions I could find were for setting up the use of the Steam driver, which I don't want to do - is there a set of instructions for how to explicitly tell it to use the default? Right now, the client is convinced it is a standalone and never even tries to connect, despite me giving it an IP address as its first argument.

#

(This is with regards to Nahuel's comment - I am said coworker)

slim mist
#

Is my understanding of roles correct?

       Actor | Pawn A   | Pawn B   | Pawn C
Possessed by | Player X | Player Y | none
 Listen host | true     | false    |


Computer | Player X
   Actor | Pawn A    | Pawn B    | Pawn C
    Role | Authority | Authority | Authority

Computer | Player Y
   Actor | Pawn A    | Pawn B     | Pawn C
    Role | Simulated | Autonomous | Simulated
faint lotus
#

To give full details on what we're seeing:

  • When we attempt to launch our game as compiled for the Development target and connect, everything works as expected.
  • When we attempt to launch our game as compiled for the Shipping target and connect (with an identical command for client and server as used for the previous test or with new ones) the server starts up and never sees traffic while the client starts up and never tries to connect.
  • I was able to determine that the client believes it is standalone by injecting some debug code into the constructor of our PlayerController class. GetNetRole() returns NM_Server on the server and NM_Standalone on the client.
  • I followed into the internals for GetNetRole() and found that it calls InternalGetNetRole() which checks to see if you have a driver, and if you have a driver uses the role it sets. If you don't, it checks to see if it can get a World* and if the world and its demonetdriver are non nullptrs. If it succeeds, it gets your role from the demo driver. If not, it defaults to standalone. I checked, and for our clients, the driver is null and it can't get to the world so it can't get the demo driver. This appears related to our connection issue, from what I can see.
#

The important code here is:

{
    UWorld* World = GetWorld();
    UNetDriver* NetDriver = GetNetDriver_Internal(World, NetDriverName);
    if (NetDriver != nullptr)
    {
        return NetDriver->GetNetMode();
    }

    if (World != nullptr && World->DemoNetDriver != nullptr)
    {
        return World->DemoNetDriver->GetNetMode();
    }

    return NM_Standalone;
}```
#

Test code being:

    auto* driver = GetNetDriver();
    if(driver == nullptr)
    {
        UE_LOG(LogImmortalNet, Warning, TEXT("I have no driver"));
    }

    if (AActor::GetWorld() != nullptr && AActor::GetWorld()->DemoNetDriver != nullptr)
    {
        UE_LOG(LogImmortalNet, Warning, TEXT("Yo, but I can use the demo driver."));
    }

    switch(netmode)
    {
        case NM_Standalone:
        UE_LOG(LogImmortalNet, Warning, TEXT("I think I'm a standalone!"));
            break;
        case NM_Client:
        UE_LOG(LogImmortalNet, Warning, TEXT("I'm a real client!"));
            break;
        default:
        UE_LOG(LogImmortalNet, Warning, TEXT("I am very confused..."));
            break;
    }```
#

Outputs:

I have no driver
I think I'm a standalone
#

Of course, it could be evaluating that way because it really is set to be a standalone for some reason, but if so, I can't tell why or why it only happens in shipping builds.

slim matrix
#

dose anyone know what the average packetloss in video games is

limber gyro
#

why does that matter? in ue4 anything that needs to be 100% replicated can be done so

slim matrix
#

UE has a command in the console that lets me set the packet loss and I was wondering what the average packet loss is in households so I could see how well things are with normal and higher than normal latency and packet loss

#

Mainly I want to see how jittery clients movement gets because if it’s high then they player movement is jittery

faint lotus
# slim matrix dose anyone know what the average packetloss in video games is

I'm just going off of conversations with network engineers I've worked with in the past and not hard numbers, but my understanding is that it can vary pretty wildly based on region, ISP, time of day, and user setup as well as whether you're on someone's backbone or dependent on the standard consumer internet.

#

And, generally speaking, that you're less concerned with the median or mean case and more concerned with the worst subsection of consumers, but, again, ymmv.

floral crow
slim matrix
#

also dose UE have a way of telling if packet loss and latency is bad because I've seen how some games will alert you by showing icons if you connection is bad

slim mist
#

Will IsLocallyControlled return true for a possessed pawn when the check is made on the server?

slim matrix
#

I'm pretty sure it will only return true if it is possessed as that pawn

slim mist
#

Did some more research and it appears that IsLocallyControlled() returns true if being ran on the possessing client's machine or the server's machine of an actor that is possessed by remote client.

#

Does anyone know what the roles would be if it was a listen server and client 1 was the host?

winged badger
#

its true if its controller is local

#

owned by the machine that called it

slim mist
#

Thank you @winged badger! My understanding of the code and the above answers.unrealengine post seem to point towards a different conclusion, but I assume that my understanding is incorrect. One sec, I'll copy/paste the inferences

#
// Invoked from IsLocallyControlled()
bool AController::IsLocalController() const
{
    const ENetMode NetMode = GetNetMode();

    if (NetMode == NM_Standalone)
    {
        // Not networked.
        return true;
    }
    
    if (NetMode == NM_Client && GetLocalRole() == ROLE_AutonomousProxy)
    {
        // Networked client in control.
        return true;
    }

    if (GetRemoteRole() != ROLE_AutonomousProxy && GetLocalRole() == ROLE_Authority)
    {
        // Local authority in control.
        return true;
    }

    return false;
}
winged badger
#
bool APawn::IsLocallyControlled() const
{
    return ( Controller && Controller->IsLocalController() );
}
bool AController::IsLocalController() const
{
    const ENetMode NetMode = GetNetMode();

    if (NetMode == NM_Standalone)
    {
        // Not networked.
        return true;
    }
    
    if (NetMode == NM_Client && GetLocalRole() == ROLE_AutonomousProxy)
    {
        // Networked client in control.
        return true;
    }

    if (GetRemoteRole() != ROLE_AutonomousProxy && GetLocalRole() == ROLE_Authority)
    {
        // Local authority in control.
        return true;
    }

    return false;
}```
#

literally all you need

#

everything but source code is wasting time and energy in this case

#

translation

slim mist
#

The second if condition is satisfied when ran on the local controller because their role is AutonomousProxy, and the third if condition is satisfied when ran from the server because their remote role is authority and the local role is

#

AH HAH

winged badger
#

if you are in singleplayer, it returns true

slim mist
#

Now I see where I went wrong!

#

I totally misunderstood the second if condition

winged badger
#

if you are client and own the controller, it returns true

slim mist
#

remoterole == authority, but the localrole == autonomous

#

(when ran from the server)

#

I was reading the source code but misunderstood the s third if condition

winged badger
#

and if you are server/authority and no client owns it, it returns true

#

which also means AIControlled Pawns will return true

#
bool APawn::IsPlayerControlled() const
{
    return PlayerState && !PlayerState->IsABot();
}
#

just in case you want to tell the AI apart from listen server host's pawn

slim mist
#

Sweet! This is really helping me. So, this is all in a bid to fully understand ShooterGame's execution flow of firing a weapon. I am at one last crossroads. Would you be available to help me discern this one function? It is a doosy of a function, though

#

My current mapping of the execution flow has the server repeatedly being invoked at different times during the execution, which means my understanding is incorrect

winged badger
#

you can try to paste it here

#

no promises

slim mist
#

Thanks. I'll think I can cut out most of the function

winged badger
#

a milestone day just ended 🙂

slim mist
#

Congrats! Bet it was a lot of work leading up to it

#
void AShooterWeapon::HandleFiring()
{
    if ((CurrentAmmoInClip > 0 || HasInfiniteClip() || HasInfiniteAmmo()) && CanFire())
    {
        if (GetNetMode() != NM_DedicatedServer)
        {
            SimulateWeaponFire();
        }

        if (MyPawn && MyPawn->IsLocallyControlled())
        {
            FireWeapon();

            UseAmmo();
            
            // update firing FX on remote clients if function was called on server
            BurstCounter++;
        }
    }
       // ....
       }
}
#

so, the remote client who owns this would run FireWeapon, UseAmmo, and BurstCounter, but burst counter wouldnt be replicated

#

note: the server ALSO runs handlefiring due to a previous execution

#

the server wouldnt run fireweapon, useammo, and burstcounter++, right?

#

MyPawn && MyPawn->IsLocallyControlled() would return false for the server, right?

winged badger
#

without seeing FireWeapon

#

no idea what and where the RPCs are

slim mist
#

sure, one sec

#

later in HandleFiring, the client then invokes the server to run HandleFiring

// local client will notify server
        if (GetLocalRole() < ROLE_Authority)
        {
            ServerHandleFiring();
        }
#
void AShooterWeapon::ServerHandleFiring_Implementation()
{
    const bool bShouldUpdateAmmo = (CurrentAmmoInClip > 0 && CanFire());

    HandleFiring();

    if (bShouldUpdateAmmo)
    {
        // update ammo
        UseAmmo();

        // update firing FX on remote clients
        BurstCounter++;
    }
}
winged badger
#

entire function

slim mist
#

coming up

#

gonna gist it, too big for discord

winged badger
#

can go in 2 messages

slim mist
#

refresh for color coded syntax

winged badger
#

i am also inferring

slim mist
#

the thing that I dont understand is that either FireWeapon, UseAmmo, and BurstCounter is only ran on the client which means that BurstCounter++ is never replicated to other clients, or that FireWeapon is ran both on server and client...but FireWeapon makes another call to server, which would mean FireWeapon is invoked twice on the server

winged badger
#

that OnRep_BurstCounter (Replicated, COND_SkipOwner) does SimulateWeaponFire(), yes?

slim mist
#
void AShooterWeapon_Projectile::FireWeapon()
{
        /// bunch of stuff
    ServerFireProjectile(Origin, ShootDir);
}
#

yep

winged badger
#

so all shots except owning client are fake

#

as far as FX goes

slim mist
#

yep

winged badger
#

server does it when it gets an RPC to fire, and simulated proxies do it from onrep

slim mist
#

I'm tripped up because it appears that ServerFireProjectile(Origin, ShootDir) seems to be invoked twice, but clearly that isnt the case because only one projectile is spawned when shooting

winged badger
#

by the looks of this

#

i'd say its either or

#

heatscan weapons won't call that function at all

#

only functions that actually send a server RPC start with Server

slim mist
#

Here is me tracing the entire execution flow, and it appears ServerFireProjectile is called twice which would result in two projectiles being spawned for every time a weapon is fired

// Remote Client
C:SetupPlayerInputComponent
C:OnStartFire
C:StartWeaponFire                    // Server
W:StartFire -----------------------> ServerStartFire
DetermineWeaponState                 StartFire
SetWeaponState                       DetermineWeaponState
OnBurstStarted                       SetWeaponState
HandleFiring                         OnBurstStarted
FireWeapon                           HandleFiring
ServerFireProjectile                 FireWeapon
                                     ServerFireProjectile
#

I wish I could find the github repo for this so that I could provide links

winged badger
#

you want to do it proper

#

compile DebugGameEditor from visual tudio

#

put a breakpoint

#

and look at the callstack

slim mist
#

👍

winged badger
#

whats the ServerFireProjectile_Implementation?

slim mist
#
void AShooterWeapon_Projectile::ServerFireProjectile_Implementation(FVector Origin, FVector_NetQuantizeNormal ShootDir)
{
    FTransform SpawnTM(ShootDir.Rotation(), Origin);
    AShooterProjectile* Projectile = Cast<AShooterProjectile>(UGameplayStatics::BeginDeferredActorSpawnFromClass(this, ProjectileConfig.ProjectileClass, SpawnTM));
    if (Projectile)
    {
        Projectile->SetInstigator(GetInstigator());
        Projectile->SetOwner(this);
        Projectile->InitVelocity(ShootDir);

        UGameplayStatics::FinishSpawningActor(Projectile, SpawnTM);
    }
}
#

OnRep_BurstCounter (Replicated, COND_SkipOwner) would require BurstCounter to be mutated by the server for it to replicate, right?

#

i've been at this for hoouuuurs today

slim mist
#

This function is insinuating that BurstCounter++ will be called on a server, but I don't see how IsLocallyControlled() would ever return true for the server?

if (MyPawn && MyPawn->IsLocallyControlled())
{
    FireWeapon();

    UseAmmo();
            
    // update firing FX on remote clients if function was called on server
    BurstCounter++;
}
#

okay,I think it straight up doesnt because I see the server increments burstcounter elsewhere in the code

#

FINALLY. I've finished understanding this...after 5 hours...

slim mist
#

which idk, maybe they fucked up? but thats generally wrong assumption by a reader

rapid bronze
#

Hello, i have a little worry about something

I wrote a code that saves a .JSON file of the player stats on the Machine in a specified project path and when it's requested it loads them from the said file
Basically acting like a simplified local Database, if it can be called like that
All of it is in the GameMode

My worry is when I'll create a Development Server Build and run it on Dedicated, a Client connected to the server, will it have the file saved locally too or since it's all handled in the GameMode will only be saved on the Server Machine?

Never really did anything like this before, thanks i advance ^^

quasi tide
#

When do you think using replication graph is beneficial?

vivid seal
#

i have an OnRep in my player controller for the player pawn, that spawns the UI on the owning client when it receives a valid pawn reference. this works fine, and the pawn is valid on clients, the UI is spawned, but then every component I try to access on the pawn during the UI widget's OnConstruct event is null. is an actor considered valid before all of its components are initialized, or is my issue something else?

winged badger
#

your controller and pawn might and are likely to replicate in separate frames

#

meaning your PC can have a valid Pawn NetGUID but no pawn to resolve it to

vivid seal
#

is there a callback i can hook into in blueprint for when the pawn is actually there on clients? or do i have to go manually add a call in the player character class i'm using to tell the controller it exists (on beginplay for clients or something)

#

also i have changed nothing and now i don't get the error

winged badger
#

blueprints don't have a good hook

vivid seal
#

so its definitely some replication race condition

winged badger
#

HUD BeginPlay

#

likely best of the options

supple mural
#

Hey guys, I'm confused about the GameState. I have an event in there that works by looking at the player states of different players and does stuff with that info, but how do I activate this event?

#

is this the right place to ask this question?

hollow stirrup
#

GameState is mostly for replicating values, best practice-wise. That being said, if you need to use a method in there, feel free to reference your GameState through your GameMode, which has all sorts of default callbacks and ways to access it

supple mural
#

Ah so I'm going in the right direction. That's good to hear thanks a lot!

hollow stirrup
#

Keep in mind your gamemode only exists on the server

#

So if you need something to execute on clients you have to create a method in your playercontroller and call it through those

#

Playercontrollers are only replicated individually though, so they only exist on the owning client and the server (for each), so make sure you iterate through all of them if you need something called on all clients

#

Finally, gamestate values can't be modified by clients, so if you're planning on editing them, the playercontrollers will have to send a request back to the server and have the server-version of the playercontrollers doing the modifications

lime leaf
#

Hmm, what could make a server spawned replicated actor valid on the server but not valid on the client?

#

I do a retry to update a map since maps aren't replicateable..

#

*replicable

#

I replicate an array of said actors that are valid on the server, but going through the array on the client they are all invalid

#

both the actor making the array and all the actors in the array are set to replicate and with always relevant and net load on client..

#

I have an event I call with a 1 second delay to then call the function to make the map, and if it fails to do so, calls the event again waiting one second more, still, the actors do not become valid on client.. even when no further changes to the array are done on the server..

kindred widget
#

@lime leaf What are you trying to do exactly? Why would you want a replicated actor on the server alone and not on a client? The whole point of replication is to have it on clients from the server.

lime leaf
#

You haven't properly read what I wrote or it didn't come across clear enough hmm, well obviously I want the actors replicated, it is just that on the client IsValid returns false

#

for the actors in the array, the number of entries is correct but all are giving access error " trying to access .. none"

#

I do wait 0.2 secs before the check, and if the check fails I wait some more, it is just that even if the actor containing the array is replicated, the array is set to be replicated, and the actors in the array are also set to replicate, the replicated array contains invalid actors

#

they are valid and fine on the server

#

so of some reason they aren't valid on the client.. I've googled a lot here and found some reference to the actors having to have owner be something active on the client, which isn't my issue.. hmm

#

Seems I have some instability in replication.. not sure why.. other objects set to replicate don't always as they should.

kindred widget
#

Oh, yes, I did misread that as "How can I make."

#

The actor itself is replicated, and the Array of pointers pointing to the actors are replicated?

lime leaf
#

yup

kindred widget
#

Is the place storing the array replicated as well?

lime leaf
#

but the actors in the array, even if valid on the server and fine, on client IsValid is false and trying to access them gives an access error to "none"

kindred widget
#

And not a player controller of another client?

lime leaf
#

the actor containing the array is replicated yes

#

the actors in question are "Upgrade" and the "Player_Upgrades" contains the array, it's owner is "Player" which is owned by a custom playercontroller on both server and client

#

I have other things that replicate fine, so hmm..

#

I need the Upgrades replicated so I can display stuff in the UI of the client 🙂

#

So Upgrade has repnotify for f.ex. progress, which is triggering update of UI for a progressbar, stuff like that

kindred widget
#

That's certainly not normal behavior. If you have replicated actors inside of a replicated array of actors, on a replicated actor, the client version of the replicated actor with the array should be updated whenever the server changes it's array.

#

Can I see how you're checking the replication?

lime leaf
#

hmm, I could make some screenshots of the process maybe

#

Basically I just call spawnactorfromclass for the upgrade in question, that inherits from Upgrade, and then add it to an array called Upgrades, in Player_Upgrades

#

the array has the correct number of entries and I have meticulously gone through all Upgrade classes and checked that all are always relevant, replicated and net load on client..

#

*the correct number of entries on the client, just invalid entries..

#

I don't know if screenshots makes much sense.. it is as explained..

#

then what I do after spawning all the upgrades, I call the event that is to execute on the client, to build the UpgradesMap which contains Upgrades on IDCode (string), and it gets all actors from Upgrades on the client and add them, since maps can't be replicated..

#

but it fails to get IDCode since the Upgrade actors in Upgrades are all "none" .. on the client :S

kindred widget
#

I wonder if the client call or the array replication is happening faster than the actor replication somehow.

lime leaf
#

Well it wouldn't matter a lot, if it fails on the client it calls the event again, which I have linked as a run on server calling a run on client chain (2 events) then calling UpdateMap again... hence if it takes longer before the Upgrades are spawned, it tries again until it goes through.

#

But what happens is that it never does, seconds pass and print strings of "failed, waiting.."

#

Thing is, I took a 1+ year break from multiplayer and did a lot of changes, programmed computerplayers and singleplayer modes, now coming back to multiplayer it doesn't work, I vaguely remember it worked before.. hence, it might be that 4.26 contains a bugfix, one can hope 🙂 Other than that, IDK what I am doing wrong here..

kindred widget
#

That is odd. I would definitely double check the actors being spawned for their replication. The array seems to replicate fine if it has invalid entries and it's not set on the client. The only reason those entries should be invalid is if the client doesn't have that actor spawned from the server. And replicated actors spawned via SpawnActorFromClass are always replicated at some point.

lime leaf
#

Yeah, what I am thinking too, this theoretically should be working

#

I can do some checks as you said, have a "hollar" from the Upgrade class to check if it spawns on the client

#

Getting "Upgrade says hello from client" doing an IsSever-not-branch and a print string so, the Upgrade actors are replicated

kindred widget
#

If you put a single print just on BeginPlay, it prints from all clients and the server?

#

Also, are you working in BP or C++?

lime leaf
#

both C++ and BP in general but for this one for now only BP

#

When I spawn the Upgrade, and then add it to the Upgrades array, is there a chance it just stores "none" if the actor isn't yet spawned? shouldn't be, I mean it should store a reference to the to-be spawned actor, it does work other places in the game..

kindred widget
#

I highly doubt you're getting a nullptr from the SpawnActorFromClass, unless the spawning fails. But for something like that, you can just make it ignore conditions and spawn always anyway.

lime leaf
#

Nevermind I did check the valid on the server before adding to the array, the Upgrade was valid

#

Also the Upgrade now in a test does report from the client that it is running from ticks.. so I know it is spawned on the client. I have other things that spawn the same way into an array that is replicated and it works.. so this is mysterious

kindred widget
#

Do the upgrades print from all clients and the server itself if you just do this in their graph?

lime leaf
#

lol, it takes time to test here since the game has startgame screen and multiplayer setup, and level streaming, but yeah, I added what you said and suddenly I got ONE Upgrade working haha

#

a random upgrade in the midst of all

#

reports being found in the client UpdateMap function

#

At least one worked, this is just weird

#

by adding the begin play..

#

not in that one in particular but in the parent class Upgrade

#

lots of handler actors/classes are spawned one by one in a sequence on server, separating them to not all be run on same frame

#

Player_Upgrades is just one of many, Player_Criterias has same problem, very similar

#

All of this works flawless in singleplayer, so the bug has to do with replication I reckon

chrome bay
#

very rare that anything made for singleplayer just works in multiplayer tbh

lime leaf
#

Might be a systemic bug, since I also have ores (it is an RTS) ores of gold and crystal, that I spawn similarly on server and client, but fails to initialize on client..

chrome bay
#

perhaps you're spawning too much

lime leaf
#

@chrome bay yah

kindred widget
#

Wouldn't the clients still eventually get updated though? Even if it's seconds later.

lime leaf
#

maybe.. I do have 0.2 sec delay between each step in the init sequence, I could add more delay

chrome bay
#

Sometimes if you're really hammering it you can drop the spawn packets

lime leaf
#

yeah @kindred widget that's what I thought too..

chrome bay
#

Delay isn't really a solution because anybody who joins after the initial step will still receive them all at once

#

Here's the worlds most awful video showing spawn packets being dropped

#

Doesn't take long before the client stops seeing actors

#

Network is just busy being hammered by everything else

lime leaf
#

@chrome bay it waits till all clients have loaded the map, then runs init on the map, then waits till all are done on all clients, then runs the making of the players which have ticks on each that goes through their own sequence of init of server objects for the player/client, no clients join later, they are allready logged in on gamemode when this goes on

#

but hmm..

chrome bay
#

What happens when a client leaves then wants to re-join?

#

It's not really a suitable solution

lime leaf
#

I know ticks can drop, already accounted for

chrome bay
#

But also depending on what the network condition is at the time, you still have no idea if the first step made it to a client yet

#

So you really can't rely on it

#

Have you tweaked any of the base actor settings, like net update frequency etc for these actors?

#

The default is 100, which is obscenely high

#

If those actors are also moving, there's another big chunk of bandwidth gone

lime leaf
#

@chrome bay probably need to be better, sure. It is dependent on all clients keeping connected as it is right now.. I am aiming for listen server and LAN play first, then hopefully Steam

#

The steps are triggered by strings, the strings change once the steps are done. in this case though, just a delay and an event on the client to update a map..

#

the strings are also added to an array and hence not done twice.. the client calls a server event to set the next string in the sequence when it is ready, for when it needs to be done on client before proceding..

#

But it isn't built to handle disconnect/reconnect yet..

chrome bay
#

an array of strings is possibly replications' worst enemy also 😄

#

arrays of arrays

lime leaf
#

oh, well the strings are only on the server, but nah, all is bytes anyways! 🙂

chrome bay
#

Is this for some kind of procedural spawning?

lime leaf
#

I started programming at age 12, I am now 49 ..

#

Always learning though, a noob at a lot still

#

4 years of unreal engine

chrome bay
#

What I mean is TArray<FString> is less than ideal for replication

lime leaf
#

If you scroll up you see what it is

#

the string stuff is just the sequence for initializing objects, has nothing to do with the replication issues with Upgrades

chrome bay
#

right ok, from what I can gather it's just spawning too much stuff. How many actors are you spawning on the server then replicating to clients?

lime leaf
#

Except I do replicate strings (!) in Upgrade .. hmmm would that be a problem though? works fine for other objects

#

it is maps that is not replicable hence the workaround with updating a map on the client side from a replicated array

chrome bay
#

But how many actors are you spawning?

#

Not an entire maps worth surely?

lime leaf
#

74 Upgrades, most of the steps are less objects..

chrome bay
#

Note that any actors saved into a maps can be referenced over the network already

#

So 74 actors in total?

#

I think ultimately you're just going to have to profile it so see what's going on

lime leaf
#

but spawning prototypes is a lot more heavy and seem to fail sometimes too.. prototypes are buildings and a lot more data, hmm.. spawning a lot shouldn't really be a fail though..

chrome bay
#

well it will be, as you can see from that video it only takes 100-130 actors being spawned in succession, in editor, before the client stops seeing them

#

using the default settings of course

lime leaf
#

@chrome bay I mean, the object type Map, map of string -> actor, indexed by IDCode (string), those can't be set to replicate

chrome bay
#

I'm not really following tbh - probably need specific knowledge of the game. But I would start by using the network profiler then go from there once you have more info

#

Very easy to use

lime leaf
#

It was the reason why I added the sequence thing, so that I wouldn't spawn all in one frame 🙂

chrome bay
#

But that's what i mean, it's unreliable - it doesn't necessarily matter how much is being spawned in one frame

#

If you spawn a handful of actors that use a lot of bandwidth, and keep using it, other spawn packets will start to drop

lime leaf
#

@chrome bay thanks, never tried the network profiler 🙂 cool. I've done a lot of profiling otherwise, I'll look into it

chrome bay
#

In theory you could spawn 500 actors in one frame. So long as they aren't all competing for bandwidth, eventually they will get through

lime leaf
#

mmm

chrome bay
#

Gets up to nearly 500 actors without breaking a sweat, but everything has just been carefully tuned or adjusted

#

Mind you, replication graph also seems to have a separate pool of bandwidth that it keeps aside for actor spawning

lime leaf
chrome bay
#

If you're doing RTS I recommend Rep graph

#

will help a lot

#

Pretty much the perfect use-case for it

lime leaf
#

Yeah, mmm, will look into it. I have aimed for 4 player, but also hoping to be able to have 8 player support.

chrome bay
#

It's good for when you have lots of the same sorts of actors/lots of connections

lime leaf
#

I've just started porting stuff to c++ too, after 3 years of blueprints hehe, wish I started c++ earlier..

chrome bay
#

Saves a lot of CPU time on the Server, but does also tend to divvy up the available bandwidth better i think

lime leaf
#

blueprints are fun, but c++ performs a lot better. I know nativization helps though, but still

chrome bay
#

We're using it on HLL, don't think that game would be feasible without it

#

BP for networking isn't that great unfortunately

#

Some stuff just plain isn't available, and some optimisations just aren't possible in BP - but it all adds up

kindred widget
#

Nativization is what drove me to learn C++.

#

I was kind of surprised how similar LUA was to C++ actually. Made learning it a breeze once I got past Pointers.

lime leaf
#

I know c++ from before, a couple decades of video effect programming 🙂 but when I started getting into Unreal Engine I fell for blueprints, now I am porting stuff to c++ though, might have to port a lot to get the performance I need..

kindred widget
#

@chrome bay Speaking of HLL, congrats again. I saw a Top Indie games list with you guys on it.

lime leaf
#

blueprints really struggle with arrays and lots of spaghetti. I recently ported "GrowCurrentPlants" for farms in my game, went from 20ms to like 0.1ms

kindred widget
#

Well, a single loop in blueprint is like ten nodes all getting executed each loop body, not including what you put in it.

lime leaf
#

Yeah it is the interpreter thing, slow. Nativize supposedly makes it better but can't beat doing it in c++, unless you code worse code than nativize generates I guess..

#

I haven't been able to package/cook my game, ever, haha, in 3 years now.. I hope I am able to some time! 🙂

#

I only tried like 5 times..

#

I should've made it a habit from the start, now it takes 10 hours..

kindred widget
#

That's going to be a fun day. All them cooking warnings. 😮

lime leaf
#

And I'd rather work on new stuff

#

Yeah I know :S

#

Got some hurdles ahead.. My movement code isn't exactly working well enough yet either, I can get two windows in PIE and listen server, single process, still get choppy behavior on the client

#

I do interpolation and movement on both client and server. not using unreal engine's components for it, they're "spaceships" just above ground and only in fixed z plane. but for now rely on physics impulses for movement, might have to switch to not using physics idk..

#

at least I can see the ships on each screen, and the buildings built appear on both, and most things work, just performance still sux a bit, better with some c++ but got a long way to go

kindred widget
#

That'd be kind of fun to program. plane locked 2D directional physics movement.

lime leaf
#

also thinking about doing my own a-star in 2D, I had no luck getting much performance from navmesh and AI in UE, I need something cut-down for peformance, there are like upto 2000+ colonists walking around and I want them to walk around buildings, also got drones flying with resources from different sources to colony base, they need to avoid buildings too. Might be fun to get it working though, but some work. Needs to be c++ definitely.

#

A future version 2 of the game might be 3D though, terraforming and not just one ground plane z

#

sorry, ranting 🙂 got passion anyways..

kindred widget
#

Nah. I was just wondering how I'd even start to optimize 2k colonists.

#

Nevermind networking, just the local computational alone.

#

Then again if their meshes are simple, and they don't have a crazy anim blueprint, I imagine that's not terrible. That was a lot of what I was having trouble with when I was considering a city builder when I first started.

lime leaf
#

Well, they walk only between work and habitat, hence the path can be precalculated and only change when new buildings are added in the area

#

and I don't mind them walking on top of eachother, they're so small you won't notice

kindred widget
#

Yeah, that makes it easy. Just interp them through the vectors on their path.

lime leaf
#

right now they just walk straight, you don't really notice it that much either, as said they're tiny. But still the AI behavior trees take some time..

#

yeah, simple path points and straight vector interpolation

#

for farms, they do walk between seeding and when picking up ripe vegetables/plants and packaging, that is where the behavior trees are a bit slow, think many many farms...

#

I think I can make something simpler in c++ for that, than using UEs behavior trees

#

One of the biggest bottlenecks right now is cable component hehe, of all things.. I have gold mines with a cable between a drill on a robot arm and the mine, they're taking up a lot of performance

floral crow
#

Does anyone know how to properly set DemoNetDriver as the default NetDriver in DefaultEngine.ini? Can't find the required syntax anywhere, not even where to put it...

kindred widget
polar wing
#

@chrome bay Mentioning rep graph, I need to start digging into it properly from next year haha. I don't suppose you know of a phenomenal resource that gives you all the info you might need? I've checked out the ShooterGame example and pieced together various Epic rep graph talks and content, but wondering if there's some fancy schmancy resource somewhere that kinda brings everything together?

chrome bay
#

ShooterGame is the only resource tbh as far as I know

#

But to be honest, there's not that much to it once you get into it

#

The key thing to bear in mind is you lose all the per-actor-instance relevancy checks etc. Relevancy etc. all calculated based on predetermined values from the CDO

meager fable
#

what's the difference between is local controller and is local player controller

kindred widget
#

@meager fable IsLocalController just checks that the controller has a local netmode. So if you spawn a controller on clients for like AI, that would be a local controller, but it's not a player controller. IsLocalPlayerController does the same call to check the netmode, but also checks that the controller is a PlayerController and not say an AIController.

meager fable
#

oh okay, thanks

peak sentinel
#

I am selecting roll direction based on mouse input but server/client is not synced and server always correct position, where am I doing wrong?

soft shell
#

I've a replicated (simple) sphere actor that's spawned from the pawn.. I'm noticed that the server is correctly registering hits, but clients don't seem to be (or they're very poor, maybe 1 in 25 hits).. is this because of replication? I.e. clients are following the server and may not actually "hit"? or am I just doing something else wrong

chrome bay
#

Highly likely yeah

#

The former that is

#

Client is just going to be sticking the actor wherever the server tells them

soft shell
#

Thanks 👍

lime leaf
#

OK so on the Upgrades I talked about, all are in fact replicating, it just takes like 30 seconds or more, they come late, very slow.. why is the bandwidth/spawn speed so slow? is it still spawning trees in the map perhaps? there are 1000s of actors on a map, and I do level streaming of the maps, my wish is to do a loading progress that makes sure all is loaded before the game is started obviously, that has to include all predefined stuff the players need.. but 30+ seconds to spawn a < 100 actors? something seems off.

#

the replication process is very slow, in PIE 2 player 2 windows, maybe to do with the net interface bandwidth? might be something is replicated that is huge, shouldn't be but have to check..

#

a lot of appear-to-be more important is happening though, in rendering etc.. maybe I should look at network priorities..

winged badger
#

@lime leaf we can spawn a level with 30k actors procedurally and network it to 8 players in 12 or so seconds

#

but we don't spawn stuff server side and then let it replicate

#

we spawn it on all clients to and network it after the fact

#

and its usually not the bandwidth you need to worry about, its the CPU time spent on evaluating actors for replication

lime leaf
#

how do you "network it after the fact"? hmm, interesting

winged badger
#

same seed, same name, IsFullNameSupportedForNetworking returns true on instances, bNetStartupActor and bNetLoadOnClients true

lime leaf
#

I do something similar for farms, had to give up replication, I run farms both locally and on the server, but let the server decide when a harvested item is actually packaged, otherwise it runs separately

winged badger
#

and not letting them replicate at all to the connection until the client finished the procedural generation

lime leaf
#

mmm

winged badger
#

same seed + name + IsNameSupportedFOrNetworking

#

basically make sure the level is identical

#

and all actors there are net addressable

#

the booleans are our way of lying to the engine so it treats the actors as if they were loaded from package

#

and not letting them replicate - if client receives a bunch for a static actor it doesn't have (is not possible under "normal" replication)

#

that actor won't have an actor channel made

#

it will still be net addressable, but it won't replicate

#

clients report to server as they finish chunks of the level

lime leaf
#

hmm.. so if I spawn the Upgrade actors on both client and server.. into the same array which is replicated, could that work?

winged badger
#

all actors that need replication spawned this way have the same base

#

that handles IsNameSupported, resolving in editor references via GUIDs, and making them not relevant for a connection until client that owns it is finished generating the level

lime leaf
#

that way they will be there, and I can make sure they are identical, but the server ones are the ones being modified, and will replicate overwriting the ones that were spawned, so that makes me able to get the names and stuff for UI regardless

winged badger
#

no

#

for starters

#

there is no guarantee that same NetGUID will have same Actor name

#

if you leave it to the engine

#

if you do 2 player MP test in PIE

#

they will usually end up with character_0 as local one both

lime leaf
#

ah yeah I know they won't be that identical but for my use as in getting the name of the upgrade, the state of it (unless I click to run them) will be initialised

#

they will when I click not work though, since not being the replicated ones

winged badger
#

there is not much room for networking actors after the fact

lime leaf
#

so if I call a server RPC it wont work unless they have been replicated. but yeah, hmm how can I do what you're doing in blueprints, or do I have to go c++ on the Upgrades first..

winged badger
#

as long as your upgrade actors don't need to replicate themselves

#

you have a lot of options though

#

can't do any of it in BP really

#

blueprints only have about 10% network functionality exposed

#

technically you can make a MP game in BP

lime leaf
#

the upgrades aren't reaally needed for others than a particular client to know, not really.. It is just that availability f.ex. of buildings (that are spawned on the server) well, it is only needed to know for the particular client.. maybe I don't even need replication.. got to think this through. But yeah lots of options 🙂

winged badger
#

always many many more with c++

#

i don't do any networking in BP

lime leaf
#

I might have to go much more c++ to get things working well enough, I have been thinking about starting to port base functionality and classes, have ported some, but it will take time..

#

how it is with the Upgrade actors right now, they call a rep notify with the upgrade progress and the progress runs on the server, a lot works that way, the core functionality on the server, the client gets the repnotify on progress and keeps a ref to widget to show progress on screen

#

it could theoretically just run on the client. I guess I was thinking about if it was an e-sport game and you wanted a observer actor to know the progress or something

#

for custom display of stuff...

#

but it would mean a lot of rewriting that approach, I have some functionality that runs only on client.. I was hoping replication would be easier :S

#

I can make a loader though, since they do initialize even if it takes time, I can do a count comparison to set the tasks to done..

lime leaf
#

the weird thing is how long it takes for these Upgrade actors to replicate, well I at least made it wait till it is finished but we're talking 2 minutes for < 200 actors, something seems wrong

#

So, well, I learned today, network/multiplayer in UE seems more difficult than I feared, but I'll keep learning..

#

..ratespeeds ..looking into it.. ok I'll shutup.

ember needle
#

All, I thought that projectile movement component, by "faking" physics, would actually provide the same results in multiplayer. It looks like this is not the case, and obviously I don't want to use "replicate movement" because that is simply choppy. Am I correct in my understanding or is it actually supposed to be the same on all clients?

lime leaf
#

that link I posted above fixed it for me, at least a lot better now with those settings suggested in DefaultEngine.ini

faint saddle
#

Hi! I asked around and apparently this is agood place to ask about networking issues?

#

I'm trying to set up steam multiplayer in c++

#

I've followed all the instructions to the letter but I can't seem to manage to find other hosts when I send out builds to testers

#

Locally I can connect fine, even when loading up published builds twice

#

what code and configs should I post here?

ocean geyser
lime leaf
#

Could you publish a listen server game on steam? or do you need a standalone server for multiplayer?

#

I think I've seen a listen server.. hmm, well @ocean geyser I'll also check those vids when I get that far..

kindred widget
#

A lot of games run Listenserver.

faint saddle
#

@ocean geyser I looked through the steam subsystem video but I really don't think I'm doing anything different to that.

lime leaf
#

I'm getting 120 ping to the US from here (Norway), so, about 8 fps, will be playable with interpolation locally

faint saddle
#

I'm using listenserver, I want the whole thing to be as self-sufficent as possible, hence why I want to use steam

lime leaf
#

first priority is singleplayer computerplayers, already got that working somewhat, not finished but getting there. next is LAN listen server, next will be Steam

#

But it is OK to work a bit parallel on things, so I've been working a bit on listen server locally in PIE

#

Planning to get a new gfx card for another machine I got here, so I can run two steam accts

#

Currently my game is running at about 50fps singleplayer, dropping down to 25-30 when map fills up with stuff, 4 players, 1 human and 3 computer players. I've got a RX 580 8GB GDDR5 ram and a 6700K SkyLake, 32GB ram, hoping my target will be geforce 1660 6GB ram as minimum or something, in 1-2 years.

kindred widget
#

To be fair, I don't know that I'd drastically concern yourself over overseas latency. People who play with friends from overseas just accept latency as a known problem.

lime leaf
#

Yeah, just want it to not be too choppy 🙂 but 8fps is pretty OK with local interpolation

#

Got a few friends in the us that might become betatesters at some point

#

When I fixed those settings the replication went from 2 minutes to 3 seconds

#

So, all in all some progress today 🙂

#

and the movement code too was affected by this rate issue, so now it works pretty smooth

kindred widget
#

Yeah, the default 10,000 bits per second is a bit brutal. Bumped into that when I was attempting some gatherable foliage.

lime leaf
#

I have trees that you can chop down in the game, I have manually placed every tree, about 2000 trees on each map, 4 maps haha.. But it works, only using replication after hiding the tree to chop down and replacing it with the pieced tree that runs physics parts falling (only if seen).

kindred widget
#

I was originally replicating a Vector array of tree locations for mine. Making clients set them up locally. Turned out that a much better approach was to replicate a different vector array. Place them all in the map, and simply keep only a list of the cut down tree's locations. Then use that on the clients to locally remove trees. Turned my 2000-4000 array of vectors into a few hundred.

lime leaf
#

Sounds good 🙂

#

I do a sphereoverlap for branches already ready to be cut, then trees to cut if no branches are already ready to be cut. then spawn the branches, then do a sphereoverlap to find branches cut, then do piece by piece gathering by colonists.

#

I have started to move towards 2D grids instead though, I have f.ex. all buildings stored in a 2D grid and have my own c++ function to get a circle-overlap to find nearby buildings, runs 20x faster than sphereoverlap

#

might do something similar for trees too..

#

So trees that are chopped down outside of view, no physics..

#

Basically aiming to cut away with anything that I can for performance..

winged badger
#

@kindred widget next step: upgrade to use FFastArraySerializer

kindred widget
#

Haha, yeah. It was just a fun test. I probably would have if I ever did something like that seriously. I absolutely love multiplayer programming and game design, but I've been sticking to messing around with it and focusing my actual design efforts on singleplayer.

faint saddle
#

spent the last few hours sending out builds and having them simply not show up for me when I click join

#

no servers ever show up for me

#

It works under a null subsystem

#

all testers are on a different steam account and can see the steam overlay

thin stratus
#

And you have a custom AppID?

faint saddle
#

yes, but I don't seem to get different results using it

meager spade
#

always OnRep

#

never multi for state changes

#

Material change is a state change

#

If you multicast, then say Player A changes his mesh to Mesh B, Player B becomes relevant to Player A and sees him with Mesh A.

#

how about if a new player joins?

#

same thing.

#

Multicasts i see as a fire and forget and doesn't change gameplay state.

winged badger
#

🪓

#

you move out everything that doesn't belog there

#

i'll assume that your blueprints are also direct referencing the UI at this point

#

always nice having 30% of the game module in the UI

faint lotus
#

Is there some difference between the command line for a client built using the Shipping Target and the command line for a client built using the Development Target? I've been chasing on the idea that I didn't have a driver properly configured, but that was not the problem, so I'm back to the drawing board.

The core problem I'm encountering is that when I try to start Shipping Target clients, they go into standalone mode and never try to connect to the server. This doesn't happen for me in Development.

#

Alternatively, is there a target other than WindowsNoEditor I should be using to build a dedicated client?

#

Alternative Operating Systems aside, of course

#

It would appear that I should be showing up as WindowsClient if I properly built this. Oddly, this is not an issue in Development builds.

#

It looks like I should be building with the -client flag, so I'll chase on that lead for now.

bitter oriole
#

Building WindowsNoEditor is perfectly fine

#

Standalone mode is fine

#

"never try to connect" is something you need to debug

#

Define "connect", basically

faint lotus
#

I mean that to the best of my understanding, it never even makes an attempt to connect to the IP Address I tell it to connect to. It runs as if it were both server and client when it is absolutely no such thing.

Like you said, building with the client flag made no difference, so I'm back to utterly stumped.

bitter oriole
#

How are you trying to connect ?

faint lotus
#

By providing the explicit IP address (In this case 127.0.0.1 since I'm testing locally) to the client executable as its first argument

bitter oriole
#

You should try using "open <ip>" in the Blueprint console command node, the PlayerController console command function, or using Travel directly. Not sure IP arg will work in Shipping, if that's an engine feature you're using.

faint lotus
#

That is remarkably unfortunate

#

I'll chase on that

#

You'd think something as critically important as that would be documented, but I suppose massive gotchas with zero documentation is pretty par for the course at this point

bitter oriole
#

lmao

#

Seriously though, yes, you should expect little documentation on developer features

faint lotus
#

I've been trying to avoid using Sessions

#

Which seemed perfectly viable, when connecting via IP address

bitter oriole
#

Sessions is what most engine users will be looking at first, but yes, if you want your own system, just use travel directly

faint lotus
#

Will do - thank you for the help

grim lintel
#

Hi all. Has any of you guys any info about how I can go about the creation of a join/drop menu for local mutiplayer? Or specifically how I can detect gamepad input by index? Do I have to create player controllers first?
Any help would be much appreciated. Thanks in advance, have a good rest of your day, evening or night. My googeling session wasn't that fruitful.

tidal crown
#

Does UE4 automatically manage PlayerArray for me within a GameState?

#

or do I need to manually add/remove PlayerState from it?

#

reading through the code and haven't been able to tell yet

faint lotus
#

(Follow up from the earlier conversation - connecting by IP address in the cmd line does work in shipping, but it runs your default game mode's InitGame before trying to connect, so if you write something in that function that falsely assumes it is a server and it somehow chokes on that call, you'll never get to the point where you try to connect. That's a week of chasing red herrings instead of fixing what I took to be an irrelevant bug I'm never getting back..)

meager spade
#

@tidal crown it will be managed automatically

tidal crown
#

@meager spade Great! Thank you.

peak sentinel
#

I thought I need CMC in the end

meager spade
#

bReplicateMovement is simple movement

#

not smooth

#

its basically updated every actor update (which can be a fair few frames)

peak sentinel
#

I want to escape CMC hell without editing its code to simplify it, why there is no another way aside from cmc 😦

#

Actually, if I am not wrong you told me you removed FindFloor and replaced with nav movement before, I wasted some days on trying that but gave up so fast lol 😄

#

Actually, can I somehow interpolate that movement to make it smooth?

meager spade
#

if its not multiplayer sure

#

but multiplayer, would require network stuff

edgy knot
#

Heya.
Trying to make an anim notify work in multiplayer. I use the anim to throw a projectile at a giventime. Right now, the projectile is thrown from both client and server

#

can't really find why

#

someone has an idea ?

#

the projectile should be thrown from a player's anim and everyone should see the anim and the projectile thrown from the player's hand

#

oh

#

that seems to be a pb then xD

#

will check that out !

#

ok i've tried that, but then only the server throws

#

which makes sense

#

can't do if doesn't have authority cause then i guess all clients will do

#

i do

#

before i implemented the anim, i had an RPC running on server that would throw the thing and it worked fine.

#

I tried adding an animation and using animnotify to throw at a certain time and now I'm not sure how to proceed

#

trudat

#

how would you proceed ?

#

for the context, it's a frisbee game

#

everyone should be able to throw and see peeps throwing, pretty basic I believe

#

I don't care about potential cheaters and it doesn't have to be 100% accurate and pretty

#

it's really just a game for a small community

#

I don't believe I know what Server mirroring means yet 😄

#

i'm fine with that

#

even if it's a bit glitchy with latency, so far noone complained

#

so i guess i'm down the dirty path, is there a way to do what I want down this path ? :p

#

say the anim runs locally, the projectile spawn will indeed be a bit delayed on clients, but it's alright

shut gyro
#

Has anyone had problems with replicating projectiles at sockets on the simulated proxies? It seems like because of how the animation tick rate runs, information about the projectiles relative to the socket bones causes projectiles to sometimes appear slightly off the socket position

sharp star
#

Hey, is there a way to know if a player disconnects from a different level (Happening when servertravel)?

summer tide
#

So I'm trying to assign SK meshes to my player in lobby, using a widget and saves the info in game-instance. When I start the game and enter the gameplaye level, I then in character construct I get the data from game-instace and assign them to my character. What's wrong here?

#

How would I fix that? Since I don't see any other way. Maybe when the game starts in character I can use Switch Auth then connect server event to authority and remote to multicast event assigning the SK meshes?

supple mural
#

Hey guys, if I lower player health do I have to do the same in his PlayerState?

#

I want to lower his health on a health bar somewhere that another player will see

summer tide
#

@dull lance Currently the server sees the same chars that server made and client sees the same chars the client made

supple mural
#

So NO ONE knows if this should be in the player state

winged badger
#

it should definitely not be in 2 places

#

and pawn is also replicated

supple mural
#

Alright, so how would I have the other player know their health then?

winged badger
#

and pawn is also replicated

#

so it doesn't need to be on PS

#

only situation it does would be if you had a game where you can swap pawns but they share the same health

supple mural
#

ahh

#

so playerstate is only for persistency

winged badger
#

there are things you may want to replicate

#

that really don't belong in pawn

#

score, number of kills, stuff like that

#

and player state can access the pawn

#

so not putting health there doesn't prevent you from creating the UI by iterating over gamestates playerarray

#

if you need UI to display health, only things you need is for widget to have a reference to the replicated object thats in charge of tracking health, and OnHealthChanged delegate in that object

#

(because you really don't want to be accessing widgets from your say, healthcomponent, pawn or playerstate)

#

those shouldn't be even aware there is such a thing as UI

supple mural
#

ahh

#

Alright. I understand now. Thanks a lot Zlo, I appreciate it.

supple mural
#

I'm assuming you meant the former

winged badger
#

only gameplay class that should manipulate your widgets is HUD

#

and usually only to instantiate and show/hide them

#

widget gets a reference to be object its supposed to be displaying OnSpawn, and after that, ideally it gets updated by delegate broadcasts from that object

summer tide
#

@winged badger Do you know how to fix my issue that I mentioed above?

supple mural
#

Alright that makes sense. Thanks a lot

#

Hey guys, the dedicated server doesn't appear in PlayerArray in GameState right?

fossil spoke
#

Correct, a Dedicated Server does not have any Player associated with it.

supple mural
#

alright Beautiful

#

thansk

fossil spoke
#

A Listen Server does though.

supple mural
#

That makes sense, as it is also a player

fossil spoke
#

Right

twin juniper
#

Should i be spawning Items in the gamemode? items that can be attached to players

fossil spoke
#

If your Item is an Actor, you can spawn it in whatever class makes sense for that to do so. As long as your clear on what the network context of that action is, because that will have consequences for Replication etc.

#

Specifically, if you dont spawn a Replicated Actor on the Server side, it will not Replicate.

#

Since the GameMode is only available on the Server, you will know that your spawning it on the Server side.

#

However, if you know the network context of where your calling the spawn function, then you can do so in whatever class make sense in context of that Actor.

twin juniper
#

so i guess when i spawn i use an rpc

#

only for spawning then attach it