#multiplayer
1 messages · Page 118 of 1
GameState has an array of all playerstates
Guys is there any good course for multiplayer game in UE5?
The playerstates are an Player State Object Reference, how do you get access to the variables?
Cast it to your custom PlayerState Class
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?
GameMode doesn’t exist on Clients, it cannot use RPCs
Try the GameState
Okay
Also this UserWidget has a score variable in it so Will gamstate be a good idea to use?
Is it a player's score?
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?
- It will change locally.
- It won't change for anyone else.
- The Server won't know about it.
- It will be "corrected" the next time the Server alters the Variable.
- BP OnRep Variables will trigger their OnRep if set locally, due to those being Property Changed Notifiers
- C++ OnRep Variables will not trigger their OnRep if set locally iirc
- 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.
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?
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:
- GAS.
- 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
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
When does it try to get that? Please share your code (clean and readable).
Number 2) is probably your only way.
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.
I was thinking exactly about that. But there not so many resources about CMC's custom abiltiies. Could you recomend me one?
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
Most scariest thing to me right now is that CMC's Flag's are only limited to four, which seems not compatible with my game
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...
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
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
Oh, that's great, thanks!
But at some point you might want to ensure that you don't overdo the data part ,cause that can hit bandwidth
The Multicast will execute on Clients. Clients don't have access to the GameMode.
You do an RPC to the server, it updates the score, then the score is "replicated" back to the clients
each client does not update the game mode with the score locally
Of course, thanks again. When will the quantum internet arrive? 😭
Thanks! I will have a look.
Thanks Let me try it again
Thanks
Thanks its getting executed on server
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.
You just start the dedicated server a second time. It will auto increment the port
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.
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
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
Yeah, that's what I was searching
Thanks
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
I asked this in #online-subsystems but nobody knew how to fix it
check logs
and send them here
So net ids can differ for the same replicated actor but on two different clients?
Yeah
You'd think they'd all be the same.
They are per package map, i.e per net connection
It'd still make sense to have the net id for all actors in a world to be the same, across all connections.
Ehh would be extra work that the engine doesn't really care about
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
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
Packaging failed on the dev build
shipping works but the servers don't as mentioned before
Remove spaces from directory names
#1 cause of packaging problems!
Also looks like that file is locked.
okay so, for some reason my client player and my client/server player are sometimes being added to the same "orange" or "blue" array despite there being a condition on the size
https://blueprintue.com/blueprint/2fywa5vi/
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
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
You typically don't want to be using any of those "Get X by index" nodes when trying to refer to players in online multiplayer, there is always a better way.
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.
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
which online service would you choose for a survival game?
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?
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
Nevermind I think I found the reason. Looks like some code is scaling the vector down when serializing the move.
Oh I know usually it should be avoided, I just mainly wanted a quick and dirty implementation when I was working on this last night. I just had my curiosity piqued cause the node said it was consistent across client and server which seemed different to when I last used ue a while ago haha
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?
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?
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
For instance, let's say you have a spawner actor which is essentially like a gate or something the enemies leave from to attack something, on BeginPlay you want to register that spawner with some system or do some logical initialization, but perhaps it should take place server side only, in that case you would use HasAuthority to initiate that server-side only initialization
i never would have thought of that example, and that makes perfect sense
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.
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)
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
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?
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?
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)
if the coins collection contributes to the same pool and the goal of the game, it can be in gamestate
you usually dont want to cointain any state data in gamemode
So state = Player Gold, Player Health etc?
or State as in Started, Running, Game Over.
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
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?
because when the multicast is called on the server, the actor hasnt fully replicated yet, so the client did not receive the multicast event
usually you dont want to have RPC on begin plays
pretty much, GameMode for rules, GameState to maintain and check the state of the game if it has reached the goal
Ah ok thank you !
i see that makes sense, is there some kind of way to check if an actor is done replicating?
not that i know of, what is the use case of the multicast event?
in this case I was setting a static mesh to be a random one from an array of static meshes
and the "random" is decided on the server?
Use OnRep instead
in this case i would recommend using OnRep instead
that does require that I set the component to be replicated right?
Yeap
alright thanks!
if you dont want to replicate the whole staticmeshcomp, you can replicate the staticmesh variable to set locally
i think
What is included in replicates the static mesh component though?
not sure..
Just checked, as for the static mesh class it's only the static mesh, and all it does is ReplicatedUsing=OnRep_StaticMesh
physics i suppose
And the UPrimitiveComponent (second top most parent class) replicates one single bool
i will set the net dormancy to dormant after setting the static mesh so i dont mind replicating it
Where the game build is located?
thanks everyone!
You're welcome 😄
@latent heart do you know how to fix the advanced steam sessions plugin not allowing players to join others?
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?
Not a clue.
Look into AActor::AddComponentForReplication()
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?
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
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
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.
yeah honestly no idea why I set it up like that, did it months ago when I knew a lot less and I guess it never brought up any bugs. so more like this?
minus the replicated variable
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?
I think I found the issue. Expected Player Count is being set on Event BeginPlay but OnPostLogin is running first
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
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 ^
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.
Okay so what you're saying is that the player controller's class should call the HudChangeTeam? Then on the server, I set the team (which is done correctly so far)
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)
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.
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
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)
ah okay
Your widget can still call whatever Run On Server event in any replicated actor class, but it can't Run On Server on itself.
Would changing RPC_Server_HudChangeTeam to Run on owning client be the right choice?
No
so only directly via player controller bp
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.
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
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.
Oh because the server-player is being blocked to entry from client begin play
Not sure what you mean by that.
the RPC_Client_BeginPlay is set to Multicast
Why?
i thought I needed to multicast to other clients the events happening afterwards
If this is on a player controller it only exists on the server and the owning client.
Doesn't exist for other clients.
so the multicast would literally do nothing
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.
gotcha, so from begin play I just need to check if it has authority and use the remote path
what do you mean by the "remote" path
currently got this set up now
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?
oh you mean the switch one
Yeah
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
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.
hm it still says both clients have no auth now, after a has auth branch returning false
Clients wouldn't have authority.
If it's a replicated actor spawned by the server, then the server has authority.
Oh I think I misunderstood what you said then, so no has auth on the player controller after remote?
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 😛
Sorry for the late response, thank you for the info
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
It seems like the client is now changing colors correctly, but the server isn't. It's detecting when the server joins, but the client of server is null or something? the display name is nothign
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
PCs are replicated only to owning clients
server has them all, but clients only have the one
so replicate the stuff in PlayerState instead
I'm trying to add a widget to the player controller's viewport, inside of a "PlaneModelPawn" blueprint that's possessed by each player
Is RepNotify reliable?
that question made me laugh even though idk the answer
Reliable in the sense that it will arrive on a client eventually
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?
If you aren't changing the level actively then you can't change the controller anyway. A special pawn that doesn't have any input stuff available would work yeah.
{
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
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?
if you need a controller in a networked environment, make sure to do it only after PossessedBy(OnServer) and OnRep_PlayerState(OnClient)/RecieveControllerChanged(OnServer/Client)
as for checking if the actor is local, you can use GetRemoteRole and GetLocalRole but that that check need to change based on its server or client.
can someone help me with understanding OnRep functions?
I don't understand why they don't get called for me
Thanks. Testing this on a multicast seems to work perfectly. Is this what you had in mind/do you see any problems with using this in a listen server?
i usually prefer using IsLocallyControlled
but its pretty much the same thing
Yeah that's my problem, using that function needs a reference to a controller, which sometimes is invalid on beginplay
thats why instead of beginplay, i will do the checks on either of these function PossessedBy, OnRep_PlayerState or ReceiveControllerChanged
@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.
Is that also the case with the player state? I'd assume not since I believe the controller owns the playerstate however I am getting similar issues on beginplay there (testing's difficult though, they're such rare bugs that I can't properly reproduce them)
player state comes with the player controller
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
Damn that sucks
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
Yeah for Controller that works
Not a guarantee for any PlayerState to be valid though
Yeah unfortunately that was introduced after 4.26 which is the version I'm on
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
I'm not referencing the playerstate on the pawn's beginplay. I'm referencing the controller on the playerstate's beginplay.
I'm wondering if this would be invalid
as that would explain a lot
game state for save game? 🤔
For one it's invalid for everyone but the local client and the server
yeah that's what I'm going for
it's saving local user data
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.
That's a CPP thing
oh yeah..
so what I'm getting from this is it IS worth learning cpp replication
I was told by colleagues otherwise lol
very much useful..
hmm... Would it be better to call this on the pawn's possessed? As you said that the PlayerState and controller would be valid then
Possessed is a Server Only event, though you can kinda make a RunOnOwningClient event for the owning clients, make sure its reliable though
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
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
just curious, any chance the "floor" is generated rather than fixed mesh?
also are there any warnings on the outputlog?
Nope, unfortunately not
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 😄
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 🤔
How do you replicate the movement of the physics object
Just finished trawling the logs, unfortunately no warnings or errors related to my object :c but good suggestion, and good to know regarding the actor initialization! Thanks
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.
What engine version
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
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
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
@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.
I cant get it, probably I cant do it without good explanation
Look it up on youtube. There's a lot of step-by-step guides using custom depth to see objects through walls.
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.
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
Okay thank you!
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?
Print string, get world location
On the parent BP, or inheriting BP, or both?
Wherever you want to do it
Thanks will give it a try shortly
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?
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.
when i sent a reference over network, like a reference to a data asset, the variables aren't serialized right?
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?
Perhaps it has to be a custom movement. Sending a separate RPC before starting doing that move doesn't mean that the RPC will arrive in time. Instead, when the CMC will be dispatching the movements clients wants to do, it has to find that custom movement and change the capsule height when it's required, so that all the movement is tested using the same data.
Data assets are for static data, so it won't send the variables over the network. It just tells the client to use the same data asset on his local machine.
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
Making the static mesh the default scene root of the parent BP fixed the offset.
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?
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?
Send client RPC executing that code
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
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
lemme try
Use OnRep instead. If the property bound to an OnRep is changed, it'll be replicated to clients anytime the replicated object will become relevant
where can i find that option?
Under any property, for instance under your CurrentGrabComponent
so i need to change the replication to replicated?
To RepNotify
but i already have that set
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
but the problem is that they don't receive the change.. i'll make a video of how it looks
here
wdym?
What's the object that stores it? Is it your character or maybe something else?
my character
All right, and where do you create the component? What side (server/client)?
the component? it's like in map, like before even starting
So it's a default component of your character?
Which is created prior to play time, I mean
yea, like it's a variable
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
wdym, like it's a variable with rep notify and i set it with custom event on server to make the rep notify work for server too (if i change it as a client)
yea but then i would need to rewrite the entire code that's already in rep notify
but still, it doesn't replicate to client before it's loaded
the client RPC can be called on the server RPC?
What do you mean? If you have a client RPC that executes client side, then it only will be able to execute a server RPC if the client owns the object the server RPC has to be done on
im still concerned why doesn't the client see the change that was made before him loading even with multicast
Oh, so do you create that component on runtime?
I'm not that used to UE4 interface, can't really tell the difference 😔
no, the variable is already in player before loading, im just changing it on button press
and the component is also in the map before
And to change that you're using these RPCs, correct?
yes
All right, just got the whole picture, aaand yeah, it should be replicating the object back, as it's using the repnotify 🤔
yeah, i don't know what's wrong
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?
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
So the rep notify is called client-side upon joining. What's the component value though? What is it set to both sides?
the same thing as the server
All right, but what's the problem again?
here's the video of what's happening
So is it playing the animation client-side? Is it pickup animation or something?
nah, just the physical animation and it's just setting the location and rotation of the hand skeleton, but also the component "jumps" instead of being held by the hand
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
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
I guess it's not really a replication problem anymore, but the way you use the received data in your project 🙌
i suspect the binding is too late as the call happens within the spawned actor. Any suggestions?
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.
Would doing a valid get on the actor before spawning it work?
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
No, as the actor is not even spawned
ill have a look into the Lyra and experiment with the dumb approach
gl 😛
hhha, thanks... (thinking owning PlayerController)
so i can cast to it
ill experiment more but thank you
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.
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
Comparison against nothing?
Again, comparison against nothing
You should really go through your code yourself 🙏
yea to check if it should be either dropped or grabbed
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?
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
Thanks I'll try that out
@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
What function exactly? The BindAndCall or WasAlreadyExecuted?
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
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?
That's what I mean. It's not the best approach though. Firstly try to think about the message above
(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)
yeah but i think i may need to think more about what you said on it always being the case.
no, sorry
So the player controller index doesnt seem to be the problem, I tried to change the index but still nothing happend
And I dont know what else I can connect to enable input node for the player controller
Don't use that node in general, at least for the code that will not be thrown away. What is the blueprint you've sent? Is it the player character?
No its door blueprint with button
So are you listening for a player input action from something that doesn't belong to the player?
Well I guess
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 👐
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
Pawn or PlayerController:
Input -> run on server event
Run on server event -> call OpenEvent on door
Door:
OpenEvent -> set bool IsOpen(replicated, repnotify)
OnRep_IsOpen -> do the actual movement of the door
Don't multicast for this, only one RPC is necessary (to get from client to server)
Okay so I tired to impement what you suggested, but I dont know how I should continue with the door blueprint(2nd picture). Sorry for asking so much im kinda new to this
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?
This is somewhat poor logic flow.
- 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.
- You shouldn't be trying to RPC to the server from a multicast. Multicasts already run on the server.
- 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.
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?
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.
how does that relate to multiplayer?
technically, its not a movement mode, as you're not going anywhere prone
even if I am just crawling around?
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
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
the CMC has a FSavedMove, a native class that packages the move and sends it to server
Yeah I added an additonal variable
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
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.
Why would the owner of the PlayerController be a BP_DoorButton?
That's a bit messed up
Yeah as I said Im new to this
Up to your first animation it seems ok, but nowhere does this code ever leave the one character.
I want to sus can call and all of others take call
just it
like dokaebi skill from r6
You'd want to get all actors of class and call an event on them
Multicast runs on the same actor on all machines
Not all other actors of the same class
I cant get it what I need to use
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...
If a client disconnects and the server detects that their controller is no longer in use, is the controller destroyed automatically?
Yes
Nice.. thank you
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
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
Is that the default actor damage system?
y
Did you hook it up to actually do damage? It doesn't do anything by default.
yy ofc
Are you sure the event is being run?
y
How?
Right. And you've checked the value of is dead?
I'm not sure how this shows that hte 'is dead' value isn't false.
y well i just checked it and it fires
That isn't what I asked.
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
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
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.
If this blueprint is exactly what the course is showing, get a refund. None of it is correct.
(when it comes to multiplayer)
@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.
Because you're only updating it on the server
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?
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
Use is from an Blueprint Interface.
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)
Ahh ok
I can see that. But that doesn't matter
Ok thank you
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
so to update clients would i need another function to update the materials on the clients?
Yeah. And because it is a stateful change - you'd want an OnRep.
Ahh thanks ! I,ll try to code it : )
(Assuming the SRV Use Btn function is actually running)
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)
Basics of networking
Player can be player character, player controller or player state.
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...
To teh right of that is the response to "Do Thing" which I didn't cover.
Updated it.
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?
End of frame
cool - thanks
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?
if i send an RPC from a player, is it going to run on that sample player aswell?
a multicast that is
Sending an RPC from a player, from a client, will only execute it locally for that player.
It only sends the 'effects to remove' variable every so often so if you set it more than once, it will only eventually receive the last value you set on it.
If you're deactivating 10 effects at once, the first 9 will be overwritten immediately and do nothing.
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
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.
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?
probably gonna need to show code on this one
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?
In any of the physics that match your movement
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
I'm worried about vector desynchronization, because in theory, the line trace from the camera's face will never match the server and client if it moves?
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
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
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.
I'm stupidly afraid I'll run into the same mistakes when I first learned that Network Emulation should be enabled during development, I'm probably really worried too much... But even such questions from me don’t bother you, which impresses me even more <3
this depends a lot, if you have a backend its probably best to just store it there and fetch it when needed, if cheating is not an issue you can store it wherever rly, game mode is probably not a good idea, thats not the inteded use of the class.
I wonder why Epic Games haven't done this themselves yet? It seems like this is an important part of the engine?
people have asked quite a bit for that, no luck yet lol
You will always get corrections with network emulation set to have package loss. The idea is that package loss should never break the game. Without package loss enabled, there can still be corrections, but they will be minimal and the reconciliation stuff should make them almost invisible
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
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.
The code in the picture is overall wrong
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.
It was more like a look into the past, because earlier, according to many tutorials, I thought that doing Multicast RPC for everything would help make multiplayer, what was my horror when I found out that many tutorials on YouTube were deceiving me ;P
Just need to get a "eureka" moment so it becomes a bit clearer.
- 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.
- 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
Ok so should all Client <-> Server communications happen in the controllers?
They need to happen in a Client owned Actor
Have you read the Compendium that is pinned to this channel?
Ah yeah okay
This one ? https://cedric-neukirchen.net/docs/intro/
Here you can find all available tutorials in one place!
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?
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?
The latter
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).
Yeah
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.
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
@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.
Your PlayerController, PlayerState, Pawn/Character (if possessed) are good starters
Thank you for the explanations!
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
I assume that OnRep automatically returns the updated value to the server bit similar to an OnChanged event in a Dropdown menu in JS?
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
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
(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
Ahh i think i get that.
That's the most basic I can explain it on phone atm
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
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
I was only using multicast because i saw it in a tutorial xD
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
Indeed that's why i,m trying to "fumble" my way around in multiplayer scenario,s now, I remmeber getting my first errors in UE5 and it driving me crazy but now i at least have a small idea of how to do somethigns 🙂
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
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
Yeah the button is a similar issue as my beloved door
I thought the image might add some context, A simple overlap check and then interact.
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
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
casting isn't bad
Yeah it isn't
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?
Also you should just do the code you have in that image but in the Character :P
So the player should tell the button "I,m standing on you ?"
No, the button should only get the Interact call
That's pretty bad code though. Instead, you should do it like;
casting IS the class check
Ahh
Hm not sure tbh. Controller Rotation should work fine with standalone too
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
This is in the chracter to "use" the button.
assuming that's what you want to have happen
Omg ofc it has a Cast Failed if its not a Third Person Charatcer #faceplam
That can work but it's a bit overkill, you can just do a trace (or get overlapping actors) when you press the button and choose what to interact with
Try to keep your references / knowledge flowing in one direction
Character knows/cares about InteractableObject, but InteractableObject doesn't care about Character
True.
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
InteractableObject could be a Button, Chest, Lever etc.
Yup. The only way to know about the current Overlapping actor ALL THE TIME is for showing popups.
Am using Box Collision on the button atm
You basically inverted the setup hehe
But yes the character could set his overlapping actor himself.
Yeah that'd be better
The problem with your setup is that you can't handle multiple overlaps
you'll still need some sort of collider on interactables but that can just be the mesh
The last overlapped actor would set itself on the character
Yup, you'll want some code to CHOOSE the actor you want to consider to be "selected" or "highlighted"
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
i kinda want to ask for a long time..
a sphere collision or trace every frame..? for detecting interactables
I'd start with this:
Button input -> get overlapping actors on InteractionSphereOvelapper -> choose one -> interact with it
depends
Either is valid
Tidied the code xD
used the is valid to make sure we have a value in OverlappingActor.
2 things
well cause on a player, it would move around alot, means it would need to update the transform of the sphere collision too
You can't test if the overlapping actor variable has the interface
Before setting it
You need to connect the OtherActor pin
lol damn it i missed that XD
And in the top part of your code you would put the server RPC before the interact call
I should seen that xD
Ok lets see if i can get this to work as an RPC then I need to examine all the other styles of comms. 🙂
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
In that scenario I would probably use an array and check the nearest actor and then show a message "Interact with X"
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
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
Yes
via the server Multicast.
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.
hoply crap this is a HUGE bag of worms i opened here. xD
Basically, if client didn't get the OpenDoor message, the door would be closed for them and open for those who got it
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.
Ahh ok that makes sense thanks!
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
Ok step 1 i made the repnotify var
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
you now have an onrep function
I see i have a function now OnRep_MaterialArray
that's where you put the code that should run when the variable changes
So that would be where i say hey turn green
Hm it seems like my playercontroller gets assigned a rotation (probably from the HMD) on the client, then passes this to the pawn. Then the HMD tracking correctly influences only the camera instead. Whereas in standalone and listen mode, the playercontroller rotation is correctly 0.
I wouldn't replicate that array tho
replicate a bool like bIsActive
or an int MaterialIndexToUse
I got a bool named On/Off
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
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
ok let me rechange this im sorry if im being a pain 😭
Not sure where that would happen. Characters send the Rotation from Client to Server in the CMC. Don't think Pawns have anything for that by default
No worries. Just try to read what we explained a bit more carefully. Adriel already more or less wrote you exactly what to do
So i ONLY check the value in this function
Correct
It's really strange, I'm not sure if even anything is being sent
Anyway I'll investigate more tomorrow
Inside the button I set this bool ?
Yes
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;
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?
Yes server
Omg you guys are amazing!
Doing the trace there should be just fine
I have some working code i can inspect and mess about with and try to establish how the information is being passed about.
Please don't throw another note in. We already went over this stuff with them.
This only causes more confusion
My bad, sry :P
Thank you al so much for your patience.
One last thing is I would move the is valid check
I think i was struggling a little to understand that you need to create Events for each stage of the passing.
Cause the variable can be different on server and client if unlucky
Ah ok i changed it.
Call the is valid check in the RPC before the interact call
Like so : )
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...
I,ll have a mess about with this tonight and see if i can understand a bit more of this. 😉 Once again thank you !
The delay is normal though?
Not sure what you mean
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?
You really don't seem to get the setup of the CMC hehe
Trace probably goes from current pawn location
show your code
I think so :P
Just a minute, I’ll complete the whole picture in a convenient view on Pastebin...
The trace will be done on both for the same timestamp
Which means they are in the same location
Or at least should be
This is why I am confused, because this is, in theory, a simulated point where all the data is in the same place
Exactly
If done correctly, let's see if it's done correctly.
Here it is: https://pastebin.com/xvzERGAp
I placed the points of interest on top and cleaned things up as much as I could.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I would change GrapplePointLocation == ZeroVector to GrapplePointLocation.IsNearlyZero()
Oh, I didn't know this function existed, thanks! I'll replace it.
The TickComponent code is probably wrong
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
I also thought about this, since I had never found a use for it as EntryPoint anywhere before
You want to do this in the function called UpdateCharacterStateBeforeMovement
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
Thanks a lot! I'll rewrite this now then.
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)
Great! Thanks again.
hehe
Are you using an OnlineSubsystem?
dont think so
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
I just choose Listen Server and 2 players in option
Not sure then, just ignore it fwiw
Ok ty :L)
WORKS! I don’t even know how to thank you... You provide absolutely free and enthusiastic help that is not available on the entire Internet or is sold for thousands of dollars. I'm shocked, a good shock.
I wish there was a way to donate to the most helpful ppl on here XD
"Have a beer on me!" 😄
I agree, these people are just amazing.
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
I am sure you helped not only us, but also many people too. I would pay for a subscription just to make it more enjoyable for you to do this.
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.
Same i would also
Appreciated. Maybe one day :P
Well look at Ryan Laley he,s doing ok i think theres a lot of demand 😉
Especially with the stunts Unity have pulled lately.
There are really few people like you, so thank you financially on behalf of those you helped - can help not reduce this number of people further, especially if you have encountered people whom you helped, and they remain dissatisfied :P
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 🙂
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
Certainly! But human joy from help, especially such a big one, cannot be avoided :)
LOL
🤣 someday the quantum Internet will come out and we will forget about it like a bad dream...
And sometimes good...
Do people commonly make their own network managers instead of using the replication graph? 🤔
I think commonly people just use the defaults. ReplicationGraph is pretty special and with Iris it might not be needed anymore in the future.
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.

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)
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?
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
https://github.com/Yalenka/SurvivalGame/blob/main/Source/SurvivalGame/Player/SurvivalPlayerController.cpp#L98
character is calling it from controller
If I want to add character leaning, this wouldn't need to be part of the CMC would it?
does a lean affect the movement capsule? If it is just visual, but the collision is not changed, then I dont think need it needs to be part of the CMC
If leaning does anything to movement then CMC, otherwise not. Being slowed down while leaning or similar also counts
@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 🙈
Aaaah, it spawns a spectator pawn before the actual one...or not
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
Q : If you have a variable set to RepNotify everything inside the OnRep function can be seen by client and server correct?
What do you mean "seen by client and server"?
OnRep function is just like any function, it just gets executed when the variable changes
In BP - the OnRep will be called for both server and client. In C++, server has to call it manually.
So Client or Server press 1 to open and close box which then runs the Open or Close Box events.
Flipflops don't work across the network.
Each copy of unreal will have its own value of whether it's flipped or flopped.
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
That's because the client isn't telling the server to update the variable
Welcome to MP
You're only trying to do it locally when the client does it
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 ...
Which is slightly different to the button you guys helped me get working yesterday. 🙂
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.
very good thanks
Its ok, I just wanted to let you know where I was gathering this information from because it might be helpful to know. 🙂
In other words, do this on the client and ask to do this on the server?
this is RPC?
Thank you for the helpful advice anyway 🙂
Not for me. I already think like 98% of tuts are pretty meh.
Don't do anything on the client, ask the server to do it fro you and it will update the client automatically. If you need to respond to events, e.g. trigger the box open animation, use an OnRep to trigger it.
There are exceptions to this where responsiveness is important.
This is good advice in general. Eventually you'll learn what you can do on the client. But for starting out, just do everything on the server first.
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.
An fps game won't do it like this, for instance, but opening a box is probably a good candidate.
That's because a vast majority of tutorial makers don't actually make games. They just regurgitate other tutorials.
ok so is everything on the server just do the client ask to the server
to do this
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.
yes networking is very problematic lol
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?
wow nice tip
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 !
Compendium and then WizardCell's articles. In that order. All of 'em are pinned resources
If you look at that image I posted, like 90% of that workflow goes away if you don't do MP.
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.
yes the workflow change a lot
If you want to write better code, write your SP game as MP 😂
Im not going into the C++ examples yet they scare me xD
its looks very well with BP
is good to you learn c++
the network works better there
Yes I have heard that for a true multiplayer game you need C++ and BP together.
For every game you should use c++ and BP together
a last question about multiplayer Daekesh, can i use the matchmaking of steam how much i want?
Im just hoping to do a super basic FPS style game 1 gun, 2-4 players and a couple loot boxes which drop ammo.
because of perfomance and functionality
If only to declare structs and enums.
Even if all you do in C++ is create your structs, enums, and BP function libraries. You already gain a crap ton of power
have things in the c++ that you cannot do this in the BP
BP is a extension limited of c++
As a first project? Sounds decent.
Afaik, yes.
Though depends what you mean by "matchmaking"
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
nothing just connect players to a room
same room
I don't think steam offers a "find players of equal skill to create a lobby" kind of system
Start over
Is there a clear source about gun firing and killing activities for multiplayer?
Yeah, all online subsystems provide the concept of a lobby - that's what a session is, really.
What do they take 30% for?!?!?!?
I mean it's easy to implement. Use the XKCD strategy.
exactly her dont offers i just want create a lobby and then find other player without filter
i dont like this
What do you mean? There are multiple ways to do it.
30% is very very expansive
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
There are reasons why even with 30% robbery big titles still release games on steam
but not for big companies not
Literally just pay me to do it. I can 100% do better than them.
For them, the cut gets reduced as they sell more.
why? popularity?
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.
I reckon and anything translate to profit is too good to past
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
ofcourse
Maybe they'll be an update with Fab?
Steam monopolized the games store, is that right?
Legally, they're not actually a monopoly. But realistically they are
smart guys
There's always the epic launcher to sell your games on!
hey all, what is the right way to replicate an actor pointer inside of a NetSerialize?
Write its netguid? I guess?
At least in the USA, fees and taxes are extremely low and fixed
lol
like 6% or something like this
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
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.
damn wierd, in another project the game instance replicated everything thats why i was so confused
but damn alr then thanks
i swear bro
That’s now how it works lol
i had a array and every time i changed smth from the host the clients saw all the same variable
And where was this array?
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
Nah prob a component on an actor or a player controller or gamestate
Perhaps it was a magical game instance 😔
True
Ive never touched game state before
It's your chance 😉
Yes
So other than replication and lvl specific i can use it just like game instance and im fine yeah?
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.
ahhh
okok thanks yall ❤️
Yeah, but that's a copy, so it doesn't actually persist throughout the worlds. But that's true that you can move data over new instances of the game state
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?
If you use a Boolean with repnotify then you can just replicate that change and trigger the break using the repnotify.
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?
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.
thank you ^^

