#multiplayer

1 messages · Page 118 of 1

scenic kraken
#

Hi, how to access a gamestate or playerstate of a specific player in multiplayer? (for example, a variable of playerstate of player 2)

dark edge
hard violet
#

Guys is there any good course for multiplayer game in UE5?

scenic kraken
thin stratus
muted pewter
#

I have a dedicated server running and two clients are attached to it I am trying to show a UserWidget to all two clients by using Event(Replication=Multicast) in Server's Game Mode but widgets are still not visible in clients screen? Any idea what I'm doing wrong?

fossil spoke
#

Try the GameState

muted pewter
#

Okay

#

Also this UserWidget has a score variable in it so Will gamstate be a good idea to use?

regal geyser
#

Question about replicated variables.

When a variable is set to Replicate, and the client tries to change it, will it be successful? From my understanding only server can change this variable and if it will be different from previous value, then it replicates to all clients.

But can a client locally change this variable for himself only?

Lets say there is Replicated variable Health, but client locally sets it to a large number, will it be reverted back to the current server's value or the server won't know about this change?

thin stratus
# regal geyser Question about replicated variables. When a variable is set to Replicate, and t...
  1. It will change locally.
  2. It won't change for anyone else.
  3. The Server won't know about it.
  4. It will be "corrected" the next time the Server alters the Variable.
  5. BP OnRep Variables will trigger their OnRep if set locally, due to those being Property Changed Notifiers
  6. C++ OnRep Variables will not trigger their OnRep if set locally iirc
  7. C++ OnRep Variables might also skip triggering the OnRep if the Server, afterwards, manages to set the Variable to the same Value that the Client already set it to.
    a. You can fix that by marking it as always calling when defining it in C++. BPs shouldn't really have that issue I guess, cause the OnRep calls locally already. Might still skip the Server induced call.
muted pewter
#

I have a Bp_ball attached on a map and this map is opened on server ,this bp_ball tries to get Default game mode of server which returns , Im unable to figure out the reason also im i doing it the right way?

tidal temple
#

Hello, dear developers.
I'm stunned by the "movement lag" problem caused by server corrections.
As far as I know, there are several ways to implement new and custom movement abilities:

  1. GAS.
  2. CMC network prediction data.

I've tried both ways, but it looks like the "rubberbanding" is still there. Especially with a ping of 100+.
Most games (including indie ones) that I know can handle this ping quite well. Are there any helpful resources or issues that I just haven't noticed? Thank you.

Example Of Ability: https://pastebin.com/VEd3Nm7s

thin stratus
thin stratus
#

There are some things you can do in GAS that can utilize movement, like RootMotionSources, but if you actively start to modify the CMC on Server and Client (given your Ability is predicted), you will see rubberbanding.
The GAs are not "in sync" with the CMC and the CMC also wouldn't know about any of the Abilities State when replaying.
Aka, if a correction comes, nothing will replay the activation of your ability.

tidal temple
thin stratus
#

The only thing I can recommend is the pinned Git repo with some examples

#

Everything else will be you having to read teh CMC code, understand it and utilize it matching your specific requirements for the movement you want to do

#

+- asking here once in a while

tidal temple
woven basin
# tidal temple I was thinking exactly about that. But there not so many resources about CMC's c...

Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv

Join our community discord!
Discord: https://dis...

▶ Play video
thin stratus
#

CMC by now allows defining a container struct with data

#

You can make your own and add more data into it than the 4 flags

muted pewter
#

I have a BP_Goal attached on map and this map is opened in Server i need a way by which whenever a ball hits that goal it should call a function of Game Mode (Update Score UI)? I have tried calling Event(Server Replicates and Multicast) but it fails to cast Game Mode

tidal temple
thin stratus
#

But at some point you might want to ensure that you don't overdo the data part ,cause that can hit bandwidth

thin stratus
woven basin
#

each client does not update the game mode with the score locally

tidal temple
tidal temple
thin stratus
#

^ this is example code only.

muted pewter
muted pewter
unreal sapphire
#

Is there any information available on running multiple sessions of a game on the same dedicated server? I haven't been able to find much info on this.
I would think it should be possible, perhaps by running the same dedicated server process but on different network ports? Would love to hear the most commonly used routes for this. Thanks.

thin stratus
wet arch
#

Hi @coarse skiff I'm not sure where to answer the question about Firebase analogs for Unreal. So I will leave it here. When we started the current project, I was also looking for something to store player information. As it turns out Playfab and Gamesparks are still alive 😉 Even though they were bought by MS and Amazon. You can have a look at them.
I didn't really like the level of support for these products back then and we eventually just decided to write our own backend in Python + DynomoDB.

buoyant coral
#

Hi, where is it safe for the Player Controller to set a reference to itself on the pawn that it owns?

// Pseudocode
Character = Cast<ACharacter>(GetPawn());
Character->PlayerController = this;

Something like this in the APlayerController::BeginPlay() returns a nullptr

#

Or how can I get a reference from the Character, I don't think that using UGameplayStatics::GetPlayerController(this,0) works neither

hollow eagle
#

Pawns already know who is controlling them

#

You don't set it yourself.

#

On the server you can override PossessedBy to be notified when this happens, on both the server and owning client you can listen for ReceiveControllerChangedDelegate or override NotifyControllerChanged.

#

And to get it you just call GetController

buoyant coral
#

Thanks

quartz iris
#

The Advanced Steam Sessions create/joining of servers works inside the unreal engine 5 project, but whenver I upload the build to Steam with the correct AppID, I can't join my friend's server and viceversa. What could be causing this issue?
It appears my friend can create a server, it's just I cannot join it. I can do the same, create a server but nobody can join.
Here's my code for creating/joining

solar stirrup
#

and send them here

plush wave
#

So net ids can differ for the same replicated actor but on two different clients?

fathom aspen
#

Yeah

latent heart
#

You'd think they'd all be the same.

fathom aspen
#

They are per package map, i.e per net connection

latent heart
#

It'd still make sense to have the net id for all actors in a world to be the same, across all connections.

fathom aspen
#

Ehh would be extra work that the engine doesn't really care about

gloomy axle
#

For some reason, when I try to cast to my game state from a client, after the cast it doesn't call my Choose Team event?

#

from the game state, with the player input

#

it seems to skip it completely

fathom aspen
#

Yeah since Server RPCs are dropped when called from actors you don't own

#

Actors you do own are PlayerController and any other Actor it owns

#

Pawn/PlayerState

#

If you look in the output log you will see the engine telling you that

#

no owning connection for actor... RPC will be absorbed

quartz iris
#

Packaging failed on the dev build

#

shipping works but the servers don't as mentioned before

latent heart
#

Remove spaces from directory names

#

#1 cause of packaging problems!

#

Also looks like that file is locked.

gloomy axle
#

sometimes the client is on orange and the client/server is on blue, which is correct

#

im not sure why they would be put on the same teams. this is on my game state

spare moss
#

hi, more sticking my head in here out of a curiousity then an actual need.

But I noticed the blueprint node says that GetPlayerState (Gameplay Statics) has a consistent index across all clients and server but that appears to very much not be the case in my game. I'm curious if anyone else has experienced this?

In each client the HUD layout is the same and pulls from a preset index
TL: 0
TR: 1
BL: 2
BR: 3

But as you can see in the image, each one is pointing to a different playerstate (The names are pulled via GameState->GetPlayerName

and there doesn't seem to be any consistency either in the layout.

Game's TL, TR and BR all have their own local player in slot 0, Yet BL has the local player in slot 3

sinful tree
#

Eg: Player joins game, their PlayerState begins play on clients, that begin play could signal to the game state that a player joined and the GameState can broadcast an event dispatcher with the playerstate that joined. Any UI could then bind to that dispatcher and associate itself with the particular playerstate that joined. No need to mess about trying to figure out which index is which, just that when a player joins, there will be a signal for them on clients when they join, and you could do the same with EndPlay and signal when a player leaves.

Any interactions with a controlled pawn has a playerstate reference attached to it as well, or if it's not directly controlled, you could always give it a replicated playerstate reference when the server is spawning it that other clients could then use.

shadow hatch
#

so the blueprint 'onrep' replication setting makes the function trigger on both server and client(s), correct? how do i make this happen through cpp as well? from what ive noticed if i do an onrep through CPP it only fires on clients which also means i have to find another workaround in case i want my code to work the same both in standalone and dedicated

haughty sierra
#

which online service would you choose for a survival game?

haughty sierra
#

how can i handle persistent data with steam?
like players last position ingame

#

or do i need a database for this?

#

i want a dedicated server

#

and which database should i use

#

i tried playfab but it doesn't worked as i intended

#

what do you think about epic online services?

halcyon adder
#

Hello!
I'm using AddForce to move my character in zero-G. The call is done on both the server and the client, but my client receives a server correction when it moves (although it works for the host).
Is there any way to get some details about what is causing the correction to happen?

#

I could use p.NetShowCorrections 1 to confirm that the position reset happens because of server correction, but not sure how to go from there

halcyon adder
#

Nevermind I think I found the reason. Looks like some code is scaling the vector down when serializing the move.

spare moss
dusky yoke
#

Hey. On BeginPlay I'm spawning a tornado. If players overlap the tornado I want them to take damage. That works fine for client & server. However:
If players are standing inside the overlap sphere when the tornado spawns, I'm spawning a sphere on beginplay to counter them not being overlapped. However, only the first client is being registered. I'm not too well versed with foreachloops and such, could anyone point me in the right direction?

mystic estuary
#

Hello, if I need a spectral actor that essentially shows what the player is building, what would be the best approach to do it? I guess I have to use a AActor for the base class, but as for telling the position the client wants to move the spectral actor, should I use OnRep or NetMulticast?

#

And what can I do with prediction? I have to spawn the actor client-side, and tell the server to spawn as well, so that other clients would see it as well, but it would make the telling client receive a second spectral actor. Should I simply destroy it or maybe it's possible to make it irrelevant to the owning-client?

wanton cedar
#

when dealing with RPCs, theres something I'm misundestanding kind of. switch has authority really feels like a Run On Server rpc without the call. How is the right way to know when I should be wanting to use authority over an RPC?

#

that might sound stupid, but im setting everything up with RPC's and not using authority at all, because I think i misunderstand why/when its appropriate

mystic estuary
wanton cedar
#

i never would have thought of that example, and that makes perfect sense

sinful tree
# wanton cedar when dealing with RPCs, theres something I'm misundestanding kind of. `switch ha...

HasAuthority is used to determine whether or not the current instance executing the code in question has authority over the actor.
It is useful for events where it can begin execution on either a client or the server, such as Begin Play, Overlap events, etc.

RPCs are a means of having one instance of the game call to the other. So a Run On Server event means you're allowing a client to call to the server to execute the code, so long as the client owns the actor where you're calling it from. Same with Run On Client, you're allowing the server to call to the client, so long as there is an owning client. Multicast will fire to all clients who have the actor relevant regardless of ownership and can be called on any replicated actor by the server.

wanton cedar
#

so long as the client owns the actor where you're calling it from. < the source of my none for a while. lol

#

thx guys. ill think on this

#

so many ways to achieve the same end, of course, but I feel like there is always a network clean way to do things which makes it the right way

#

cig n espresso time, but, last general question of advice. im doin this level, and i've got the staticmeshactors (spheres) replicating transforms. so I can shoot em or grab em. But what I'm trying to figure out the right approach for, is to not have them broadcast transforms until their transform is changed. theres quite a few of them, so it makes sense to lighten server load if they dont move the whole match. I was wondering if repnotify fits this, and can be toggled relevant to replicate when onhit or isgrabbed?
so much learning, I was examining the RPC flow in the profiler and saw they were very active, and began to wonder about relevancy + replication (thx ryan laley)

wanton cedar
#

sorry if this is a basic question, i just keep reading and learning. figured ask if the category was the right direction to read into

echo bough
#

what are the proper ways to add a component at runtime in multiplayer?
Authority adds Component that is replicated, clients need to wait OnRep of the component variable before able to bind events from it?

south crane
#

i have a really simple setup. Server spawns actor, actor on begin play has switch has authority -> multicast event but the multicast event does not trigger for clients unless I put a small delay after beginplay why is this?

fiery wadi
#

Sorry if this is a basic question, As an example 4 players run a course to collect as many coins as possible, Would you store each players number of coins in the Game Mode or Game State or within each player's controllers?

#

I assume each client would send to the server +1 coin for their Client ID (Associated Controller) every time they collect a coin

#

Server (IE.Game Mode)

echo bough
#

you usually dont want to cointain any state data in gamemode

fiery wadi
#

So state = Player Gold, Player Health etc?

#

or State as in Started, Running, Game Over.

echo bough
#

the only difference between gamestate and playerstate here are their relevancy and disconnection i think

#

state as in variables that contributes to the goal of the gamemode

fiery wadi
#

So if theres a 4 player limit and a maximum of 100 coins these are "defined" rules which would go in Game Mode? and the 1st player to reach 100 coins is declared winner.

#

Game State would basically trigger "PlayerController1 has picked up 1 coin" + 1 to PC1 Total Coins.

#

if im thinking right?

echo bough
echo bough
fiery wadi
#

Ah ok thank you !

south crane
echo bough
south crane
#

in this case I was setting a static mesh to be a random one from an array of static meshes

echo bough
#

and the "random" is decided on the server?

south crane
#

yes

#

to keep it consistent between players

echo bough
#

in this case i would recommend using OnRep instead

south crane
#

that does require that I set the component to be replicated right?

mystic estuary
#

Yeap

south crane
#

alright thanks!

echo bough
#

if you dont want to replicate the whole staticmeshcomp, you can replicate the staticmesh variable to set locally

#

i think

mystic estuary
#

What is included in replicates the static mesh component though?

echo bough
#

not sure..

mystic estuary
#

Just checked, as for the static mesh class it's only the static mesh, and all it does is ReplicatedUsing=OnRep_StaticMesh

echo bough
#

physics i suppose

mystic estuary
#

And the UPrimitiveComponent (second top most parent class) replicates one single bool

south crane
#

i will set the net dormancy to dormant after setting the static mesh so i dont mind replicating it

quartz iris
south crane
#

thanks everyone!

mystic estuary
#

You're welcome 😄

quartz iris
#

@latent heart do you know how to fix the advanced steam sessions plugin not allowing players to join others?

echo bough
#

do you know how to handle replicated component that are added during runtime by the authority? the clients need to bind and event from it.
i must use a replicated variable?

mystic estuary
tardy fossil
#

if i have a replicated variable in an actor thats using the conditional replicated condition: COND_InitialOnly, will it replicate the latest data in the variable? or the data it spawned with?

boreal bison
#

I have a fully replicated multiplayer game and in my lobby UI, I have this running when a user presses create game. it takes all the current users in the lobby and stores the count in the game instance, then initiates server travel to my game level:

#

then in the gamemode for the level, it checks when we've reached our expected player count before setting up the game:

#

this all works fine in the editor, but in my live build on steam, the game doesn't start

#

server travel happens and then nothing

#

I guess I just noticed that I set it up where if the player count is 1, it doesn't run the check

#

maybe that'll fix it, but if that's the case I have no idea why it's been working in the editor

boreal bison
#

seems to not have fixed it

#

the other thing is that in the first image, my Status Change event runs this in the lobby game mode:

#

but in the live build it skips over that entirely and goes straight to the server travel

sinful tree
# boreal bison then in the gamemode for the level, it checks when we've reached our expected pl...

You don't need to seperately keep track of the count of the number of players. The GameState has the PlayerArray which you can get the length of to know the number of players currently in the game (you're already using it to store the number of players in the game instance).

Not sure why you're binding to an event dispatcher on the player controller any time someone is joining the game, for anything about the "Expected Player Count". You can use the OnPostLogin event to know when a player joins the game on the server, and again, you can know how many players are in the game currently by checking the PlayerArray. You shouldn't need to rely on any player controller to tell your game mode to start doing stuff.

No point in having replicated variables in the Game Mode - it doesn't get replicated.

As for your gamestate bit, it looks like you're trying to replicate a UI reference which can't be replicated (UI doesn't replicate) and as soon as Server Travel is called, it starts moving everyone to the new map, so anything that happens after the server travel command is executed is basically ignored as everything is being destroyed to make room for the new level you're travelling to.

boreal bison
#

minus the replicated variable

late cargo
#

Heyo, how do i go about replicating a child object's movement?

I have a blueprint that holds some useful shared functionality, called B_NetworkedPhysicsActor.

I then have an object that inherits from B_NetworkedPhysicsActor. However, because it inherits, I can't set it as the scene root. Because it's not the scene root, Replicate Movement does nothing.

Big sad. Any advice? Or am I going to manually need to cache the position and rotation and then send it via a replicated variable to clients to apply the position?

boreal bison
#

I think that's why I bound the event

#

so that whenever it gets set, it also checks the count

#

changed to this and it now runs in standalone:

#

so we'll see if it runs when built

#

it did

#

thank god

gloomy axle
#

How do I replicate a function on a widget? I set up a server-to-client entrypoint into a function that simply changes the color of an image, but for some reason the server's widget image doesnt change
B1 - event on widget's event graph
B2 - function that changes image color based on param,

#

the client's widget for its team indicator is changing, but the server's isnt

#

assume the widget is spawned and managed correctly ^

sinful tree
# gloomy axle How do I replicate a function on a widget? I set up a server-to-client entrypoin...

You don't replicate a function on a widget as widgets do not replicate.
You'd send an RPC on the player's controller, playerstate or controlled pawn to request the change or on a component belonging to one of these actors. The server should then set the team variable likely on the playerstate of the person who's team is changing. That variable could be set to be an OnRep so that when clients receive the change, you can use the OnRep to change anything else that needs to change when clients receive the new value.

gloomy axle
#

the Client's ETeams is being set to Orange and the Server's ETEams is being set to Blue correctly

#

(HudChangeTeam is the RPC event for changing color)

sinful tree
#

The "Hud Change Team" should be on the Player Controller or Player State.

#

Most likley playerstate seeing as it's probably something that you want set on the player state anyway.

gloomy axle
#

Oh so the entire function? How should I change the actual color of the indicator then? Just via reference?

#

or wait, this is because widgets are client-side only right

sinful tree
#

Run on Server RPCs can only happen on actors or components that are:
A) Replicated
B) Owned by the client making the request (so their player controller, playerstate or controlled pawn)

gloomy axle
#

ah okay

sinful tree
#

Your widget can still call whatever Run On Server event in any replicated actor class, but it can't Run On Server on itself.

gloomy axle
#

Would changing RPC_Server_HudChangeTeam to Run on owning client be the right choice?

sinful tree
#

No

gloomy axle
#

so only directly via player controller bp

sinful tree
#

Run On Client means the server would be calling the owning client of the actor. Again, it can only happen on replicated actors that are owned by a client.

#

You can call Run On Server events on ANY client owned actors or components, such as their player controller, playerstate or controlled pawn.

gloomy axle
#

Okay, so maybe I should have the function (ChooseTeam) that determine the team logic to return the team the player should be on, then on the player controller I'll set the indicator via the output of ChooseTeam

#

this is how i call chooseteam

#

this is on the PlaneModelPawn class

sinful tree
#

Begin Play fires on both the server and the client.
What you're doing here is:
Server fires Begin Play > Tells client to run Begin Play > Client does everything you have in RPC_Client_BeginPlay
Client fires Begin Play > Tells server to Run Begin Play > Server tells client to run Begin Play > Client does everything you have in RPC_Client_BeginPlay.
So, yeah going back and forth over the network and then executing the same thing twice.

All that should be required is a "Has Authority" node and use the "Remote" path to have it so the client is only executing what follows.

#

From what I can see what follows, you're calling to the GameState to call "Choose Team" but that actor is not client owned, so nothing from that point could be replicated to others.

gloomy axle
#

Oh because the server-player is being blocked to entry from client begin play

sinful tree
#

Not sure what you mean by that.

gloomy axle
#

the RPC_Client_BeginPlay is set to Multicast

sinful tree
#

Why?

gloomy axle
#

i thought I needed to multicast to other clients the events happening afterwards

sinful tree
#

If this is on a player controller it only exists on the server and the owning client.

#

Doesn't exist for other clients.

gloomy axle
#

so the multicast would literally do nothing

sinful tree
#

It would still execute on both server and client.

#

But it's completely unnecessary

#

begin play fires on both, that means you can use Has Authority to split up what needs to happen on the server and the client.

gloomy axle
#

gotcha, so from begin play I just need to check if it has authority and use the remote path

gloomy axle
#

currently got this set up now

sinful tree
#

Oh there's a different macro version available that has a built in branch for it.
And now what you're showing is that you're doing this on the pawn?

gloomy axle
#

oh you mean the switch one

sinful tree
gloomy axle
#

makes sense

#

hm it's throwing a none type error for get controller

#

oh im dumb

#

wait, it's still saying it's invalid

#

this is odd, it's the same controller i cast to

sinful tree
#

You technically don't have to get the controller to check the authority of the actor, in fact, if you're doing this on the Pawn, that changes how this whole thing works as Begin Play fires on all clients when that pawn starts existing on a client.

#

Get Controller will return null on clients who are not controlling the actor as controllers do not replicate to every client.

gloomy axle
sinful tree
#

Clients wouldn't have authority.

#

If it's a replicated actor spawned by the server, then the server has authority.

gloomy axle
#

Oh I think I misunderstood what you said then, so no has auth on the player controller after remote?

sinful tree
#

The idea behind using the "Has Authority" was based on the idea that whatever you were wanting to have running afterwards was only supposed to be running on the client's copy of the player controller
That no longer applies here if you're doing this on the pawn as the "remote" path would execute on all clients whenever the pawn starts play on any client's instance, which can happen multiple times throughout the game as pawns can go in and out of relevancy on different clients.

#

You can still use the HasAuthority, but then you probably want to use a "Is Locally Controlled" in there too if you only want whatever happens next on the player who is actually in control of the pawn.

#

Keep in mind, that using Has Authority would prevent a Listen Server Host from executing the "Remote" path.

#

So you may only want to use Is Locally Controlled 😛

gloomy axle
#

Sorry for the late response, thank you for the info

queen mortar
#

Hey I tried to make directional movement blend space in my multiplayer game, but for some reason, when I try to go backwards, or to the side I can see stuttering on client side. I dont know if or what component should be replicated, I tried to replicate sprint and that seems to be working, but I cant find the solution to this one

gloomy axle
#

hm its failing to cast to the player controler from the server's client

#

what would be the correct way to get the player controller from the listen server? it's working fine for the client

winged badger
#

PCs are replicated only to owning clients

#

server has them all, but clients only have the one

#

so replicate the stuff in PlayerState instead

gloomy axle
brazen anvil
#

Is RepNotify reliable?

wanton cedar
#

that question made me laugh even though idk the answer

sinful tree
rose turret
#

I'm a bit stuck on the controller/pawn model for my use case

the flow for my game is: start in the lobby where you're looking at a 3D UI (there are characters with WidgetComponent menus next to them) and then when everyone is ready, the actual game starts and I spawn a normal Pawn for you and you run around and do things

in that lobby state, should I have a special Controller/Pawn? or should I use the same controller but put it in a locked state so the user can't move around? and should I have it possess a special pawn that looks out at the UI?

thin stratus
wheat niche
#
{
    FOnlineSessionSettings SessionSettings;
    SessionSettings.bAllowJoinInProgress = false;
    SessionSettings.bIsDedicated = false;
    SessionSettings.bIsLANMatch = false;
    SessionSettings.bShouldAdvertise = true;
    SessionSettings.bUsesPresence = true;
    SessionSettings.bUseLobbiesVoiceChatIfAvailable = true;
    SessionSettings.NumPublicConnections = 4;

    IOnlineIdentityPtr Identity = OnlineSubsystem->GetIdentityInterface();
    FString SteamName;

    if (Identity.IsValid())
    {
        TSharedPtr<const FUniqueNetId> UserId = Identity->GetUniquePlayerId(0);
        if (UserId.IsValid())
        {
            SteamName = Identity->GetPlayerNickname(*UserId) + "'s Lobby";
        }
    }
    
    SessionInterface->CreateSession(0, *SteamName, SessionSettings);
}

void USteamInstance::OnCreateSessionComplete(FName SessionName, bool Succeeded)
{
    if(Succeeded)
    {
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("Session '%s' created successfully!"), *SessionName.ToString()));
        FString mapPath = TEXT("/Game/Maps/LobbyLevel?listen");
        GetWorld()->ServerTravel(mapPath, true);

    } else
    {
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Failed to create session '%s'!"), *SessionName.ToString()));
    }
}

Hey i dont know why but everytime i try to create a session with steam it fails can someone tell me why

kindred gazelle
#

tldr; Is there any way to check if BP execution is only running on the owning client without needing a reference to the controller? (and ideally without an rpc?)

bit of a weird one... but I find that when running network emulation profile "bad", occasionally player controllers will be invalid on beginplay.

To clarify, on my pawn's beginplay I am running "Is Locally Controlled" bp node on a branch and I notice that sometimes it will be false for the owning client (when it should always be true). I do some testing and find that when that function is false for the owning client it means that the controller is invalid. This only happens on "bad" network profile, and if I put a short delay before the check, then it returns true. It seems that high latency causes the controller ref to be temporarily invalid.

My first thought is to just loop until it is valid, but that means other clients will be constantly running that loop forever. Is there any way to check if BP execution is only running on the owning client without needing a reference to the controller?

echo bough
tame kraken
#

can someone help me with understanding OnRep functions?
I don't understand why they don't get called for me

kindred gazelle
echo bough
#

i usually prefer using IsLocallyControlled

but its pretty much the same thing

kindred gazelle
echo bough
#

thats why instead of beginplay, i will do the checks on either of these function PossessedBy, OnRep_PlayerState or ReceiveControllerChanged

thin stratus
#

@kindred gazelle BeginPlay does not mean your Pawn is possessed. Neither does it guarantee that the Controller replicated yet. BeginPlay only guarantees that the GameState is valid and the Actor you are in. If you need to make sure another actor is valid, you need to use what lAsaka posted. Such as OnRep for Controller or similar.

A Pawn placed into your scene for example won't be possessed and BeginPlay calls anyway.

You cannot check for locally controlled on BeginPlay of a Pawn.

kindred gazelle
echo bough
#

player state comes with the player controller

thin stratus
#

Pawn only has a valid PlayerState when possessed

#

And only once the variable replicated

#

So same story

#

That's what OnRep calls are for

#

Which for the native stuff are all CPP only

#

Hence why BPs suck for multiplayer

kindred gazelle
echo bough
#

that ReceiveControllerChanged says it works on both server and client, havent dig deep enough but it seems to work fine if you need a controller ref in your pawn

thin stratus
#

Yeah for Controller that works

#

Not a guarantee for any PlayerState to be valid though

kindred gazelle
#

Yeah unfortunately that was introduced after 4.26 which is the version I'm on

thin stratus
#

Yeah sitting on ass old versions is def the best way to have a shitty time haha

#

We helped shipping the ascent with that like 3 or so years ago. That version and 4.27 were def fun

kindred gazelle
#

I'm wondering if this would be invalid

#

as that would explain a lot

echo bough
#

game state for save game? 🤔

thin stratus
#

For one it's invalid for everyone but the local client and the server

kindred gazelle
#

it's saving local user data

thin stratus
#

It can totally be that the Owner variable hasn't replicated yet if you are unlucky

#

At least I think so

#

That's what OnRep_Owner would be for

#

You won't get out of race condition hell in BPs.

echo bough
#

actually

#

such case

#

wouldnt a LocalPlayerSubsystem

#

works the best

thin stratus
#

That's a CPP thing

echo bough
#

oh yeah..

kindred gazelle
#

so what I'm getting from this is it IS worth learning cpp replication

#

I was told by colleagues otherwise lol

echo bough
#

very much useful..

kindred gazelle
echo bough
#

Possessed is a Server Only event, though you can kinda make a RunOnOwningClient event for the owning clients, make sure its reliable though

kindred gazelle
#

I'd rather avoid an rpc since latency issues will be far more noticeable but if that's my only option I'll move what I have to onto that then. Thanks for the info guys, you've been super helpful

late cargo
#

Hey all, I have a replicated physics object. Replication is working beautifully in terms of responsiveness, but the static meshes on the client is offset up into the sky and off to the side. This is consistent behaviour, as if all of the objects were replicated from the server and then had an exact relative offset applied.

Attached a quality artwork sketch for reference 😛 movement is synced perfectly too, but with the same offset too.

#

So yeah, just wondering if someone has run into this before

echo bough
#

also are there any warnings on the outputlog?

late cargo
#

And no relevant warnings, but let me double check just to be extra certain 😄

#

Then again, if there were warning on the client I might have missed them as I'm not running PIE, I'm debugging from IDE. So let me go check that console too.

#

I'm going to go through the logs, there is some stuff I missed, I want to see if any of it is relevant. I'll be back in a bit 😄

echo bough
#

i have sync issue when the floor is generated on actor initialization and i had to turn on replication for the actor and the added components to work.
im not sure about your case unfortunately 🤔

solar stirrup
late cargo
late cargo
# solar stirrup How do you replicate the movement of the physics object

Simulate Physics disabled and then at begin play enabled for whoever has authority, then use replicate movement to sync the movement. It's so weird it syncs perfectly just with this weird offset. IE. If I push an object down the ledge, the object on the client exhibits the same movement but still with the relative offset.

solar stirrup
#

What engine version

late cargo
#

5.3.1 source

#

The funniest part is that the replication is flawless 😂 just that absolutely weird offset. And it's the exact same offset every time

wheat niche
#

Hey im currently trying to create a method that creates a session if i use the SessionSettings.bIsLANMatch = true; the session gets created but if i set it to false it wont work anymore

shrewd ginkgo
#

I want to add a skill to my killer in the game

#

I want the killer to see the location of everyone's characters behind the walls

#

how can I do it

#

It doesn't matter as a ball of light or as a silhouette

dim barn
#

@late cargo Are you sure the actual location numbers are different on server vs client? Or it just looks that way relative to some object like the floor. Pick one object that has this client-side offset you want to get rid of, and print out its world location both on server and client. Are the numbers actually different?

#

@shrewd ginkgo You could use custom depth to make players always visible to the killer.

shrewd ginkgo
#

I cant get it, probably I cant do it without good explanation

dim barn
#

Look it up on youtube. There's a lot of step-by-step guides using custom depth to see objects through walls.

rocky kestrel
#

I have quite large game rn and hundreds replicated events. Every event is set to reliable is that problem? If I set some event not to be it wont get executed always.

#

Game works fine even with multiple players and server doesn't crash.

mystic estuary
# rocky kestrel I have quite large game rn and hundreds replicated events. Every event is set to...

It depends on the nature of the event. If it's something like "equip item", then yeah, it must be reliable, but if it's something "display that I've moved ghost of the building I'm placing", then it really should be unreliable, as it wouldn't change much. As a rule of thumb try to keep things that fire each tick or are visual unreliable, as, as I said before, it doesn't change much if other players won't receive that change in their world

late cargo
# dim barn <@156799987919880192> Are you sure the actual location numbers are different on ...

Further investigating the cause (but still not sure of the root issue) is my blueprint structure. I have B_NetworkedPhysicsActor that inherits from Actor. It contains some useful functionality that I would like to reuse. My cubes then inherit from B_NetworkedPhysicsActor.

B_NetworkedPhysicsActor has itsef, then as a child the default scene root, followed by a child static mesh.
B_PhysicsCube has itself, default scene root (inherited), and as a child of that the inherited static mesh. I then go and just replace the static mesh model.

All positions and rotations in the blueprint assets are 0'd out and then I drag the B_PhysicsCube into the scene.

Question: I'd like to try your suggestion of printing out the world location but I'm quite new to UE5, what nodes would I use for this to make sure that I'm getting the accurate information?

dark edge
late cargo
dark edge
#

Wherever you want to do it

late cargo
brazen anvil
#

when working with the cmc I am testing for desync using 500ms packet lag. Is it good to test with some percentage of packet loss as well? If so how much?

mystic estuary
brazen anvil
# mystic estuary I've heard this from Jambax 👐

Hmm yeah that makes sense. It would also be wise to have ping caps to help with the desync issues. And if possible maybe a packet loss cap. I was just testing the default crouch with a large amount of packet loss and noticed I was never able to get the positions out of sync. But when testing my version I do get out of sync and then end up in a constant desync state. I think I know what is causing it though.

tardy fossil
#

when i sent a reference over network, like a reference to a data asset, the variables aren't serialized right?

brazen anvil
#

If my CMC needs to correct a move, but correcting it involves calling a function to change capsule height, where is the best play to call that function?

mystic estuary
dim barn
tardy fossil
#

yeah i'm doing some reading on FNetworkGUID.. i wonder if its possible to override a data asset's FNetworkGUID to make it a uint16

late cargo
shrewd ginkgo
#

I want to add skill to my character. If he sus he can make call to find non-sus players. I make something like that is it correct?

grave lynx
#

Hey, I have a keypad, to let a player move stuff on it, I spawned a dummy pawn and posses it, and the pawn have a ref of the keypad to interact with. I would like to use the actor itself. The actor is spawned by the server. A have a StartInteract method called by the server on my actor so I know when and who pressed E on it. The problem. On this function, I enable input and bind action, but the binding doesn't seems to work:

EnableInput(MyPlayerController);
if (InputComponent)
{
  InputComponent->BindAction("Jump", IE_Pressed, this, &AKeypad::Down);
}

Working for server, what's the solution for client?

mystic estuary
#

You can essentially wrap the binding code in a client RPC, and it would work for both client/server. If it's the server-side player, then the client RPC will be executed regardless, binding that input for the server player

dire dragon
#

when my server loades and if i change the variable (rep notify) really fast (before client loades in) then the client doesn't see the change but when i change the variable (rep notify) after the client loades in then the client sees the change, how to fix it

grave lynx
mystic estuary
mystic estuary
#

Under any property, for instance under your CurrentGrabComponent

dire dragon
mystic estuary
dire dragon
mystic estuary
#

Yeah, didn't see it 😅 If you have set it, then you don't need to use any RPC yourself to change the value -- just change it server side, and clients will receive it anytime the owning object will become relevant for them

#

So move your code from multicast to the RPCSRV_SetGrabComponent, and you should be fien

dire dragon
mystic estuary
#

What is the CurrentGrabComponent stored in?

#

And where is it created?

dire dragon
dire dragon
mystic estuary
#

What's the object that stores it? Is it your character or maybe something else?

mystic estuary
#

All right, and where do you create the component? What side (server/client)?

dire dragon
mystic estuary
#

So it's a default component of your character?

#

Which is created prior to play time, I mean

dire dragon
mystic estuary
#

But why do you replicate it if it's already there?

#

Replicate it via RPC calls*

#

Marking the component as Replicates will be enough to replicate it. Initially I thought that you were trying to modify something dynamically, something that doesn't exist when the world starts

dire dragon
dire dragon
dire dragon
grave lynx
mystic estuary
dire dragon
#

im still concerned why doesn't the client see the change that was made before him loading even with multicast

mystic estuary
#

I'm not that used to UE4 interface, can't really tell the difference 😔

dire dragon
#

and the component is also in the map before

mystic estuary
mystic estuary
#

All right, just got the whole picture, aaand yeah, it should be replicating the object back, as it's using the repnotify 🤔

mystic estuary
#

Are you 100% that it doesn't? Did you try to print something in the repnotify to check whether the client even calls that upon joining the game?

dire dragon
#

well.. it first prints when i grab it and as soon as the client loads in then it prints that it also grabbed it (but with client).. i don't know what's wrong

mystic estuary
#

So the rep notify is called client-side upon joining. What's the component value though? What is it set to both sides?

mystic estuary
#

All right, but what's the problem again?

dire dragon
mystic estuary
#

So is it playing the animation client-side? Is it pickup animation or something?

dire dragon
tame sapphire
#

Looking for some advice i have an event on my player character that is set to run on server and spawning an actor (This seems to be working fine) however i am also calling an event dispatcher within this spawned actor that it seems to reach if I add a breakpooint to it. However I am trying to bind to this event dispatch in my player character after the actor has spawned but this doesnt seem to ever be reached... the print string in the picture does. Any help is appreciated

mystic estuary
# tame sapphire

Either the binding is too late, and the thing has already been fired, or the event is fired too late, as the listener is already destroyed

mystic estuary
tame sapphire
#

i suspect the binding is too late as the call happens within the spawned actor. Any suggestions?

mystic estuary
#

If you would use C++, you could've spawn the actor as deferred. If you don't have such possibility, then you have to invent something. If you're familiar with Lyra's Gameplay Message Subsystem, then you can use that in your project. You would need to wait for a gameplay message prior to spawning, and broadcast it message from the very same place you're doing right now.

tame sapphire
#

Would doing a valid get on the actor before spawning it work?

mystic estuary
#

A dumb approach is to give the spawning object a new field that is ExposeOnSpawn, which would be the object you need to receive the event on, and the spawning object would use that exposed field to send it

mystic estuary
tame sapphire
#

ill have a look into the Lyra and experiment with the dumb approach

mystic estuary
#

gl 😛

tame sapphire
#

hhha, thanks... (thinking owning PlayerController)

#

so i can cast to it

#

ill experiment more but thank you

mystic estuary
# tame sapphire

Oh, forgot about another approach. Not sure whether it's going to work from BPs, but you can hide the event dispatcher (or not use) from outside, and create a function called BindAndCall_MyEvent which would take the callback (event to call) as an argument, and bind it to the event dispatcher itself. If the event dispatcher has already dispatched the thing, then you call the passed callback in the very same BindAndCall_MyEvent function, otherwise you only bind it, so that it'll be called when the event is executed.

mystic estuary
# tame sapphire

If it's impossible to make an event input for a function (so you cannot essentially pass it in the function), then you can also create a function that would be called something like WasAlreadyExecuted (or whatever fits into your needs), and the code that is binding the event (in your case the one on the screenshot) would check the boolean result of that function (WasAlreadyExecuted), and call the SERVER_Finish_CombatAbility itself

mystic estuary
#

Again, comparison against nothing

#

You should really go through your code yourself 🙏

dire dragon
queen mortar
#

Hey so I tried to replicate door opening but, doors only open when server presses the button and when client tries, nothing happens. Also when server opens door, client can see it open as well. Any idea how to fix it?

mystic estuary
# queen mortar Hey so I tried to replicate door opening but, doors only open when server presse...

Server RPC can only be executed client-side if the client owns the object. Don't use the GetPlayerController(Index) node as it doesn't work well for networking, that may be why the server player (index 0) can interact with the door, while clients (index >0) cannot.

I saw an excellent explanation on how to make replicated doors with all the networking stuff explained perfectly https://www.youtube.com/watch?v=WoY3ZVVqfTo

queen mortar
#

Thanks I'll try that out

tame sapphire
#

@mystic estuary can i be cheeky and ask for a visual example? or expand a little on what would be in the function as in my head atm calling the functyion in the PC is the same issue as calling to the event so i think i may be a little confused between the 2

mystic estuary
#

What function exactly? The BindAndCall or WasAlreadyExecuted?

tame sapphire
#

i think you mean a function on the spawned actor that gets set to true in stead of calling the event dispatcher, then where im trying to bind to it in the pc do you mean just pull out and do a branch?

#

I think the already executed

#

dont think i can input an event for the bind and call

mystic estuary
#

Actually though, is it always the case? I mean, is it always the case that the event is too late to start listening for after spawning the object? If it is, why don't you execute the code you need to execute when that event is fired?

mystic estuary
#

(the screenshot is meant to show 2 different blocks of code, like the BeginPlay of the spawning object, and how you would bind the event a that way the thing that would spawn the object)

tame sapphire
#

yeah but i think i may need to think more about what you said on it always being the case.

mystic estuary
#

Is it supposed to be a question?

#

😛

tame sapphire
#

no, sorry

queen mortar
#

And I dont know what else I can connect to enable input node for the player controller

mystic estuary
queen mortar
#

No its door blueprint with button

mystic estuary
#

So are you listening for a player input action from something that doesn't belong to the player?

queen mortar
#

Well I guess

mystic estuary
#

But, as I have already said, Server RPC can only be executed client-side if the client owns the object. The door can have only one owner, so it's not going to work that way

#

I recommend watching the video I've linked as it'll clarify many networking problems you'll encounter along the way, making your way as easy as possible 👐

tardy fossil
#

a good way to do it is to put a generic "Use" server rpc in your pawn blueprint and have the server do the logic to see if the character can open a door (with a raycast or something) then call the open event.. or even better yet use a custom interface with the function "OnUse" your door can implement

dark edge
#

Don't multicast for this, only one RPC is necessary (to get from client to server)

queen mortar
shrewd ginkgo
#

I want to add skill to my character. If he sus he can make call to find non-sus players. I make something like that is it correct?

sinful tree
# shrewd ginkgo I want to add skill to my character. If he sus he can make call to find non-sus ...

This is somewhat poor logic flow.

  1. You should avoid trying to call consecutive Run On Server events as that means you're effectively allowing clients a means to cheat and call the second Run On Server without calling the first.
  2. You shouldn't be trying to RPC to the server from a multicast. Multicasts already run on the server.
  3. I don't think this is doing what you think it's supposed to be doing.

Here's what your logic is doing, assuming this is running on "Player A":
Presses "Make Call" input > Runs On Server > Multicasts to everyone > Multicast everyone checks if Player A is sus (which may not work as the sus variable isn't replicated), play an animation on Player A if they are sus > Everyone attempts to call "Get Call On Server" but only the owner of Player A and the server itself will successfully execute it > Server (does it twice since both the server and the owning client of Player A called it) checks if Player A is not sus and if not sus, play an animation and a sound at the location of Player A.

brazen anvil
#

If I wanted to add a prone to my character would it be better as a new movement mode or just a one off thing?

outer radish
#

wondering if anyone knows any marketplace or epic content examples of using depth in materials to get a room interior visible, but really it's fake on a flat surface. If that makes sense.

winged badger
#

how does that relate to multiplayer?

winged badger
brazen anvil
#

even if I am just crawling around?

winged badger
#

for crawling sure

#

if you're just knowcked on your arse and completely immobile, then plugging it into the CMC is not worth it

#

"one-off" things don't do predicted movement

#

which can and probably will cause corrections and jitter

brazen anvil
#

Yeah I have my current setup not using movement modes and instead I have a int that tells me which "mode" I am in. I just end up in a infinite desync if I have packetloss and spam the movement switch

winged badger
#

the CMC has a FSavedMove, a native class that packages the move and sends it to server

brazen anvil
#

Yeah I added an additonal variable

winged badger
#

generally when you add movement modes you want them to be a part as your custom FMySavedMove

#

then the custom move modes can be processed predictively

brazen anvil
#

Yeah I have tried this like 3 different ways and they have all ended up with infinite desync so I am not sure what the reason for that is

#

So what I am currently doing is adding a uint8 to the custom network data. Its value determines which stance I am in. It is also a repnotify. So when the server gets it, and it changes, the proxies react to the change. but when spamming it I get the infinite desync

#

So its like one of the packets that tells the proxy to change position gets dropped and then it can't recover.

dark edge
queen mortar
dark edge
shrewd ginkgo
#

I want to sus can call and all of others take call

#

just it

#

like dokaebi skill from r6

dark edge
#

Multicast runs on the same actor on all machines

#

Not all other actors of the same class

shrewd ginkgo
nova wasp
#

Is there a simple way to visualize/reason about the speed at which fast array serializes send data to a client?

#

I'm seeing my stuff slow down a lot with higher counts which makes perfect sense, but I would like to know... where it does that 😄

#

If it's replication graph I might need to start smashing things

#

let me see...

deep shore
#

If a client disconnects and the server detects that their controller is no longer in use, is the controller destroyed automatically?

deep shore
#

Nice.. thank you

fiery wadi
#

Hi, I have an actor component which I called MovementInputComponent(Has all the functions to move as you can imagine) but when I spawn an actor with this component and use the Set Input Modes it seems to stop working.
Anyone any ideas please?

#

I display a UI widget to get the player to select a team and thats what causes the player to spawn which is why Im using Set input Mode UI Only to Begin Play then want to release Input to the Game once the player has selected what team to be on

queen escarp
#

imm

#

im applying damge via server on a "npc" that should damage itself

#

but its not working to damage is dealt,

#

the vvalues is not null reff is not null

latent heart
#

Is that the default actor damage system?

queen escarp
#

y

latent heart
#

Did you hook it up to actually do damage? It doesn't do anything by default.

queen escarp
#

yy ofc

latent heart
#

Are you sure the event is being run?

queen escarp
#

y

latent heart
#

How?

queen escarp
latent heart
#

Right. And you've checked the value of is dead?

latent heart
#

I'm not sure how this shows that hte 'is dead' value isn't false.

queen escarp
#

y well i just checked it and it fires

latent heart
#

That isn't what I asked.

queen escarp
#

oh waiit

#

i found it now

#

ok since his damaging himself, and is not a child from player character the cast fails

#

before redcing the damage to the health

#

hmm could i instead of having the "damage causer" as objective could i have "all players"

#

or i think i solved it

fiery wadi
#

This might be a super basic question but I am trying to get a better understanding of Multiplayer in UE.

#

I have a button which turns green for On and Black for off

#

I have this inside the Button Blueprint, I am not sure of how Switch Has Authority works atm, From my understanding Authority = Execute on Server, Remote = Execute on Client(Local Machine)

#

Is this correct or am i thinking wrong?

#

At the moment the button turns green when the player "uses" it but it doesnt update on the clients

#

I am doing a course on Udemy as well but starting to feel like im "Copy, Pasting" without actually understanding whats going on. xD

latent heart
#

Authority means you're on the server, basically. So switch on has authority will take the authority path on the server and the non-authority path on a remote client.

#

It's more advanced than that, but that's the basics.

latent heart
# fiery wadi

If this blueprint is exactly what the course is showing, get a refund. None of it is correct.

#

(when it comes to multiplayer)

fiery wadi
#

@latent heart no this isnt what the course is showing it,s where i am trying to make a correlation on how you interact with clients.

quasi tide
#

Because you're only updating it on the server

fiery wadi
#

Im trying to not "copy/paste" as they have done a lot of Server Client interactions but not really gone into explanations as to what is happening so I am trying to break it down into system I can understand if this makes sense, So Switch Has Authority just determines if you are the server or the client.

#

@quasi tide So this updates the Server, and anything on the Remote side updates all connected clients?

quasi tide
#

This is saying, "If w/e is calling the Use event has Authority over this object, call SRV Use Btn

#

If something doesn't have auth of the object, it won't run that method

fiery wadi
#

Use is from an Blueprint Interface.

quasi tide
#

This is only executing on the server. Don't think materials are replicated for you. So you would need an OnRep.

#

(If materials aren't)

fiery wadi
#

Ahh ok

quasi tide
fiery wadi
#

Ok thank you

quasi tide
#

What matters is if the thing that is calling Use has authority or not.

#

If it does, then it'll execute the server use btn function

#

If not, it won't

fiery wadi
#

so to update clients would i need another function to update the materials on the clients?

quasi tide
#

Yeah. And because it is a stateful change - you'd want an OnRep.

fiery wadi
#

Ahh thanks ! I,ll try to code it : )

quasi tide
#

(Assuming the SRV Use Btn function is actually running)

fiery wadi
#

Ok i,ll try to do so the clients update OnChange of material on the button (IE... It turns green when the server or client changes its state)

latent heart
#

Player can be player character, player controller or player state.

fiery wadi
# latent heart Basics of networking

Thanks , Im also watching this to try and make some sesne : )https://www.youtube.com/watch?v=OVeo3cVTIcU&ab_channel=Kekdot

🧑🏻‍🚀Get the project files here on Patreon: https://www.patreon.com/posts/66842088

In this video we take a look at the basics of replication. We will cover the concept of replication and what it takes to replicate the server instance to the client instances to keep everyone in sync.

We also take a look at how we set an actor to replicate, we l...

▶ Play video
latent heart
#

To teh right of that is the response to "Do Thing" which I didn't cover.

latent heart
woven basin
#

For replication - does it replicate the values as they change, or at the end of the frame?

i.e. - if I have an actor on the server, and I do "actor move" twice in the one frame/function - will the server replicate two movements to clients - or will it just replicate the "final" state?

latent heart
#

End of frame

woven basin
#

cool - thanks

fervent leaf
#

Hi, I'm spawning niagara effects by button press. So basicly on picture 1, I just select the wanted Niagara effects on blueprint, spawn them and add them to replicated array on multicast called from server. The effects spawns correctly but when i stop pressing the button, the effect only deactivates on server, not on clients. On picture 2, I check every object on array on the server. I have "NiagaraComponentToRemove" that is replicated using "OnRep_RemoveParticleEffect" OnRep just deactivates the effect, which should remove the effect but this never happens on clients, only on server

#

Is this completely wrong im doing the spawning and I just dont understand why the OnRep isn't working as I'm giving it a new value on server?

limber gyro
#

if i send an RPC from a player, is it going to run on that sample player aswell?

#

a multicast that is

latent heart
#

Sending an RPC from a player, from a client, will only execute it locally for that player.

latent heart
#

If you're deactivating 10 effects at once, the first 9 will be overwritten immediately and do nothing.

limber gyro
#

i prrobably didnt express it properly, i have an RPC that executes in the server that then calls a multicast

#

im asking if the multicast is also going to be sent to the player that sent that original rpc to the server

#

nvm

#

it has to

#

it was a dumb question

#

im just tired

tidal temple
#

Hello, dear Unreal Slackers!
@thin stratus Thank you very much for your advice on CMC, thanks to them I almost completed the system, but I ran into a small problem.
The main engine of the component is the uint8 data type, which has little to represent. To capture the physics of one of my movements, I need to transfer a vector (Grapple Hook), what methods are there to obtain this vector within the boundaries of the CMC? It is possible to perform a LineTrace on behalf of the server and the client, but then where can this be done so that both the server and the client receive the data? Thank you.

upbeat basin
#

I have an actor that has Replicates Always Relevant and Replicate Movement turned on. I am somehow getting (0,0,0) from GetActorLocation node on a widget tick. If I turn off ReplicateMovement then GetActorLocation starts to work as it's intended but can't see the location changes on the client. Does anyone have an idea about what might be happening here?

limber gyro
kind grove
#

yo guys, I'm setting up some sort of skill tree system and I was wondering, in a multiplayer game what would be the best practices for setting each player's skills/upgrades? PlayerState? PlayerController? GameMode even?

thin stratus
#

E.g. if you are falling while that is happening you can trace in PhysFalling

#

There is also the more generic version with PerformMovement you could use

tidal temple
thin stratus
#

But I just told you what to use

#

The server and client perform the same movement during the same numbered timestamps.

If the server or client move result in a different end location you would get a correction.

#

I coded a whole hovering drone with the CMC as a logical base. I traced a lot and it was all fine

tidal temple
#

I'm struggling a little with my English skills, sorry xd
This seems to work for my game, thanks!
You have no idea how much you change the process of entering such complex topics :P

thin stratus
#

Just do it please. The worrying about the desync is a waste of time

#

One day I will have the time to write down how the CMC works , at least to some degree.

tidal temple
limber gyro
tidal temple
limber gyro
thin stratus
limber gyro
#

from the little stuff that we have its quite a complicated class to unravel and i think that the original prgrammer left epic, not sure

fiery wadi
#

Omg i still cant get this to work it feels so simple but yet so complicated xD The button turns green on the server but the client cannot interact with it.

thin stratus
#

The code in the picture is overall wrong

fiery wadi
#

Can someone please point me in the right direction.

#

I,ve watched about 3=4 "Basics of replication" video's but still cant't seem to get my head around it.

tidal temple
fiery wadi
#

Just need to get a "eureka" moment so it becomes a bit clearer.

thin stratus
#
  1. You should not use Client or Server RPCs in the Button Actor. The Server RPC needs to happen before you call Interact , in e.g. your Character.
  2. You should never replicate state with a Multicast, because new players or players that are out of relevancy range won't get that. You should use RepNotify Variables for this where the OnRep function calls when the value changes/arrives on the client.
#

For 2., the variable would be the Material. You would get the 0 and 1 array entry and set the replicated variable. And the SetMaterial call would happen in the OnRep

fiery wadi
#

Ok so should all Client <-> Server communications happen in the controllers?

thin stratus
#

They need to happen in a Client owned Actor

#

Have you read the Compendium that is pinned to this channel?

fiery wadi
short arrow
#

Anyone experience an issue in Unreal 5.2.1 Creating a child of Replication Graph returns an error and the project can't be compiled? Tried the same exact thing in 4.27 and it worked fine

#

I haven't tried 5.3 but maybe the issue is fixed there?

fiery wadi
#

I can understand the "words" inside the replication but (Execute on ALL / Multicast ) Broadcast this to all connected clients, (Run on Owning Client) Run this code ONLY on this Client/Actor, (Execute on Server) Run this code on the Server and update all connected clients values (I think thats what this means, Means the server can verify the data being passed instead of directly passing information between clients) Reliable = How important is this data to be processed in order of priority.

#

I dont know if the Exectute on Server thought process is correct.

#

Can I ask for a definition of a "Client Owned Actor" please, Would this be say "A barrel of gold" as every client would have their own version of this barrel, Or is it something that is possessed by a controller such as a Character/Pawn?

solar stirrup
#

Actors have an Owner member

#

You can call server RPCs if you're the owner (i.e. generally your player controller or pawn is set as the owner server-side).

solar stirrup
#

Not necessarily possessed though, you can spawn an actor on the server, and set its owner to a player controller, and that player will be able to call server RPCs on it.

thin stratus
#

It is literally client owned

#

The Owner Pin on an Actor being set to something that ultimately has the PlayerController of a Client as Owner

fiery wadi
#

@thin stratus I tried to read it but the issue is a lot of it tends to blur into one and it doesnt really show good examples of using Replication in a laymans terms it tells you what it is and what it does.

thin stratus
#

Your PlayerController, PlayerState, Pawn/Character (if possessed) are good starters

fiery wadi
#

Thank you for the explanations!

thin stratus
#

In return if executed in a non owned actor the RPC is dropped

#

Which is the problem when calling it in a random actor in your level

fiery wadi
#

I assume that OnRep automatically returns the updated value to the server bit similar to an OnChanged event in a Dropdown menu in JS?

thin stratus
#

So, in BPs, the OnRep is a property changed notifier. Do it calls when Setting the Variable as well as when the value replicates to the Client.

C++ works a bit different, as there it is a proper notifier for the replication of the Variable and won't call on Server or when Clients modify the variable

fiery wadi
#

I coded a Messenger Style app quite some time ago with a dedicated server app using Sockets but that was in a different language xD

thin stratus
#

(Client modify only triggers the OnRep locally of course and is just a side effect)

#

Yeah let's assume you RPC before calling Interact or even before performing the logic to get the Actor in the scene (which I assume might be a Line trace)?

#

The Interact in the Actor is therefore executed on the Server Side

#

You can then get the Material from the Array and set the RepNotify variable

#

And then it will call on Server Side (in BPs) cause of the Property Changed part, and on the Client due to replication (if your Actor is set to replicate)

#

So in the OnRep function that automatically gets created if you change the type of the variable to RepNotify, you can call the Set Material function and pass in that replicated Variable

fiery wadi
#

Ahh i think i get that.

thin stratus
#

That's the most basic I can explain it on phone atm

fiery wadi
#

np i really appreciate the time and effort you are putting in to trying to help!

#

I think the issue is theres a lot of text out there but not much in the way of step by step explanations and until you get that "eureka" moment where it all snaps into place you kinda feel like your drowning in a sea of text 🙂

#

So much tutorials but am trying to not enter "Tutorial Hell" lol

thin stratus
#

Yeah but that's with everything

#

Like, you'll often have that problem that you need to use something and fail with it a few times before it clicks

fiery wadi
#

I was only using multicast because i saw it in a tutorial xD

thin stratus
#

Only because I know how this stuff there works doesn't mean I don't fail everywhere else

#

My web dev adventures are the same as yours

#

Just that tutorials are outdated after 1 day and everyone does things differently

fiery wadi
thin stratus
#

But that's what this place here is gold for

#

Cause you can post the result of a tutorial

#

And if you are willing to learn and read something then you'll get information on mass

fiery wadi
#

This is the project im messing with and the "button" that changes colour

#

So 1 player can make it green and the other can make it return to black

thin stratus
#

Yeah the button is a similar issue as my beloved door

fiery wadi
#

I thought the image might add some context, A simple overlap check and then interact.

thin stratus
#

Both come down to interaction with actors in the scene

#

Idk how your pre interact side of code looks like

#

But the overlap would happen on server and client so you should be fine with calling the RPC on button input and using the currently overlapped actor on the server

fiery wadi
#

I know casting is "bad" but as im only testing i thought it was ok, The button tells the player hey your standing on me

thin stratus
#

Yeah it isn't

upbeat estuary
#

I have a pretty strange issue that probably happens due to me not understanding something right:
I want to replicate a simple virtual reality pawn, and had rotational issues that I could track to the following:
If I enable any of the "Use Controller Rotation Pitch/Yaw/Roll" checkboxes (e.g. on the default pawn) and add a CameraComponent, set this as default pawn in the gamemode and just click Play with Netmode set to client, the Pawn has an initial rotation that depends on my physical HMD rotation. This doesn't happen in listen/standalone mode. Any clue what I am misunderstanding here?

thin stratus
#

Also you should just do the code you have in that image but in the Character :P

fiery wadi
#

So the player should tell the button "I,m standing on you ?"

thin stratus
#

No, the button should only get the Interact call

dark edge
#

casting IS the class check

fiery wadi
#

Ahh

thin stratus
dark edge
#

This code as written will check if OtherActor is a BP_ThirdPersonCharacter, and if it is, it'll set thet local ref and also tell it that its overlapping actor is self

fiery wadi
#

This is in the chracter to "use" the button.

dark edge
#

assuming that's what you want to have happen

fiery wadi
#

Omg ofc it has a Cast Failed if its not a Third Person Charatcer #faceplam

dark edge
#

Try to keep your references / knowledge flowing in one direction

#

Character knows/cares about InteractableObject, but InteractableObject doesn't care about Character

fiery wadi
#

True.

thin stratus
#

Yeah my suggestion would be moving the code to the character. Have a SphereCollision in it and save the currently overlapping actor like that. Can ensure the overlapped actor implements the interface first too

fiery wadi
#

InteractableObject could be a Button, Chest, Lever etc.

dark edge
#

Yup. The only way to know about the current Overlapping actor ALL THE TIME is for showing popups.

fiery wadi
#

Am using Box Collision on the button atm

thin stratus
#

You basically inverted the setup hehe

fiery wadi
#

But yes the character could set his overlapping actor himself.

dark edge
#

Yeah that'd be better

thin stratus
#

The problem with your setup is that you can't handle multiple overlaps

dark edge
#

you'll still need some sort of collider on interactables but that can just be the mesh

thin stratus
#

The last overlapped actor would set itself on the character

dark edge
#

Yup, you'll want some code to CHOOSE the actor you want to consider to be "selected" or "highlighted"

thin stratus
#

The usual setup is to add overlapping actors to an array

#

And to loop them and grab the best one based on some conditions

#

E.g. distance and angle

echo bough
#

i kinda want to ask for a long time..
a sphere collision or trace every frame..? for detecting interactables

dark edge
#

I'd start with this:
Button input -> get overlapping actors on InteractionSphereOvelapper -> choose one -> interact with it

fiery wadi
#

Tidied the code xD

#

used the is valid to make sure we have a value in OverlappingActor.

thin stratus
#

2 things

echo bough
#

well cause on a player, it would move around alot, means it would need to update the transform of the sphere collision too

thin stratus
#

You can't test if the overlapping actor variable has the interface

#

Before setting it

#

You need to connect the OtherActor pin

fiery wadi
#

lol damn it i missed that XD

thin stratus
#

And in the top part of your code you would put the server RPC before the interact call

fiery wadi
#

I should seen that xD

thin stratus
#

And call Interact on it in the rpc

#

Can check for is valid in the RPC too fwiw

fiery wadi
#

Ok lets see if i can get this to work as an RPC then I need to examine all the other styles of comms. 🙂

dark edge
#

I would start with just getting overlapping actors and choosing one on input

#

then later you can do it on tick / timer or maintain the selected actor on begin/end overlap

#

What you have will break on multiple overlaps

#

If you're close to Door then move closer, therefor beginning overlap on a chest on the other side of the door, the chest would become your selected actor

#

probably not quite what you want

fiery wadi
#

In that scenario I would probably use an array and check the nearest actor and then show a message "Interact with X"

dark edge
#

I would make a function to select an actor from overlapping actors by distance, angle, has interface etc, then the only difference is when you call that

#

yes, get overlapping actors returns an array

#

jsut return the closest one that implements the interface, if any

fiery wadi
#

for the urposes of this test just trying to keep it simple as i can 😄

#

So if im right the "event" to change button material belongs with button.

#

then the character tells the button to change its material

thin stratus
#

Yes

fiery wadi
#

via the server Multicast.

thin stratus
#

No

#

Bad Drib

#

No Multicast

dark edge
#

Yes, the general form is like:
Character
Input -> choose what to interact with, call an RPC passing the thing
RPC -> call Interact interface

Button:
Interact -> set variable(replicated, repnotify)

OnRep_Variable -> Change the actual thing you can see(color, door angle, whatever)

#

OnRep is the key

#

don't multicast

#

The reason why you want to prefer repnotify for stateful things vs multicast is for late joining or other cases where the client might have missed the multicast.

fiery wadi
#

hoply crap this is a HUGE bag of worms i opened here. xD

dark edge
#

Basically, if client didn't get the OpenDoor message, the door would be closed for them and open for those who got it

fiery wadi
thin stratus
#

If you want a Multicast vs OnRep Reallife example:

Imagine you live in a House with multiple people. You are standing in a Room and you want to tell people in that room something.

If you Multicast the talking, people who are elsewhere in the house or not at all in the house won't hear you. They will also never know that you said something if they come to the room later.

If you OnRep whatever you are saying it's equal to leaving a note on the wall.

fiery wadi
#

Ahh ok that makes sense thanks!

dark edge
#

You would multicast things that don't really change the state of the game before/after it.

#

a grenade exploding for example

#

that can be a multicast

#

as 1s before and 1s after the grenade, the state of the game is pretty uch the same

#

but a door being opened is different

fiery wadi
#

Ok step 1 i made the repnotify var

thin stratus
#

You Multicast one time events. Game example would be an exploding Barrel.

The VFX and Explosion sound are multicasted, cause only the peeps in the room (around the barrel) care about it. The change of the mesh being broken and maybe a fire burning in the broken barrel are OnRep (they are state) cause peeps who later to the barrel need to see that

fiery wadi
dark edge
fiery wadi
#

I see i have a function now OnRep_MaterialArray

dark edge
#

that's where you put the code that should run when the variable changes

fiery wadi
#

So that would be where i say hey turn green

upbeat estuary
dark edge
#

I wouldn't replicate that array tho

#

replicate a bool like bIsActive

#

or an int MaterialIndexToUse

fiery wadi
#

I got a bool named On/Off

dark edge
#

yeah

#

onrep that

#

that's what you change to turn it on or off

thin stratus
#

The bool or just a single material instead of an array works too

#

If you only have 2 options for the button then the bool works fine of course

fiery wadi
#

So this basically turns it off and on and updates the bool.

thin stratus
#

Yeah no

#

You set the boolean in the Interact to true or false

#

In the OnRep you only get the boolean

#

And decide based on its value what material to use

#

Sorry, brainfart while typing

fiery wadi
#

ok let me rechange this im sorry if im being a pain 😭

thin stratus
thin stratus
fiery wadi
#

So i ONLY check the value in this function

thin stratus
#

Correct

upbeat estuary
#

Anyway I'll investigate more tomorrow

fiery wadi
#

Inside the button I set this bool ?

thin stratus
#

Yes

fiery wadi
#

This should turn the light on ?

#

well button.

thin stratus
#

You need the RPC still

tidal temple
# thin stratus You need the RPC still

Sorry to distract you again!
I do my Trace in PhysCustom and judging by Trace Debug, the client and server hit there with a delay. You mentioned timestamps, initially I thought that the physics calculation function works based on them, but apparently I need to apply them myself or do I have a completely wrong understanding of the architecture? Thanks again!

void UARSCharacterMovementComponent::PhysGrappling(float deltaTime, int32 Iterations)
{
    if (GrapplePointLocation == FVector::ZeroVector)
    {
        FHitResult GrappleHitResult;
        const bool bIsGrapplePointAvailable = ARSUtils::PerformEyeTrace(GetWorld(), GetPawnOwner(), GrappleHitResult);
        
        GrapplePointLocation = GrappleHitResult.ImpactPoint;
    }

    const FVector& PullVector = (GrapplePointLocation - GetPawnOwner()->GetActorLocation()).GetSafeNormal() * GrappleSpeed;
    Velocity = PullVector;

    const FVector Adjusted = Velocity * deltaTime;
    FHitResult Hit(1.f);

    SafeMoveUpdatedComponent(Adjusted, UpdatedComponent->GetComponentQuat(), true, Hit);
}
#

I also disabled the simulated proxy in PhysCustom, I saw this in several repositories, I hope this is right.

if (GetOwner()->GetLocalRole() == ROLE_SimulatedProxy)
  return;
fiery wadi
#

woo getting closer. Ok server can turn the btn green but client cant turn it off, So i guess that needs to be done via a Execute on Server?

thin stratus
#

Yes server

fiery wadi
#

Omg you guys are amazing!

thin stratus
fiery wadi
#

I have some working code i can inspect and mess about with and try to establish how the information is being passed about.

thin stratus
#

Please don't throw another note in. We already went over this stuff with them.

#

This only causes more confusion

fiery wadi
#

Thank you al so much for your patience.

thin stratus
#

One last thing is I would move the is valid check

fiery wadi
#

I think i was struggling a little to understand that you need to create Events for each stage of the passing.

thin stratus
#

Cause the variable can be different on server and client if unlucky

fiery wadi
#

Ah ok i changed it.

thin stratus
#

Call the is valid check in the RPC before the interact call

fiery wadi
#

Like so : )

tidal temple
# thin stratus Doing the trace there should be just fine

It turned out not :(
I clearly see the first shot on the client, which runs the "predictor?", and the second on the server, which goes through the ping time, perhaps it’s in the trace function itself? Although, judging by the timestamps, this shouldn’t change the picture.

const FVector& TraceStart = EyesOwner->GetPawnViewLocation();
const FVector& TraceEnd = TraceStart + EyesOwner->GetActorRotation().Vector() * TraceLength;
        
// Trace Function Here...
fiery wadi
#

I,ll have a mess about with this tonight and see if i can understand a bit more of this. 😉 Once again thank you !

thin stratus
#

Not sure what you mean

tidal temple
# thin stratus The delay is normal though?

Linetrace shot from the client and from the server. Roughly speaking, I see how the client fires the first shot and sets the grapple coordinates from the moment of input, and I see how the server does the same after 30-40 milliseconds, but according to the changed position of the player? Although in theory it should not have changed, since the player did not send data about the change to the server?

thin stratus
#

You really don't seem to get the setup of the CMC hehe

dark edge
#

show your code

tidal temple
tidal temple
thin stratus
#

The trace will be done on both for the same timestamp

#

Which means they are in the same location

#

Or at least should be

tidal temple
tidal temple
dark edge
#

If done correctly, let's see if it's done correctly.

tidal temple
thin stratus
#

I would change GrapplePointLocation == ZeroVector to GrapplePointLocation.IsNearlyZero()

tidal temple
thin stratus
#

The TickComponent code is probably wrong

fiery wadi
#

Once final Q before I drive all these people crazy "Not enough login credentials to launch all PIE instances, change editor settings" how do i fix this plz XD

tidal temple
thin stratus
#

That runs before the PhysXYZ stuff

#

There you can take your GrappleAvailable and begin Grapple if not already grappling

#

You also should save somewhere that you are indeed already grappling

tidal temple
thin stratus
#
void UCharacterMovementComponent::UpdateCharacterStateBeforeMovement(float DeltaSeconds)
{
    // Proxies get replicated crouch state.
    if (CharacterOwner->GetLocalRole() != ROLE_SimulatedProxy)
    {
        // Check for a change in crouch state. Players toggle crouch by changing bWantsToCrouch.
        const bool bIsCrouching = IsCrouching();
        if (bIsCrouching && (!bWantsToCrouch || !CanCrouchInCurrentState()))
        {
            UnCrouch(false);
        }
        else if (!bIsCrouching && bWantsToCrouch && CanCrouchInCurrentState())
        {
            Crouch(false);
        }
    }
}
#

It handles Crouching

#

So you mimic that fwiw

#

Crouch -> BeginGrapple
Uncroich -> EndGrapple

#

bWantsToCrouch -> bGrappleAvailable

#

bIsCrouching -> ??? (bIsGrappling)

tidal temple
thin stratus
fiery wadi
#

dont think so

thin stratus
#

The warning means that the number of Client you selected in the play settings isn't aligning with the number of actual logins with the backend

#

By default this should theoretically never call

#

Unless you use something like EOS or so

fiery wadi
#

I just choose Listen Server and 2 players in option

thin stratus
#

Not sure then, just ignore it fwiw

fiery wadi
#

Ok ty :L)

tidal temple
fiery wadi
#

I wish there was a way to donate to the most helpful ppl on here XD

#

"Have a beer on me!" 😄

tidal temple
thin stratus
#

I thought about having a Patreon, but I don't know if that would work. I don't really have the time for it cause i laready to 40+ hours a week UE client work.

#

Also not sure if a Programmer Tutorial kind of Patreon pays off :D

tidal temple
thin stratus
#

I don't think too much about a "Give me a coffee" type of button. If you take the knowledge you gained and help someone else in the future then I'm already happy.

fiery wadi
#

Same i would also

thin stratus
#

Appreciated. Maybe one day :P

fiery wadi
#

Well look at Ryan Laley he,s doing ok i think theres a lot of demand 😉

#

Especially with the stunts Unity have pulled lately.

tidal temple
fiery wadi
#

But yes if you do it for work too it might be too much so I really appreciate that there is ppl like you willing to share knowledge 🙂

thin stratus
#

A lot of people here help. Adriel did help Drib too. You also tried to. I think it's fine. Again, take the knowledge, help the next person when I'm not available.

#

The Patreon would be for extra content, like write ups of stuff I learned throughout the years. Not to support me answering stuff here. I wouldn't take money for that

tidal temple
thin stratus
fiery wadi
#

LOL

tidal temple
#

And sometimes good...

short arrow
#

Do people commonly make their own network managers instead of using the replication graph? 🤔

thin stratus
#

Just quoting Epic

#

It is also important to note that Iris does not support the Replication Graph. While Iris does not have any concept of “nodes” to control when and where actors are replicated, the new net object filters and prioritizers are intended as a replacement for the functionality provided by the Replication Graph.

#

Nope

#

I have not touched Iris yet

#

There was no need to dive into an experimental plugin for me yet

#

I have, I just don't like you so I won't share.

latent heart
#

Surely the only way to even talk to teh server is to send rpcs?

#

Make sure you send unreliable rpcs

#

And maybe compare to the last sent vector

#

(the last compressed vector)

dark edge
#

Any particular reason not to do it the same way as CMC?

#

I mean the CMC basically just spams moves at the server, are you avoiding sending the last input on tick for some reason?

#

I know, but it basically just spams a stream of data at the server. Is there a particular reason you want the rate to be much slower than frame rate?

#

Is this for vehicle movement?

nocturne quail
#

calling ServerRestartPlayer function spawn and restart the player, but the controller is always nullptr. any idea what could be the reason?

#

means can move around with keyboard a s w d

#

but mouse rotation not working

brazen anvil
#

If I want to add character leaning, this wouldn't need to be part of the CMC would it?

woven basin
thin stratus
#

If leaning does anything to movement then CMC, otherwise not. Being slowed down while leaning or similar also counts

upbeat estuary
#

@thin stratus regarding my question from yesterday, I think I know what happens now.
Seems like when there is no explicit cameracomponent in the scene, the player controller takes the rotation from the connected HMD. When then possessing a pawn with bUseControllerRotationX=true, it passes that to the pawn. So far so good. Now, given a pawn with an explicit cameracomponent:
When starting as standalone/listen server, it directly spawns the pawn, possesses it and applies the HMD rotation to the pawn's camera component, never changing the rotation of the controller or pawn itself.
When starting as client, there seems to be a period where there is no cameracomponent, I assume because it's waiting for it to spawn. The controller therefore gets the HMD rotation, then possesses the pawn, applies the rotation to the pawn and from then on only changes the cameracomponent's rotation.

I am not 100% sure that is what's happening, but it seems to make some kind of sense. It's also incredibly annoying 🙈

upbeat estuary
#

Aaaah, it spawns a spectator pawn before the actual one...or not

static prism
#

guys how the default online subystem works? the matchmaking for exemplo how can i connect to a player in another local just searching for it?

#

like the node find session

#

this is very specific

fiery wadi
#

Q : If you have a variable set to RepNotify everything inside the OnRep function can be seen by client and server correct?

quasi tide
#

What do you mean "seen by client and server"?

#

OnRep function is just like any function, it just gets executed when the variable changes

fiery wadi
#

I have a box which is set to replicate

quasi tide
#

In BP - the OnRep will be called for both server and client. In C++, server has to call it manually.

fiery wadi
#

So Client or Server press 1 to open and close box which then runs the Open or Close Box events.

latent heart
#

Flipflops don't work across the network.

#

Each copy of unreal will have its own value of whether it's flipped or flopped.

fiery wadi
#

The issue i have is the Server can Open and Close the box and it updates on the Clients Screen, but the other way it doesnt update.

#

Oh didnt know that 😮 Thank you Daekesh

latent heart
quasi tide
latent heart
#

Welcome to MP

quasi tide
#

You're only trying to do it locally when the client does it

fiery wadi
#

I was watching this video and i saw that he runs the 2 functions within the RepNotify function. https://www.youtube.com/watch?v=gfXcIF5-CRU&t=3s&ab_channel=Kekdot

🛒 Our Unreal Engine Marketplace Templates:
https://www.unrealengine.com/marketplace/en-US/profile/KekdotYoutube

🧑🏻‍🚀Support us on our 💲Patreon for awesome benefits: https://www.patreon.com/kekdot

Part 1 link: https://youtu.be/jtWhd4ugPW0

In this tutorial (PART 2) I explain how you RepNotify works and how you can use it / what the benefits of ...

▶ Play video
#

Which is slightly different to the button you guys helped me get working yesterday. 🙂

quasi tide
#

Not to sound rude - but I don't really care what that video does. The code you posted simply won't work the way you expect. The client needs to do a server RPC and then in that server rpc, it should change the variable.

fiery wadi
#

Its ok, I just wanted to let you know where I was gathering this information from because it might be helpful to know. 🙂

static prism
#

this is RPC?

fiery wadi
#

Thank you for the helpful advice anyway 🙂

quasi tide
latent heart
#

There are exceptions to this where responsiveness is important.

quasi tide
fiery wadi
#

I am finding that a lot of information is either A: Super hard to understand or B:Explain bad practices, So you end up learning 100 different ways to do things as theres not a lot of accurate information in easy to understand steps.

latent heart
#

An fps game won't do it like this, for instance, but opening a box is probably a good candidate.

quasi tide
static prism
#

to do this

latent heart
#

Yeah. And it you need it to be more responsive, you can start simulating a "the server said yes" answer before you actually get an update from the server.

#

But that's a more advanced topic.

static prism
fiery wadi
#

Would you say that compendium is the best place to start or what books would you recommend reading for getting a good understanding of UE Multiplayer?

latent heart
#

Get it working first and then make it look good.

#

Compendium is a good start.

static prism
fiery wadi
#

I,ll re-read that then and see if i can make some sense rather than trying to run before i can walk with this.

#

Thanks !

quasi tide
#

Compendium and then WizardCell's articles. In that order. All of 'em are pinned resources

latent heart
#

And this is why you never convert a SP game into MP, it just will not work. You might as well rewrite it from scatch.

static prism
#

yes the workflow change a lot

latent heart
#

If you want to write better code, write your SP game as MP 😂

static prism
#

looool

#

it will cost more and more to me

fiery wadi
#

Im not going into the C++ examples yet they scare me xD

static prism
#

its looks very well with BP

#

is good to you learn c++

#

the network works better there

fiery wadi
#

Yes I have heard that for a true multiplayer game you need C++ and BP together.

latent heart
#

For every game you should use c++ and BP together

static prism
fiery wadi
#

Im just hoping to do a super basic FPS style game 1 gun, 2-4 players and a couple loot boxes which drop ammo.

static prism
latent heart
#

If only to declare structs and enums.

quasi tide
#

Even if all you do in C++ is create your structs, enums, and BP function libraries. You already gain a crap ton of power

static prism
#

have things in the c++ that you cannot do this in the BP

#

BP is a extension limited of c++

latent heart
latent heart
#

Though depends what you mean by "matchmaking"

fiery wadi
#

I,ve done it as single player in BP,s

#

So wanted to try add MP to it but going to have to rewrite it, it seems xD

static prism
#

same room

latent heart
#

I don't think steam offers a "find players of equal skill to create a lobby" kind of system

shrewd ginkgo
#

Is there a clear source about gun firing and killing activities for multiplayer?

latent heart
#

Yeah, all online subsystems provide the concept of a lobby - that's what a session is, really.

quasi tide
#

What do they take 30% for?!?!?!?

latent heart
#

I mean it's easy to implement. Use the XKCD strategy.

static prism
static prism
quasi tide
static prism
#

30% is very very expansive

quasi tide
#

Well, that's what they get to dictate because you'd be a fool to not release a game on Steam as an indie.

#

Very few exceptions have been able to circumvent it

dark parcel
#

There are reasons why even with 30% robbery big titles still release games on steam

static prism
#

but not for big companies not

quasi tide
#

Literally just pay me to do it. I can 100% do better than them.

quasi tide
quasi tide
#

It wasn't long ago that Steam introduced a declining cut for the bigger titles pretty much. Indies won't get to take advantage of it.

dark parcel
quasi tide
# static prism why? popularity?

Because, the PC crowd pretty much refuses to use anything but Steam. So sure, some games were still selling, but they weren't selling as much

latent heart
#

Maybe they'll be an update with Fab?

static prism
quasi tide
#

Legally, they're not actually a monopoly. But realistically they are

latent heart
#

There's always the epic launcher to sell your games on!

fluid flower
#

hey all, what is the right way to replicate an actor pointer inside of a NetSerialize?

latent heart
#

Write its netguid? I guess?

static prism
#

At least in the USA, fees and taxes are extremely low and fixed

quasi tide
#

lol

static prism
#

like 6% or something like this

soft flare
#

Yoyo guys im having a question about mutliplayer (again, yea its the only thing im keep running into problems) so i have like a zombie survive lvl in the game, it has the "current wave" variable stored in the game instance and changed from the lvl. Now the problem is this doesnt replicate for clients for some reason (at least in the ui) can someone help pls?

#

Basicly whenever a zombie dies it runs it on server and then goes + 1 current wave,

#

But as saied the variable is in the game instance

blissful talon
# soft flare But as saied the variable is in the game instance

Game instance is not replicated. Wave counter shouldn't be on it anyways, as the game instance is persistant throughout the whole execution of the game. You probably should move it to something like GameState, as that thing is only created for a certain game session, and is replicated to everyone.

soft flare
#

damn wierd, in another project the game instance replicated everything thats why i was so confused

#

but damn alr then thanks

graceful flame
#

I doubt it

#

GameInstance doesn’t replicate

soft flare
#

i swear bro

graceful flame
#

That’s now how it works lol

soft flare
#

i had a array and every time i changed smth from the host the clients saw all the same variable

graceful flame
#

And where was this array?

soft flare
#

So i started working with game instance as if it would replicate perfectly

#

Its stored in the game instance

#

It was kind of an inventory

#

But when i opend the inventory up as a client he saw the same items inside

graceful flame
#

Nah prob a component on an actor or a player controller or gamestate

blissful talon
#

Perhaps it was a magical game instance 😔

soft flare
#

Ive never touched game state before

blissful talon
#

It's your chance 😉

soft flare
#

So game state are level specific?

#

they reset when i leave the level ?

blissful talon
#

Yes

soft flare
#

So other than replication and lvl specific i can use it just like game instance and im fine yeah?

graceful flame
#

The GameState isn’t tied to one level it can be reused on other levels but a new instance of GameState gets created so it starts “fresh” each time.

blissful talon
true hill
#

Hello might be dumb question, but i have created an actor with a UGeometryCollectionComponent. In a multiplayer context, im triggering a function that creates some fields to 'break' the component into pieces but i trigger it only on the server. When im authority on the server everything works fine, but on client i dont see the actor being broken into pieces. Actor replicates and all.. did i miss something? or should i multicast the createfields function?

graceful flame
true hill
#

thank you for the reply, i can/will do that.. so i guess it was wrong of me to expect the component to replicate the 'break thingy' on it's own since i have set it to replicate?

graceful flame
#

If a client joins after that event runs to break the stuff it won’t appear broken for then because they weren’t connected to the server when that happened or that event was dropped due to packet loss or that client was beyond the netcull distance of that actor so it didn’t even run.

#

But if you make a new isBroken? boolean and use repnotify to handle the logic for true then you don’t have to worry about all those network conditions it will just replicate and catch-up whatever state it should be.

true hill
#

thank you ^^

hoary spear
#

Replicating object refs in an array may cause OnRep to be called multiple times as the objects get replicated individually ; Is this also true for asset pointers ? Like a TArray<MyDataAsset>?

#

I expect the answer to be no..

fathom aspen
#

Why no? Aren't UDataAssets UObjects at the end of the day?

#

I would say yes only if the type was a POD, and the said elements were all set in the same frame

#

But still i would suspect that is a reliable guarantee since they can go into different packets (i guess)