#multiplayer
1 messages · Page 183 of 1
Sorry - just so I'm 100% on this;
so does that means one per PIE client? i.e. its safe to use in a single process for multiplayer?
or not safe?
yes, it is safe
every PIE client (and server) has its own game instance that isn't shared.
and that applies to all subsystems? a subsystem is a singleton only in the sense of per client, not per process?
no, it applies relative to the thing that owns the subsystem
arh right - yep - gotcha - makes sense
I noticed that testing WHATEVER in single process is a pain in the ass, you will code something, then run two seperate processes and boom, most of things will not work
an engine subsystem is one per engine (which might as well be a true singleton). An editor subsystem is the same - you can't have multiple editors in a single process.
But a world subsystem is per-world (well, persistent level). A local player subsystem you can have multiple of in a single PIE instance since you can have multiple players in one PIE (for splitscreen or couch coop or whatever).
It's really not that much of a pain.
Avoid static variables and globals unless you're fine with sharing them across instances. That's the main thing to avoid.
Almost everything else acts normally unless you're digging into low level parts of the engine's handling of PIE.
whole initialization process acts differently
Which... is not that different for most purposes and is trivial to handle in most other circumstances.
If you're avoiding fixing PIE bugs you probably have bugs elsewhere, and are shooting yourself in the foot by having to launch a separate process just to test changes.
no, I am not avoiding but, I am testing ALSO with separate process now, nobody told me, and none of the tutorial with multiplayer told that you should test mp also in seperate processes to be sure your netcode, initialzation code or somthing works properly
I mean... you should be testing packaged builds regularly anyway.
PIE does not substitute for real network scenarios.
this is the lesson I learned
yeah - i've setup a nightly build script that always packages my game for shipping, so I can test a "real" game via Steam just for piece of mind
i have no idea what are you talking about, this is my own !virtual method and i have not deprecated it yet
Nothing substitutes for actual playtesting. Not to mention differences in build configuration between the editor, non-editor builds, and even between debuggame/development/test/shipping.
yeah, packaging the game is lottery, one time it will be successful, one time it will crash, another time editor just shutdown without any reason xD
that teaches you how to run it via a command line
it is very simple
I have mine in a batch file, and it runs at 3am each morning, sending the build to my NAS
so I have a nightly build to refer to, and logs if it fails etc
that looks like clients unloaded some classes during seamless travel that server kept loaded, leaving their NetGUIDs on its Acknowledged list
so server thinks client can translate NetGUID into class, client can't and that happens
static FAutoConsoleVariableRef CVarNetResetAckStatePostSeamlessTravel(
TEXT("net.ResetAckStatePostSeamlessTravel"),
GNetResetAckStatePostSeamlessTravel,
TEXT("If 1, the server will reset the ack state of the package map after seamless travel. Increases bandwidth usage, but may resolve some issues with GUIDs not being available on clients after seamlessly traveling."),
ECVF_Default);```
set that to 1, UE5.0 +
woo thank you, I will take a look
I'm guessing GEngine is just as bad?
Inside UPlayer of the default ConsoleCommand in UE5.4 - this is how Epic is getting the console :
UConsole* ViewportConsole = (GEngine->GameViewport != nullptr) ? GEngine->GameViewport->ViewportConsole : nullptr;
So that reference to GEngine is probably the issue?
GEngine isn't bad. There's only one engine in a process, period.
GWorld is bad because there are multiple worlds in a process.
Assuming GEngine->GameViewport is the only/primary/expected viewport is bad, but GEngine itself isn't the problem here.
bonus points if you start juggling worlds during PIE session
if (PlayerController && PlayerController->GetWorld() && PlayerController->GetWorld()->GetGameViewport() && PlayerController->GetWorld()->GetGameViewport()->ViewportConsole)
{
ViewportConsole = PlayerController->GetWorld()->GetGameViewport()->ViewportConsole;
}
else
{
ViewportConsole = (GEngine->GameViewport != nullptr) ? GEngine->GameViewport->ViewportConsole : nullptr;
}
I just modified the engine source to this, and its resolved the problem.
i.e. if the UPlayer already has a reference to PlayerController, then just use that to get the correct viewport.
otherwise fallback to GEngine.
Just tested - problem solved
that feels wrong
I appreciate you (and Epic) are probably correct over my lower knowledge. I'm 100% open to an alternative or another approach
still trying to find what your original problem was
@winged badger
console commands from one client show as output on another client when running under one process.
that is the problem I was trying to solve
ah, i always just ignored that
PIE testing single process has more then 1 caveat
especially if you expect anything static to have its own value on each client
yep - which silex and Snaps etc were helpful to point out earlier
it is good for the first round of tests
I'm not trying to do anything 'static' - its more how Epic had the console using that static that was tripping me up
I've modified my source so I can include Console in my shipping build, and it whitelists the commands I want, rather than allowing all the engine content stuff. So hence trying to test some thing in console.
including late join tests
i would assume there is a way to do that without modifying the engine
which is always a last resort - pain in the arse to maintain
Yep - just overriding one funciton
I'm using a source for something else, so splitting the function made it easier
but otherwise trying to keep it as close as possible to prevent issues later - yep
when I was beginning with MP on UE5 I was wondering why the heck AddOnScreenDebugMessage displays on every client, so debug printing was also the problem while testing in single process
anyone know why the data variable isn't being replicated to client actor?
you didnt set the Data property to replicate?
no I already have it set to replicate in the actor
I even tested in the actor's begin play, on the server the data is recieved there fine but on the client its empty
did you rename the property after you set it to replicate?
no
its weird because, on the server it works okay but when the client spawns the item the data is also not recieved
so no matter what the client never gets the data
try setting the data after actor is spawned
this is blueprint networking, and it has its weird caveats, c++ code doing the same would orderly replciate
so just updating the data with rpcs in the character who spawned it?
hmmm
void ABasePlayerController::Local_ChangeSpectateCamera()
{
if (!GetSpectatorPawn())
return;
bIsSpectatingFreeRoam = !bIsSpectatingFreeRoam;
if (bIsSpectatingFreeRoam)
{
GetBaseSpectator()->bIsFreeRoam = bIsSpectatingFreeRoam;
if (GetMainHUD())
{
GetMainHUD()->GetSpectatorHUDInstance()->DisplaySpectatingPlayerInfo(false);
GetBaseSpectator()->EnableChaseCamera(false);
}
GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Red, TEXT("ChangeSpectateCamera to FreeRoam"));
}
else
{
GetBaseSpectator()->bIsFreeRoam = bIsSpectatingFreeRoam;
GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Red, TEXT("ChangeSpectateCamera to ChaseCamera"));
if (GetMainHUD())
{
GetMainHUD()->GetSpectatorHUDInstance()->DisplaySpectatingPlayerInfo(true);
GetBaseSpectator()->EnableChaseCamera(true);
}
// TODO: Make it nicer to switching to a player to spectate
Server_SpectateNext();
if (!CurrentSpectatedPlayer)
Server_SpectatePrevious();
}
}```
My camera is not switching for "chase camera" (just simply thirdperson view for spectating players). It's executed locally via PlayerController
```cpp
void ABasePlayerController::Local_ChangeSpectateCamera()
{
if (!GetSpectatorPawn())
return;
bIsSpectatingFreeRoam = !bIsSpectatingFreeRoam;
if (bIsSpectatingFreeRoam)
{
GetBaseSpectator()->bIsFreeRoam = bIsSpectatingFreeRoam;
if (GetMainHUD())
{
GetMainHUD()->GetSpectatorHUDInstance()->DisplaySpectatingPlayerInfo(false);
GetBaseSpectator()->EnableChaseCamera(false);
}
GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Red, TEXT("ChangeSpectateCamera to FreeRoam"));
}
else
{
GetBaseSpectator()->bIsFreeRoam = bIsSpectatingFreeRoam;
GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Red, TEXT("ChangeSpectateCamera to ChaseCamera"));
if (GetMainHUD())
{
GetMainHUD()->GetSpectatorHUDInstance()->DisplaySpectatingPlayerInfo(true);
GetBaseSpectator()->EnableChaseCamera(true);
}
// TODO: Make it nicer to switching to a player to spectate
Server_SpectateNext();
if (!CurrentSpectatedPlayer)
Server_SpectatePrevious();
}
}
Ignore pls that mess in code. it is executing on local clients because debug prints are printing correctly but camera is not switching to that active one. Ofc course on server it works xD what am I missing?
When creating a lobby from the main menu, should it be done in the same level or a whole new level?
I just realized the issue might be completely different, I am trying to replicate a 2d texture which I believe cant be replicated?
They cannot.
You can if you write the code your self
Infact someone already done it in market place
Not even that expensive and save you time if it's that important to replicate textures
an asset pointer can
yeah, im taking a picture on one device then sending that over to all clients. But now im wondering if it would be less expensive to just send a notify everyone to take a screenshot from the same position in game
They are probably not guaranteed to see the same thing
that assumes that they would see the same thing
Pros and cons
Depends on how big the texture is.
just 128x128
single channel?
i would guess not, its a normal color png converted to a texture
on c++ of course?
blueprint should be able to do that too
you should be able to create a render target from that data
im looking into it, but seems like a hassle to convert the texture to bytes without a plugin no?
it would just be pulling data from the mip, converting it to uint8 and populating the array... in c++
i would imagine a function to get data would exist exposed to blueprints, but i've never had a use for it
FImageUtils::ExportRenderTarget2DAsPNG() looks like it would do the job, and compress it too
not from blueprint
If I want to move character (Set World Transform), and need to do it on server, can I do it ONLY on server, and not do it on the client? Seems to work but wondering if there are any drawbacks to this
And as a general question too, can I do certain actions on client owned actors ONLY on server, if I don't care about the action's latency?
Like usually for example when sprinting, you call the sprint function both on the client, and on the server, so that there is no latency. But if the action is important, one-time, and so I don't care about latency, what are the drawbacks of calling only on server
If you move something on the server that is replicated and the movement is marked to replicate, then it'll move that actor to that location on all clients automatically.
You can do whatever you want on the server without doing it on the client, however, not everything is replicated automatically to the clients.
Got it, thanks
A drawback of having the server always be the authority of everything is that you're then introducing a poor experience for players - If I press my trigger button on my gun, I'd rather it feel that it actually triggered immediately when I clicked rather than wait for the server to tell me that I fired a moment later because I had to wait for the server to say it was ok to do so and that I'm seeing what the server saw.
Hello, how does a Event Node know who the Owning Client is by default? If i run a Event with (Execute on Owning Client) in my FirstPersonCharacterBP, is the owning client the client that this FirstPersonCharacterBP request came from?
So for example, how is it determined here who the owner is ?
Hello, please help me, I use Steam multiplayer in my game, I need to organize a system for getting the current sequence time from the server (I create a server in my game, start the sequence, then after starting the server, the player joins, and I need to make a system that will automatically access my game (server), receive information about whether the sequence is running, if so, the client's game automatically receives the current sequence time on the server) if someone knows how to do this, please describe in detail
are you trying to have like an ingame time or something?
i tried this
the simplest way is to have the client request the time from the server, then the server will send back the time, from there you play at that time
I'll show you an example
Well, it's obvious how to do it, it's actually what I did, right?
oh didn't see the other photo's, it looks okay? What result are you getting
is the level sequence player playing anything at all?
sequence playing on server and client only when i start sequence when client is already connected to server, when i start sequence and client connect after server played sequence, sequence doesn’t start on client
you might be trying to do it too quickly
client might not be finished setting up before you've sent the information
add a delay to the onpost login to test and see if that's the case
question about function replication internals, bear with me here...
an abstract actor class has an event set to replicate, a child actor class then adds a call to the parent, does the resulting child call then cause two replications? or does blueprint know to handle this as one replication?
totally didn't see that
Do you mean that there is a long delay and when I start it, it does not have time to exchange information?
No, but first you need to fix your current issue that sswires pointed out. You are doing an RPC inside of the gamemode. The gamemode is not capable of replication. You need move all of that code somewhere else.
The simplest place would be your third person character
Ownership is something very important to understand. You already saw a table that contained entries like “Client-owned Actor”.
50 % of the time if I try to test a multiplayer game with a listen server and a few clients, as soon as I press f8 (to eject from one window and start controlling another), unreal crashes with this:
Assertion Failed: !GIsPlayInEditorWorld
Any ideas?
hey guys, what would be the best practice to get two players to connect to the same session that the host finds?
when on client playerstate is available ? want to assign variable in playercontroller but on beginplay it is still null. PostInitializeComponents also
OnRep Player State
fiuuuuck I forgot about it, thx
its called also on server or not?
OnRep only get called on Client in cpp
wdym
if you want to OnRep function be executed on serer you must call OnRep manually but I don't know if built in OnRep_PlayerState is called on server by engine on the server or not
ok
also not sure what you mean by call on rep manually
for ex
it's executed on client when something is replicated from server
void ABasePlayerController::Server_SpectateNext_Implementation()
{
CurrentSpectatedPlayerState = GetNextViewablePlayer(+1);
OnRep_CurrentSpectatedPlayerState()```
somebody told me here you can do it in that way if you want OnRep be called also on server
but if it is bad practice, ok
good to know then
I'm beginner in multiplayer but I don't see the point of calling OnRep on server
it's already the server
I think it is just code organization to not repeat something twice
@bright summit nvm, I get what the code is doing
but be mindful of context, there are things you want to run on server and things that run on client
I know
ohh I thought it was the ApplyDamage built in unreal, which is deprecated
💯
What things should I make in unreal to know if I understand multiplayer
I'm really stuck on how to implement this feature. Basically I want an ability where a player can see the recent footsteps of other players
My current plan is to have an AnimNotify (Basically an event you can set to trigger on a specific frame in a animation) and from that event, spawn in a new actor (game object which can be placed in the level) that has a decal to print a footstep onto the ground.
The part I'm concerned with is how to do it so that it limits the network vulnerabilities. I could do it so that the anim notify runs locally, limiting the bandwidth required with sending a lot of duplicate data, and have it so that the decals only spawn in if the player has a certain gameplay effect active, but that would technically mean the ability is client side authoratitive, which is bad. Server side means that I'm using a lot more bandwidth, but there is some authentication taking place
Maybe if I keep track of the anim notify data on the Game Mode so that only the Server has the data at any given point. Then when the gameplay effect is active, it simply subscribes to the event to receive this data as it is populated. When it is received, it adds it to a component on the Player Controller which replicates down to the client to spawn in the decal locally
Maybe try making an inventory system? It is a requirement for a lot of games, will teach how you handle things like server side authentication of items, replicating data to clients, how to send Client->Server RPCs, and there are already a few examples on YouTube on how to make it for singleplayer so you don't really have to come up with a lot of the logic. Although you will need to learn where to place each piece of logic
When I launch multiple windows for sessions (1 listen server, 3 clients for example), how do I switch between windows?
Other than f8
wasn't there some other shortcut?
Alt+Tab
or shift + F1
I have my player character set to replicate but we don't see it when multiple clients are playing... It just seems that the character is invisible
Can anyone give me on advice for best way to make the chaos wheeled vehicle pawn's mesh to explode? Currently I'm doing it like this which works but would like someones perspective the best way to do this. Specifically handling hiding the pawn mesh and spawning the collection for explosion
@whole iron
Hey !
No problem ! I managed to make it working yeah and it wasn't an easy deal until I put my hands on a MarketPlace Plugin.
I don't know if I'm allowed to promote a plugin on this channel but we can continue this conversation in private 🙂
Hey guys! Can someone tell me where the event for timeout is? I can't find it!
I want a player to join via IP, but if there's no server I want it to fail after 10 seconds and have an event for that.
I've tried the Event NetworkError from the GameInstance, but nothing
Thanks in advance for the answers 🙏
I believe you would be looking for “event TravelError” and/or “event NetworkError”
Well, both of these never trigger it seems
And the log is showing to me this message every 10 seconds : LogNet: Initial Connect Diagnostics: Sent '9' packets in last '10.215907' seconds, no packets received yet. (but with slightly different values each time)
Are you doing it in your project @worthy oak?
hmm interesting ok. It looks like it hasnt timed out yet though?
It's been running for >5 minutes now, still no timeout
I want to have a very short timeout, but I can't find how to do it
That I am not sure on TBH. Would have to look into it more
Okay, thank you for your time.
Anyone else?
Got sort of a weird issue here if I put my camera into free-movement mode where it can rotate all the way around the pawn. If I then rotate my camera to face the front of the pawn and hit D, the client and server are disagreeing on what direction the pawn is moving which is causing jitter. I imagine it's something to do with the server not knowing about the camera rotation or something, but I'm not sure exactly what the issue is.
Anyone have any suggestions?
how are you spawning them?
Can someone tell me why the print string does not fire when i use a "Run on Server" node when the previous code is a Interface Call?
Is it possible a version of the object doesn't exist on the server?
Yeah, i just figured that out, had to run the previous code on the server, but im still not sure as WHY the server can't call at least the print string
I'm not 100% sure cause I haven't tried to send a server RPC from the server recently, but could just be that it will only execute if it's being sent from an object that exists on a Client, not from an object on the server?
That actually makes a lot of sense
You could try changing it to a NetMulticast instead for a quick test
Hello, I've got PS5 build running, but it fails to connect to my dedicated server (it works fine for PC). After I do OpenMap, it says
[2024.05.24-17.12.34:395][576]LogNet: UIpConnection::HandleSocketSendResult: Socket->SendTo failed with error 21 (SE_EADDRNOTAVAIL). [UNetConnection] RemoteAddr: *our public IP address*, Name: IpConnection_2147482369, Driver: PendingNetDriver SonyNetDriver_2147482370, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID Connection beginning close timeout (Timeout = 5.000000).
[2024.05.24-17.12.39:400][876]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionLost, ErrorString = UIpNetConnection::HandleSocketSendResult: Socket->SendTo failed with error 21 (SE_EADDRNOTAVAIL). [UNetConnection] RemoteAddr: *our public IP address*, Name: IpConnection_2147482369, Driver: PendingNetDriver SonyNetDriver_2147482370, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID Connection will be closed during next Tick()!, Driver = PendingNetDriver SonyNetDriver_2147482370
[2024.05.24-17.12.39:400][876]LogNet: Warning: Network Failure: PendingNetDriver[ConnectionLost]: UIpNetConnection::HandleSocketSendResult: Socket->SendTo failed with error 21 (SE_EADDRNOTAVAIL). [UNetConnection] RemoteAddr: *our public IP address*, Name: IpConnection_2147482369, Driver: PendingNetDriver SonyNetDriver_2147482370, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID Connection will be closed during next Tick()!
[2024.05.24-17.12.39:400][876]LogNet: NetworkFailure: ConnectionLost, Error: 'UIpNetConnection::HandleSocketSendResult: Socket->SendTo failed with error 21 (SE_EADDRNOTAVAIL). [UNetConnection] RemoteAddr: *our public IP address*, Name: IpConnection_2147482369, Driver: PendingNetDriver SonyNetDriver_2147482370, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID Connection will be closed during next Tick()!'
[2024.05.24-17.12.39:416][877]LogNet: Browse: /Game/login?closed
Does anyone know why it might fail?
I've seen someone before say that their call to ServerTravel was missing ?listen at the end. But aside from that not terribly sure
I'm connecting to a dedicated server, the client doesn't have to be a listen server
ServerTravel is not for connecting and neither does it need ?listen
Either way, I'm using OpenMap
Was referencing this post (just FYI) #multiplayer message
@mystic estuary Keep in mind that your PS5 license is under NDA, so be careful of what you share
Mentioned the same Socket->SendTo failed with error 21 (SE_EADDRNOTAVAIL)
When you test with PC, do you use any kind of Subsystem?
And if you test with PS5, do you use a Subsystem for your PS5 build?
I'm not sure about that part. Should it be under ProjectSettings config?
No, you set that up via your Ini file
Similar to the NetDriver
The main point is that there is a good chance that you can't connect to an IpNetDriver and SubsystemNULL Server from a SonyNetDriver and Playstation Subsystem
Works, thanks, now i can have deers with rpgs in multiplayer
Found this as a suggestion. Someone mentioned PS5 being unable to connect to their dedicated server:
[/Script/OnlineSubsystemUtils.OnlineEngineInterfaceImpl]
+CompatibleUniqueNetIdTypes=PS5```
In DefaultEngine.ini we have DefaultPlatformService=null
I think the UniqueNetId part only hits after connecting. This fails earlier already.
Especially if both builds use Subsystem NULL, then it shouldn't matter.
Given you have a PS license, shouldn't you have access to UDN?
At least to the PS part?
The Server here can't really help with Console due to the NDA. You should have other contact points to ask for this.
Sicerath is in theory not even allowed to share UDN answers.
We don't have any unique config for platforms, so both of them should be using null subsystem
Yeah, I can try that as well
Well it's clearly a Playstation issue then though, so you gotta go to the point of contact for PS and ask them what this is about and how to solve it.
How does one go about running a locally hosted server on a seperate process from the client? Dedicated server?
Hello, I'm quite new to multiplayer and a little confused. I have a replicated actor in my game, one tile of a hex map, that contains a widget component. When any player clicks something in the widget, I want to update the tile by calling a method with a parameter on the actor. Since the tile actor is not owned by the player, a server RPC will just be dismissed. I know I should basically route this through the player controller, but that would be I always have to route all necessary payloads through the player controller to the targeted actor. That's sounds not very good, but how would I do this otherwise?
Yeah, Server-only Process is a Dedicated Server.
welp, that sounds fun to set up
Going from UI to Server doesn't really leave you any other option.
You can route it through some Component on the PlayerController to keep it cleaner.
Or in other examples, if possible, simply tell the Server that you press the key to do X and the Server can then do X on its own.
You can test it in Editor via PlayAsClient, or via .bat files (command line arguments) as Standalone (still using Editor Data, but other process).
But ultimately to make a Server to distribute you need the Source Engine and build with that.
Ok, so I'm not completely wrong here, it's just how it is. I'll probably make a generic way to route any of my UI actions to the server. Thanks Cedric!
It's ALWAYS a very good idea to review if such a Server is needed, or if the Client can't just host on its own.
I suppose, It just seems to be a absolute pain in the rear to differentiate between the client and server when its on the same process
The logic i do on the server does replicate, so setting transform, spawning actors, changing rotation etc. but when i spawn a particle system it does not replicate. Now my question, does it not replicate because visual effects are not meant to be replicated by the server so its turned off, or am i missing something? Because i cant understand how the clients can see that a item gets added, can rotate etc. but then again a particle system is not visible without a multicast
It's actually pretty straight forward
Transform of a Replicated Actor is replicated if you tick ReplicateMovement.
But that doesn't mean that UE rpelicates everything. Most stuff is actually not replicated
Thought so, is there a document or video where i can see what is actually replicated
Not really.
Great
it's very specific so either you get it by context, docs, or source code
Still thank you for your anwser 🙂
bUseOnlineServicesV2 is not ready for prime time is it?
It is incompatible with Steam
if i want to store for each player its location history, should i use a tmap ?
each key of the TMap would a player Actor and the value an array of FVector
depeding on how old history you want to keep you'd be investing heaps of memory for this
last 1s
So something between 30 and 120+ entries per player, depending on FrameRate.
without using TMap i wonder how i could allocate new array for each player and get them back.
the other way would be storing 1 array for each player actor
PlayerState?
i wont store on tick, ill have 1 array element each xms
you could be smart about it and store only the differences with timestamps
so when i have packet latency i would calculate how much should i go far in hisotry
like if player is running in straight line with constant speed you don't need to store all of it
thats some extra optimising that i dont need rn 😅
Either way, put it on the PlayerState then
ye
Well yeah
okay ill try that
or player character if you don't care of loseing the info when character dies
You wouldn't store the PlayerState's Location, but the PlayerState could be the place where you store it.
Or just on the Character directly, yeah
to track this, is it better to use tick and add the delta time to CurrentTime to know if CurrentTime > X
or should i use a timer
tick with time substeps
okay
now to call OnHit on server to tp all players to old location, i need to get all playerstates.
should i have the actor component that lives on the hited actor get the gamestate to do that, or should i redirect it to the gamstate and have the GS handle this
hm A replicated Static mesh
changing material on server
it dosent replicate :/?
materials isent replicated ?
cant*
No
No
huh?
What is the Material of a StaticMesh? A one time event or State?
one time event
What if I join your game after the RPC
yeah gotcha, well my game u cant join once it started so it wont be a iussue for me
hmm
The Material is part of the State of the StaticMesh
In most cases this should be a RepNotify
Unreal despawns non relevant Actors that are not loaded from the package. If you were to use RPCs any non relevant Actors, as wel as Actors that became non-relevant then relevant again would be in the wrong state.
guys hi. ı have a problem all client name the same. Why? How can ı change the name
how does the player character model replicate? it doesn't for me
While I don't think anyone is following this or had ideas (or if anyone is, I missed it among the other conversation), I discovered that I was running into an engine bug that has been confirmed and will be fixed in UE 5.4.3. On dedicated servers, because the server runs single-threaded, the physics event queue is getting cleared before the events are posted to game code. PIE, multiplayer clients, and any other multithreaded contexts are unaffected and will see events.
bug in 5.3, 5.4. You have to edit the source code to fix the bug. From memory they changed the type from int to struct so you have to do a static cast when printing.
info is available on the internet
I'm wondering if anyone could point me in the right direction here, I'm slowly learning how multiplayer works, been reading up on EOS, etc. I was wondering if anyone could recommend a company for my first game server? Also, if I were to just have something small for testing, say 5-10 friends while I'm learning, what might costs be for something like that?
If anybody has any general tips or know of any vital tutorials as well, then please let me know
I personally go for the free option since I never released any multiplayer game and still learning.
which is just to host as listen server
or if you want to test a dedicated server, just host the dedicated server build on your own machine.
that's a good point
why does my player doesn't replicate, It's invisible
Honestly, just self host the dedicated server. Or spin up a $10m/month VM with a cloud provider and host it there. You don’t need much. Focus on doing listen server local testing for the bulk. If your new to MP don’t complicate it straight away. Keep it simple.
ex for the meaning of HasAuthority means that it's the server, see this video at 7:05 --> https://www.youtube.com/watch?v=UmJzuRO4Qjs&list=RDCMUCpsN2TfWGmun4peN2IPgcKg&index=21&ab_channel=reubs
Try my C++ Survival Game Course:
http://bit.ly/unrealsurvival
Discord:
https://discord.gg/meFRZfm
Today I do my best to teach the basics of networking to you in under 30 minutes. Enjoy!
Business Email: contact@reubs.io
HasAuthority does not mean it's the server.
Authority deals more with who is responsible for the actor. If you spawn an actor locally on a client, then that client would have Authority of that actor.
For a replicated actor that is spawned by the server, then the server would be the authority.
understood but then, I got another problem, my player character's arm are not replicating even if they should
How are you replicating the arm?
as it should replicated
Just clicking "Replicates" doesn't mean everything you do with an object is replicated.
when the player takes a gun, the gun is located correctly on all clients and server but not the arms
they are just not showing
Well that's usually because the arms are "Owner Only See".
(only visible for itself, seems to not be replicated somehow)
BRO
thx
it's dumb but it's the default settings
❤️
It's a visibility setting of scene components
of rendering
How do I replicate the transform of a camera component?
The "replicates" on the component is checked, but the transform of it doesn't replicate to other players
Do I have to manually pass in transform data via events?
Server Rpc is the only way for Client to communicate to Server
I know that, that wasn't the question.
well if you have to ask this, then....
If it doesn't click yet, I will try to explain. What ever you do on client machine will only apply to the client machine.
If you want to send data to others, as a client your way of communicating is via Server RPC. The server can then replicate the values to other clients.
The camera component in questions is on the server...
Which is my question
Does Server automatically replicate transform, or do I have to pass it to clients via RPCs
the camera would exist in every machine
you gotta ask first, whos sending what data and what data to follow
marking object as replicate doesn't magically replicate their properties
Are you using ControlRotation?
And are you moving the Location of the Camera ?
I created map and I assigned Game Mode to it and Game State, if I enter the map straight when I have this level in the editor, I can see the quest widgets get updated. The info about widgets I care about is in the Game State as Actor Component, and if I enter it by Creating Session, then these widgets are not beeing shown.
skgframeworks vs lpsp for fps multiplayer game cons and pros ?
i do this but nothing changed
is that ur post cause i just replied to it with smth that helped me
If I create widget in the actor component, it doesn't replicate or what i'm doing wrong?
I have BP Resource with Actor Component Gatherable.
I create widget for the Resource inside the Component, because there I have all needed info.
When player clicks on actor (Event Select Resource in Bp Resource), then I sent interface Show Selected Resource to the Player Controller.
Turns out this only works for the server client?
The 2nd client doesn't see the widget when it clicks it. I think I tried all combinations and it only somehow started to work when I put the Create Widget logic in the BP Resource and not in the component, but I really wish I could have it in the component.
widgets dont replicate
So I have to create widget inside Player Controller?
so every player has their own?
wow, even if there is like 1 shared thing in the level?
Doesn't need to be in the PlayerController, but you generally have to handle replicating the creation yourself.
Just trying to understand. Since I have Resource in the level right. Wouldn't it make sense for the Resource to create widget of itself, and players just access it?
Or this is the problem that it doesn't work like that?
If it should only show for the local Client then you need to target the LocalClient via ClientRPC
I mean sure, but if the event that shows it is on the Server, you gotta get to the Client first
You are using a ServerRPC to create the Widget
So it's pretty normal that this only shows on the Server
On top of that the RPC is in AC_Gatherable, which is probably not owned by any Client
So Server and ClientRPCs don't really do anything anyway
Okay, but even if I set it the event to not replicate, it still doesn't work. Which means that this Create Resource Widget doesn't exists anywhere? It's triggered on Event Begin Play
so On BeginPlay of the AC_Gatherable you create the Widget?
Yeah
Then the Widget should also exist for everyone
You should possibly not mark the Variable as Replicated
I thought so, but well this doesn't work and I tried to debug it in every possible way
I replicated all components, blue prints that are connected here..
The Widget Variable shouldn't be replicated
And Variables inside of the Widget neither
Widgets can't even replicate themselves or inner properties.
Yeah cause the variable tried to replicate the Server Version of the Widget
But the Widget has no Client version mapped to it
So the variable locally just becomes null
Wow, good to learn on what should I look next time
And the variables you have inside the Widget should also not be replicated
Thank you so much
They can't replicate anyway
but now you are talking about the Widget Blueprint and not the Actor Component that creates widget?
Yeah, you have a GatherableReference variable in the Widget
That is marked as Replicated
That's redundant
Okaay
Widgets are local only. There is no replication ever going to happen. Widgets are meant to mostly display replidated data that is located in other classes
so only the data that the widgets are taking in should be replicated
and widget is created on local, so doesn't make sense because everyone has their own basically
Yeah, you can take e.g. a Replicated Health Variable that is located in your Character and display that value. But you can't make a Replicated Health Variable inside the Widget.
Got it. I was even more confused why it's not working because I have very similiary setup Health Bars and they were working. Probably too much panic mode and trying to click too many things that I had no idea what it ''really'' does. Thank you for claryfing it for me. I have lot's of widgets to setup and this will help me a lot.
ı m sorry. ı can't find bug fix on the internet. Can you help me how can ı make ? I'm beginner for multiplayer.
thenks for help bro.
have u tried the fix
I want person x to have a phone call feature and everyone else's phones to ring. like the dokaebi character in rainbow six siege
how can I do it
anyone know how do i import a float variable from BP_Weapon_Component to UI Widget?
because i cant get all actors from class
create widget on the weapon, while creating widget you set reference of the weapon (where you have all variables), and then in the widget you can take that variable and get all info from the weapon
i dont get it
i got this, and the In text must be the variable from BP_Weapon_Component, but i dont know how to get the variable from the BP_Weapon_Component to the UI
look for documentation/videos on variables and references
how do i replicate changing the mesh of my character. when i log in to the map i want to give random appearance to all players but i couldn't replicate the set skeletal mesh. and where and how should i do the random selection part. i want to distribute 8 costumes to 8 people so that everyone will be different
you still have to set the reference
u didn't
Randomly choosing can be done on the character, but then you have to either Multicast that skeletal mesh was changed (will work if all the players are already in the game, multicast will make everyone around see the change), but if anyone joins AFTER the changing event, they will not see the change, in that case yo uwould have to use Repnotify
deffinitly don't use multicast if it's something that needs to be in sync
Just RepNotify your skeltal mesh
server set the random mesh, done
If Client -> ServerRpc -> GetRandomMeshFrom Array and Set Skeletal mesh
If Server -> GetRandomMeshFrom Array and Set Skeletal mesh
Can someone explain me why the first client that I host with, isn't also the client itself? And it doesn't get event from Game State about quests, but then every other client that joins works normally? Also, looks like the event Quest is firing (foor loop for 2 items), but it's not shown? Any keywords what to look for?
Quest Manager is actor component of game state.
if you are in Listen Server mode, the 1st Window is Server
if you dump your logic in OnRep, just remember that's only get Client in cpp
Can I somehow make first window to be both server and client?
It says here that listen server is both server and client, but why the UI doesn't get updated then also on it?
wdym by that?
Listen Server is the Server
if you want every player to play as client you will need to play Stand Alone (Dedicated Server)
like what is the reason that this UI is not working on the first window
can't tell from that picture alone
what i'm missing that the first hosting window isn't also client ?
do I have to also add some logic here for the host to become player ?
this is Game Instance
Are you going to use Listen Server or Dedicated Server?
Dedicated Server = Headless, no Render on it's part
Listen Server = Player and render but as a Server
I will use Listen Server I think, like players can host game themselves
if the game will be succesfull I will probably want to upgrade to dedicated servers
but so far I choose to go with listen server
If that’s the case your first window will always be the server and client
If you want to test what the game is like on a dedicated server you would set your netmode to client (not standalone)
so what do I have to look into so this hosting client will also get widgets shown ?
By creating the widget in the client. How are you making the widget?
this is Quest Manager in the Game State
and this is Player COntroller
and when I host with the first client:
And how do you call that?
anyone knows what to add in the object for cast to bp_weapon_Component
The object your trying to cast
If it’s a component in your character don’t cast just drag the component out
its not
the variable is in the bp_weapon_component
so i need to get that variable from the compoennt to the widget
Ok so something to keep in mind here. Begin play will fire server side and client side and currently your code isn’t distinguishing a difference.
I would suspect that if you played with 2 clients in netmode client it would work as it’s being forced to be a client at that point. However in a listen server where one of you is the server, you need to ensure your calling the create widget nodes on the client.
Even if client and server in this case would be the same machine
So where is this component
huh
You keep saying component
i got an widget
and im tryint to get the float variable from bp_weapon_component
to the widget
so i can use the variable in the coding for the widget
Right but what is bp_weapon_component and where is it
THANK YOU
this makes sense
I moved the logic to the player controler to call to that component to create widget for itself
There ya go yeah thats a way to handle it 😄
nevermind fixed it
this is what I was missing
oh god, there is so many small things to consider! 😄
thank you thank you thank you!
there are indeed haha now you will wanna understand why it works, player controllers do not replicate which is why its working
so keep that in mind before you go running server code in there
but that is also why its currently working for you 😄
of course! glad its working
Sorry let me clarify
I thought PCs do replicate to their owning clients...
My player controller is kinda whole brain of my player so I put a lot of logic here. Other thing I could consider is probably Pawn that player posseses or Player State (but this I'm like 5%)
Because the server certainly has a copy of all of them.
Yes sorry this is what I meant
bad phrasing lol
each player has their own playercontroller and players don't know about any other playercontrollers basically?
Does your player brain need to run on every client for every client?
Right you cant get another players player controller
I misspoke ignore my first comment 😂
yes, I guess? not sure -for every client part
Figure that bit out.
The server have everyone's controller
Everything that needs to run on each client for every other client can't be on the PC.
ohh, you are trying to make me think if should I put some things on Player State?
because Player State is avaliable for other players not like PC
Yes
Or their pawns.
Depends who "owns" the logic, the player or the thing they are comtrolling.
okay, I will consider, but so far I try to put info only that is needed for the local player, like I don't have things here that other players would access
Yeah if its UI thats a decent argument to be made
since UI really only applys to the local player
In this case of quests, these will be global quests, so each player has their own widget? but they all take info from 1 place (Game State)
Right but that first part is the key part, each player has there own widget
How each client gets the info for the widget yes that needs some replication consideration
Yeah, got it ❤️ thank you guys for help
how do i add multiplayer to my game? Cuz all the tutorials arent working
That's a very vague question
ikr
you have to understand it first
This compendium is meant to give you a good start into multiplayer programming for Unreal Engine.
beat me to it lol
So its better to make dedicated server, and then add the code into the game so u can join the server?
it's better if you learn how to make single player first before you dip your toes to multiplayer
depends on the game and if you need control over server side
you can't even reference, how you gonna reference and keep track of multiple game instance?
Im working on a singeplayer game, but i cant finish it
Im just gonna follow a tutorial...
multiplayer is way harder than single player
It can be fun though if you wanna get your feet wet
I'm a firm believer that one should know how to add before doing multiplication
If you start with listen server, you will not need to rework much logic if you decided to move to a dedicated
and tbh at least in my opinion. Getting something like a shooter or or even a basic lobby setup is achievable and you can learn alot. There will be considerations you will want to take, and testing/expanding to ensure its a smooth experience before release
but you can learn the concepts doing that
nah, im alr ig, its too much for me to make multiplayer game, make dedicated server.... make join and quit.... make replicating things..
and blah blah
its a ton of work yes haha
but
but anything worthwhile is
i made a small game, i was making it for the first time
i was 2 days learning and 2 days working
so 4 days and i made this
starting small is a great idea
Yeah thats great congrats!
nice 🙂
the ai is kinda broken tho
if its any consolation AAA games are hardly bug free xD
and tbh lately are even more buggy LOL
i just cant get the doors to work so the ai dont sees me
and i also cannot make jumpscares cuz idk how...
someone give me ideas for new game
fortnite 2.0
my best game rn...
oh
does anyone here know how to animate jumpscare?
Error: I spawned an actor on the server but it doesn't replicate
what is wrong?
I used a Server RPC to make the call from the client to the server to then spawn it
Where is the ServerRPC located
it was in a component
And the Component is on what Actor? And is the Component marked as Replicated?
the component was made by the engine, it was the WeapongPick Component from the default 1person shooter
That doesn't really answer my questions
It must be and it must be on an actor owned by the client fwiw
i was wondering why the begin play in my playerstate component wasn't firing. Then I found out begin play is not even firing on the playerstate itself. Why is that? There are two players in the game so shouldn't the server also print 'begin play' twice for each player?
im creating a listen server where one of the players is a server and a player btw
It could be you forgot to set the playerstate in gamemode
two player states do spawn and a lot of other replication logic is already working for both players. they can exchange information etc. Its just begin play for some reason
i guess ill just call begin play type of event from the gamestate or something like that
why is my AI's pawnsensing not working? I copied the code for my ai from other game, and on PawnSense, it doesnt do anything, even if put it so if the ai sees you the it prints a string
I used default touch joystick but no matter who's joystick I move, only the client character moves
someone have any idea why's that?
I saw a reddit post having the exact same problem as mine
https://www.reddit.com/r/unrealengine/comments/jofcxz/replication_problem_with_touch_joystick/?utm_source=share&utm_medium=ios_app&utm_name=iossmf
anyone know what would be the best practice for updating a variable on an actor located on all clients? Is there a better way than to just have the actor call an RPC which is on the character BP?
In my project I am trying to update the character pose based on the weapon that is equipped. When I equip a weapon, I sent a FGamePlayTag to the inventory container of the weapon I am equipping. Then I get the data asset of the weapon in this slot which stores the pose to use for holding this particular weapon. Then I set CurrentPose to the pose on my character. Inside my animation blueprint I get this pose and feed it into Blend Poses node.
Right now I have the tag replicated and was hoping that because the tag gets set (on the server), it would replicate and update the pose, however that is not the case. It works correctly if I replicate the CurrentPose however I don't see why I need to if I can determine the pose based on the tag. Anyone see anything wrong here?
Cat what are you trying to do?
rep_notify
on the actor itself? when i do that it doesnt replicate all the time because the object is server owned I believe
if the object is server owned this is a good news, you can call replicate the changes to all client by updating the value of some variable using onrep
Just a normal replicated property would do. OnRep/ReplicatedUsing is for if you also need a function to be called when the property is changed as a result of replication.
what if the call is being made from the client's object?
clients don't have the ability to replicate things
only server can do
I understand but what would be a good way around that, if I want the client to update something
Clients can only communicate to the server VIA RPC.
clients call an rpc
I just realized that I need something other than Player Controller to store resources (gold, wood etc) of my players. I basically have variable Player Number on everything that exists in the game, so everyone knows on which ''team/side'' they are, if that makes sense. Now, when the unit is gathering resource, the logic to increase resource amount, is on the Player Controller, but if I started to understand correctly, I don't really have a way to tell unit that this is his Player Controller, because they are not really possesed? I put photo so you can picture it my tries with that. It was somehow working sometimes, but I don't think it's gonna work perfectly on the cooked game. Or is there something that can help me actually differentiate which Player Controller the ''unit/worker" is aiming at, basically? Btw this is done with Task on behavior tree. The last photo I think it won't actually work if it will be hosted and not LAN, right?
so I would have to call an rpc on the character bp right? since rpcs cant be on the object itself
good idea it should be on character
if your other object is weapon, you should do that rpc in character since character will own that weapon
its a simple bed and when the player interacts I want to update a bool saying that this bed is occupied
but it just seems kinda hacky to store so many RPCs all on the character BP i thought there would be a better way
split your character in many parts
You'd make a generic RPC for interaction.
Like.... Press E > Determines whats actor is in front of the player > RPC to server the actor
Server > Verifies player can interact with that actor > calls an interface or utilizes an interaction component on the actor > actor does its thing
so Id be replicating the interaction rather than the actual bool directly in a way
Clients don't replicate.
Only the server does.
Clients can only RPC to the server. The server has to do the replication.
I came up with something like that, I'm not tripping? Will I be able to actually get all players controllers if I have listen server with 1 host?
You don't want to use the GetPlayerController X or GetPlayerCharacter X getters in multiplayer, they're not a reliable way to know which player/character is which.
also check this, you will get started with it quickly
https://github.com/eyupalemdar/InteractionSystem
For this you might consider using player state instead of player controller to hold this information.
I have a question. I have a variable (bool) that is replicated. I call a server RPC that sets it to true. In the OnRep, I print the value and I can see it changed to true. It prints on both clients and the server and it is correct. However, when I get the variable in the animation blueprint it is still showing as false.
Is there any other way to differentiate which Player Controller I'm aiming frm the unit, that isn't really possesing anything at or should I just move my logic to other place, and if yes, then which place is better to just have simple variable which tells what team I have. So like in short I can Loop trough all of these (if I have 3 players I have 3, if I have 5, I have 5 so the number is ==), and then ''aim'' at exactly this.
Needed to make sure I'm not tripping, I got it from one tutorial and it was fishy from the start
General rule of thumb, if it’s a value pertaining to a player (kills, gold, wood held) and you want potentially other players to see that value I’d use player state
Why does this work though? It's a bug when it's on the editor and it's not gonna work in the cooked build?
I read somewhere that this can only be used on LAN? because there you have Indexes of each player ++, but on listen server everyone is 0?
If you're getting the OnRep to fire, then it is definitely replicating. You're more than likely not retrieving the value correctly.
...no
So this would be ok way to differentiate which Player Controller I'm aiming at from the server?
I guess I can only do it because it's from the AI behavior tree task which is server
It's still not a great way to handle it. What happens if a player disconnects?
Haha right, controller dissapears and everything resets?
I set up a function to get the bool and I am calling it on the animation update
So I could use the same logic from this to check which Team Number Player State has, but I don't have to care about if I can call to there from the place I'm?
Just need to make sure before I dive into another hole xD
like this will make more sense than Player Controller to differentiate to which play I want to ''aim''.
Anything that you may need to use to determine player ownership is generally best handled by assigning it a playerstate variable.
You don't want to use GetPlayerState X either.
If this is in an AI, the AI itself can be assigned a PlayerState that owns it.
how does your blueprint ui look more modern? is that unreal 5.4?
Flat Nodes and electronic nodes plugins
Do you mean to just put Player Number variable in the Player State and this would be ok way to differentiate?
and this would be like base for everything the player owns
No. You don't use the numbers at all.
Dude! What is your plugin to have such beautiful nodes?
You use the reference to the playerstate directly. Your team ID can be a number, that's fine, but the playerstate is the thing that indicates who owns it.
Electronic Nodes + Flat Nodes
Like I can assign Player State to the unit in the blueprint ? Or I have to manually come up with something like Team ID on the Player State, put interface to get Team ID, and use it as a reference who is who?
My problem, how to tell Actor that isn't possesed or anything so he will know which Player State is his?
Like if he deposits resource he needs to know to which Player State right?
so I was thinking about checking if the Team ID on worker, is the same as on Player State
if yes, then ++ resource
@pallid mesa Pinned your blog post here^
You can assign the Pawn that is AI Controlled a variable of PlayerState.
When you spawn that AI, you can assign that variable the PlayerState of the player who is going to be "in control" of that AI. You now have a means to determine the Player that is control of that AI.
If you want to go a step further and have teams, then yes, you would implement a team variable on the PlayerState.
So then if you want to know in your tasks which player is in control, you'd get the pawn of the Ai Controller and read the PlayerState.
Okay, so to make 100% sure, we are just talking about some kind of consistent variable like Player Number on everything that the player owns?
This one I'm not sure about. you'd get the pawn of the Ai Controller and read the PlayerState.
How do I read PlayerState from the Pawn? Or are we talking about that variable and checking all Player States and matching the variable from the Pawn with the one from Playe State? Or i'm missing something?
Because now I have basically all that logic in the Player Controller, but as I said I'm not sure about using this method with calling number index to the player controller and if it's consistent in multiplayer.
NO. No numbers.
Team ID, that can be a number.
Who is in control of a pawn, should be a reference to the PlayerState itself.
You create a variable in your pawn class called "Controlling Player PlayerState"
Set its type to PlayerState. Assign it when you spawn it.
Target currently is Player Controller, and the only one pawn that player owns is Camera Pawn... since this is top down game with 1 camera pawn and lot's of units to be controlled. Should I asign that Controlling Player PlayerState to every unit I'm spawning?
its duplicated, already pinned
here.
Whats the difference if i run a function off of multicast or run on server when it comest to replication?
For example i was following a tutorial and the guy put stuff after run on server but it didnt work for me because my stuff was already after a multicast event if that makes sense
but it started working when i used multicast
on both client and server
so i pretty much solved it by running the function on the multicast event instead, can this cause problems later?
Yes
oh nvm then, somehow missed it
Yeah it's further down the list, oops
Run on server means it goes from owning client to the server, or just stays on server if already there. Multicast runs on everyone but only if called from the server
thanks for the intentions bm ur a sweetheart <3
It was working in 1 person mode aswell
Generally in solo you're still the server iirc
Run On Server is a means of having a client to call to the server on a replicated actor, but it only works in a few conditions:
- It's an actor that is replicated, the client is calling it and owns the actor they are calling it on.
- It's an actor that is replicated and the server is calling it - ownership doesn't matter.
- It's an actor that was spawned on the client which wouldn't be replicated - it would execute only on that client.
- It's an that is not replicated and the server is calling it - it would execute only on the server.
Multicasts are a means of sending an event to all players, but will only be received by clients if called on by the server.
The same logic applies. If it's an actor spawned on the client, it can still execute but only on that client. For replicated actors, it'll be sent to all clients that have the actor relevant when executed on the server, but non-replicated it'll only trigger on the server.
Does anyone know why the emitter location of my tracer particles doesn't update on the client when off the host's screen? Probably a simple setting I bet
Hmm, I'm doing logic for Spawning Units from the Player Controller to the Building, should I start with getting Player State from the Pawn I spawned and assign it to the Player Controller, so then from Player Controller I can send it further to everything (building,units etc.) and then I can just get PlayerState from anything and this will basically work?
nvm fixed it
Use the playerstate as it's something everyone can reference.
An example: Let's say you wanted to color your pawns based on the color chosen by a player.
You wouldn't want to have to replicate the color seperately on all the pawns if all you had to do is know the PlayerState so that you can read the color they picked - then you only have to replicate that color choice once rather than for each pawn.
If you made it so it references the PlayerController, then you can't do that as other clients can't read the PlayerController, and thus they can't know the PlayerState.
If you ever need to get the PlayerController, let's say on the server, you can read the PlayerController from the PlayerState itself.
or not...I alt tabbed then my camera went crazy and crashed the editor :L
since I have items spawned in the world I don't set the owner until player interaction. Is there a reason to set this back to null, say inventory is full?
like 'if' someone else comes along then they take ownership so it shouldn't be an issue generally
Do replicated variables go to owner only by default? Or whatever "None" is for the condition in blueprints.
Setting ownership still allows RPCs to be called on owned actors. If you have Run On Server calls on your items, the client could potentially still call it on those items even if they're not in their inventory if they have ownership of it.
ok, I'll clear it in the edge cases then
This is game changing. This makes me want to throw a lot of logic to the pawn from the controller and then player info on playerstate, but the starting point would be probably after spawning Pawn I would Get Player State and send it to the the playercontroller, so I can distribute it further if I'm handling ''controlling'' spawning logic here. I guess it won't kill it to have 1 more variable with Player State that I can use, right? So then I create Player State variable on everything(building, units) and connect it from the source (in case of Producing Unit which happens from Player Controller, to Unit on Spawn Actor).
Wait do I already have Get Player State in the Player Controller that I can send as reference to everything I'm spawning from player controller?
Yep
Player Controller has reference to its PlayerState and Controlled Pawn.
Pawn has reference its its possessed controller and PlayerState.
PlayerState has reference to its Controller and Pawn.
Can you just help me with 1 example. This is my starting point for the spawning Building and Units for every player.
Should I set Owner as player state?
You can, sure.
or should I create variable Player State inside building and unit and expose it on spawn
The problem in doing that is that it's only an "Actor" reference, so then you have to cast it to PlayerState when you want to use it anyway.
ok, then it's not good
so it's better to create new variable and expose it? since I see that actually every actor has PlayerState inside self?
Setting ownership also exposes it to be available for RPCs from clients not sure if you want that or not.
Up to you. Casting isn't that expensive, but setting the owner has additional things associated to it, like what I mentioned with the RPCs.
It may be wise to use the PlayerState in owner, as then if you have variables that only need to be replicated to the owner or everyone but the owner you can do that.
If you want to call client RPCs to the owning client then you can do that too.
Ok, this is a little complicated so I think safer way would be just to create Player State as variable everyhere and set it on spawn
so in case of building as it's only actor I can create PlayerState and expose it on spawn, but in case of Character which is Pawn already, it has PlayerState built in, but I cannot expose it on spawn
so I just have so create universal variable like PlayerState Something
right?
So first set Player State from Player Controller in the building
and then I can send it further from building to the unit for example? Sorry for stupid questions but I want to make sure now I get it on this one example
Hey, i've got a power up that when picked up should be hidden with collision disabled for one client, not all so that they can still pick it up, how can i do this?
Is it common or bad to replicate an entire actor component? I am looking at a project that does that.
UPROPERTY(ReplicatedUsing = OnRep_CurrentMyComponent)
TObjectPtr<UMyComponent> CurrentMyComponent;
UFUNCTION()
void CurrentMyComponent();
It wouldn't make much sense if it's already attached to the actor, but if it is attached at runtime, then it can make sense to replicate the reference, though there are other ways of getting its reference without replicating it.
What would be a different way
GetComponentByClass
hmm ok.
Do you know of any good documentation on how simulated proxies and server code work together? I am interested in reading more about how replicated variables, OnRep, RPCs, etc all work in relation to the different roles.
How you would do this is:
-each client has to have knowledge of which player(s) are and are not allowed to see/interact with the pickup. Typically the go to way is to use the unique net id from the playerstate to refer to specific players that can or cannot pick up/see the item
-the item could consider itself disabled when it arrives on scene until it has a vetted list of who can/cannot interact with/see it. If you imprinted that player info onto the item on the server, then let it replicate down to the client's version of the item, the item can know what to do once that info arrives: Either stay deactivated, or activate itself - based on who the local client's player is and whether they are on the 'cannot interact/see' list that arrived. Does that make sense?
This follows common networking practive of initiating the critical info of who can/can't interact/see the item on the server so they have full authority over the situation. I'm assuming you already know the basics of replication and OnRep - but if not, let me know. 🙂
wow, thanks
There's a lot of resources for this online - epics documentation on this is pretty decent.
But here are some high level points of interest:
-replication:
-a passive form of networking
-can be slower to network than RPCs
-more friendly on net performance than RPCs
-more resistant to player-joined-in-progress-match bugs
-great for networking states
-always flows from server to clients
-RPCs:
-an active form of networking
-typically faster to arrive than replication
-can be 'reliable' or 'unreliable' (whether it is guaranteed to eventually arrive or not) which also can affect timing and perf cost
-great for networking events (replication can networking 'events' too but it's not as intuitive to do so)
-can flow from server to clients, server to one specific client, or from one specific client to server (this gets into 'autonomous proxies')
Cont'd
OnRep:
-refers to a special function that is called when a specific item replicates
-generally named as 'OnRep_MyVariableName'
-only needed if you need to run specific code when your item has actually replicated to client
-this fn is automatically called by the engine when the item replicates
-it is common to call this fn yourself on the behalf of the server right after you change something about the replicated variable so that the server and client are running the same code (since the engine will not call the OnRep_ fn on server for you).
-requires you to use the meta word ReplicatedUsing instead of Replicated on the UPROPERTY that is replicating.
-you can actually add a param to the OnRep function that matches the type of the replicated var, and the engine will fill it out for you with the previous value before it was replicated - this can be super handy! Typically, we name that param, when we are using that pattern like so: PreviousMyReplicatedVariable for clarity.
Caveats:
-if you change a replicated variable more than once in a single frame, only the most recent change will replicate over in terms of receiving your OnRep call. In fact, since replication can actually be postponed for a frame or more depending on what's going on with your net-load, it can even miss changes that were the only change in the given frame if it decided not to send that frame - assuming you made a change after that change (which is replicated instead). Basically, when the engine decides to replicate one of your items marked for replication, it will either send the latest version of that thing, or will wait to send it (for some reason I won't get into here). If it does not send it this frame, it may decide to send it next frame - the most recent version of it - which may now be different.
No prob! I've done this approach on a multiplayer game before and it worked rather well. If you mark the player info on the item right as it spawns, you should be able to just make that info use the replicated initial only condition so it doesnt keep looking to see if it needs to replicate that info. In that case, the replicated info should arrive on client right when it gets its BeginPlay call
cool, this is my first multiplayer game so i'll try my best to get it done 👍
Cont'd
Simulated Proxy:
- a proxy that is simulated on a client connection to represent what some other player or what the server is doing. i.e. the actions you see it making were originally performed on a machine that is not yours.
Proxy:
-just means 'a thing that is only a representation of the original' <- this is important to understand what Epic means here by the word 'Proxy' because it's never really explained clearly and it can be confusing otherwise.
Autonomous Proxy:
-a proxy that is being controlled by a local player, not on a hosting server, but on a client.
Server (as a net role):
-a thing that is the original. May be controlled by the server (in which case, the roles of any replicated versions of this thing would be considered simulated proxies), or the server may lend control of the thing to a single player (in which case, the role of the replicated version of the thing on that player's client would be Autonomous Proxy and the role of that thing on all other client's machines would be 'Simulated Proxy')
Local Net Role:
-this is also just referred to as Net Role or Role since this is what we are usually talking about when we talk about net roles
-refers to 'what my net role is, on this machine'
Remote Net Role:
-refers to 'what my net role is, on the other machine' where 'other' is a client machine if you are the server, and the server if you are a client.
-if you are on the server, the remote role of anything replicated should either be Simulated Proxy if none of the client's the thing is replicated to is a player that is controlling that thing, or Autonomous Proxy if one of the clients the thing is replicated it is a player controlling that thing.
-if you are on the client, the remote role of anything that has replicated down from the server will be Server.
idk lmao, it was the bullet class from the engine default first person character
you are trying to doing replicating of bullet class in your first per shooter game or what?
is it better to use RPCs server -> Multicast or directly a rep notify function in terms of broadcasting changes to all clients in a dedicated server session ?
Should be index 0 in the array
What does "My Copy" here mean?
You usally work with relative references in that case. And it depends on what part of your game wants to know about the Controller on the Server.
E.g. a possessed Pawn can just do GetController on the Server.
Or a the PlayerState can do GetOwner->CastToController.
If other Actors that you coded need a concept of "my controller", then you might want to set a Controller Variable on it when Spawning or it similar and use that.
I don't think you can just say "my copy of the controller" on the Server at any given time, cause the Server wouldn't know who "my" is.
Can someone good on EAC tell me pls?
#epic-online-services message
Hi,
Is it possible to run a dedicated server and client on same PC using steam?
I got his error:
Warning: STEAM: Failed to initialize Steam, this could be due to a Steam server and client running on the same machine. Try running with -NOSTEAM on the cmdline to disable.
which seems to imply not. But that would be lame.
I don’t believe so. The only way I know around it is run one of them inside a VM
ah ok thx. That sure makes dev painful.
Must I run the steam client for running a dedicated server?
Would I need 2 different accounts?
Only for testing “steam”. You can test multiplayer locally as dedicated and client.
yeah I've been using the null online system until now and happily running a dedi and many clients on a PC. But now I want to get steam working.
It is possible.
I don't know why you get that warning, but I am able to.
Like Afrayedknot suggested, you could run the server in a VM as a workaround.
I can try to help with the setup, but I have no idea why you got the warning.
I guess the warning implies there could be a different reason that it fails to initialize Steam.
If I turn off the client then the dedi does manage to init Steam.
Are you using multiple steam accounts?
Is it a good idea to rep notify results from hit events ? Because the server and client side always return different values
What is this used for?
If not shooting then just decide who's hit result do you wanna take. The client side or the server one.
I have a procedural mesh which changes shape upon hit, and many times it shows slightly different results on both clients , and when logging into the server session with clients no changes are shown on the mesh. Plus if you ask me I would want to take the server results
the thing is - even if you could kinda get it working - are you going to trust it? i.e. you start having issues - is that because you are running together? Or is it a "real" problem?
What if it works 'together' but not when seperated.
Why not just pay $10 to host it on a cloud VM for a few weeks.
Otherwise I feel you might as well just be testing the null connection and just doing MP testing
It sounds like you are doing trace on multiple machines and hoping they will give the same result?
U won't get same result because of latency
What I see in my world is not gonna be the same as your world
im testing on the same machine
So are u doing traces in multiple machine hoping for the same hit result?
Because that's not gonna work
so whats your solution, should I fire first on server authority then multicast everything?
Just one.
Depends on which data u want to take
Well I may want to use all manner of steam functionality. If I can test multiplayer with a single click like I do now, that makes a huge difference to developing and testing functionality.
I would probably just listen to client hit data and replicate the change according to the client data
why does the on component begin overlap activate when im not even overlaping
why client ?
I've never had any issues when testing separate accounts/machines from a single one. The processes are separated after all, just low latency.
Separate dedi and client running on same PC through steam and connecting with sessions?
If u want to interact with a door, and you actually hit the door in your world. Don't you want the door to open?
What if in server which is behind when the trace happens, the hit trace doesn't hit the door?
You will end up not opening the door despite interacting with it
Really up to your design how you want it to play out
Ah that could be it. I am using standard plugins.
Thanks, will investigate that.
Ah
If u only care what the server sees then go ahead, but the cons is there.
Cool
Print string the hit comp and the hit actor
U will find out what it overlaps with
what?
no
listen
i got a capsule on the ai
and i got on component begin overlap, print string
and it prints when im not even in the capsule
and what about clients who log in who dont see the result, i would need to rep notify everything?
What result
change of the procedural mesh which was caused by the hit
I am not familiar with procedural mesh
How you actually do the change? If it can be translated to a replicated variable then do that
All clients need to do is update the change from the server
Print string the hit actor and the hit comp to find out what triggers it..
Again print string the hit comp and the hit actor so u know what activate your begin overlap. But you are being very combative and rude, I'm not gonna help anymore
bro i dont get it
pretty sure something wont be right here
Idc anymore
probably that means hook the hit component to the print string?
If you want to follow server, have you make sure to just trace on the server?
It probably won't show up as where you hit as client tho imo
There’s no particular trace being done like a line or sphere trace, all that is happening is that it gets the info of the hit location from the hit component event
Because there is delay. Imagine shooting a trace from your character forward for your location.
If your latency is 100 ms, 1 second later, the server machine will shoot a ray from the character instance in the server forward. It won't yield the same result
Are you trying to deform your vehicle?
Yes correct
It takes the hit location results, inverses the direction of hit then loops through all vertices in the procedural mesh
So there’s no line or sphere trace being done
What I would probably do is deform the vehicle locally. Then notify the server about where to deform using server rpc.
Then server can notify clients to deform the copy of the vehicle that get damaged in their world and apply the deform effect
So if it were me, I will just check if the on hit in my own machine, and if it's locally controlled
So basically on the component hit event use client authority first to gather all info of the hit, then pass that to a server rpc then multicast ? Or rep notify ?
Anything that needs to be in sync shouldn't go to multicast
You either use repnotify, or replicated. If you need a function to run when something changes, use repnotify.
But assuming your car can get deformed multiple times
Yeah multiple times
On its sided etc. I don't think a single hit on rep will cut it
Late joiners will just deform the latest value
And for that rep notify will need to be used
Sure but that's not gonna help with your multiple deformation problem
Because that’s the job of rep notify am I right ? It notifies incoming clients
You will need an array that contain the list of deformed data
Hmmm I don't see the Advanced Sessions plugin in the list. I'm using 5.4.1
I have all that function of storing array of vertices etc
On client -> vehicle collide-> add deformed data to array -> apply deformation to vehicle.
Send server rpc that updates the array.
Server replicate the array to clients.
Client on rep the array, make the deformation based on the incoming data
That's my 2 cent but I'm beginner in mp.
Probably make sure to mark the array to skip owner
Why do we need to skip owner ? It means the owning client ?
U wouldn't need to apply any collision to your own vehicle from the server.
All of this goes without validation btw, I am not in a stage where I care about cheating
Neither do I , it’s not a shooting projectile it’s just visuals
Are you using cpp? You can get the old values in OnRep function if you do
OnRep, I would just check the length of the array from the old array with the new incoming array.
For loop, apply the deformation starting from the index (new array num - old array num)
no cpp at all, infact i need to learn some of it so i can create a for each loop for the deformation since in blueprints it kills the framerate for a sec
this is where the loop takes place
do you say I should replicate the vertices array variables?
as in set them to rpelicate
No comment on your system, I have no clue. I only give opinions of how I would send data as the player that collide and send the info I have to apply deformation in my machine and also in the server, which the server ultimately send to all clients and make deformation based on the incoming data
yeah I got you
I never understood the difference in using - is locally controlled vs using client side authority form the switch has authority
Switch has authority is checking if the machine have authority over the actor or not.
Normally authority is server unless, you spawn an actor locally, then even if you are the client. You still have authority over that actor.
Locally controlled is to check if you locally controlled the actor or not.
For example, there are 4 players. And there is a function that print hello string if that actor is locally controlled.
Only the actor that you own (eg. Your player character) will print string. The rest 3 characters which are controlled by other players (simulated proxies) are nor going to print string because you don't locally control those characters
ok understanding this slowly..
so like you had mentioned deforming the vehicle after the is locally controlled check will only deform the vehicle on my side and the result will only be visible to me?
When I think about it, it's kinda a bit more complicated. Was thingking that for deformation to be responsive, you might want to deform locally without caring about network.
Is your game gonna have late joiners?
I also wanted to let you know I am doing the replication tests on 2 clients directly where the dedicated server instance is running in the background, not the traditional 1 window is the server and the other client
yes
late joiners is more of a problem lol
because the server instance is like that of rust or dayz
Well that's gonna be harder to solve then 😕, I am also newbie in mp.
Prob got nothing else to suggest other than above. And even then, you might encounter problem where deformation is not responsive (the deformation doesn't happend right away at the time of collusion for vehicles you don't own)
Hard to say when I'm not doing the same thing as what you are trying to do.
you dont sound like a newbie though lol but yeah understandable
I am newbie, but there are multiple wise people in this channel. Not the liveliest channel but hopefully someone else can give an insight
Hi all, I'm making my first multiplayer game, I got it all set up so that when I launch it's detected by Steam, however when I get a friend to launch it Steam doesn't detect their version and we can't find each other's servers in game
not sure if I'm missing something very obvious but any help would be greatly appreciated
Does someone have an idea what I'm missing here? The GameMode should contain the rules of the game, but I have a widget on an client that should display some buttons depending on those game rules. The client can't access the GameMode, so how would the widget know what to do? The rules are in form of a DataTable and don't change during gameplay, so moving them to the GameState doesn't seem right.
I noticed some things dont work as intented when playing as "Client". Is that normal?
it works perfectly on standalone or if i check play as listen server
Try to consider the GameMode more as a place you do logic that is only on the server. GameState is what you're looking for here.
Consider something like a deathmatch setup. You have two teams, multiple players on each time, and a score for each side.
GameMode would bind events to something like a player's death, to update the correct team's score in the GameState. GameMode manages the functionality of doing the updates. GameState holds the values for that so that both server and client can access them.
Multiplayer is all about "Trying" to replicate similar experience across different game instances.
How you send data across the network and how you receive them is for you to design.
Things don't magically be in-sync. It is your job to make the experience seamless by sending data from one machine to another
So by design, you will need to determine, what code runs in the server, what code runs in the client.
Ok, so despite it being called state, it can also contain important information for all clients. Of course the GameMode then still needs to make sure the clients actually follow those. I guess then I'll just do it like that, thanks!
do i need to test playing "as the client" or "as a listen server" ?
for me to determine if it works in mulitplayer or nah?
depends, do you want to play as a client (meaning you will connect to dedicated server) or do you want to play as a listen server
unreal use Server - Client model
your game should work wether you are playing as listen server or as client
if it doesn't then, well you need to check your code
but if you select "play as listen server" it tells you that the editor will act as both the client and a server
so whats the differnece between that and play as client?
yes because listen server also playing the game
Play as Client = you are connected to dedicated server and that will be the server
Play as Listen server = There is no dedicated server, you are the server but you are also a client because you are playing the game
Think of listen server as a player that host the game
how does stuff work on listen server but not on client then?
it does work if i play on listen server tho?
This is the series I followed to set up multiplayer, explains the extra steps you need to take to set up things in multiplayer
https://youtube.com/playlist?list=PLNb7FZ2Nw2HTBgWggHGaMtHAOygKcXIyW&si=br_E55YwS7tlXYMt
because the code probably run on server
and u don't have it run on the client machine
and no one can tell if you don't even describe what is wrong
can't just say stuff
Have you checked if you added your input mapping context?
becareful with begin play in multiplayer btw
what to check here?
Well. One might also say that important information is state.
beginplay -> sequence -> this
I dont understand
BeginPlay can be too early in multiplayer context
Shouldn't add input mappings in the pawn, honestly.
You need to make sure that the character is possesed before doing this
welcome to multiplayer, read the compedium before going further.
Adding input mappings in the pawn is just not a good idea in a lot of cases.
An InputMapping is a frame that says "This game style needs these inputs."
So you have a game that allows you to run around as a character, drive a car, fly a plane and drive a boat. Four very distinct sets of controls that might need to be remapped differently based on player.
There is no point to adding and removing these based on what pawn you are using atm. Cause you can just add all four of these at the player controller's beginplay, and still only the possessed pawn gets the inputs.
Input Mapping Contexts simply say that you "can" use these inputs if they're on an input enabled actor at the moment. Input enabled actors by default are level blueprints, player controller, possessed pawn.
TLDR, move this to your player controller's beginplay and it'll run fine.
I see, that make sense
had mine on OnAcknowledgePossession, wasn't thingking about other actors that I can play as, but to make it scaleable I will do that too
wheres my player controllers's beignplay?
Do you have a player controller?
Do you have a GameMode?
yes "ThirdPersonGameMode"
Open it and look at the class specified as Player Controller.
and look for Player Controller in the same World Settings
Make a new blueprint derived from player controller. Then set that newly created Player controller in World settings.
Is allowing Client Side Navigation safe for movement stabilization and maybe cheating? Without checking this, my character cannot move in Top Down Template
You are already the controller, you can just pull the node self
multiplayer is too early for you btw
I just started doing most of mine on PlayerController beginplay because it's the same as Lyra's experience stuff mostly. Each "Mode" has a set of controls to apply. And they just apply them early on and leave them.
I do have some specialized ones like for building where I push a context mapping temporarily with an activated widget, also removes itself when the widget is removed etc. So that the building controls can override the pawn's controls temporarily. But for most things you can just plaster them up early and never touch them.
this is your first week in Unreal level
self wont appear
btw i just realized it was already casting to player controller why would i need to do all this?
isnt it essentially the same?
you don't need to cast
you are inside player controller
the logic u copied is from the pawn/character
hence the need to cast and get a ref to the controller
this is what was originally inside the player controller
so whats the point of "moving this to my player controller's beginplay" as @kindred widget suggested
Some initialization of pawn happens before gamestate is ready to call beginplay. So this works sometimes at very start of game.
Other times. The following happens.
You Spawn Pawn
Beginplay Runs at the end of spawning.
Possess is called.
You had no controller at beginplay.
Ok, so what should i do if i want looking up and down being replicated on client?
For animations?
No, just looking
Input got nothing to do with replication
then why are we talking about this
Look input isn't replicated. It's local authority.
The topic before will save you from input issues later.
yeah, nothing to do with replication
The look input might be different. What is your look settings? Camera on a spring arm, or?
What are your inputs in the pawn for looking? AddControllerPitch/YawInput?
Oh. Yeah this is animation stuff.
There is a thing called a 1D Aim Offset. You can also use the 2D AimOffsets. Same thing largely. But the 1D is easiest for simple shooters. You give the pitch of it via GetBaseAimRotation in the animgraph.
basically I'm spawning a bullet from a server RPC and it should spawn for all clients and server but it doesn't
I have a multicast rpc that sets item meshes for armor on clients and servers, when this is called mid game is works perfectly fine and clients are able to see the server equip the armor. The problem is when clients join they can't see armor the server is already wearing
You shouldn't be using RPCs for stateful things. The armor was equipped. This is state. A set of data that was set to replicate. OnRep that equipment and fix up the visuals whenever equipment replicates.
not sure what i'd put in an OnRep function
What did you put in the multicast?
ArmorMesh->SetSkeketalMesh(Mesh);
#multiplayer message
I switched the ID to the dev ID (480) and that got my friends game to show up on steam, still can't find each others servers though. Any help would be greatly appreciated.
Is there any reason why this doesnt work? I couldnt get it
I cant rotate the character while playing as client, no matter what i do
Character and movement is replicated
I have the following setup to get the rotation and forward vector of the camera of the player that spawned this weapon BP to check the bullet path. Now the issue I am having is, I can't seem to find a way how to get the player camera manager in a way that it works with replication and not with this index 0 node. If I cast to the player controller in beginplay after checking if it's local then the others wouldn't have access to that nevertheless. Maybe I have a wrong idea in mind but I need the rotation of the player camera manager for it to include camera shakes as well
If your character has a camera, you can use the camera's world rotation instead of using the Get Player Camera Manager
Which blueprint is this, character?
this didn't work btw. Doesn't include camera shakes
Yes, you can use Get Owner(dont forget to set Owner first) and access camera like this
Oh
You're right, shakes don't affect camera rotation
owning pc is the player controller that owns this character
Try Get Owner > Get Owner > Cast To Player Controller > Get Camera Manager
I guess thee Get owner twice was a typo?
No. First one is owner of weapon( character ), second one is owner of character ( controller )
You should call get owner two times if its weapon blueprint
ah yea my bad
I assume I should do this once in begin play of the weapon BP and not for each bullet being shot xD
Try this 
I tried this and it works locally but when the ai bots shoot It shows me "accessed none trying to read property Player Camera Manager"
maybe because it's bots they prob return false for the cast to playercontroller on their side?
Yes because AIs dont have player camera manager
They dont have player controller, therefore no camera manager
would that work for other players though. As far as I know every player can only access their own player controller and thus player camera manager
what BP are you in?
Do you ask for my question or my answer?
For my rotation problem, it's in my character blueprint.
okk thx
In rep notifies, setting “skip owner” skips all changes to only the owning client ?
also try this:
void AMasterActor::SpawnBulletServer_Implementation()
{
auto SpawnBulletLambda = [this]() {
FActorSpawnParameters SpawnParams;
SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
SpawnParams.bNoCollisionFail = true;
SpawnParams.bDeferConstruction = false;
SpawnParams.Owner = this;
AYourBullet* Bullet = GetWorld()->SpawnActor<AYourBullet>(BulletClass, SpawnLocation, SpawnRotation, SpawnParams);
Bullet->SetReplicates(true);
Bullet->SetRemoteRole(ROLE_SimulatedProxy);
};
for (FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
{
APlayerController* PlayerController = Iterator->Get();
PlayerController->ClientSpawnBulletRPC.BindLambda(SpawnBulletLambda);
PlayerController->ClientSpawnBulletRPC();
}
}