#multiplayer

1 messages ยท Page 91 of 1

sinful tree
#

Has Authority is, yes,

#

You want to use the authority path when you use it.

crystal palm
sinful tree
#

It checks whether the currently executing code is running on the instance that has authority over the actor. Replicated actors exist on both the server and clients, so the overlap can be detected on both. If the actor was indeed spawned by the server, then Has Authority (Authority) will ensure that only the server is executing the code.

However, if the actor was spawned on the client, then the client would have authority of the actor, even if it is an actor marked as replicated as it would only exist on the client.

mellow stag
#

I'm having a big cheating issue on my multiplayer game that is running through dedicated servers. Any ideas for what I can do about getting an anticheat?

chrome bay
#

anticheat software alone won't do much if the gamecode has inherent exploits

#

without knowing what the cheats are we can't offer any advice

mellow stag
#

Main ones are, people are speedhacking/phasing through walls

#

Phasing through walls is probably the biggest issue.

chrome bay
#

you can turn on the engines built-in speedhack protection, which is off by default.

#

assuming this is character movement

#

I also suggest a custom engine build which disables the fixed timestep mode of the engine

mellow stag
#

How would you go about preventing phasing through walls/ specifically actors

chrome bay
#

There's not really any reason a cheater should be able to do that unless the server is blindly accepting their position

#

or theres some function they can call/spoof which allows them to teleport

#

Those two steps above are basically essential for any UE game though. Any "off-the-shelf" cheat for UE games will basically include those hacks by default, they don't even need to be specialised packages for your game.

#

The fixed timestep thing is relatively recent

#

AFAIK anyway.

mellow stag
chrome bay
#

Have a look at GameNetworkManager.h - it contains a bunch of config variables you can enable. In 5.2 they start at line 191

#

Movement Time Discrepancy settings for Characters (speed hack detection and prevention)

#

It's not perfect, and it does increase server processing time, but it's better than off by default.

mellow stag
#

Awesome, thanks!

arctic minnow
#

If someone knows how to make this work please help! ๐Ÿ™‚

#

๐Ÿ™‚ ๐Ÿ™‚

#

๐Ÿ™‚ ๐Ÿ™‚

crystal palm
#

actuali when a client do it crashes any solutions?

sinful tree
crystal palm
#

what to do?๐Ÿ˜ข
it's muliplayer only

#

@sinful tree

#

i need to client call possess

sinful tree
#

You cant do it on multiplayer. The server must. The client can trigger the overlap but possession can only happen on the server.

crystal palm
#

@sinful tree ok ty
but that crashes don't break my project?

crystal palm
#

.

#

how a client call possess?

chrome bay
#

Ask the Server to do it, then wait

#

(via RPC). Seems silly though, just listen for the overlap server-side instead.

crystal palm
#

huh?

upbeat basin
#

Is calling an RPC on the target machine (calling a server RPC while already being in server for example) same as calling a regular function or is there a networking overhead happening anyways?

crystal palm
#

i don't know what RPC even is

stoic acorn
#

I'm trying to (in my mind a seemingly simple thing) have a player press a key which brings up a widget on all connected player's screens. For some reason when the key is pressed it's only making visible for the player who pressed the key. First image is on the Player Controller. Second image is in my HUD class
Any clues appreciated

thin stratus
stoic acorn
#

๐Ÿ˜„

thin stratus
#

Let me ask you 2 questions

#
  1. What is special about the PlayerController in regards to Multiplayer?
  2. Can and should the HUD replicate?
#

Although the second one would be HUD not Widgets I geuss

#

Spoiler: If you can't answer this, I will point you to the network compendium

stoic acorn
#

hmmm

  1. A unique PlayerController is assigned to each connecting player. It is on the Server and Owning Client.
  2. The HUD only exists for each player separately
thin stratus
#

Good, so then let's check your code.

#

What are you again doing on your PlayerController?

#

You are performing 2 RPCs as far as I can see.

#

One of them is a ServerRPC, one is a Multicast.

#

Given your answer for 1., what could be wrong here?

stoic acorn
#

hmm. So it's firing it once for the server and again for the other clients?

#

So is it toggling it on and off again?

thin stratus
#

Nope, you just wrote that the PlayerController only exists on Server and OwningClient

#

What do you think will the Multicast achieve here?

stoic acorn
#

Ah. I thought that having a custom event set to server would then send to all clients with the next custom event set to multi cast.

thin stratus
#

No. A ServerRPC will send the call from OWNING Client to Server (so this only works on Client owned Actors, which the PlayerController is).
And a Multicast will send the call from Server to all Clients that have an Instance of that Actor. Since the PlayerController doesn't exist on anyone but the OwningClient (and the server), the Multicast is only calling on those two.

stoic acorn
#

from your compendium I understood that the Player Controller being on the server and the owning client meant that you could ask the server to multi cast to all player controllers

thin stratus
#

The Multicast works depending on the Actor you call it on.

#

If you want it to call on Everyone, it has to be called on an Actor that exists on Everyone.

#

So the ServerRPC in the PlayerController is fine.

#

But now you have to get a different Actor and call the Multicast on that.
Any idea what Actor you could use?

stoic acorn
#

so that would be GameState, PlayerState or APawn

latent heart
#

Pawns aren't necessarily on everyone

thin stratus
#

Yeah, GameState would probably be the best option

latent heart
#

If they become non-relevant they will not receive multicasts.

thin stratus
#

Pawn could be out of relevancy range, correct

stoic acorn
#

But can the gamestate cast to the HUD class?

#

or would you use an Interface?

thin stratus
#

The Multicast calls on everyone locally

#

From there you can get the PlayerController and then the HUD

#

The other problem is your RPC usage in the HUD class

#
  1. The HUD only exists for each player separately
#

That was your answer. The Multicast in your HUD is redundant

latent heart
thin stratus
#

Well, ListenServer it does, but only for the Server itself counted as a Client

stoic acorn
#

ok gotcha, thanks for the help. I'll probably come back crying here later today

latent heart
#

A general way to do things is to route server rpcs through the player controller and multicasts back through the gamestate. But multicasts are, in general, a bad idea unless you have a very good reason.

#

In the majority of cases a replicated state is probably better.

thin stratus
#

Yeah Multicast only makes sense if you are fine with players who connect late to not get the result of the Multicast

stoic acorn
#

Basically I'm trying to end the game with a Widget that will pop up for everyone with a messages as to which team has won

thin stratus
#

If the Widget has to show for them too, then it's better to run this through some variable that is on the GameState, repnotify and doing the widget in there

latent heart
#

Like if you wanted some ingame chat, that might be okay with a multicast because late joiners don't care. Or something.

#

But multicast also happens instantly and will clog up your network if you use it too much. Normal replication happens over time to avoid that.

thin stratus
#

In the OnRep of that you can check if the game ended and show the Widget

#

As well as passing the Winning Team with it

#

The idea of ServerRPC in PlayerController and then GameState for replication to everyone stays teh same

#

Just that it wouldn't be a Multicast

#

The benefit of this is that people who join late or reconnect will get the Widget again

stoic acorn
#

Actually thinking about it, I think the Replicated Variable makes more sense, as there are two different conditions for the two teams to win the game.

#
  1. Where a player crosses over a threshold
  2. Where the player is captured by the opposition
thin stratus
#

Yeah that can also go into the Struct fwiw

stoic acorn
#

ok I'm putting Structs on my list of things to learn about

#

btw, I'm a stupid artist with a game idea. This is breaking my brain a little but I almost have the core loop complete and am champing at the bit to start doing some artwork ๐Ÿ˜„

thin stratus
#

Don't call yourself stupid. (:

stoic acorn
#

haha, when it comes to Replication I think it's fair to say that I am

latent heart
#

The fact you're an artist, but have the wherewithall to a) think of a game idea b) try to put it into practice and c) actually get to the point where you're learning how to program, especially multiplayer programming which is very difficult, just means you're actually quite smart.

stoic acorn
#

Aw thanks man, appreciate it. It's very slow going but I'm getting there. I've saved this conversation with you two as it's definitely helped clear up a couple of fuzzy notions I've had about how all the pieces fit together.

knotty briar
#

i SEE

#

I see

#

Thats interesting

#

I'll definitely consider it after this project as I can reuse that code for almost all multiplayer games I decide to make

pure elm
#

does anyone have any idea as to why servertravel does not work? on pressing the button the server transitions to the new level but client does not

pastel escarp
#

when game is over I force use SpectatorMode but when I use seamless travel back to the game menu, nothing loads and I think controllers break, any idea why and how to fix it ?

keen flicker
#

Hi. so if i want to replicate SK Mesh variable in actor class and its owner is playercontroller which replicate condition should i use?

kindred widget
keen flicker
#

oh ok, repnotify is called on client right or both?

pure elm
keen flicker
pure elm
keen flicker
#

run on client

#

but im not sure about execution order, should server or client call first.

pure elm
#

Thanks

#

I think run on server, and then call the events on the clients

#

But will the clients stay connected?

keen flicker
#

not sure about that but might be somehting about bSeamlessTravel

kindred widget
kindred widget
pure elm
#

Im testing this in pie, does that make a difference?

kindred widget
#

AFAIK servertravel won't work in PIE unless stuff has changed recently.

keen flicker
#

so setting it to repnotify is like replicated? just repnotify notifies when it replicates, what about replication condition. options seems not understandable

#

there should be like bNetdirty or something that if the value is changed it'll replicate

kindred widget
#

Conditions are for different types of replication. Like SkipOwner would be used if you never wanted that value to replicate to the owner of the actor. You use that for letting the owner simulate it on their end but still replicate it to everyone else. None just means it replicates to everyone.

keen flicker
#

so in my case replicating to everyone means only to my player? because this replication is doing in actor that has PC as an owner

#

if my understanding is correct PC only exists 1 per client so replicates to all mean only to my player

thin stratus
#

@kindred widget SEAMLESS Travel

#

ServerTravel alone works fine

#

Also there is a console variable that enables SeamlessTravel in PIE (Experimental)

kindred widget
#

Oh, neat, will have to look that up and test.

fathom aspen
kindred widget
keen flicker
#

I see, thanks for clarifying. been not sure about this for a long time, never had a chance to test it myself

kindred widget
#

Technically everything of a client's is owned by the controller in some form. So if that were the case, nothing owned by a client would ever replicate to any other player, including their pawn.

keen flicker
#

I see, so everything that replicates to clients their root owner in owner chain is from PC/GameState/PlayerState ?

kindred widget
# keen flicker I see, so everything that replicates to clients their root owner in owner chain ...

Hmm? Not sure what you mean by PC/GameState/PlayerState? By default a client owns two things, Their PlayerController, and PlayerState. The PlayerController owns the PlayerState. PawnPossession also changes ownership, so any time a player possesses a Pawn, that client is set as it's owner via setting the owner of that Pawn to be their possessor's PlayerController. You are free to extend this by making a weapon actor and setting the possessed pawn as the owner.

GameState has no owner and never should. Anything replicated with no owner is technically owned by the server as far as RPC/replication goes.

keen flicker
fathom aspen
#

Yeah, if it bReplicates=true, then yes

kindred widget
#

Worth noting there is a default implementation of this you can see. GameMode spawns the player's default pawns. GameMode is not replicated.

keen flicker
meager spade
#

๐Ÿ˜•

kindred widget
#

No. The sole requirements are that it is spawned on server, and set to replicated.

#

If it doesn't replicate to the client, then try setting always relevant as a test to see if relevancy is the cause.

keen flicker
#

ahh it becomes more clearer now, thanks

stoic acorn
#

Is it possible to get the player controller from Other Actor 'On Component Begin Overlap'?

fathom aspen
#

OtherActor->Instigator->GetController

nocturne quail
#

what's difference between these two setting on an AMyActor ?

    SetReplicates(true);
    bReplicates = true;
keen flicker
#

Is this enough to replicate this variable?

#

event gets called on server

upbeat basin
#

You can just set the variable where you call this event and remove this event

#

You're already calling it from server, you don't need to multicast it again and filter for the server

keen flicker
#

ahh ok, this is just for example. i need to set the mesh later in the function

upbeat basin
#

I mean, if you're not going to use the Remote part of the authority switch then you still don't need the function to be an RPC. I'm not entirely sure about your aim but from the naming of the function, it shouldn't be an RPC

keen flicker
#

actually the function pass in Character and i need to the mesh on server and replicate to client, or i can just also set it on client? because idc if the mesh needs to be the same on both sides

stoic acorn
twin juniper
#

Just want a quick nugget of guidance. I have gameplay setup and menu for joining in online subsystem setup and working correctly.

I need to create a lobby so that the players wait in the lobby before joining the gameplay and the host can exit after 3 minutes if the client didn't join. Can someone tell me briefly how should I go about doing so( in C++)?

quasi tide
upbeat basin
#

When we open a map with listen option, does it run another executable for the server on the background or is the game package comes with the server stuff itself and runs in the same executable?

echo bough
#

instead of running Standalone, the game will run in ListeneningServer

#

its just with added hosting capabilities, its the same executable

echo bough
nocturne quail
knotty briar
#

Good news @untold rose , I scrapped the whole game state system as it wasnโ€™t working out, I gotta learn more there but for now what I did was create an actor in the level that spawns when the level is made and all it does is hold the variable for the array and has an event that can be called when the lap finish is confirmed. Only issue now is that when I add the player controller to the array, it adds two controllers instead of one

nocturne quail
#

this is a very long process

twin juniper
#

Someone else?

nocturne quail
quasi tide
#

What part are you confused on?

twin juniper
# quasi tide What part are you confused on?

The only confusion I have is about transitioning players into gameplay. Should I just travel to the Gameplay level from lobby and it will spawn default pawns? The players in lobby are just a show right?

#

And also I should use OpenLevel when in Lobby to transition to Gameplay Level right?

quasi tide
#

Use seamless travel

#

It keeps your players connected to your server and Steam also requires it

twin juniper
quasi tide
#

Yeah

twin juniper
quasi tide
#

Wizard says a lot of words in this. It's useful.

twin juniper
#

Because I use them to position characters

quasi tide
#

As long as you set them up

twin juniper
quasi tide
#

But if no player start exists, I believe it just spawns at 0,0,0

twin juniper
#

I have everything done, just this step of adding lobby

#

Just a general question, lobby can be just a floor on which players run, right?

quasi tide
#

Sure

#

3D lobbies have become more prominent in recent years.

dark parcel
#

What does it mean to build from source code? In building dedicated server contex

quasi tide
#

Clone the repo from github and then build the engine from that.

#

(Or if you have access to Epic's P4 server, use that)

dark parcel
#

I'm not using github, is there something I need to be aware of when creating dedicated server? As long my game package and compiled. It's good to go?

quasi tide
#

Your only choices are to clone from their github or get access to the source through their P4 server.

nocturne quail
#

SetReplicates(true); for an actor should be in constructor or beginplay?

dark parcel
#

Oh f do you mean clone the unreal engine on github

echo bough
#

constructor

dark parcel
#

I hope they are compatible with my plugins...

nocturne quail
dark parcel
quasi tide
#

A "source" build is just a build of the engine that you compiled yourself from the actual source code of Unreal. Obtained via github or their P4 server.

#

A launcher build is the one you download from Epic

dark parcel
#

I downloaded source build one but switched to 5.1. I guess I need to download 5.1 from github to run dedicated server

echo bough
#

APawn does set bReplicates = true in its constructor

dark parcel
#

Yeah using launcher build atm

echo bough
#

be prepared to burn 500GB space

#

๐Ÿ˜†

dark parcel
#

Btw are u guys using version control? Is it even viable? My project is 80gb..

echo bough
#

ofcourse

dark parcel
#

Hmm maybe the wrong section to ask

#

But github have file size limit?

#

Like 2 gb or something

sweet quartz
#

hi ! yes after a specific amount you need git lfs (large filestorage system or smth like this)

quasi tide
#

Azure Devops has free, unlimited repo size, with git lfs as well.

nocturne quail
stoic acorn
echo bough
#

then just set bReplicates ?

nocturne quail
echo bough
#

you need to specify each component to replicate

nocturne quail
#

if the actor has static mesh, it needs to be like mymesh->setreplicates..... particularly

echo bough
nocturne quail
#

but SetReplicates(true), give warning but it replicates all comps in the actor class

echo bough
#

just set them to true right after you create your actor comps

nocturne quail
#

all right

#

thanks for help )

quasi tide
#

PostInitializeComponents

echo bough
#

also probably never replicate everything ๐Ÿซ 

quasi tide
#

Replicate the smallest amount of stuff that you can.

#

The ultimate goal of networking is to do as little of networking as possible.

nocturne quail
#

if an actor is replicated, all of its child actors will also be replicated?

#

ex:
AItemBase() is repliacted
and
AItemWeapon : public AItemBase
will also be replicated?

#

or it need to set replication particularly?

echo bough
#

by default they will inherit it too, so yeah they will replicate

nocturne quail
quartz iris
#

Is this correct so far?
This is within the gamestatebase
I also need to show the player state wins in text, is this correct?

dark edge
quartz iris
dark edge
#

that is about as incorrect a BP graph as you could make

quartz iris
#

k

dark edge
#

Lose the tick. What are you trying to do, detect if one of the players has won a round (whatever that means)?

quartz iris
#

yes

dark edge
#

What's the trigger to check? When should you check?

quartz iris
dark edge
#

Delete all that too

quartz iris
dark edge
#

Lose the multicast. Death and winning and damage should all be on the server

quartz iris
#

ok

dark edge
#

This is all a goddamn mess tho tbh. Like the whole thing.

#

Start with damage

quartz iris
#

What was wrong with the round wins check?

dark edge
#

Everything

quartz iris
#

thats not helping lol

dark edge
#

First off fix your damage setup

#

What is the win condition, one of the players goes to 0 hp?

quartz iris
#

yes

dark edge
#

ok so after event any damage, just check if has authority, if true, then process the damage

#

If false, you can do a damage popup or whatever but leave that for later. Get it working right.

#

Damage -> has authority -> deal dmg to hp -> did you die? -> tell the GameState (call an event on it)

quasi tide
#

AnyDamage will only execute on the server anyway

dark edge
#

lol i never noticed that

quasi tide
#

That's what the icon on the event means ๐Ÿคฃ

quartz iris
#

ok

quasi tide
#

You can set it to, I think it's like BlueprintAuthority specifier in the UFUNCTION

dark edge
quartz iris
#

do I need to get the player that died/the killer with the inputs?

dark edge
#

Game state wants to know who died

quartz iris
#

fr fr

dark edge
quartz iris
#

(killer input links to event damage causer)

quasi tide
#

At least last I checked back in like 4.23 or something like that ๐Ÿ˜…

quartz iris
#

this correct so far?

dark edge
#

from the damage event to there

quartz iris
dark edge
#

you're ON THE SERVER ALREADY

quartz iris
#

Cus its on server

#

ye got it

#

does that ruin the code?

#

or it does it twice or something?

dark edge
#

It's just gross and unnecissary and I'm not sure you're still not doing a multicast

#

You can multicast the play sound etc

#

but it might be better to repnotify that

#

but that's just decoration, get the core of it working

quasi tide
#

So in C++, it does jack all. But it's a guard for BP code.

quartz iris
dark edge
quasi tide
#

๐Ÿค”

quartz iris
#

Or its because it was ran from a server initially?

dark edge
quartz iris
#

got it

dark edge
#

That looks fine, the death sound will play on host only but that's whatever

dark edge
#

ONLY the multicast will run on client

#

You probably want run on owning client for your sound events

quartz iris
#

so this way I did this it will only play the sfx for the host?

dark edge
#

unless you want everyone to hear the damage sounds

#

the hit sound would run on all as it's multicast

#

the others will only run on host

quartz iris
#

ok good

dark edge
#

and you're mixing playerstate and pawn together in the player died event but that's whatever

#

so what happens to a pawn when they die, is dead a state?

#

or do they just get deleted instantly

quartz iris
dark edge
#

k that's fine

quartz iris
#

The thing I didn't get was

dark edge
#

just delete that

#

set local player win shouldn't be a thing

quartz iris
#

how can I get the other player's round wins within their state to show up on a widget

dark edge
#

i mean i guess it can be

dark edge
quartz iris
dark edge
#

that'll work for the local player

#

the other player(s) will be in GameState.PlayerArray

quartz iris
#

but how can I get the specific player

dark edge
#

which one?

quartz iris
#

wouldn't that also get the local players state round wins

quartz iris
#

Like this? or not ?

#

presumably I need to filter out the local player

#

I don't know how to do that tho

nocturne quail
#

can we use GetLifetimeReplicatedProps in character class?

quartz iris
crystal palm
#

i want to teleport my pawn into spawn and it works correctly but in client side it teleports then it backs to last location what to do?

obsidian cargo
#

Do subsystems go weird with multiplayer in PIE? I have a GameInstanceSubsystem with a TMap that I'm adding to during BeginPlay. The entries in the TMap seem to be disappearing when I launch PIE with 2 or more players, but works just fine if I only have 1.

kindred widget
#

You should have two separate subsystems with two players. How are you testing that the tmap is disappearing?

twin juniper
#

Has anyone got this issue before and now a solution:

Old World Map_Lobby not cleaned up by GC! Object CameraActor /Map_Lobby:PersistentLevel.CameraActor_4 is being referenced by IpConnection /Engine/Transient.IpConnection_0:
quartz iris
#

So how can I get this part of the code to not show up on every player's hud?

#

As it's currently in a server event

crystal palm
#

hi
i need help about this:
i teleport my pawn into somewhere and it works correctly but in client side it teleports then it backs to last location what to do?

gusty slate
#

Are you applying the new position from a server function or client?

#

Moving pawns should be done on the server actor

gusty slate
#

You should call the SetPosition in a server context

#

On the Server Pawn reference

#

Can we see your code?

#

You only need to execute the teleport ie the function that sets the position on the server

#

as location is already replicated

crystal palm
#

Ok ty

obsidian cargo
#

Same code works fine when PIE is single player, In multiplayer the TMap is empty when I hit the breakpoint near the server retrieval.

dark edge
#

When you're doing multiplayer you have to ALWAYS keep in mind which computers the code is going to be running on in whatever specific thread of execution you're writing

kindred widget
obsidian cargo
#

My subsystem is a loot table subsystem, and the TMap is loot tables that have been registered. I've wrapped all access to the subsystem with this call: static ULootTableSubsystem* GetSubsystem(UWorld* world);

#

I'm not seeing anything go through that call that would be clearing entries

#

Though I do see one oddity in the debugger when registering the tables

#

I have a watch entry of UnrealEditor-Engine!GPlayInEditorContextString and its value is L"Not in a play world"

#

Then when I attempt to retrieve the value of the TMap, I have the world L"Listen Server"

#

The extra odd part is this pattern is the same regardless of the number of players with PIE, yet the table is only found with 1 player in PIE

thin stratus
#

What Data is saved in that TMap?

obsidian cargo
#
    TMap<FName, FRegisteredLootTable> LootTableMap;```
thin stratus
#

Also PIE might only be creating one of those for both players

#

Cause you play SingleProcess

#

In PIE (if not disabled)

#

Not sure though

obsidian cargo
#

I'm only expecting the server to have the data, but maybe Single Process is messing it up

thin stratus
#

I would test Standalone fwiw

quartz iris
obsidian cargo
#

I'll see if I can get that working. I haven't been able to get clients to connect with PIE and unchecked single process. Maybe because my project is based out of Lyra?

dark edge
#

All the code before this is running on the SERVER ONLY because it's being kicked off by Event Any Damage

#

So you're on the server, and only on the server, until you call some sort of RPC or set a replicated variable that is responded to elsewhere (RepNotify)

quartz iris
dark edge
#

Don't think of it like that

#

you can call a multicast or run on owning client RPC from the server

#

This event chain is on the server

#

so just call it

left geyser
#

Hello everyone. I've been using Unreal Engine for a while, but just recently I started playing with multiplayer. I'm trying to wrap my head around what lives where, how it gets replicated, etc. What I'm currently struggling with is the GameState. It is created by the GameMode which lives on the server. The documentation mentions that the GameState is replicated to the clients by the server, but the GameState is not marked as Replicated anywhere in the GameMode? What replicates the GameState?

quasi tide
#

You have to mark GS as replicated.

#

It's just saying that GS lives on the server & the client

#

As opposed to the GM which only lives on the server

hollow eagle
#

The gamemode doesn't need to tell it to replicate, it already does by default per the constructor of AGameStateBase.

quasi tide
#

(I couldn't remember if it was replicated by default or not & I am not on UE to check)

left geyser
#

I do not see the AGameStateBase constructor.

#

Silly me, I found it.

#

It looks like it's not present in the AGameStateBase header, but it's present in the .cpp file. I guess the Generated files contain the constructor declaration.

crystal palm
#

hi
any body knows how to replicate set material node

left geyser
#

Thanks everyone.

stoic acorn
#

If you wanted to have a persistent ID for a player that is triggering an event, what would you use? I initially thought it would be the Player Controller but I'm struggling to get that consistenly from an 'On Component Begin Overlap' Box Collision placed in the level.

boreal bison
#

I'm trying to have my UI show whose turn it is, so I create it in the first image, and in the second image I have a gamestate event dispatched that gets called on the UI to show whose turn it is, but for some reason Get Owning Player only ever gets the server's playerstate and I can't figure out why.

potent coral
#

how can i send data from the client GameInstance to the server? no matter what i do it seems to always take the value from the server GameInstance

quasi tide
#

GI isn't replicated

#

Use some kind of proxy

potent coral
#

basically i want to make it so clients can set their name in the main menu, and after joining a server i want it to send that name over

#

and since client and server have different game instances i tried to use that for storing the name

quasi tide
#

An easy way is to store it in GI, then when the client gets their PC, do a server RPC of the value.

#

PlayerState already has a player name variable that you could look into as well.

potent coral
#

thats basically what i want to do

#

i just dont understand how to get the clients game instance instead of the server one

quasi tide
#

You literally cannot do that on the server.

#

Where is that code running?

potent coral
#

player

quasi tide
#

You're just getting the local GI and then setting it to some name.

#

If you're running this in single process mode - that may be giving you some screwy results.

potent coral
#

im setting the player name to the variable i stored in the GI

quasi tide
#

And then you're just reapplying it

potent coral
#

player name is a 2d text

#

reapplying it?

quasi tide
#

When this code runs, it will use w/e the name is in the local game instance.

#

Because the game instance only exists on each machine.

#

You have no access to another client's game instance.

potent coral
#

so where else should i store the name?

#

for later sending it to server

quasi tide
#

And again - there is also a PlayerName variable inside of the PlayerState already.

#

There may be some function inside PlayerState to be able to set it with a custom value.

potent coral
#

yeah but i want to get this to work first

quasi tide
#

You have to send the server the name through a Server RPC.

#

The Server would then tell all connected clients to update the name on their sides with either an onrep variable or a multicast.

quasi tide
#

No

#

Because all that's going to do is get the GI on the server and then send that value to the MC update name

#

The SV_Update Name event is running on the server, not on the client that has the name that you selected.

potent coral
#

so i have to run the event on client?

#

and from the client event run it on server?

quasi tide
#

Do you know what that does?

#

Or are you just guessing?

potent coral
#

im just guessing lol

quasi tide
#

Read Cedricks network compendium

#

Once you start thinking about what machine the code is executing on, it becomes a lot easier.

potent coral
#

i understand what machine the code runs on, i just dont understand how i can retrieve the clients value in an event while still being able to send it to the server

#

because if i do this i dont think it will launch the event on server

quasi tide
#

You have to pass that value from the client to the server

#

The only way to do that is through a server rpc

potent coral
#

but where would i call that rpc from?

quasi tide
#

For the 3rd time

#

If you want to keep it in the character, there may be an event that gets called on the client side for them as well.

obtuse field
#

if I'm using AddReplicatedSubObject, and I want to change which owner is replicating the UObject, can I first use AddReplicatedSubObject from the new owner, and then RemoveReplicatedSubObject from the old one, or it doesn't matter which one I use first?

subtle peak
#

Should I spawn particle emitters only on the server (since its being spawned) or should it be spawned via multicast since its visual only?

round mist
#

Does each player have a game state, or is it server side only?

subtle peak
quasi tide
#

Game State exists on both server and client

#

GameMode is server only

round mist
#

Oh.

subtle peak
#

what

#

oh

round mist
#

That explains the issue I'm running into. lol

terse prawn
#

AI behavior trees only run on the server right (or at least should)?

subtle peak
#

Hey I have an "owning client event" that sets visibility of a weapon when the player scopes (so you dont see the weapon mesh through the scope).
This works fine for the clients, but when the server does this, the visibility of the weapon gets set on all clients too. Why does this happen? The weapon component is not replicated

round mist
soft halo
#

Where would you recommend I run the update system for Multiplayer? (When the client enters the server, the upload variables system of the previously made actions in the game.)

#

for example game instance, gamemode etc

subtle peak
round mist
#

Can you not just use "owner no see"?

#

You can also make it a custom event and have it run only on owning client.

#

That should also do it.

subtle peak
#

Yeah thats what I'm doing now that not working

round mist
#

Oh interesting.

subtle peak
#

I can try the "owner no see" nodes

round mist
#

The fact that the weapons are replicated are the issue. It's running on the server, which is the owning client, but then the server is triggering an event on a replicated actor, which triggers it for everyone.

subtle peak
#

hmmm

round mist
#

Hmm. Honestly not sure.

#

I'm definitely not an expert though. It's probably pretty simple.

#

Maybe the owning client event needs to be on the weapon.

subtle peak
#

Its probably not an ellegant solution, but I could maybe multicast and set the visibility to true on the other clients again

round mist
#

So you have a ToggleVisibility event running on owning client on the weapon, then the server could trigger it instead of directly setting the visibility?

subtle peak
round mist
subtle peak
#

Hehe true

dry dove
#

Any one used playfab?

subtle peak
round mist
halcyon compass
#

I encountered a very strange problem. Can anyone help?
I listen in the Tick method of custom UtickableWorldSubsystem class
If it is currently a server, and there is a new Player Controller joining it, then spawn an Actor on the server, and set the OWNER of this Actor as this Player Controller.
On the client, I can see the replicated Actor, but when I want to call the server RPC, whenI check connection by using the Actor-> Getowner (), sometimes it is Nullptr, it will cause I can't call server RPC. Not happened every time, but there are quite equivalent the probability.
Does anyone have any idea? Many thanks!

potent coral
ivory bear
#

If you want server lists and lobbies, do you implement those with Steam/EOS/etc.. or code some of that yourself?

fossil spoke
#

Steam is a platform that agregates sessions.

#

EOS is also a platform that agregates sessions.

#

These platforms can be queried for sessions.

#

You would need to perform that query and build the Server list within your game.

boreal bison
#

I'm trying to have my UI show whose turn it is, so I create it in the first image, and in the second image I have a gamestate event dispatched that gets called on the UI to show whose turn it is, but for some reason Get Owning Player only ever gets the server's playerstate and I can't figure out why.

small grail
ivory bear
keen hound
#

rq how do I replicate rotation?

#

I think I might know how but while I do that I'll see what you guys can tell me

#

disregard

#

figured it out

boreal bison
#

the player in turn macro:

#

and then onrep:

small grail
sinful tree
#

You can't reliably do so in multiplayer.

#

The playerstate is key.

#

You can use an index, but you use that index to access the Player Array (which is the array of playerstates)

#

If you want to have players in different order, then you create and maintain your own array of playerstates.

#

The owner of playerstate is the controller, so you don't need to maintain anything for that other than getting the playerstate who's turn it is, Get Owner of that PlayerState, cast that to your player controller class.

karmic briar
#

how does fortnite handle their day and night system?

#

how are they sync between players

#

does epic have a special system that handle their day and night system

small grail
sinful tree
obtuse field
#

I've noticed that after I replicate TArray of UObject's in 5.2, UObject is added to the array on the client side a little later than array element is created, and so, functions are being run with invalid, null object for this particular index. Is there a way to do something with it?

#

Would e.g. using FastArrayReplication fix it? Or Is there a way for ReplicatedUsing to tell me what changes were made?

sinful tree
boreal bison
#

and on the client, the print statement says it's controller 0, not controller 1

sinful tree
#

Player controllers are only replicated to owning clients. So when a client checks what their player controller is, it's always 0.

boreal bison
#

that would explain why get owning player in my widget is always getting the local controller

#

but when I get the playerstate, it should get the actual playerstate, right?

sinful tree
#

It's not great to use the index getters at all.

#

In a widget, you can get the owning player of the widget (which would be the local client's playercontroller) and then get the playerstate.

boreal bison
#

like this

#

but for some reason when I do this, the get owning player -> player state always says player state 0

#

so then the UI never changes to reflect that it's player 2's turn

sinful tree
#

Don't rely on index of those things...

#

When you're comparing objects, then it'll know whether it's the right one or not.

boreal bison
sinful tree
#

Yes

boreal bison
#

for some reason it's not

sinful tree
#

You're comparing what the local player is, comparing to the replicated version you're broadcasting from gamestate.

#

So if it's not the local player's playerstate, then it should say "Waiting for turn".

boreal bison
#

that's what it should do, yeah, but it's never saying Your Turn for the remote client

sinful tree
#

You probably have a different problem: You're calling Run On Server events in the gamestate.... That's not possible from clients.

boreal bison
#

so is it an issue with the event dispatcher?

sinful tree
#

Clients can only call Run On Server events on actors they own.

boreal bison
#

or the turn logic or something

#

should I not do the event dispatcher from the gamestate if I want the player's UI to change when their turn changes?

sinful tree
#

No, the dispatcher is fine. You cannot call those events from a client and expect them to work. You have to call the Run On Server event on one of their owned replicated actors, such as their controller or playerstate, once running on the server, you can call the functions you need to call on the gamestate that you want to have replicated effects.

#

So these, you can't call from a client if they exist on the gamestate. It will fail as the client doesn't own the gamestate.

boreal bison
#

yeah that is never called on the client, it's only on the gamestate

#

I believe it's called from the gamemode

#

and then the event dispatched is called on a repnotify from the gamestate

sinful tree
#

When is start game called?

boreal bison
#

I haven't looked at this in a while lol, I don't think this is the optimal way to do a countdown at the beginning

#

but it functions

#

and here's where the countdown is called

sinful tree
#

Ok, so the first player (likely the host) turn has ended. How do you signal that they've finished their turn to move on to the next player's turn?

boreal bison
#

The player clicks to flip a tile, which calls a multi cast on the gamestate to flip the tile for everyone

#

endturn is called after that

sinful tree
#

Clients cannot call multicasts.

boreal bison
sinful tree
#

And they cannot call RPCs to gamestate at all

boreal bison
#

o.O

#

they click on the tile and the tile click event is here

sinful tree
boreal bison
boreal bison
#

the client makes a request to the server

sinful tree
#

Don't do this though... This is kinda bad.

boreal bison
#

๐Ÿ˜ฌ

sinful tree
#

The multicast does execute on the server, so it technically would call the run on server "End Player Turn".

#

I wouldn't put it there just for clarity of what you're doing.

boreal bison
#

gotcha

sinful tree
#

You'd be better off putting it the server call either before or after the multicast call.

#

And I'd probably do the cast check prior to the multicast as well, just so you're not multicasting if you don't really need to.

#

ie. You only care if the touched item is a BP_Tile.

#

So only multicast if it is a BP_Tile, and pass through the touched component.

boreal bison
#

makes sense

#

so back to the UI thing, I'm still not sure what broke the turn validation that updates the UI

#

weirdly enough it used to work and then randomly stopped working at some point as I was adding new features and I have no idea when

#

but on every player, when I run this from the widget

#

I get the same playerstate 0 every time

#

no matter the player

sinful tree
#

So at the beginning when the game has started, the first player is seeing "Your turn" and all other players are seeing "Waiting for turn" right?

#

Again, don't worry about the index, it's useless.

boreal bison
#

yes

#

right okay

#

but yes

#

and when the first player does his turn, it's the second player's turn

#

all the functionality works

#

it just doesnt get represented visually

sinful tree
#

Do you see that the first player sees "Waiting for turn" after the turn has ended?

boreal bison
#

yeah

sinful tree
#

But the second doesn't see "Your turn"

boreal bison
#

right

#

or any other additional players

#

but it's because the event dispatcher is passing the playerstate from the gamestate

#

and that playerstate does have the corresponding index

#

but the owning playerstate in the widget doesn't

#

so this never returns true for anyone other than playerstate 0

sinful tree
#

You are passing the object reference of who's turn it is through a replicated variable and that variable is being fed through the event dispatcher. That's what this part is doing.
Is the value coming off of the "OnTurnChanged" event in your widget changing?

boreal bison
#

Yeah

#

I have this print statement

#

and for "In turn" it shows Playerstate 0, then 1, then 2, etc.

#

for each turn

#

and then "Playerstate" only shows Playerstate 0

sinful tree
#

This one here you mean?

boreal bison
#

Yessir

sinful tree
#

That is exactly what one would expect.

#

Owning Player == 0

boreal bison
#

Okay, so my check is not the way to do it

sinful tree
#

Owning PlayerState == 0

#

The index does not matter.

boreal bison
#

right

#

okay so then all I need to do is use a different check to validate whose turn it is

sinful tree
#

Checking if they are == should work as you are passing a reference to the object, and the == should check if they are equal.

boreal bison
#

Iโ€™m not sure what could be causing it to not work

#

Not sure is generous, I have no clue lol

sinful tree
# boreal bison

This works flawlessly on my end after pressinging page down at least once, but at least the text changes correctly.

#

(Ignore the other text displayed ๐Ÿ˜› )

boreal bison
#

wtffff

daring gorge
#

anyone know what this error is?
LogWindows: Error: Assertion failed: PawnOwner->GetLocalRole() == ROLE_Authority

twin juniper
#
Epic Developer Community Forums

Hello, I am working on a multiplayer game, we have ragdolling on command as well as a velocity threshold that triggers ragdoll on impact. We seem to have a major issue with the state of a player being mismatched even by the server and every other client, what happens is the client that gets โ€œragdolledโ€, they get back up, they see everything norm...

sinful tree
thin stratus
daring gorge
#

oh im trying clientsideprediction and it fails whenever it starts listen server

#

also the clause was different, it was supposed to be role<role_authority

thin stratus
daring gorge
#

yes i did use check()

#

its in cmc

thin stratus
#

Right, then it should be pretty clear now or?

daring gorge
#

for now i just made sure that the client prediction data returns only when its run on clients and if its server it simply returns a null

#

is that a way to get through this or should i be doing something else

thin stratus
#

You can check how the CMC does it :P

daring gorge
#

i probably should

twin juniper
woven bramble
#

Guys, I can respawn Character, but I can't update what's already in the game.
For example, if there is someone at the Level, how will the newcomer get the updated information of those who are at the Level before?

quiet fjord
#

Guys, can someone ask me a little question about a bug that I'm getting

knotty briar
#

I have a problem in multiplayer... I'm not sure if it is just me, but is it alright if someone could answer this for me? When using the join session node, it works in the editor just fine, but in the packaged project, it does not work, instead taking you back to the same main menu level eventually.

#

I thought it may just be a problem with the actual node itself but after trying it with the advanced sessions plugin, it was still happening

quiet fjord
#

If you are using the advance session in shipping mode it will give you problems since it only works in development mode. To make it work in shipping mode you must make some configurations with steam

thin stratus
#

Also you have an RPC in your GameMode which is giga wrong :D

woven bramble
thin stratus
#

You can't execute ServerRPCs on Actors that aren't owned by the Client the calls them.
And the GameMode is double wrong cause it only exists on the Server.

#

The RPC has to be in the PlayerController

woven bramble
thin stratus
#

You are chaining RPCs

#

The PlayerController one is enough

#

There is no need to call a ServerRPC when you are already on the Server

#

And on top, the GameMode doesn't exist on Clients. RPCs are redundant in it

#

And yes I'm sure, I'm working with this engine for a few years now

#

RespawnPlayer does NOT need to be an RPC

#

And also shouldn't

#

The PlayerController array in your GameMode also doesn't need to be replicated

#

There is nothing it can replicate to

woven bramble
#

I got this system from Unreal Engine's official site tutorial.
That's why I was surprised.

#

So it's 100% the same. i didn't change anything

thin stratus
#

You are following that stupid Unreal Engine YouTube tutorial

woven bramble
#

yeah

thin stratus
#

Yeah it's garbage

#

I called them out years ago

#

I can link your the thread

#

They never cared to redo it or at least take it offline

woven bramble
#

Then the system is completely broken. But I built everything on it.

thin stratus
#
#

For your own sake, read my Compendium that is pinned

#

And avoid that tutorial

woven bramble
#

oh, I built everything on bullsh*t. It's really sad and a waste of my time.

#

Btw Why does this whole system work, what kind of trouble do you think I will have in the future?

#

Oh, now I remember. "cedric-neukirchen" is your website. I learned a lot from you, really thank you.

#

You even replied when I opened a thread on the forum years ago. I remember it all now hahaha

woven bramble
# thin stratus And avoid that tutorial

By the way, which path should I follow for the basic logic of the Update system? When someone enters the game, it really confuses me that I pass on the knowledge of what happened before in the game.

thin stratus
thin stratus
# woven bramble By the way, which path should I follow for the basic logic of the Update system?...

What you are talking about is State. **State ** should almost always be replicated via Replicated Variables.
If something has to react to the State Change, especially when joining late, they should be OnRep function.
That State is usually placed in e.g. the Character (what Mesh, Color, etc.), GameState (what Team is leading), PlayerState (how many Kills, Deaths, Assists, PlayerName, etc.).
If they are replicated, they will be up to date when your new Player joins.

#

There are sadly also a lot of OnRep Functions for already existing stuff in the Engine. E.g. OnRep_PlayerState in the Pawn/Character class.
And those aren't available to you in BPs. You can either make your own setup if you need that, or learn C++ (which is kinda requirement if you want to really do multiplayer games).

woven bramble
thin stratus
#

You don't need to run an event "EveryoneUpdate"

#

OnRep functions call for connecting players when they receive the new data of that variable

#

You should store the State Data in the Actor that it belongs to

woven bramble
thin stratus
#

No

#

OnRep calls automaticlaly when the Data of that Variable replicates to the Client

#

That includes poeple that join

#

OnRep is also only needed if you need to call a function based on that data

#

If it's just plain "This is how many kills the player has", then it's enough to just mark it replicated

#

There is no need for you to call an event to send updated data

woven bramble
# thin stratus There is no need for you to call an event to send updated data

Ok, now I understand better.
I'm taking your time, I'm so sorry, can you briefly summarize this?

What I wanted was to select a character by pressing the button in the Lobby, save it. When I enter the game, it spawns whatever skeletal mesh is. (Set Skeletal Mesh)
In other words, by pressing the button RunOnServer > Multicast, Set Skeletal Mesh works.
But when someone else enters the game, it sees its default mesh, because it does not update.
Which way do you think I should follow for such a system?

thin stratus
#

That is basically what I just said: State has to be done with OnRep

#

You are experiencing a bug from not following that.

#

Your State here is "SkeletalMesh"

#

In other words, "State" is everything that changes and then remains like this for everyone until changed again.

#

Such as "what skeletal mehs someone has"

#

Multicast, Set Skeletal Mesh works.
By using a Multicast, you only fire that event ONCE.

#

And only to the players in relevancy range and connected

#

Let's ignore the need for RunOnServer etc., if you want to fix this you have to remove the Multicast and create a variable, e.g. "CurrentMesh" of type SkeletalMesh.

#

You set that to RepNotify

#

And in the OnRep function (gets auto generated) you call SetSkeletalMesh

#

And then instead of the Multicast, you just set the CurrentMesh variable (after the ServerRPC)

#

That should already fix your issue.

#

Don't use Multicasts for things that require to be uptodate for people who join late or are far enough away (literally distance based) that things aren't relevant for them.

woven bramble
thin stratus
#

It's not stupid. This is really difficult for beginners.

#

And it doesn't help that Epic has that video up.

#

All it takes to learn multiplayer is to sit down and read the Compendium + literally just trying around in the Editor.

#

There will be a gazillion more issues in your future game dev life regarding multiplayer

#

This here is just the very very very beginning :D

woven bramble
knotty briar
#

I'm only using the advanced sessions, not the advanced steam sessions and the thing is, it didn't work even before adding in this plugin

#

LogScript: Script Msg: Found a session. Ping is 55
LogOnlineSession: OSS: Join session: traveling to {ip address}:7777
LogNet: Browse: {ip address}/Game/Main/MainMenu/L_MainMenu
LogInit: WinSock: Socket queue. Rx: 32768 (config 32768) Tx: 32768 (config 32768)
LogNet: Created socket for bind address: 0.0.0.0:0
LogNet: IpConnection_2 setting maximum channels to: 32767
PacketHandlerLog: Loaded PacketHandler component: Engine.EngineHandlerComponentFactory (StatelessConnectHandlerComponent)
LogHandshake: Stateless Handshake: NetDriverDefinition 'GameNetDriver' CachedClientID: 5
LogNet: Game client on port 7777, rate 100000
LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 0.02, Realtime: 14.04. IpNetDriver_7
LogNet: Initial Connect Diagnostics: Sent '10' packets in last '10.014697' seconds, no packets received yet.

#

thats the logs for it

#

but i still don't understand

thin stratus
#

Can it be that the player literally times out?

quiet fjord
#

It gave me problems when I used the advance session when I was creating a prototype in shipping mode. It only connected when I used it in development mode

#

since then I use connections with aws

knotty briar
#

aws?

#

amazon web services im guessing

#

thing is I only want the game to have LAN capabilities

#

it works in the editor

#

but from two pcs it doesnt work

quiet fjord
#

with aws you can also create a lan connection

#

A good option would also be to use the EOS system

queen escarp
#

Question guys how would i best do AI for multiplayer Npcs, like have a parent class with the logic replications and whatnot or should i keep em seperate for each npc ?

quiet fjord
#

It depends on what type of npc, if for example they are village-type npc with a very similar pattern, I recommend that you make a state factory

#

If, on the contrary, it contains a more complex behavior, it uses the state tree system.

queen escarp
#

hm state factory state tree

#

i mean

#

this is how im doing it now and im guessing there is a better way or more functionall way

grave notch
#

whats the proper way to move player characters on the server, and i mean server only?

quiet fjord
#

What do you mean moving the characters to the npc?

grave notch
#

just move player characters based on their inputs but only from server

#

for some reason there is a line in movement component (or somewhere close to that, i dont remember exactly) that applies InputVelocity only if local machine is owner of that pawn

quiet fjord
#

keep in mind that the default movement of the players is replicated therefore the other players will see that the character moves

grave notch
#

something like that iirc

#

so basically if i change InputVelocity on the server it doesn't actually move character

grave notch
quiet fjord
#

what you want is for the character to only move on the server. If a customer presses an input?

grave notch
#

yes, move on the server, and client only get replicated movements

quiet fjord
#

what you can do is perform the function of moving in a multicast and within the multicast you have to say that if it is the server that is moving and if it is other players that it should ignore it with that you already have it

grave notch
#

i already have GAS ability that perform movement, and its server only, but it just doesn't work

quiet fjord
#

you can do it with node is server

#

I have something similar to what you say but I apply it to animations

grave notch
#

it is executed on the server, but movement component doesn't move character based on inputs if character is a proxy as i understand

quiet fjord
#

to optimize the performance of connections

#

keep in mind that each character has an autonomous proxy

grave notch
#

as i understand on the server all characters are SimulatedProxy and i need to somehow make them AutonomousProxy?

quiet fjord
#

In Unreal Engine 4 (UE4), "Autonomous Proxies" refers to objects or characters controlled by the player in a multiplayer environment. In a multiplayer game, each player has an autonomous proxy that represents their character in the game world.

The term "autonomous" refers to the ability of each proxy to independently make decisions and take actions on their own client. Each client has its own autonomous proxy that makes local decisions based on player input and server updates.

In a multiplayer environment, the authority is on the server, which means that final decisions about game state and actions are made by the server and then replicated to the clients. However, autonomous proxies on clients have some autonomy to perform local predictions and actions before receiving acknowledgment from the server.

For example, when a player presses a button to make their character jump, their standalone proxy on their client immediately performs the jump action before confirmation from the server arrives and is replicated to the other clients. This provides a more responsive gaming experience and avoids the feeling of lag due to network latency.

It is important to note that while standalone proxies perform local actions, the server has final authority and can override or correct actions taken by standalone proxies if they differ from the server's decisions.

In short, "Autonomous Proxies" in UE4 refers to characters or objects controlled by players in a multiplayer environment, who have the ability to make decisions and perform local actions before receiving confirmation from the server. This allows for a more responsive gaming experience and reduces the feeling of lag due to network latency.

#

I hope my clarification helps you understand it better.

grave notch
#

this is just chatgpt

#

well i know that

thin stratus
#

@grave notch Well the CMC is build around the idea of locally predicted movement.

#

If the Character is client owned and you want to move it from server side then you can only really set Velocity directly

#

Or location fwiw

#

But the Input stuff remains locally

grave notch
thin stratus
#

That probably won't work

#

It's not just one line of code :P by far

woven bramble
#

Guys, I have 2 Door_BPs in my scene.
When one opens the door, the other client can see that the door is opened. And each door works independently and flawlessly.
But if I open the door when there is no client in the game and the client has come, the door appears to be closed.
I solved this problem with RepNotify method. But I have another problem.
Only the last door I opened opens. (Because that actor is the last to be set.)
If I create multiple separate Door_BPs the problem is solved but it's a tedious process because there are many doors on the scene.

#

btw I press f key and send a line trace, I'm using interact. I get the angle of the door in Door_BP. and there are RunOnServer > Multicast > RepNotify

quartz iris
#

Is what im doing correct for the round winner?

#

and also match winner

upbeat basin
# woven bramble Guys, I have 2 Door_BPs in my scene. When one opens the door, the other client c...

Well the solution is correct, you should use RepNotify functions to replicate a state for a late joiner or a player that becomes relevant again for replication. But it feels like you should change your design a bit. You should have your boolean that represnts if the door is open or not in the door itself, so each door instance can store its own state, instead of storing only the last door that you interacted with on somewhere else

meager spade
#
static FAutoConsoleVariableRef CVarWithArrayOnRepFix(TEXT("net.WithArrayOnRepFix"), GbWithArrayOnRepFix, TEXT("If true, attempt to prevent issues with Arrays not receiving OnRep calls until their size changes if their Archetypes have different values from instances in levels."));```
#

this seems to fix arrays not replicating

twin juniper
#

While doing server travel or using OpenLevel we use an url. We add the parameter listen to it to signify that it's on listen server. Let's say I open lobby level and now I am going to gameplay level, do I need to add "listen" to the url again?

patent spruce
#

I was reading this article https://gafferongames.com/post/udp_vs_tcp/ so that I could try to understand the use cases for UDP and TCP in multiplayer games. It was published in 2008. Is this a good reference, or did their use case change over time?

peak mirage
#

So I just try some experiment with Replication Graph today, looks like the graph calculates its grid distance base on player's camera location, not character or controller's location

#

Is there any way I can change the default 2D grid so they use a location offset to the camera position instead of the camera's location, in a RTS game?

woven bramble
peak mirage
#

Because in RTS camera is far away from the battle field, and I need to check if the actor is far enough from the point that camera is looking at, not the camera itself

upbeat basin
knotty briar
#

I have a question. Basically I figured out why the multiplayer wasn't working, it was because the ports weren't allowed in the firewall. So my question is, would UPnP work? and if yes, how do I use it in unreal engine

#

because the thing is, I want it setting up automatically rather than me having to go there and doing it for each device its on

woven bramble
upbeat basin
#

Well if that's the character, it means you're not storing doors' open state in door class, you're storing it in your character and you're storing only the last interacted door's state

#

You should create your replicated boolean in the door blueprint, when you interact with the door, you should change the boolean inside of that door object

#

And on the RepNotify function of the boolean, you should change that door's rotation in there, so when a new player joins, they can get the replicated value of the boolean and change the state of the door accordingly

#

Also your open door function is multicast, if you're going to set your replicated variables in it, it can just be server RPC, when you set your boolean on server, RepNotify function will run on everyone, like multicast, so you don't need that function to be multicast

woven bramble
nocturne quail
#

this GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const needs a method to be declared in .h file or not?

queen escarp
#

hey guys when im using server travel for all clients im using a transition level between load

#

but how do i put a loadingscreen instead or something like that ?=

latent heart
#

In this UE5 Tutorial we will design two Levels from scratch and a Level Transition with Loading Screen between.

๐Ÿ’€ TIP a Custom Amount:
https://www.paypal.com/donate/?hosted_button_id=JN9EL84MVX5ZE

๐Ÿ’€ Download FREE PS1 Style Assets and more:
https://www.starkcrafts.com

๐Ÿ’€Wanna support and exclusive Content?
https://www.patreon.com/starkcrafts

...

โ–ถ Play video
#

This engineer-oriented talk about assets loading management for good performance and smooth transitions by Epic Games' Support Engineer Axel Riffard goes over different methods to craft beautiful and highly optimized loading pipelines for your game, be it single or multi player.

Learn more about Unreal Engine at http://www.unrealengine.com

โ–ถ Play video
queen escarp
#

ty

latent heart
queen escarp
#

holy moly

latent heart
#
#

I'm pretending to be google.

queen escarp
#

ok i can take the hint

latent heart
#

๐Ÿ˜›

queen escarp
#

yeah i acctualy googled it a few days ago but with no luck tbh i dont remeber why now since it seems super easy

latent heart
#

To be fair, I did include the words "transition level" in my search

queen escarp
#

lawlz

icy jetty
#

That makes more sense, I rmbr not finding much with just loading screen lol

latent heart
icy jetty
queen escarp
#

xD

icy jetty
#

Wrong reply but eh

queen escarp
#

ok so if im understanding it correctly a loadingscreen is basicly a seperate widget that u apply before transition and disable when entering yes ?

#

question, how would i apply it to all "remote" players "all players"

latent heart
#

I think it's one you apply in the transition level itself, but I may be wrong.

graceful flame
#

So I know about adding a widget for a load screen then travelling to the transition level and finally to the next level but it defaults to a camera at 0,0,0 before anything is loaded. What's the trick to keep the loading widget on the screen before showing the level environment?
Currently I have an object at 0,0,0 with a world space widget inside it showing the same loading screen. I then carefully hide the 0,0,0 object with other assets used on the level so it isn't seen during regular gameplay. Is this the best practice to hide the ugly asset popping and texture loading stuff?

graceful flame
#

It seems that even when I used a world space widget at 0,0,0 to mimic a loading screen it doesn't load in fast enough. The best way might be to just have a plane or cube with a material that looks like a loading screen instead.

#

If you test with the "bad" network conditions the loading delay is much more obvious.

Best solution seems to be a 0,0,0 cube with a two sided material that has some sort of loading animating material on it that is consistent with whatever loading widget material you show the player when they complete a level or whatever and need to transition to the next one.

quasi tide
#

<@&213101288538374145>

limber gyro
#

hye guys, im having an issue that only happens in the server, if im playing as a client it works fine, so heres the issue: when i shoot at a character my projectile sets a timer for that character, in the client that timer runs normaly from 0.3 to 0, but in the server its always at 0 even after it was just changed.

#

im thinking that the variable is probably not being updated in the server but the collision that trigger the variable change happens in the server so it should change the value in the server right?

kindred cypress
#

Hello, why does a Replicated Actor Component doesn't accept inputs? I added the component on server side to the player's pawn

Gamemode get all players - for each -> Execute AddMyComponent for player's pawn
inside my player pawn the AddMyComponent event is set as Execute on Server, the component is marked as Component Replicates

latent heart
#

Are you sure you actually have players when that executes?

#

Does the component get added? Does it replicatE?

#

Have you tested any of that?

#

Also marking "AddMyComponent" as executes on server won't do anything if it's already being run by the server (because the game mode doesn't replicate at all ever, so that loop can only run on the server)

limber gyro
#

in the character base class

{
    phisicalAnimationTimer = 0.3f;
    direction.Normalize();
    phisicalAnimationDirection = direction * 15000;
}```
#

in the proejctile class:

if (character)
            {
                AProjectArenaPlayerState* state = Cast<AProjectArenaPlayerState>(character->GetPlayerState());

                if (state)
                {
                    //client stuff
                    if (state->team != team)
                    {
                        FVector direction = character->GetActorLocation() - BulletOwner->GetActorLocation();
                        character->ActivatePhisicalAnimation(direction);
                    }
                }
            }        ```
#

again in the character tick:

if(GetLocalRole() != ROLE_AutonomousProxy && isDead == false) // we dont do this in our own machine to not get aim punch, only on other chharacters
    {
        if (phisicalAnimationTimer > 0)
        {
            phisicalAnimationTimer -= DeltaTime * 1.0f;
            MeshThirdPerson->SetAllBodiesBelowSimulatePhysics(FName("spine_03"), true);
            MeshThirdPerson->SetAllBodiesBelowPhysicsBlendWeight(FName("spine_03"), phisicalAnimationTimer, false, true);    
            MeshThirdPerson->AddForceToAllBodiesBelow(phisicalAnimationDirection,FName("spine_03"),false,true);
        }
        else
        {
            MeshThirdPerson->SetAllBodiesBelowSimulatePhysics(FName("spine_03"), false);
        }
    }```
#

i can confirm with break points that the if is being hit, the issue is that the timer is 0

#

basicly the idea is that the the hit makes the timer go to 0.3f and then it does a physical animation in that small window

kindred cypress
latent heart
#

It's probably an input issue then. ๐Ÿ˜ฆ

kindred cypress
#

cause this works just fine

latent heart
#

Is it activated by user input? I.e. a mouse button?

limber gyro
#

i am assuming since that even happens in the server that the server would know

#

event'''

limber gyro
#

i mean, its working on the client, it just doesnt work on the server, so is the server reseting the value?

#

ye, its suposed to be happening on a raycast or on an onOverlap

#

and for example, the on overlap happens on the server correct?

latent heart
#

And have you checked to see if the overlap is actually working on teh server?

limber gyro
#

i have

latent heart
#

everything happens on both the server and client. The server just updates the client every so often.

#

The client does not update the server.

latent heart
limber gyro
#

becase the other stuff gets triggered

#

and i actualy see the value change

#

it just gets reset to 0 on the tick

#

im just a bit confused with the architecture i guess

#

ok so my first assumption is that the server is changing the value back to 0

latent heart
limber gyro
#

because i didnt call that change with an RPC

limber gyro
#

should i call is server?

latent heart
#

GetWorld()->GetNetMode() != NM_Client is a good check

limber gyro
#

i can check it real quick

#

k i will use that

#

will be back in 2 mins

#

jsut gonna test the thing

latent heart
#

if (GetWorld()->GetNetMode() != NM_Client) { UE_LOG(LogTemp, Log, TEXT("It's run on the server!")); } directly after if (character) {

limber gyro
#

ok with that check its not running on the servers

#

so i am assuming the value change was only on the client

#

now im even more confused lol

#

i was under the impression that those kind of events would happen in the server

latent heart
#

Overlap events will happen on the server, but only if your client is actually telling the server where it's going.

limber gyro
#

so i guess i have to RPC it

latent heart
#

You should use ACharacter. It's automatic for that, I believe.

#

Has lag compensation etc.

limber gyro
#

thats the character movement class no?

latent heart
#

Yes

limber gyro
#

im aware of that

latent heart
#

If you need any kind of human-model-based networked movement, use the CMC

limber gyro
#

yes character movement component

#

so i got it to work on the server with the rpc

#

now it doesnt work on the client, is there an rpc that runs both on the client and the server?

#

is multicast a proper option here?

latent heart
#

No

#

Multicast is for the server talking to every client

#

What did you change?

#

Show me the new code.

limber gyro
#

i just made that function an RPC

#

nothing more

#

and it worked on the server

#

and didnt work on the client

#

basicaly it got inverted

#

which makes sense

latent heart
#

You need to do it locally and remotely.

#

So have 2 functions (or even 3)

limber gyro
latent heart
#

No

limber gyro
#

aww come on, there has to be

#

i cant stand ugly code T.T

#

im gonna need to have 2 identical functions?

#

thats just awfull

latent heart
#

Oh wait

quasi tide
#

It's pretty common to have identical-like functions in networking

quasi tide
#

Get out while you can. It's all downhill from here.

#

Multiplayer was a mistake

latent heart
limber gyro
#

why isnt there an RPC that executes on the client and then on the server?

#

it makes sense to have something like that right? im not crazy...

latent heart
#

Only execute #1 if you're a remote client.

#

Because most stuff doesn't work like this. The actual "move_actual" part might be different on the serevr and client.

#

For movement it's going to be very similar, but for shooting? Might be totally different.

limber gyro
#

writing 2 functions for the exact same thing feels like an abomination

#

i dunno man, if the only solution i guess im gonna have to take it

latent heart
#

It's not really for the same thing.

#

They are wrapper functions.

#

The body of the stuff, in this case, goes into a single function.

limber gyro
#
{
    phisicalAnimationTimer = 0.3f;
    direction.Normalize();
    phisicalAnimationDirection = direction * 15000;

    ServerActivatePhisicalAnimation(direction);//we need to call a server version so that this effect also occurs in custom games for the player that is the server
}

void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
    phisicalAnimationTimer = 0.3f;
    direction.Normalize();
    phisicalAnimationDirection = direction * 15000;
}
#

ended up doing it like this

#

it works

#

ive never been so unhappy after fixing a bug

latent heart
#

That's replication of the function, though. Don't do that!!

limber gyro
#

????

latent heart
#

As in, you've copied the actual code to a second place.

limber gyro
#

so whats the best solution then?

latent heart
#

You don't need 2 copies of the code.

#

Add another function which both of those call

#
void Move(...)
{
  if (Client) { ServerMove(...); }
  MoveImpl(...);
}

void ServerMove(...)
{
  MoveImpl(...);
}

void MoveImpl(...)
{
  // do move here
}```
limber gyro
#

function()
{
ActivatePhisicalAnimation();
ServerActivatePhisicalAnimation();
}

like this?

#

wait

#

im failign to see how that is not the same thing

latent heart
#

You have the code to do the move in 2 places. YOu have exactly the same code in 2 places.

#

That is a potential bug waiting to happen

limber gyro
#

ye and i was trying to avoid that

latent heart
#

That's why you wrap that one bit of code in another function (BlahImpl) and then call that from each place, instead of copying the code.

limber gyro
#

ok i get what ur saying now

latent heart
#

What you have is: ```cpp
void Move(...)
{
if (Client) { ServerMove(...); }
// do move here
}

void ServerMove(...)
{
// do move here
}```

#

Or so

limber gyro
#

let me think about this

#

cause im calling those functions in the projectiles and those are spawned in the server

quasi tide
#
void AProjectArenaCharacter::ActivatePhisicalAnimation(FVector direction)
{
    DoThePhysicalAnimation(direction);
    ServerActivatePhisicalAnimation(direction);//we need to call a server version so that this effect also occurs in custom games for the player that is the server
}

void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
    DoThePhysicalAnimation(direction);
}

void AProjectArenaCharacter::DoThePhysicalAnimation(FVector direction)
{
    phisicalAnimationTimer = 0.3f;
    direction.Normalize();
    phisicalAnimationDirection = direction * 15000;
}
#

This is what Daekesh is saying.

limber gyro
#

ye, thats what i figured, it was just taking a bit longer than it should because ive never seen that pattern and im a bit sleepy

quasi tide
#

btw - your physical word is spelled incorrectly ๐Ÿ˜…

limber gyro
#

when english is not ur first language u sometimes make mistakes

#

heck i make mistakes even in my own language hahaha

latent heart
#

But mostly yes.

quasi tide
#

I'm not writing for that silly goose

#

I cared far more about extracting to a method

latent heart
#

You know he'll be back in an hour asking why it happens twice on the server ๐Ÿ˜‚

quasi tide
#

We'll cross that bridge when we get there!

limber gyro
latent heart
#

Hehe

limber gyro
#
void AProjectArenaCharacter::ClientPhisicalAnimation(FVector direction)
{
    if (GetWorld()->GetNetMode() != NM_Client)
    {
        ServerActivatePhisicalAnimation(direction);
    }

    ClientPhisicalAnimation(direction);
}


void AProjectArenaCharacter::ClientPhisicalAnimation(FVector direction)
{
    phisicalAnimationTimer = 0.3f;
    direction.Normalize();
    phisicalAnimationDirection = direction * 15000;

    ServerActivatePhisicalAnimation(direction);//we need to call a server version so that this effect also occurs in custom games for the player that is the server
}

void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
    ActivatePhisicalAnimation(direction);
}
#

does this look alright?

latent heart
#

== NM_Client

#

Because you want to check if you're on the client ๐Ÿ˜›

#

But no

#

Where is ActivatePhysicalAnimation ?

#

1 moment

quasi tide
#

Also Client prefix typically means it is a client RPC. Not sure if that is the intended purpose though. Just a heads up.

limber gyro
#

imma call it local than xD

latent heart
#
void AProjectArenaCharacter::PhisicalAnimation(FVector direction)
{
    if (GetWorld()->GetNetMode() == NM_Client)
    {
        ServerActivatePhisicalAnimation(direction);
    }

    ActivatePhisicalAnimation(direction);
}

void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
    ActivatePhisicalAnimation(direction);
}

void AProjectArenaCharacter::ActivatePhisicalAnimation(FVector direction)
{
    phisicalAnimationTimer = 0.3f;
    direction.Normalize();
    phisicalAnimationDirection = direction * 15000;
}```
limber gyro
#

the thing is, i need to call the server rpc when im a client running as server

#

thats where the error was ocurring

quasi tide
#

So also check if you're a listen server.

limber gyro
#

running in the client everything was fine

latent heart
#

You don't!

#

You only need to call the Server version if you're a NOT a server.

limber gyro
#

i know thats how it works in theory, but in practice thats not what was happening

latent heart
#

The "Server" method isn't "only run when you're on a server" it's "SEND this to the Server"

limber gyro
#

or maybe im missing something

latent heart
#

So the code I sent there will work ^

limber gyro
#

so why was the error ocurring when i was the server?

latent heart
#

What error?

#

Have you used the code, verbatim, that I put pasted a few minutes ago?

limber gyro
#

the physical animation timer value not being set

limber gyro
#

its compiling

#

give it time

latent heart
#

What you had before was wrong.

limber gyro
#

im trying to fix all the text error

#

errors

latent heart
#

Because you werne't telling the server that you were moving.

limber gyro
#

cause i changed the names

#

ur code does indeed work

#

im still confused tho

#

GetWorld()->GetNetMode() == NM_Client, this is suposed to run when im on the server

quasi tide
#

And it would?

#

That little snippet is saying, "Only send this server RPC if I'm a client"

limber gyro
#

exactly

quasi tide
#

If you're the server already, you don't need to do a server rpc

limber gyro
#

so only the local version runs

quasi tide
#

No?