#multiplayer
1 messages · Page 202 of 1
the client disconnects automatically , when joining from windows build but not happening when joining from editor
happening after 10-15 seconds
when you build your project from the source engine for a dedicated server build, can you still use the editor the same way and make changes to the project with this new source engine as the engine version?
I have a signIn level which is loaded on game start. When sign in is success, it uses open level function to open the mainmenu level. I m using AWS GameLift. When i use my command to connect to the server map from mainmenu level, the input is disabled, but if I use my command to connect to server map from the signin level, everything works fine. I m unsure as to maybe the problem is using the open level node? Both signin level and mainmenu uses the same gamemode. Can anyone help?
I'm running into an issue where anim notifies on replicated enemies do not trigger if the host is far away from them (it triggers for clients but not the host). The enemies are still replicated (always relevant) and can move, but no longer receive the anim notifies like usual. As soon as the host moves closer everything starts working again. Is there some kind of net relevancy distance for anim notifies? (UE 4.27)
Edit: Found the setting on the mesh: "Visibility Based Anim Tick Option"
so, by changing the pawn actor rotation doesn't change the actual viewing direction when client possess the pawn again?
say, I put pawn into a car after unpossess, client then possess the car. When client exit the car, I turn the pawn away from car's door and then unpossess car and then possess the pawn.
but somehow the client still facing toward the car. If I do this on the listening serve window then it works fine btw.
I did try run the SetControlRotation on the server side player controller, but got the same result.
What's the actual criteria for which actors can be passed in an RPC param? What happens if, say, you target a non-replicated actor that is known to exist on both the server and client, like a map trigger
is the correct way to set a RepNotify blueprint variable with a reliable RPC?
ok, but to set the value on the server it has to be done with a server reliable rpc right?
you could checkout VR Expansion plugin. The vr character in the plugin is setup to replicate out of the box
Hi folks,
I would like to have an actor mode that is not replicated, but multiple children that are in a multiplayer session. The intent is that each player can move this parent independently, but the children are synced relative to the parent for each player.
Is this possible without recreating “replicate movement” myself to use a non-world origin?
Thanks! I’m fairly new to Unreal engine.
(Copied from my Reddit post when the bot suggested I come here 🙂 )
So you want to replicate some actors without using unreal engines built in replication system?
I’m hoping to use the built in replication system. If I understand right though, “replicate movement” will replicate things relative to the world, rather than relative to the actor parent. That’s what I’m hoping to switch
It’s an XR application, and a similar use case would be if each player had a handheld 3d map they can move sub-actors on, with each other player having the map contents synced but moving the map itself independently
This isnt replicateing right what could I do to make it work better?
a lot, in the nicest way possible
Client>Server>Multicast for an interaction thats going to then call interact locally for each is bad, what happens if your client is lagging and on client B his view isnt facing the thing so the interaction fails but on client A it worked?
It's possible ye, all you need to do is turn off replicate movement and use your own movement system. If you're using character movement component then you might have other problems
Character movement component is replicated and is super mega hard coded to work a specific way
So much so that I look for every opportunity to not use it
I'm using forces to handle movement for my game .. but the movement is very stuttery .. is there any resource I could start with to learn how to deal with this ? My assumption is that this has smth to do with prediction but I don't know where to start
now on client side the Multicast Hello is not printing , is there aything wronf in this blueprint
on button click
it is multi-casting fine , when clicking the button on host side , but on client side , it is not sending call to server
sounds like that actor isn't owned by the client's PlayerController
so you mean on spawning i need to assign owner ship of the play controller at index 0
you need to assign ownership but dont use player controller at index 0 node, since if its a listen server, that will actually be the server hosts player client
or if its a dedicated server it will be the first player that joins
In C++ Unreal Engine: By default, a non-RPC function already gets called in the Server. If inside that function a Server RPC is called, will the logic inside that Server RPC be affected by network delay, or will it be instantaneous since the non-RPC function was already called in the Server-side?
Based on my testing inside the editor, they seem to be the same and unaffected if I set the testing ping high, like instantaneous. However, I am unsure what's the behavior in an actual networked environment.
Anyone can shed some light on this?
Thank you very much.
a server calling a server RPC will be instant, like a normal function
float AFirstPersonCharacter::TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{
Health -= DamageAmount;
ClientUpdateHealth(this, Health);
}
This function is getting called on server and I am calling the client to change the health variable for client too, so i wanted to ask if this is the way how we do it? also i have marked health to replicated and this function
void AFirstPersonCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps)
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AFirstPersonCharacter, Health);
}```
@tardy fossil i m new to this unreal , multiplayer , can you share any good reference for this ownership and RPC related thing
Thanks for the clarification. I assume non-RPC function (called from Client) that also calls a Client RPC follows the same logic, such that it's instant as well?
Therefore, delay will only exist if it's non-RPC function (called from Client) that calls Server RPC. Likewise, non-RPC function (called from Server) that calls Client RPC.
Is my understanding correct? Thank you.
having a client call a client rpc is not something i usually do, so im not 100% sure but i have no reason to think it'd be different than a server calling a server RPC since data doesn't actually need to be sent over the network
https://www.youtube.com/watch?v=JOJP0CvpB8w a bit of an oldie but still relevant
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
is ClientUpdateHealth a rpc so the clients can do something when the Health value changes? if thats the case i'd just use a OnRep.. like a UPROPERTY(ReplicatedUsing = ClientUpdateHealth) above your Health variable
and make ClientUpdateHealth a class member function so you dont need to pass a "this" pointer or the health value
ou
doesn't work smh?
wait if i don't pass the health value then how it will be set?
its working now
Hi, I would like you to help me solve a bug in my game made with Unreal Engine 5. I declared a variable inside my GameState, which I retrieve and display in a widget, but the bug is that on the server the correct value is displayed, whereas on the client it repeatedly shows the value 0
you need to replicate the variable
i've done it but it doesnt work
well actually show your work
Do yo know what would be the best way of doing it and if so can you tell me?
Hi,
I'm using forces to handle movement for my game .. but the movement is very stuttery .. is there any resource I could start with to learn how to deal with this ? My assumption is that this has smth to do with prediction but I don't know where to start about that if you could guide me towards smth
Question about replication and inventory: how to properly spawn a character's weapon in hand in multiplayer?
(Listen server, ping 30-60)
I think you need to spawn from the host, and then make a multicast to everyone except the hostfor the same thing.
Because if you repeat the logic on the server, duplicate weapons will be spawned
In my inventory structure, there is a reference to the spawned weapon, so this creates some difficulties
or convince me that it is very difficult and unnecessary to do predications on the inventory))0
Why not just spawn replicated actor and attach?
Spawn replicated in advance and show/hide as appropriate is best way to predict this on clients.
You'll probably end up with weapon switching animation anyway which will likely hide the spawn delay anyway.
I think there's further specific options inside the character movement component for predicting physics beyond default if you're trying to make it physics movements. I've never messed with them but I never use force to move either.
Thx for answering my question, actually using an RPC to add the force seems to make things work as intended .. I just noticed very recently that the server never got the information which is why it was correcting the player back to the original position constantly.
With InputVector .. the RPC is handled by unreal
I'll also look for the options you mentioned, that should help me deal with better latency, thx !
Good luck I appreciate you physics movement people. Chaos vehicle movement is insane compared to my enhanced input component lol
If the GameMode only exists on the server, why are my PrintStrings in the GameMode displaying to the server and all clients?
Hey guys, i have An question does anybody know how to replicate horror engine (its na aseet) bcz i Heard that you can replicate IT but i tried by best and its kind of broken
Like player is allways sprinting and crouching doesnt slow down
I don't know what that is, but if it wasn't made with networking in mind then you'd basically be remaking it from scratch
Server lag, that why I want to predict it
Object will spawn in your hands not immediately
You can technically client side predict spawn the actor, it just needs to be stably named I’m pretty sure
Is multiplayer replication easier with C++?
not really
I don't think there's an easier or harder they both accomplish the same goal with the same amount of setup. The answer to this question will always be subjective though
perhaps you can ask a more specific question and we could tell you which choice might be better for what you're looking to do?
instead of ticking replicate movement its better to use repnotify to set the location of actors that are most of the time static right?
you could do that yeah
I'd take it a step further and also make the actor dormant if you don't think it's necessary to replicate them every frame
Difficulty of replication doesnt really change with BP or C++
BP has limited feature set when it comes to Replication
You are able to achieve more with C++
Replication is easier in a singleplayer 
Basic things like damage replication or replication of the characters abilities.
My game also uses a text-based communication system
What do you mean with more? Replication on a deeper level or simply more functions?
There are more features available to you in C++ than in BP when it comes to managing Replication.
Cool, what is one of those features for example?
PushModel is a good example
You miss out on stuff like FastArraySerializer
Thats just tip of the iceburg stuff
So in this case you mean Network Managers and Optimization?
actually, push model is one of the few "advanced" features supported in blueprint (it's automatic for blueprint set nodes if enabled).
The rest, yeah.
Any time you need any form of custom serialization, C++ is your only way. Need more control over how a property is sent, or to change the condition under which a property is sent? C++ only.
There are lots of stuff available to you in C++. No point listing them here.
The point is, C++ is much better for managing Replication.
Generally speaking, you want to build any multiplayer game with C++ (and BP)
Thank you very much
In blueprints, how do I determine is my game is running multiplayer or standalone? I'm writing a library that needs to support both mode and I just realized that I've been ignoring the standalone side and some stuff is not working right there
I see the Get Local Role node, but it's return value is undocumented. 😦
It just says "enum". Well dug, but what are the values and what do they mean?
This is in my UI code, for what it's worth. I don't want to create UI widgets on a server, obviously, so I need a check for either I am remote or I am standalone
Never mind I figured it out. I can do a HasAuthority or IsStandalone
maybe you can use the IsServer node
there is instance where Client can have Authority. E.g on the actors they spawn locally
Yes I know that clients can sometimes have authority. But since I am creating UI widgets they should only exist on the client anyway
I've got it working now
Hi,
I have some diagnostic variables that I want to replicate in development build but not in shipping.
I want to be able to netprofile without those variables.
What's the usual way?
To include them with UE_BUILD_DEVELOPMENT - but does netprofiler work with test build? Doesn't seem to work with shipping.
Or need I use DOREPLIFETIME_CONDITION with COND_Custom? Which would be less performant.
What do you guys do?
Thx
Found this:
#define USE_NETWORK_PROFILER !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
Is it logical to give actors as parameters to GameState events that would be broadcasted in multicast or onrep functions? There is a possibility that given actor is not relevant and received as null on some clients right? What's the best approach on design here to notifying all clients that a specific actor has gotten into an action, like notifying a door has opened by giving which door it is
If the actor isn't relevant why would they need to know about it? Any open state would just be a part of the actor itself. And if it were like a global message then I could be just that?
The best practices it to make it state based and not event based, that way when actors become relevant they get the latest state
I'm not asking for states or how to make the door look opened when they get relevant again though, I'm talking about events that would have specific cosmetic changes on the clients. Let's say I have 4 doors in game and 4 widgets that represent their status, whether they are open or not. Making them stored in a replicated array in gamestate
If the doors are not always relevant, listening to their OnRep event won't work when I'm distant to them. But it also doesn't feel logical to make them always relevant just because of this? If gamestate has a custom event that notifies a door is opened or closed, it'll still be null if door is not relevant.
So what would be the approach here? Or is this already some kind of a bad design? I'm not trying to solve a specific problem but rather discussing to learn how this kind of a partial relativity problems could be solved
You don't use RPCs/Multicasts for communicating state.
You can either mark the doors as always relevant and just replicate their variables as needed or use replicated variables on the GameState. The trouble with the latter is that you basically have to predefine the variables for specific doors and there's no good way to link a particular variable to a certain door on clients since the door wouldn't be replicated if it's not relevant, so it's slightly less scalable and a bit of a pain if you decide to add more doors later on.
Hi everyone! I have a physics based vehicle which I apply forces to to move. The server works exactly as I want it to, but the client seems to have more forces applied to it. My theory is that the client calls the force methods more frequently, but I dont know why.
Also it seems that delta time for the client is higher than the server, which is also a problem since I use timers dependent on delta time.
So using always relevant would be logical for this use case?
I'm bamboozled here. I have these functions for an inventory system and if this is on server this works perfectly, however if I'm on a client in BP it shows it calling the Storage ServerAddItem but when I put a breakpoint in C++ it never hits. It hits for adding the item to the player inventory, but the storage not. Only on clients tho.
It's just infinite items on clients only tho
I would change your calls here, honestly. Making scripters care about networking is bad form. You should have a simple AddItem. AddItem should internally call ServerAddItem. If this is a server instance it'll just work, if it's a client instance it'll RPC. that way your widget here simply calls AddItem and doesn't have complex logic switching.
That said. Also your client probably doesn't own the storage. So your PlayerInventory needs to be your gateway to affecting other inventories from a client.
I appreciate all that feedback I haven't done any of that yet it's worth changing it all to see
Just doing the first part of calling server inside the basic function and getting rid of the widget logic cleaned up a bunch wow that's a big step first
I wrote this inside the inventory component, I have a generic get inventory off any actor if they have one and the AddItem calls were redone to just call the RPC in itself if it's a client and it all works now. idk how this looks to you but this is what I got
It cut down the widget logic to this one function like this
Thank you for the help
Nice. 😄 Yeah makes for much easier UI handling too.
So it's an inventory component system that uses a TMap<FGameplayTag, int32> as an inventory tracker. I have a filter function that filters by tag through to the right data table, then breaks the tag name down to find data table row and returns that. In order to get the map across the network I break it down into a replicated struct of 2 arrays, TArray<FGameplayTag> and TArray<int32> and then when it calls OnRep, I send it back to my controller to filter by weight and match tags to inventory item definitions and reconstruct the map. Idk I made it without following a tutorial and it's GAS so I like it huzzah
You could easily set the door to be always relevant and just set it to be dormant and when you update its variable just forcenetupdate so all clients get the new value. This is a state thing, RPCs will end badly
RPC's also don't fire if a thing isn't relevant so you arent saving anything.
Please explain to me how replication is handled for the montage asset here. Is there some replicated TSoftObjectPtr<UAnimMontage>? I'm trying to convert this function to C++
I tried doing this:
.h:
`UPROPERTY(Replicated)
TSoftObjectPtr<UAnimMontage> CachedAnimMontage = nullptr;
void PlayAnimMontageMultiplayer(UAnimMontage* AnimMontage);
UFUNCTION(NetMulticast, Reliable)
void Multicast_PlayMontage();`
.cpp:
`void AMCharacter::PlayAnimMontageMultiplayer(UAnimMontage* AnimMontage)
{
CachedAnimMontage = AnimMontage;
Multicast_PlayMontage();
}
void AMCharacter::Multicast_PlayMontage_Implementation()
{
PlayAnimMontage(CachedAnimMontage.Get());
}`
But every time the first function call has CachedAnimMontage as null.
Probably because variable is replicated later than the function gets called. Every other call is fine, but I guess that's only because I'm using the same montage
A soft ptr would just network as a string
You'd have to load the asset
though this doesn't make a lot of sense
why is it relying on a multicast AND a replicated variable?
I need a parameter, montage is gonna be different
yes and multicasts can have parameters
Oh that's cool! I also need to call a server RPC playing the montage if an action was done on client side, does it also support parameters?
yes, I'm not sure where that idea came from because all RPC types support parameters in C++ and BP
must have missed the compedium
I dunno, probably from the void return type limitation
how do you connect return type and input param
In no way, this is just my false association
if you haven't stumble on the gold mine , here it is
#multiplayer message
and this one too https://wizardcell.com/unreal/multiplayer-tips-and-tricks/
nice, thanks
Damn wizard pretenders!
I'm using the ThirdPersonTemplate project. When I open 2 editors with netmod ListenServer, the server and client can move their characters just fine. But if I open two netmod StandAlone instances, setup a listen server, and then connect the client, only the Host can move their character. The connected client's character stutter-steps and moves 1cm at a time. Why would this happen?
Ah I figured it out. Because the template project doesn't have RPCs to move, you have to enable client side movement in the project settings
Would anyone happen to be aware if there are issues replicating Instanced UObjects in packaged builds?
EG this. It of course seems to exist on the client because it should be created when the owning actor is created. But it isn't replicating it's internal properties. But this works fine in PIE and Standalone. It only breaks in a packaged game.
TObjectPtr<UMyThingType> MyThing = nullptr;```
Is it, though? Is this on an actor? An asset? Is that object properly added to the subobject replication list (or the legacy subobject replication function)?
Seems more likely that in the editor you're not actually replicating it, you're modifying the exact same object in memory in single-process mode.
"PIE and Standalone"
That's a fair question about the replicated subobject list.
I mean it is added in PostInitializeComponents. But I guess I need to double check that in packaged.
Does anyone have a clue why I can't connect to a server in PIE (after 5.4) upgrade. Working fine in builds but tring to connect in PIE, I get this error and the client disconnects:
[2024.07.31-18.43.10:537][409]LogNetTraffic: VeryVerbose: SetChannelActor: ChIndex: 5, Actor: BP_Locke_C /Game/Wildcard/Maps/Arenas/FrostBurn/UEDPIE_1_FrostBurn.FrostBurn:PersistentLevel.BP_Locke_C_0, NetGUID: 22
[2024.07.31-18.43.10:537][409]LogNetTraffic: CreateReplicator - creating new replicator for (0x00000481B6BED800) BP_Locke_C_0 - Replicator (0x00000481BA55FDC0)
[2024.07.31-18.43.10:537][409]LogOutputDevice: Warning:
Script Stack (0 frames) :
[2024.07.31-18.43.10:538][409]LogOutputDevice: Error: Ensure condition failed: false [File:D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Serialization\BitReader.cpp] [Line: 276]
FBitReader::SetOverflowed() called! (ReadLen: 100, Remaining: 43, Max: 264)
[2024.07.31-18.43.10:538][409]LogStats: FDebug::EnsureFailed - 0.000 s
[2024.07.31-18.43.28:905][409]LogNet: Error: ReadFieldHeaderAndPayload: Error reading payload. Object: BP_Locke_C /Game/Wildcard/Maps/Arenas/FrostBurn/UEDPIE_1_FrostBurn.FrostBurn:PersistentLevel.BP_Locke_C_0, OutField: bReplicateMovement
[2024.07.31-18.43.28:905][409]LogNetTraffic: CreateReplicator - creating new replicator for (0x00000481B3A52800) CharMoveComp - Replicator (0x00000481BA55FCE0)
[2024.07.31-18.43.28:906][409]LogNetTraffic: CreateReplicator - creating new replicator for (0x00000481B3A51400) CharacterMesh0 - Replicator (0x00000481BA55AC60)
[2024.07.31-18.43.28:906][409]LogNetTraffic: CreateReplicator - creating new replicator for (0x00000481BCD81880) MyForceFeedback - Replicator (0x00000481BA55B6E0)
[2024.07.31-18.43.28:906][409]LogNetTraffic: CreateReplicator - creating new replicator for (0x00000481BCBC9300) MeleeBox - Replicator (0x00000481BA55B980)
well what is this actor doing
and is like every component marked as replicated too?
even when it makes no sense to?
This is on connect when I'm spawning the character. The weird thing is it says it has too much data for bReplicateMovement.
Well, not login but after server travel from lobby to the map
Im getting strange issue in 5.4 where players (mostly on poor hardware/connections) never get any replication updates after a seamless travel. They are spawned in, but frozen in place. Their VOIP works though.
The only thing i have to go off of is that the log gets spammed with:
LogNetTraffic: Error: UActorChannel::ProcessBunch: New actor channel received non-open packet. bOpen: 0, bClose: 0, bReliable: 0, bPartial: 0, bPartialInitial: 0, bPartialFinal: 0, ChName: Actor, ChIndex: 7, Closing: 0, OpenedLocally: 0, OpenAcked: 1, NetGUID: 0
This is being logged in DataChannel.cpp, line 3116.
FReplicationFlags RepFlags;
// ------------------------------------------------------------
// Initialize client if first time through.
// ------------------------------------------------------------
bool bSpawnedNewActor = false; // If this turns to true, we know an actor was spawned (rather than found)
if( Actor == NULL )
{
if( !Bunch.bOpen )
{
// This absolutely shouldn't happen anymore, since we no longer process packets until channel is fully open early on
UE_LOG(LogNetTraffic, Error, TEXT( "UActorChannel::ProcessBunch: New actor channel received non-open packet. bOpen: %i, bClose: %i, bReliable: %i, bPartial: %i, bPartialInitial: %i, bPartialFinal: %i, ChName: %s, ChIndex: %i, Closing: %i, OpenedLocally: %i, OpenAcked: %i, NetGUID: %s" ), (int)Bunch.bOpen, (int)Bunch.bClose, (int)Bunch.bReliable, (int)Bunch.bPartial, (int)Bunch.bPartialInitial, (int)Bunch.bPartialFinal, *ChName.ToString(), ChIndex, (int)Closing, (int)OpenedLocally, (int)OpenAcked, *ActorNetGUID.ToString() );
return;
}
UE_NET_TRACE_SCOPE(NewActor, Bunch, Connection->GetInTraceCollector(), ENetTraceVerbosity::Trace);
I find the comment "This absolutely shouldn't happen anymore, since we no longer process packets until channel is fully open early on" hilarious... its definitely happening lol
Sorry for the ping, but this is exactly what is happening. It happens after a few seamless servertravels. Is there a good solution? I saw someone say net.ResetAckStatePostSeamlessTravel=1 may fix it.
Looking at the previous reports, the common denomitor seems to be lyra. Im not using lyra, but stole these cvars from their default engine ini. Could one of these be the issue? net.AllowAsyncLoading=1 and net.DelayUnmappedRPCs=1 seem like they could cause issues, also explaining the hardware cause. I would like to use those though.
net.MaxRPCPerNetUpdate=10
net.PingExcludeFrameTime=1
net.AllowAsyncLoading=1
net.DelayUnmappedRPCs=1```
Hi, I have a question. I'm working on loading screens. I'm using seamless travel so that the connection doesn't get interrupted. I've already made the level transition map, although I'm not sure what its role is. Is there a way to know when a level finishes loading? So I can create a "loading" widget. Thanks!
there's
virtual void PostSeamlessTravel() override;
on AGameModeBase and AGamemode
I use the CommonLoadingScreen.
Not exposed to BPs
just expose it yourself, take the leap
it's super easy
you can do it
yes, i already did it friend, thanks
why all my new levels i create get automatically """smartobjectcollection""" and i cant even delete this -.-
how can i stop that all levels get smartobjectcollection?
bro what I did was override the postseamlesstravel function of gamemodebase, and to that override function I set the blueprint calleable property but isn't the function supposed to be called when the server travel ends?
turn off the smart object plugin, unless you use something that uses it in which case ignore it.
thnaks it works
Starting on a multiplayer card game. Given there's no pawn, is the player state the appropriate place to hang player stuff? Seems weird as it wouldn't be associated with the PC.
sure it is
the player state is owned by the player controller, and they reference each other in a 1-to-1 relationship.
is player state owned by the PC so it gets all the same networking properties?
well then
thank you
Hi! I placed this set of nodes inside the character BP so that even clients would have permission to throw the sounds via server. But it's not working. Even if I set the first node as run on server and simplify the nodes to just throw a multicast right away, it's still not working. The "au.visualize3d.Enabled 1" console command does show that the audio is playing for all but I still can't hear anything. The weird thing is that if I just replace the first node with a random key like "4" it works just fine.
So to simplify it even more...
The first one works, the second one doesn't. The only difference it that the second one is made to be a reusable event while the first one is "hard coded" to just play the same sound over and over.
Anyone have any ideas why this is the case?
Don't take pins across execution paths. The only way to communicate those values across the network is to add inputs to the RPCs and pass the values through, but that seems like a lot of extra data to pass through as you're effectively giving a way for clients to play any sound at any position in the game.
Basically I have like 200 interactable items and I'd like them to play sounds to players when interacted with. I feel like it would ease my workflow if I had "One 'Play Sound' to Rule Em All" type of deal happening somewhere. I went for the Character since it needed to be multicast via server. I know it's probably not the best place to put it. How would you go about making this?
I do appreciate any tips that could be given.
Are you using a bp interface to interact?
Yeah.
Is the interface event run on server or client?
Server to ease up couple systems that I have going on.
This is what the trace looks like inside any interactable.
It brings in some information that I can use inside the interactable objects.
@frozen palmYou can just multicast the fact that the thing was interacted with and have it play whatever sound or do whatever else
do you want everyone to hear a sound when something is interacted with?
Think about the minimum set of state that everyone needs to agree on.
If you
Yeah I'd like everyone to hear it. For example when player picks up an item or presses a button.
So multicast would probably be ideal here.
You now have variables that store those values. Each item actor class could have its own default values set in those variables.
Or you could look them up somewhere and set them.. However you want to handle it.
Either way the minimum amount of data is just the fact that the thing got interacted with and possibly the interator (the character fiddling with it)
Would this Multicast Event be best to be inside the character or inside each interactable?
Because if I try go with something like this...
The client2 was interacting with the soap bar but only the server got the sound.
You need to pass the location through the mc
Oh shit... It actually works now.
You can't do this as the data doesn't get passed through the network.
What @sinful tree said right in the beginning was the thing. I had no idea the pins can't go "thru everything".
I'm gonna need to make this pretty and nice but yeah... It works now.
Thank you so much @sinful tree , @neon summit and @dark edge for helping me out with this.
Was testing every possible thing for many hours and always got it working but then when I tried to introduce any events in between it always stopped working (as seen in my first images). This was a very helpful nice lesson. Thank you once again and have a nice day! 🙂
I much prefer to not use montage for an idle animation but how can I sync these properties accross all machines?
For short animation, it doesn't really matter but what if it's a long idle animations and I need late joiners to at least start at the same time as the server.
to update players timer for an example on their screen, which is controlled in the gamemode, how would i access all available connected players with the ?listen server param
to then gain access to each of their existing widget
You don't gain access to their widget as a server or listen server
widgets are local to each machine. Their job is to read stuff.
any variables that is replicated needs to be stored else where
The time can simply be a replicated float or int
Game state sounds like a good place to create the variable
Use repnotif on gamestate. Inside reptotif function put code you want to run on clients
For example send message to interface
Hi everyone
this is my player controller blueprint. i made a seperate custom event for setting input contexts. this works for the host but it doesnt work for the clients. what am i doing wrong here
thanks in advance
Hey guys, i keep getting 1 frame correction from the server, correcting my UseControllerRotationYaw. My actual GA is a little more complicated, but the core logic is just like in this screenshot.
I didn't found a way to identify the bug, but based on timing of network emulation and some eye checking, it looked like the bugged frame happen 2x the network delay, if i have 200ms, it would happen 400ms after the GA activated. This lead to my assumtion of: Yaw set to true on client first, then 200ms later, Yaw will be set to true on server, but right before that, Yaw is false on server, and it would send a 1 frame correction to client, which took another 200ms, 200+200=400.
If only there is a way to COND_SkipOwner for Yaw, that would be nice. So do you guys ever meet this bug, any way to fix it?
Hey, i have a little question. When playing in the Editor with multiple Clients, my Performance drops A LOT, and if i run more than 9 at a time UE crashes, is this just the limit Unreal can do, and if i have my own Dedicated Server it’ll allow much more Clients(my theory) Or is my game just optimised horribly?
well you are running 9 instances of the games...
like how many battlefield can your computer alone handle?
My FPS already got butchered with 2 clients and 1 server
Well my pc is pretty good soo
probably need like 128gb of ram to run 9 instances of UE at once lol
Hey, I have a WorldItemActor that holds Item Object (UObject). I work with Uobject replication manager plugin. And in both scenarios my item objects are replicated.
The WorldItemActor Load the Basic Mesh as soft Ref from Item Object. For this i Setup the ItemObject to repNotify, on this I load the mesh.
- Items that are spawned runtime (harvesting object, spawn item) are shown and can be lootet
- Items that are prespawnd (with Editor) doesnt load. I think this is because the client connects a bit later so ne repNotify doesnt run on client.
So I think about set the Item Object to Replicate.
- Runtime Spawned Items arent shown anymore (because the repNotify doesnt run any more and the mesh are not loaded)
- Prespawnd (editor) items are now shown 🙂
Maybe someone has an idea, how can I solve this?
so on the github NPP readme it mentioned this part:
After a long road and many attempts, we are dropping support for the async version of Network Prediction. We felt
the complications it introduced into the physics system were too much to maintain and performance was still too
poor in the worst/degenerate cases that it wasn't going to be a viable system for enough games to warrant the
complexities.
The original single threaded version of Network Prediction is preserved and unchanged. We still hope to use it to
build a new character moverment system with it. Physics support could come back into this version but it would be
strictly opt-in and only applicable to games with small number of objects and players.```
And for physics now we have the async physics tick check box on every mesh component(basically any comp that can sim physics).
Then how does Lego fortnite do such massive amount of constraint graph and multiplayer physics ? I probably need to rewatch the GDC talk again and check the prediction part.
A very loaded question would be, why is it very hard to do player input/physics/network predictions all in async manner.
does game instance have some type of node which can be used to retrieve the controlling instance of player controller.
game mode definitely has.
okay but gamemode is inaccessible for clients. i just cant wrap my head around the idea of multiplayer. if you cannot specifically get the controller of the client without specifying an index number, what is there left? how can I target specific clients instead of the goddamn server?
get controller node only exists in player blueprint and it returns generic controller
it doesnt return specific controller class even, you have to cast to it
so does player controller, since every client only have it's own controller replicated. only server have the "receiver end" of all player controllers.
imagine this:
- every player have remote control with buttons, and server have the receivers(server side player controllers)
- player press those buttons and send signals to server (RPC calls)
- server gets those event and inputs and then sets everything on server(like pawn velocity) then it broadcast those changes back to player
- players gets those broadcast replication(some are targeted so only 1 player gets that), and every player trying to react to what's broadcasted and then push their buttons
And yes, you have to cast to your player controller type, that's why game mode has all reference to those class types. as only server should have decision making to all events, player are only "watching" the result of what server did.
it still doesnt make sense with widgets. when you create widget and add it to viewport you cannot just simply add it for client because it wants a playercontroller but you can get playercontroller by using 'getplayercontroller(0); which returns pc at index 0, index 0 is always server, unless you manually set it to 1 but then server or any other instances of clients wouldnt see the widget still
why is there no automatic setup when it comes to widgets and multiplayer
i could have 10 client instances and only 1 of them gets the widget displayed and added to viewport
it doesnt make sense
widget should be local only.
if you want to have say, player name and health bar for example, you can still fetch all the pawns etc and get those if server set the game states. (where you can track like player kills/score/health etc)
should be, except when you preview multiplayer with listen server (2 slots) in editor then only server gets the widget displayed
you can also just fetch those value and location from the replicated pawns.
oh, that. well, because there is only 1 controller.
realistically there isnt tho?
when you PIE, unless you have say, another controller(actual game pad) and you assign different index during the game start join part.
each player has their own instance of pc
did you test the PIE with standalone process? or run everything under one process?
go to advanced settings, make sure you are not running under one process.
I mean it's possible to do all those, but much easier to emulate if you run each client as it's own process.
cause that way your player controller (0) is always gonna be the locally owned.
BUTTTT, if you ever are going to implement couch coop that joins other server, then don't do that, make your gamemode etc does those properly.
the widget still opens only on server
and funny is that if i use packaged build then the widget opens normally
why is editor like that
like I said you need to make each client their own process.
if they share the state process, the player 0 is also shared, and that depends on who gets 0, which is usually the server since you need to start server first and then the client can join.
doesn't matter which window you set as client or listen server.
This seems to be related with my Testsetup. If I start Game with 2 Players the meshes arent loadet, If i Join IT later through add another Client IT works
@formal turtle I suggest you check this pinned video:
#multiplayer message
it doesn't not show the widget thing, but you already know widget is client only since it gets added to the hud owned by client player controller(listen server also has a local player controller it just happen to also be server)
it just further reinforces the idea that unreal engine's editor is not to be trusted when running the game in preview mode
it shows one thing but in reality its totally different
not exactly but it does encourage you to test properly. as editor is more for making new things, and not for testing your thing. you can also do it not with listen server and spawn actual dedicated server now, so that's a plus. (back in old time you can't even test with dedicated server unless you build one, it's pita.)
the editor build has those WITH_EDITOR marco if you checked the C++ code, then you wouldn't be surprised if the build clients/server aren't exactly the same as the editor.
what's the best method to spawn characters (both NPC and enemy) for multiplayer? Is it done like object pooling for actors? I have an open world map that bogs down when new areas load with characters.
What class holds this function, and what event are you using to actually end up calling it?
pooling(pre-spawn during load) is better as introduce new stuff, especially lots of them just fucking destroy the game thread.
thanks, every tutorial I've seen is how to pool actors like projectiles, but I haven't seen one for characters.
I used to do a vr tower defense prototype and I keep the char pooling on game mode. I basically prespawn any pawns/ai controller ahead of the wave and make it so it only spawn like low enough amount before it hits game thread too hard and the dead pawns/ai controllers are deactivated and move to somewhere like z=-100k and just park them there. say if next wave I need to spawn up to 70 pawns, then say I already have 40 currently running, I just spawn like 3 at a time until I get total of 70 to my pool.
the heavier your pawn is then the more you need to pre-spawn. and see if there are ways to async load without hard refs for your pawn related assets.
If you are talking about over 100 pawns then you need special solution as for character movement component + skeletal mesh, around 100 char pawns are about where you start to get really heavy with default settings. so you need like rep graph/light weight movement component and other optimization method thrown in.
thanks for your insight! I definitely won't be spawning that many, but they are NPCs with ai and weapons.
penguinTD i added you can you take a look? ^^
Can I extract audio from .uasset file with javascript?
I don't know, but you can do that with the embeded python to export assets.
Thank you very much
Can u know me in detail?
Hey, I have an UI and want to pass data from server on it (chest inventory)
Some Ideas how I can handle this?
my first approach is this:
its basicly a box where I can put items on it
the box has an inventory ac
on server this works as a charm
on client all works expect the items in box showed
ok maybe I got it
the box actor was not replicated
but does this also work without replicate it?
https://dev.epicgames.com/community/learning/tutorials/LnE7/unreal-engine-asset-import-export-using-unreal-python-api
I searched this, hope that helps.
Thank you very much
Ive gotten hosting and joining working in my game (at least LAN) but when I send an invite to my other account, it works but accepting does nothing. I found this guide and I did what it said, but where do I even put the event invite accepted node? https://forums.unrealengine.com/t/advanced-sessions-plugin-accepting-steam-invitation/416571/2
it seems no one in this thread mentioned where that node is actually being placed
I guess its in the game instance its self, but where do I even find that? clicking the 🔍 does nothing
hmm I guess I can create my own
yep got it working with my own 2 steam accounts but once again none of my friends can join even from an invite
Probably a function override
yeah got it all working now, my other friend tried and Ive been able to join him, pretty awesome to finally see this
although if hes already run around the map killing enemies theyre completely bugged when I join, how do I deal with things that have already happened? I know most games would just have everyone start at the same time from a lobby though
also, why do these settings keep disabling themselves? I need them on
They are runtime only.
Meaning, you can only change them when the game is running.
They wont save in Editor
oh thats weird, whys that? I assume I can change it within the server though?
this is the server and client , is that fine and will the Client to Server RPC will work?
You are free to change it at runtime
Its probably because its a pretty important feature for most games to leave as it is.
yeah thats understandable, in this case though its a silly co op game so the players own experience is definitely the priority
the issue is that the client one is not spawning on server , so i am trying to send the Run on Server RPC from client but it is not working
the object must be owned by the client for client->server rpcs to run on the server
pawn, player controller etc generally
and replicated objects owned by those (actor components on them generally)
Replication is on
See BP_SendTOServer in my Actor class , which there in the scene bydefault
so on joining client has two , which seems correct as one is of server and another is of itself.
but when i trigger the command , is it necessary that server should also contains 2 instances of it , one of client and one of itself
this what i m getting in logs
please suggest is there anything i m doing wrong
This code doesn't really make sense
Why are you doing server rpc on server?
You use server RPC as a mean to tell server to do something as client.
Also look up ownership if this is an actor that isn't owned by the calling client
Your rpc will just get dropped if you don't understand the concept.
so basically what i want to do is on selection of slot the client will send the details to Server that i m selecting this slot and then server will check whether this can be assigned or not and then will replicate it to all other clients
Well for a start you don't want to touch multicast in that case
The slot can be a variable that is stored in replicated actor. Use repnotify to reflect any changes to the variable.
okay , thats is fine but two players can select it at same time ,thatswhy wanted to do it using RPC and want to understand RPC flow for other processes
can you share the simple example of the blueprint with the ownership for RPC
You can read the pinned resource in this channel
Exi compendium and wizard tips and trick
@glass crescent 2 people clicking at the same time is fine, you just run on the server. Who ever get there first, get the slot.
You cannot use multicast on anything stateful because multicast can be dropped and it also don't run on players that have yet to join the game.
You should try to sync a boolean across all machine, have the client able to request the server to toggle the value.
Don't use multicast for anything like this, they are used for something that doesn't neccesarily have to be in sync. E.g special effects, or fire and forget entities.
Ohkay , Thank You @dark parcel for the insights. 🙂
@dark parcel is Getplayercontroller at 0 index will give the owning client one or the host
just use get controller for multiplayer
clients are only aware of their own controller
but server have their own controller and a copy of other player's controller
ohkie
the index isn't guaranteed on server I think. e.g when client loads the world faster than server
okay
Hello guys. I have a question.
I'm spawning some NPCs and each character has a widget component which I want to show their name.
I'm spawning from game mode the NPCs, set the default controller (which is set in the character) -> Init the PC -> Init the character and from here I'm calling a multicast function which sets the name in the widget. Multicast is not working on NPCs? If it's not controlled by a player because the names are not visible to me, the player? If I'm printing something in the multicast, it's only called on the server. Nothing on the clients.
I'm using repnotify. This is working, but why is that? Multicast is not the exact same thing?
Hey guys, i am having the weirdest bug ever. My client character is basically having a timejump, back into the past 200ms, then back to normal. I have a video in slow motion, i draw arrow on character location and rotation, blue is server and red is client.
It doesn't look like correction, but the fact it only happen on clients, with network delay only, it should be correction.
Any help is appreciated.
I think it's a CMC problem when working with montages. I may have to custom the CMC code
pretty sure the only way a montage could effect movement is if it had root motion
Playing montages is supported in CMC isn't it
even take root motion
root motion drives the capsule comp
it does but CMC doesn't support root motion while adding user rotation i guess
I'd like to rotate the player depending on the input.
But if i do it in the Controller/ClientSide, it don't rotate on the server.
if I do it on server, jit doesn't rotate on the client.
To make it rotate on all client and server i need to put in a multiccast function called by the server.
But it seems a bit too much so I was wondering if there is a betterway to do it since it RPCs gonna be called all frame the input is used:
here's my code:
void AArisePlayerController::HandleMoveRight(const FInputActionValue& Value) //Bind to Input component
{
const float MoveRightValue = Value.Get<float>();
if (AcfmovementComponent && shouldAllowMovementInput && bMoveRotation && MoveRightValue)
{
MoveRight(MoveRightValue);
} else if (AcfmovementComponent && !bMoveRotation)
{
ServerTurnRight(MoveRightValue, PlayerCharacter->GetActorRotation());
}
}
void AArisePlayerController::ServerTurnRight_Implementation(const float MoveRightValue, FRotator CurrentRot)
{
MulticastTurnRight(MoveRightValue, CurrentRot);
}
void AArisePlayerController::MulticastTurnRight_Implementation(const float MoveRightValue, FRotator CurrentRot)
{
FRotator Rot = PlayerCharacter->GetActorRotation();
PlayerCharacter->SetActorRotation(FRotator(Rot.Pitch, Rot.Yaw + (MoveRightValue > 0 ? RotationRate : -RotationRate), Rot.Roll), ETeleportType::ResetPhysics);
}
Do Iris has culling?
Are you writing your own CMC? If not, you can just copy the code from third person template. No need for the multicasts
on Tick-> Interpolate to target rotation
How do i use NetCullDistanceSquared with Iris networking?
I tried without it but on client it doesnt rotate
why not? input is local
set rotation on the client locally
you don't need to take updates from server for the character you are controlling
can use Skip_Owner for the variable
multiplayer game so I need all player to see it
Does anyone know if there is an established pattern for notifying clients when a player joins/leaves a match?
I initially thought having a NetMulticast in the GameState, which can invoke a multicast delegate. However, the issue with this is if the PlayerState which is sent via the multicast hasn't been replicated to the client yet, the client cannot know which player has joined
yes but you don't want to use multicast for something stateful
Client Press Input -> Client rotate it's character -> Client Send RPC to Server with the Target Rotation
Server receive Target Rotation and replicate it to all clients except the one that is pressing the input
All other receiving clients, Interpolate towards the target rotation on tick
Gonna try that, thanks
you could override AddPlayerState and RemovePlayerState in a custom game state class
that gets called on clients
Yeah this is what I just tried and seems to work at first, but I think this will need extra state tracking this is called when the APlayerState itself is spawned on the client, but playerstates stick around when players leave
they do eventually get GC'd though im pretty sure
They go into the inactive players list to handle rejoins
or that lol
Add and Remove still get called when they join/leave though
How do i use NetCullDistanceSquared with Iris networking?
Ah yeah i'm just reading the AddInactivePlayer in game mode. That makes more sense now. Thank you both!
should it be possible to use a UObject singleton as a multicast sound player?
just to hold the actual UGameplayStatics::PlaySoundAtLocation functionality that will be called from the server. The singleton exists on both client and server but currently I can't get the multicast to play on the client
I really want to keep this functionality out of my player actor
is there a function inside gamemode blueprint that gets called when session is created. I dont remember the name but it was there iirc.
just like an actor I can send sound and niagara requests to
Hey guys, i need help with an unknown class when going from my game mode to the clients. I have a simple lobby system, where i want to display the list of players in the lobby to all players. I'm doing this from the game mode on the OnPostLogin and OnLogout events (screenshot 1):
The issue is, when I'm calling the method UpdateLobbyHUD on each player controller, the array contains unknown classes once the method on each controller is called. Screenshot 2 is debugging once a client joins a game with a player that acts a listen server. Here you can see two player controllers while we are still in the game mode. But in screenshot 3, you can see once the clients receives the call from the game mode, one of the player controllers is uknown.
Does anyone have an idea?
Thanks in advance.
Player Controllers only exist on the owning client and on the server. Other clients cannot reference other player controllers.
Your best bet here is to utilize teh Begin Play and End Play of PlayerState to know when a player joins or leaves the game and use the PlayerState as a means to replicate data about that player to other clients.
Keeping an array of playercontrollers on the GameMode is also not necessary - the GameState has a "PlayerArray" which is an array of PlayerStates in the game, and from the PlayerStates you can access the associated PlayerController if needed.
hey how can i replicate homing projectile??
Mark the actor as replicated, set to replicate its movement. Move the actor on the server. Profit.
ok do you know how can i make swarm projectile
for example... 5 projectiles spawn at same point then the follow target... but every projectile has a other way
each projectile has a different trajectory
Spawn 5 different projectiles, have them move on different trajectories on the server.
yeah but i can do do that every projectile ha its own way? and it not fly not straight ahead but in a curve
Ah I didn't know that, thanks! I opted to create a new struct where i just parse the information needed in the game mode and then send that information to each player controller when i need to. Right now im just prototyping a project, so it's not ideal solutions lol.
have you made a homing projectile work yet?
funnily enough I’m gonna be doing that soon. I would just have it move in the direction of its target on tick, and all you replicate is it’s target (although let me know if that’s wrong but it’s similar to what I do for enemies that aim at the player)
Hey folks, i can't find any horror related multiplayer setup does someone know/have some things i can work wich such as documentation or tutorials that can help, i've already have a host and join setup and working chracter but need to figure out all the other stuff
Theoretically, can Network checksum mismatch happen for cases where some variables / codes are wrapped with #if WITH_EDTORONLY_DATA / #if WITH_EDITOR, and trying to join from Editor to a packaged dedicated server would fail because the two instances have generated different network checksum?
I'm searching for answer similar to this issue, but it happens for a replicated actor component
https://forums.unrealengine.com/t/unreal-5-4-problem-with-a-packaged-game-server-spawns-the-character-and-client-disconnecting-with-failed-to-load-package-error/1841350/3
What are the fundamental factors that would affect a finalized network checksum?
Having the same problem. I upgraded from UE5.1 to UE5.4, wasn’t getting this issue before. Network checksum mismatch. FullNetGUIDPath: [126]BP_PlayerState_C_2147481901.[134]AbilitySystemComponent This is on an entirely new PC so I have no idea how there could be a mismatch… rebuilt and re-validated files. Hmm…
Hey all, hoping someone might be able to help/advise me on this issue.
Fairly new to multiplayer, so started with a simple turn based prototype. The alternating turns is working ok, but one thing I tried adding was UI which either says "it's your turn" or "its player [n]'s turn" (the n being 1 or 2 - 2 player game etc).
I'm running this locally on my laptop, netmode set to listen server with two players, debugging from Visual Studio, game running from the editor.
My GameState replicates the turn state, and my PlayerState makes use of the PlayerId, PlayerName, and I added a "bCanTakeTurn" variable, set on the server and replicated.
In the PlayerController, when I update the UI text, I iterate over GameState->PlayerArray to access the PlayerStates. A cast is required to cast to my own type of PlayerState. I then check whether bCanTakeTurn is true, if it is, "its your turn" is displayed, if not, then "its player [n]'s turn" should be displayed.
The problem I'm having is that, the client player (e.g. not the player on the listen server) never seems to be able to access the PlayerController associated with the PlayerState.
I've tried GetOwner() / GetOwningController() and under the hood I see all of these seem to be returning the "owner", as such, my cast always fails.
I don't understand why the Owner wouldn't be available for this player. During the GameMode->PlayerStates iteration, when its the listen server player's turn, it works fine. But this code is being run under a IsLocallyControlled() check, so it shouldn't really be making any difference that its the listen server player or not.
Utterly stuck/confused with this and would really appreciate any help / gotchas / info that might help shed some light.
Thanks in advance.
I may not be understanding your question correctly, but I think the issue is that you have a client trying to access another client’s PlayerController. PlayerController only exists on the server and on the client that owns it, not other clients.
Hi, thanks so much for the reply.
My apologies if the query was a bit all over the place, its kinda hard to explain the problem more succinctly. You were however spot on, about 5 minutes ago I ran into the realisation that I can't access the other player controllers.
I've managed to get the player name from the other PlayerState now by comparing the PlayerId's, so I've got a bit of progress at least, and now now try to simplify this monster mess of a function!
Thanks again @deep shore, I appreciate you taking the time to reply and having the spot-on answer 🙂
you’re welcome!
Is it normal that movement replication through UDP is so unreliable? I update it every 0.05sec. I'm writing my own network system, so I'm not using the built-in replications and such. Should I use TCP for movement replication as well?
Hey, last days I sometimes got EditorCrash after Joining another Client on Runtime
[2024.08.05-21.10.36:383][872]LogWindows: Error: appError called: Assertion failed: IsValid(Object) [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\PackageMapClient.cpp] [Line: 3050]
somebody run into this?
or have similar problems
I have a pathfinding actor that contains the grid that AI agents navigate within. I want to place this actor into the world in the editor and generate a grid that would later be used during gameplay. I want this to be only on the server. How can I achieve this?
I'm working on Steam integration for session hosting/searching. I've cracked that part, however now when clients join the server they immediately crash due to accessing a nullptr.
Fixing the crash itself shouldn't be difficult, but this only presents in a packaged build connecting via Steam.
Are there any console commands/emulation steps that might help test this without needing to package/distribute the build to use Steam? Emulated pktlag doesn't do the job and that's about the extent of my knowledge.
After typing out the above I found that clients can join if they host a game first, which implies to me it's something to do with the loading of primary data assets. Still throwing the question out there in case anybody has a suggestion.
"crash due to accessing a nullptr" is extremely vague
Guys, I have a question about replication regarding colliders in multiplayer
Can somebody help me?
don't ask to ask, just ask
I have a problem when collecting the actors from a begin overlap box of my weapon. The problem I have is that it only detects collisions correctly when the authority is the remote. But I understand that the server is in charge of managing collisions.
The problem I have is that on my server the collisions of my attacks fail
Is this correct or should I do it remotely so that the client is in charge of checking if my weapon hit a player and then telling the server to apply the damage?
sure you could do that if your game has no competitive element whatsoever
My game is a multiplayer arpg video game
that doesn't tell me if it's competitive. being able to tell the server you hit someone is easily cheatable
I don't know anything about what's going on here other than there's a collider
The problem that is happening is that only on my client does the collisions work correctly. On my server the collisions are impressive.
"impressive"?
[2024.08.03-05.32.41:067][479]LogWindows: Error: === Critical error: ===
[2024.08.03-05.32.41:067][479]LogWindows: Error:
[2024.08.03-05.32.41:067][479]LogWindows: Error: Fatal error!
[2024.08.03-05.32.41:067][479]LogWindows: Error:
[2024.08.03-05.32.41:067][479]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000
[2024.08.03-05.32.41:067][479]LogWindows: Error:
[2024.08.03-05.32.41:067][479]LogWindows: Error: [Callstack] 0x00007ff7c6db3876 LyraGame.exe!ALyraCharacter::GetRelevantCharacterMesh()
Just the old actor isn't yet initialized on the client I suspect. My issue isn't with fixing that, was just hoping for steps to pick these issues up without packaging -> distributing -> connecting multiplayer via Steam.
If it is related to primary data assets I suspect that's not possible without packaging since they'll loaded when the editor references them right?
As a rule, the server should handle collisions to avoid backdoors.
my server is imprecise
yes? it will be
there's latency
it won't always match up with the client framerate
is this for a melee system or something?
well this is assuming replication order, something you should never do
I don't know what your ALyraCharacter::GetRelevantCharacterMesh() function does
Yeah I know, I've done something dumb in here somewhere that doesn't trigger a crash when testing multiplayer via PIE but does using Steam.
That function is just returning which skeletal mesh that the weapon should be attached to, but the Character is a nullptr at this point. Doubt the function itself is relevant.
I'm more confused that hosting the game on the client, then joining the server will get around the crash.
as a client, you shouldn't assume that dependencies exist immediately
I appreciate that, and I appreciate you offering your help.
I am not looking for a spoonfed code fix, I am curious if there might be any network emulation commands to help pick up these issues in a PIE environment.
Nevertheless, here is the code. Yes, if the ACorsicanWeapon is replicated before the ALyraCharacter exists on the client it is going to crash as a result of the BeginPlay implementation.
void ACorsicanWeapon::BeginPlay()
{
Super::BeginPlay();
USkeletalMeshComponent* TargetMesh = OwningCharacter->GetRelevantCharacterMesh();
}
USkeletalMeshComponent* ALyraCharacter::GetRelevantCharacterMesh()
{
if (IsLocallyControlled() && IsPlayerControlled())
{
return FirstPersonMesh;
}
return GetMesh();
}
you can emulate late joining and such
and yes, it's very likely that OwningCharacter isn't initialised in BeginPlay
like you could get it in the initial bunch but that's not always a guarantee
Thank you, I will have a look at emulating late joining.
And also fix the weapon spawn cycle. For real this time. I promise you, future me.
Hello, I am relatively new to some of the more advanced work dealing with multi-player game creation (i was thrown into it unfortunately since the indie studio i work with lost their server setup guy).
My current dilemma is I am trying to build both a dedicated server and a client that gets directed to said server. There are a lot of guides out there, but none seem to reliably answer my particular situation.
My goals are this:
Build a dedicated server for a Linux operating system (we have a Linux server to use)
Build a windows client that can find and locate said server, while being able to select a character
Have both of these able to be scaled up for other dedicated servers
This is all completely new to me and I have been struggling to find a solid solution to this. I have managed to successfully compile a source Build of UE5.3.2, install advanced sessions plug-in and steam sessions plug-in. I just need to build the ability to connect to a server as well as the server itself.
Thank you for any assistance. I have been on the struggle bus big time dealing with this as I was just supposed to be the "build mechanics with nodes" guy
If my game is peer to peer multiplayer, does it mean that the server (the player hosting) has about 0 latency? Meaning that Clients Only as emulation target is the most accurate form of emulation? I ask because my game works on "Everyone", but there is alot of correction happening so it feels bad. On Clients only it works well.
There is no "server" in p2p
Every machine run its own instance and talk to each other.
wait i should rephrase think like valheim multiplayer
where 1 person hosts the server
On the contrary server to client model, the client never directly talk to another client.
I don't really play valheim
But p2p is like old diablo
1 person who is hosting is the server
your other friends connecting to you are clients
should there be no latency on the server in this case?
Maybe the term you are seeking is server to client model
Which what unreal use by default
In that case yes, server have 0 latency
ok cool, I found a couple bugs with server latency that I fixed anyways, but it just feels shit to play when everyone is enabled
Imo latency is why multiplayer isn't soo easy.
Doesn't matter when you don't need to care about it. Like turn based game or chess
yeah i got action combat 😭
But for any fast packed game, the difficulty rose quickly
Peer 2 Peer in Unreal is a misnomer and entirely impossible
There is always a type of Server in Unreal
Either Listen or Dedicated.
Using P2P to describe network architecture within Unreal is just simply wrong.
Yes makes sense, I dont know shit 😂
So what im talking about is a listen server basically
The Host is the Server (Listen Server)
They have 0 Ping to the Server because they are the Server.
That's a lot of questions all together. I don't know where you're upto with this but here's a rough outline.
-
Dedicated server package requires building Unreal from source, but you can emulate in PIE quite well till youre ready for that step.
-
Discovering a server from a client requires use of an #online-subsystems the specifics and choice of which depends on your platform and architecture (steam, playfab, game lift, etc).
-
Scaling servers. As above, Steam is fine for connecting to servers you spin up yourself, but if you're session based and you want servers to start and stop with demand, then you'll probably want to use playfab/gamelift/etc rather than Steam matchmaking.
question
if a player dies and the pawn gets destroyed in MP, I asssume you need to spawn a new pawn obviously but how would you possess it and assign it a new player controller?
better yet, how can you use HasAuthority if pawn is dead and there is only the client instance/server instance left?
First question
- What substitutes dying? You can have the player respawn with the same pawn if you wanted to, it'd be a simple set actor location and some logic on your behalf to "restart"
If you mean unpossessing a pawn then yes, you would need to have the server then possess a new pawn, your controller stays with you for the entire game until you move worlds
i did it both ways now or kind of figured out a way to, but im more talking about spawning a new pawn when character falls into the void
spawning it will work but for some reason the input itself is messed up. e.g i can use mouse input and rotate camera, but keyboard controls are not working
even when controller is set to 'game only'
i am guessing that you would use gamestate or gamemode to keep track of playercontrollers and check whether they have a pawn, periodically
You probably don't need to create a new pawn unless you want to do that; you can simply disable collision and movement, hide the pawn, and then reset it for reuse.
i mean if player falls into the void
they get automatically destroyed unless there is a way to suppress that
Override FellOutOfWorld to customize that behavior.
is that a c++ function? I cannot see it in pawn class in blueprint
Yes
guys why i see 2 line traces printed when I am using server call + authority should not be there just one line trace printed?
if are 2 it means it is one for client one for server nah?
Hey guys, someone know how to display a widget on a specific player that overlap a box ? I have a Big box zone where if someone enter it create a widget that display a message on screen. However i can't figure out how to only display this on the person who walks in, right now it does display on every player... do you have any advice ? Thanks !
Show the line trace code and how you print it?
once , and I used event tick instead timer function and it's fine I don't get it
can't tell unless you share the code
i think the blueprint print node prints messages on all running processess, even if that specific instance didnt call the print node
Yes but it will have Server: and Client: prefix
so at least, we can still tell whos printing
First check if the overlap only happend on server machine
So from the event, do a switch has authority
Then from there, other actor -> Cast to Player Character -> Get controller -> Run a client RPC function that display the widget
_
the idea is when an actor overlap with the box in the server machine,
you check if the actor is your player character type, if it is, get it's controller
then tell the controller to run a function (in the owning client)
Wow what is that
read it and find out
i sure will thanks
especially section 5, it goes over the switch has authority nodes
but everything written there is essential
It looks likle that 6.1 is exactly what i need lol
cant post these spaghetti here u would seee nothing but thx for answer now its fine i will see
@dark parcel This works as intended, do you see something wrong in what i did ? even if it works
I can see why it "works" but it depend on the context
because what you are doing here is you allow client to test the overlap
so in other word, there's more vulnerability
you can also do drag OtherActor -> Cast to BP_Character-> IsLocally Controlled, that will be shorter than what you have atm
@raw drift actually you are just displaying widget, doing the check locally is totally fine imo
Hello guys ,
How can I send the partyID from client to server ..
I've tried everything idk what i'm missing
The partyID I want send
attached in photo
Oh yeha that works too haha thanks
If these are UObjects, which the pin color would suggest, then that's not really possible.
It is inherited from UObject yes i thought i can xD thank you
Guys how can I correctly replicate the location of my weapon socket that is on my character. It only replicates it correctly for a second but when I do an animation with my weapon the weapon socket is not replicated on the server
Hello guys, can you recommend any tutorials for replicating enemy behavior in BP?
What do you mean?
That is extremely vague
AI logic doesn't really replicate by default. It is all ran on the server.
Hey, so I made a reddit post about this but also want to check here. Does anyone know if there's anything special or extra beyond the standard local multiplayer setup when doing cross-platform LAN applications? I host a listen server on my PC, but the android and VR builds cannot find any sessions
Yes, I'm aware of that. Currently I have setup with BehaviorTree: movement is jittery, and attacks are not replicating. I want to know where to start and maybe refactor what I've done to multicasts or something else
Also for context: I'm using this crete dev tutorial for what I'm considering standard local multiplayer setup, but excluding all the onlinesubsystemsteam elements and only using null
https://www.youtube.com/watch?v=jc0COamYRm4
Wishlist CRETE on Steam or join the next playtest here:
https://store.steampowered.com/app/2022610/CRETE/
If you want to see how CRETE looks now, consider subscribing to the channel, checking our latest videos, or joining our Discord server to follow the development:
https://discord.gg/tRbEH2Cscp Since Advanced Sessions Plugin won't work anymor...
Attacks should be done through an RPC or GAS ability. BT tasks don't replicate, so you'd do it through the pawn.
got a little bit of a weird problem here
currently making an online multiplayer game and each player has a few movement abilities. The server host can use all abilities fine but any joined players arent able to. This is because each player reads from a TXT file to choose which abilities they have, the server can read the host's TXT file so it assigns that player their abilities, but the server cant read any other players's TXT files meaning that it thinks they are all empty and have no abilites. The non host players can read thier own files though, meaning that they think they can use abilities. When a non host player uses a movement ability, they are rubber banded by the server back to their original location.
anyone have any ideas on how to fix this? is there a way to attach the TXT to each player so that the server has access to it? or anything else im not thinking of
using the AdvancedSessionsSteam plugin btw
#online-subsystems message
@silent valley what do you recommend me do in this situation? I have the file in place so that players can make a loadout before they join a server, if the server just assigns them something it wont be the same as whatever they had just saved (also i designed this system before i implemented multiplayer so i had no idea it would be a problem)
whats a good way of telling the server what each player should have and how should the players retrieve that information from the server?
Usually the only way a client can talk to the server is via RPC from Playercontroller or possessed Pawn. So you could call an rpc when you join to tell the server what configuration they want.
I'm a multiplayer noobie, trying to hack together Lyra and the Game Animation Sample, was curious where to start looking to understand what possibly make the animation replication behave so strangely, it looks like the standard lyra animations are used for replication, I think that's a clue, I also have no idea why the second player traversal simply fails, any clue might help -
Traversal needs to happen on both client and server. If you are the server, it should happen on the clients so the other clients can see it. And if you are the client your traversal simply fails because the server isn't doing it, and the server is authoritive over the pawns location.
Thank you for the reply, I will look more in depth for this. I have made some progress as of late, I will use this to further research into it
Quick question: Multicast RPCs vs RepNotify. Is there difference in terms of performance? Let's say we have a tick event and do an RPC at every tick. Versus modifying a replicated variable in (nearly) every tick and thus causing the OnRepNotify function executed on clients. Is there a performance benefit from one over the other?
so turns out im just really stupid and was entirely wrong about my entire problem. the player reads their own txt and sets their abilities just fine. i just dont know jack shit about replication and RPC's. All of my events are called locally through the player pawn and dont communicate with the server at all, so all they can do is basic wasd and jump movement. Ive spent the last like 2 hours looking into rpc's and replication but i still dont quite understand it.
So say i have some series of things that are supposed to execute from an EnhancedInputAction, that function has no replication settings in its details, so how do i make it happen on the server and on the client?
am i gonna have to rewrite all of my abilities onto the gamemode or something handled by the server? idk while ive been doing unreal for quite a while now im quite new to multiplayer development and i dont quite understand the server to client communication
Are you using GAS for the abilities? They support replication by default but you have to think about them a bit differently.
no, its just a bunch of spaghetti code
also half of it is attached to a movement component
ive got a very complex system in place
on the movement component i have things like wallrunning and sliding and quite a bit more
on the player pawn i have grappling hooks and special movement abilities
just a bunch of when button pressed, do this
but like none of it works as a client
It's not about performance but which tool is right for the job. If something is stateful you should be using a replicated variable. if it's something fire and forget, then you could consider using a multicast.
Hi, is there any way to spawn an actor on the server (non controllable one) and set its role on clients to be ROLE_AutonomousProxy so that I could somehow perform some client prediction on this actor? While still being replicated for other players.
Of course, and it was mentioned literally before the section you screenshotted. But many people don't know that, and chat history in this discord proves that overriding RPCs that way is grounds for being shot. At least if you wanna screenshot and mock people here about something, investigate the case fully, and take proper full screenshots that disprove your point
But you still remember the name, don't ya? 😆
Dur-ox-cigar
Duro the invincible
Thanks Datura! I know what you're saying and I fully agree with it. However I still would like to know if anyone knows if there is a difference in performance. Performance in multiplayer is a key element and must be considered as well
yeah i do not wanna have to completely rewrite all of this in GAS, theres just too much and i dont have enough time
I'm afraid you're in for a bad time if you're trying to retrofit multiplayer to a single player game. That's a massive undertaking, especially if you're new to multiplayer.
i have realized that
fortunately my game is relatively small and (almost) everthing ive completed so far is just on the player
i initially wanted this to be a multiplayer game but didnt realize that you kinda needed to set up multiplayer before everything else
Making your movement component changes work for client is probably the first thing you should do. It's going to require a lot of researching - movement comp networking in particular is extra tricky.
Hi, is there any way to spawn an actor on the server (non controllable one) and set its role on clients to be ROLE_AutonomousProxy so that I could somehow perform some client prediction on this actor? While still being replicated for other players.
RemoteRole?
a good majority of these are done in functions, i heard somewhere that you cant really replicate functions, will i have to rewrite this into a bunch of events and turn on replication? or will it be more complex than that
Are you setting the owner of the actor? It should be AutonomousProxy if you're able to call server functions, but this is 1:1. You can obviously predict or extrapolate and just have the server send corrections regardless of role
A lot more complex
well thats fun
looks like its probably just gonna be better to rewrite it all
rewrite it or not you are still gonna need to understand network code, and if you do you could porbably fix this as well :P
That's usually for the best for multiplayer stuff
It's hell to convert stuff that's assuming single player
im getting a dumb moment
i got a custom struct thats marked ReplicatingUsing, ive setup the DOREPLIFETIME and the OnRep functions
i update the value of the struct on server but i never get a call to the OnRep on my client
the actor is set to replicated
ReplicatedUsing
Are the struct properties you want to replicate (within the struct itself) marked UPROPERTY
Push model? Do you mark it dirty?
Ah, no 💀
Ill try that tomorrow morning
how do you properly replicate something like the player aiming their weapon around? currently I do it every frame which cant be good at all, but if I interp it it would look pretty bad, and Ive noticed in multiplayer games when you see the player do quick movements with their mouse, such as "nodding", it looks completely accurate. maybe the rate it updates it needs to be based on cursor movement or something?
like Id assume slower mouse movements = less frequent updates and more interp, and fast movements are more updates and less interp, but idk how to set that up
Well you still need to interp it but you would actually do something near to every frame (when input actually happens)
You can rate limit it to make it a tad predictable since otherwise it's sending at the client's framerate
And that's probably overkill
true yeah, I guess a timer would be fine? then I could change the delay in runtime if needed
Yeah probably at 15/30Hz, whatever you can get away with before the effect is noticeable
Any simulated proxies would just forever interp towards whatever the latest value is
Does this graph look good for when a player shoot in a coop multi-shooter game?
- Client Clicks
Detect the player's input (e.g., mouse click)
- Show Visuals (Client Only)
Display gun explosion and trace 2D image effects on the client
- Client Trace
Perform a trace (raycast) on the client to detect if the shot hit a target
- If the Trace Hits (if it doesn't, we got to 6.1 directly with the Server RPC)
Send a Server RPC (Remote Procedure Call) to notify the server
- Server Validates Trace (only if the first trace actually hit something)
Perform a trace on the server to ensure the shot is valid
- If the Server Trace Hits
Apply damage accordingly
Show visual effects (gun explosion, trace 2D image) for all players, except the client who initiated the shot
Visual hit effect -> Everyone
6.1. If the Server Trace didn't Hit
Show visual effects (gun explosion, trace 2D image) for all players, except the client who initiated the shot
Sure
You want to be careful predicting damage effects on the Client though, what if the Server rejects it and applies no damage?
Then the client thinks he damaged the enemy but didn't actually..
What would be the best way over this?
Let the Server tell the Client, like all the other Clients.
So dont predict the visual hit but still predict the gun explosion visual?
The gun still fired, so you can predict all that.
But for example if you have a Crosshair flash indicator for Hits that deal damage, you might not want to predict that.
Since it could be rejected by the server and you are giving incorrect information
That's right
I modified it
I personally think that visuals should actually be predicted in the client, to give the player a proper response to the shot.
Also, for the server validation you could rewind the character locations for a more accurate validation
Firing and surface Hits can be predicted just fine, but damage effects should not be, that was my point.
A damage effect is something which indicates the application of damage.
Showing the Crosshair flash only after the server acceptance would be a bad player experience.
The only time that would be a bad experience is in a high ping scenario.
The worse experience would be thinking you dealt damage, when you didnt.
If you have a proper rewindable server validation that would'nt happen in 99.9% of the times (unless the player is a cheater)
do you mean show "delayed for couple of frames" reality? It's even worse imho
The context he provided mentioned nothing about rewind, you shifted the goal post by adding that in.
He might not want rewind
He might not be able to implement it
whatever you implement Players will always complain, haha 
There is only so much you can do to workaround the limitations of physics
I think it should depend on the seriousness of the game, I never would want valorant/cs to lie to me an show a hit marker I didn't get
This is a major consideration as well. I wouldnt expect a game like Deep Rock Galactic to have Rewind.
But I would also want to know if I dealt damage to enemies accurately.
So in that scenario you have no choice.
On the other hand, if you're a lobbyist for peripheral hardware, you should indeed lie to the player. Broken hardware means more sales.
Hey looking for some advice i want to client side predict building idea is spawn the build on client generate a UID for it put it in a TMap<FString, AActor*> ActorMap; with the ref of the build send the UID to the server the server spawns the build then send a RPC to the client passing the UID client searches the map finds the proxy actor and destroys it
heard theres a better solution im probally wrong but from what i understand when the server spawns the build it will use the build just spawned on client as the actor it would have spawned when replicating down? also i think theres a whole bunch of stuff like stably named and all that but not sure if actors that are spawned at runtime are stably named?
I have the same exact problem with almost the same exact set up, is there a better way to do this. They are saying this is worse on performance, since it's a server action i want to be lightweight. I want to move a topdown character from the server after the client has given a location of where to go. It works on standalone or on the server instance but not on client. I have enabled allow client side navigation (this shouldnt matter since i'm trying to move from server) Thoughts?
Not sure on the first part, but i'm pretty sure that unreal uses a different method for dynamically spawned actors. Also have you tried using the built in replication for that first before trying to work around it? or is there a specific reason
I want to client side predict placing builds in my game so I want to place on the client then on the server since the actor is replicated the server will spawn another build on the client resulting in duplicates so I just tested my idea and it works the server will destroy the first placed build on the client
Are there delegates that I can use when something ( I assumed game mode ) finishes iterating begin play of actors in the level?
I want to create a window to sync animation for joining clients
Actually I would need something to fire on client side
What I do on my end is to make the actor invisible by default.
On predicting client, I spawn locally
At the same time telling server to spawn a replicated actor.
Other clients will spawn a copy but on predicting client, it stay hidden
You can sort of "replace" your locally spawned client on predicting client when it receives the actor. I would just destroy the locally spawned actor then make the incoming actor visible.
For less headache, you probably don't need to predict building placement.
Read this convo
These are my old Obsidian notes on it if it helps lol
Stably Named Objects
Stably named objects are simply objects that will exist on both the server and the client, and have exactly the same name.
Actors are stably named if they were loaded directly from packages (not spawned during gameplay).
Components are stably named if they were:
- Loaded directly from a package
- Added via simple construction scripts
- Manually marked (via
UActorComponent::SetNetAddressable)- This should only be used when you know you are manually naming the component so that it has the same name on the server and client (a good example are components added in an
AActorC++ constructor)
- This should only be used when you know you are manually naming the component so that it has the same name on the server and client (a good example are components added in an
You can also force stably named actors as demonstrated here
To have a client pre-emptively spawn an AActor that is also suppose to be server authoritative and owned, we must ensure we have the same name for the actor on the server and client as well as mark it as NetAddressable before spawning it and the outers must match.
void SomeClientFunction()
{
FActorSpawnParameters p;
p.Name = FName( FString{"FooBoo" + GetName() + FString::FromInt(FMath::RandRange(0, 1000))} );
p.Owner = this;
p.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::Undefined;
p.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot;
p.bDeferConstruction = true;
auto* a = GetWorld()->SpawnActor(cubeClass, &GetActorTransform(), p);
a->SetNetAddressable();
a->FinishSpawning(GetActorTransform(), true);
// Server RCP
Server_SomeServerFunc(p.Name);
}
void Server_SomeServerFunc(FName actorName)
{
FActorSpawnParameters p;
p.Name = actorName;
p.Owner = this;
p.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::Undefined;
p.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot;
p.bDeferConstruction = true;
auto* a = GetWorld()->SpawnActor(cubeClass, &GetActorTransform(), p);
a->SetNetAddressable();
a->FinishSpawning(GetActorTransform(), true);
}
Note : Spawn actor deferred (which is what we need to SetNetAddressable before spawning) is not able to be used here since we lose the ability to pass FActorSpawnParams and set the name/owner, so instead we are doing what deferred does but ourselves.
(it was a while a go that I did it)
if a client creates a predicted object in that way, will any RPC's called on it by that client be dropped until it exists on the server?
I'd assume it'd be the same logic for when a client joins and gets some RPC from the server about an actor it doesn't know about yet 
If it doesn't exist, then yeah
FYI, that actor should also be replicated
Same problem
I'm not sure if this is the best place to ask this but I'm working on a project and thought I would see how much is currently replicated. When testing with 2 players as a listen server. The focused window (PIE) changes making it sort of possible to control characters in both the PIE windows. Does anyone know what sort of thing can cause this type of behavior?
can't switch with alt tab?
For more context, when the client looks at something that would show a widget, it opens on the listen server instead which then gives that window the focus which is odd as I've not done anything the replicate the UI. o.O
Ahh because the code gets run on the server machine too
big part of multiplayer is filtering codes
to make sure something run on server and something run on client
in some cases, they can run on both if not addressed
Face palm of course it does. haha
Think of a collision box that adds widget to the viewport
every machine will do the collision check if you don't filter the code
Yea that makes sense now as the widget sets the input mode and focus which because it's ran on the server causes the switch.
Yea, I've not set it up to only show the UI on the owning client. 🙂
nice to see you in MP, I don't know much but will be happy to help when I can
Thanks, I know the basics but I don't dabble enough that I often forget stuff haha.
Does anyone know how to replicate the physics of a weapon?
I just ended up doing this. It stops the window focus jumping but I should probably look at replicating it properly at some point.
If it's done every frame, you probably want the client to Trace locally
also what the server sees and the client sees is not always guaranteed to be the same because well, latency
normally in networking, clients are favoured with certain treshold
There is no point in tracing on the server to begin with. If its an interactable any visual feedback will be client side only, and once you interact with it that action will go from client to server.
Doing RPC on every tick for something like a trace when the client can trace locally, I would not encourage it but maybe other people can give second opinion.
I mean, all that aside, these two screenshots are still really redundant?
Tick calls on everyone, so why even that RPC
The client does but yea the setup isn't ideal. I just wanted to make sure I'd not messed something up somewhere with the window focus switching thing but that's just because I'd not replicated.
So I think you just want to entirely make sure that the focus node runs on targeted machine
e.g. for interacting player
@thin stratus I'm trying to sync animation for players that just join the world for the first time. (Animation players and montage) in anim instance.
Was called perfectionist but I thought it's kind of necessary?
Does the projects you worked on sync anim at the start?
It just makes the server tell the owning client to perform the trace so the client doesn't have x amount of characters performing the trace, as they only care about their own character. But yea, it's not the best way to handle it. I need to find some time to tear the whole system down to handle the replication properly.
Event tick ->Is locally controlled -> Trace
@untold rose
Try that and test the game 🙂 with debug line trace
Yeah, but as ColdSummer says, that's what you use IsLocallyControlled for.
I surely hope you aren't constantly doing ClientRPCs to ensure that the local client calls something that is already possible to limit only to that client.
Don't know if they do and wouldn't be allowed to share.
O yea, I forgot about the 'IsLocallyControlled' node.
you will use it very very often 💪
It now becomes this.
That is dangerous
Cause BeginPlay is often too early for that.
Pawn itself has a function called OnControllerReceived or something like that.
I barely start on my project, but have nothing on Begin Play soo far.
Some gotchas when it comes to MP like eXi mentioned
That calls for Server and Owning Client when the Pawn gets possessed
BeginPlay is too early, as the Pawn would replicate, call BeginPlay and only afterwards get the Controller replicated if you are unlucky.
If you need to react to the Pawn being possessed and then use IsLocallyControlled, you'd need to use that OnController function in the Pawn and notify the Component in whatever way you find best.
So something like this. Wait until the pawn is possessed and then check if locally controlled?
Yes. The only edge case you could run into is that the Pawn is in fact already locally controlled when BeginPlay calls and the ReceivedControlledChanged won't call again until possession changes
So you might want to do both.
I assume this should handle it? If it has a controller already then the bound event won't fire until it's repossed so I should just call the function to check if it's locally controlled.
Yeah, that should be fine.
Thanks for the help guys. 🙂
Also, for your own sanity, get used to calling Parent versions of BP Events/Functions. E.g. BeginPlay and Tick
If anyone is familiar with C++/C# and the TCP protocol, could you help me find the error in my code? It’s too extensive to post here, but I'd be happy to send it via PM or another method to brainstorm on it a little bit and share the results if it’s fixed.
why cant i destroy a client only proxie build? nothing happens the actor is never destroyed despite it being valid?
the actor is set to replicates but is spawned on client
Why is it a client RPC?
I reckon the server wouldn't even know of the actor that the client spawn locally
nvm, should be fine
you grabbing variable from the client
try to debug Imo, print the actor being destroyed
i am trying to client side predict spawning builds so a spawn build on client then genraete a UID add it to the map send that to server sever spawns real build then that 'real' buidl replicates down and spawns on the client then server sends the UID back to the client to destroy that 'fake proxie' build
ive tryed
actor is valid and it is the right actor i am trying to destroy as i checked the location
well no way to verivy from here or without seeing
ill send pics this is on client add prxie build adds the UID and the actor to the map
send UID to the server
where exactly do you spawn locally?
server sends UID to client and calls this func
looks like you are spawning on server
its hard to explain but i am spawning a 'fake' /proxie build on the client only then i want to destroy it later but i cant
I’m trying to do Find Sessions over a WiFi network with a null subsystem but it’s failing. Is there something special you have to do? Or will this not work at all since it’s not hardwired LAN?
here Im spawning a cube locally, then server able to tell the client to destroy the cube that it spawned locally
second picture is after I pressed C
im doing it similar to that try spawning locally fire a server RPC to spawn another cube in the exact same loc and the rpc back to the clien to destroy the locally spawned cube cube
I am aware
gave example above X_X
but I can';t go thru your system
for my abilities, I also made a proxy projectile for the firing client
because I can't wait for the server to spawn the fireball
Hey there, I have a question regarding ownership and some workflows with it:
I have written an actor, lets call it DataManager, that is responsible to import/convert json files to my data structure and store this data in an array. That actor and the array are replicated.
For each entry in that array, a world presentation in form of a replicated actor is spawned. I got to the point, where I want to give the client the option to locally import jsons as well.
So he presses a button, the file browser opens and he can select a file. After the conversion, I wanted to use the local instance of the DataManager
to invoke a server rpc to tell the server, "Hey, here is new data I have converted, put that into the array and replicate it alongside its representation to all other clients".
Because the local instance is still owned by the server, the Server RPC fails silently. Therefore, I rerouted the Server RPC through my PlayerController, which worked, but left me wondering:
Is there a better workflow so that I can prevent bloating the PlayerController with RPC functions? I have read that I could set ownership when spawning the DataManager, but can't really get
my head around how that works with multiple clients, as the server can only set one client as owner?
Or would it maybe be better to let each individual client playercontroller request the ownership of the local instance of the DataManager after initialization?
Thanks!
heres a basic version of what i done
this sorry
have you tested it? that should work
make sure to change the spawning rule to always spawn
cant even get it to work like this
can you steer away from your system when doing the test
try to do it inside your character
ill try thats in a component btw
if the actor is not owned by the client, your RPC will get dropped
right
well I never do any networking with an actor component yet so I have no idea if it work or not
went back to my system and noticed the client actor disapears for like a second then re appears
well you will have duplicates in the client
One that you spawn locally
and the other one that comes from the server
yes i know but im testing a edge case where the server denys the spawn and tells the client to destroy that actor
and it destroys and then magically spawns agian
In your Spawn Server Function -> Validate (If True) -> Spawn actor -> Client Destroy Build
if false -> Client Destroy build
captured here it gets destroyed then is back somehow and all its data has changed like health and all that
yes thats my current setup
gotta sleep, gl with it
Thanks replicated my entire system here and it works but not in my system it doesnt
Hey Everyone - I feel like my logic is correct here but its not working so wanted to run by you guys.
I want to store some data in the PlayerState. I have a variable X which is set to replicate. From the client I call a server RPC from blueprints to modify X. However after this function is called I do not see changes to X being replicated to all clients, or even the owning client who called the RPC.
Is there something I am missing? I am not sure why the changes to the variable are not replicating to all the clients.
Edit: Apparently I was calling the server RPC for the game state from the client which was not working. Calling an RPC to my player controller on the server which then modified the GameState did the trick
For multiplayer games, do they use two servers? One for logging in and one for actually connecting to the game?
Quick question on this, are you seeing the server RPC are you using a rep-notify to understand if it's being received on the clients/ server?
For future reference, this might be a great tactic to make sure stuff is happening in the right order without a custom event rpc
I'm just making the variable visible from the editor so I can see when it is modified
So I can see if it is changed when another client sent the RPC
got it, I'd really advise using rep-notifies + a print statement to validate, as that will also tell you where it's being replicated
of course, but order of operations can mess you up later with that test method, so it's good to have more tools
Rep notifies are fine but I'm hesitant with them because they wont be called if a client hasnt connected to the server yet
I'm not saying you're doing anything wrong for the record
Yeah I see the benefit of rep notifies for understanding when a variable is changed for sure.
That's 100% true, it hadn't occured to me there was a possibility you hadn't connected
I appreciate the advice 🙂
Of course! Good luck, multiplayer is hard!
It depends on your server architecture and games. An auth server is generally a good thing if you have player accounts and stats, and then matchmaking. You can use middleware instead that serves this purpose like Steam SDK, Gamelift SDK, EOS, Playfab, etc. But it depends on how much work you want to do and what you want to manage
I’ve been setting up playfab but I’m not really sure how you’d be able to tell things like online friends or the status of servers without an auth server.
Yeah so for friends and such, it's REALLY best to use an API, I think Playfab has that
So "offline" is a weird thing... You don't need to be TCP handshake connected to a server to request stuff from an api at intervals
for something like league or fortnite where you invite a player to your party to queue for a match, then joining your party is really just their data being sent from an api?
You can always ping it at intervals and get your status without needing to be connected, it's just a "Hey what info do you have"->"Returns info"
"Hey where should I connected"-> returns servers you can get to
yeah and then the players being represented in your party is probably a listen server or something
Otherwise cost would be obscene
for lobbies
At least that's what I'd do, there's a million ways to do this
So a functional flow could be launch game->”offline” login map->enter credentials->logged in listen server map->api calls for friend list status and invites->party formed->queue for match via api call->connect to game server
Anyone here made the setup of FPS Arms and a TPS body mesh to show to other players? I want to know how do you handle picking up an item, say a flashlight, you can't attach it to both meshes at once, so do you spawn another flashlight, one attached to the fps arms, and one to the tps body mesh? or how?
I'm assuming that others cant see your FPS arms, so it would just attach to FPS arms for you and to TPS for all others. Not sure what the difficulty is here?
Yes your assumption is right, but I can't attach one item to both meshes at the same time, can I?
That said, often the FPS arms\weapons are completely separate items. What do you mean? the attachment is purely visual and local so its not attached to more then one.
for example, in my code, when I pick something up, I'll attach it to the mesh like this:
Interactable->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, ItemHeldStruct.Socket);
okay now it's attached to the fps arms, now we need to attach it to the tps body, I can't do another AttachToComponent to the tps mesh because then it will be detached from the fps arms, am I missing something here?
which made me think I should spawn another item that will not be seen by the owner, that will be attached to the tps mesh
Hmm, well FPS arms only need to exist on the owning client, so attaching would be purely client side for the owning client. It's probably easiest to attach a copy locally, it may be possible to attach the same one, to the FPS arms, locally only.
Yeah that might be a thing, I'm just not experienced enough to think of a way to do it yet, but I'll keep what you said in mind
Thank you
Question: I have created a Death Event for a character class that is binded via a Delegate that activates when the player's health reaches zero (a Gameplay Attributes thing from GAS).
I have the Event run on the server using ServerRPC, as originally this binding of the delegate and event was on the GameMode class but I moved it to the character class.
I wanted to ask if this way of doing things is secure enough for multiplayer (as in, players can't somehow manipulate this).
I'm using the following to restart the match after a game is complete:
GetWorld()->ServerTravel("?Restart");
When this happens I get this crash:
AActor::CallPreReplication (this=0x7fd117c352a0, NetDriver=0x7fd11dbe75e0) at .\Runtime/Engine/Private/Actor.cpp:1578
Is this the proper way to restart the match? I took it from the AGameMode class RestartGame function.
Goodday guys , I have a small issue.
When I'm packaging the dedicated server from source engine .
and trying to join from launcher version as a client its failed
PendingNetDriver[OutdatedClient]: The match you are trying to join is running an incompatible version of the game. Please try upgrading your game version
Same code and same build but only difference is Engine Source / launcher
So I have to keep working with Source engine ...
Because the other devs using launcher version I thought maybe we can avoid this issue @solar stirrup 😦
Package the client using the source engine version as well
You don't have to work using the source engine assuming you didn't modify the engine at all
But when you package your game, use the source one
I'm testing the Party / Team System so I have to travel between local to lobby ( Dedicated server ) thats why i'm packaging the server using source code
and letting other devs joining for testing purpose .
Also I'm using Edgegap Plugin for Deployment so i have to package it using Source Engine
- yes i've modified nothing in engine no need yet
is there a way to reliably deal with things that have already changed before a player joined? like if one player kills some enemies, then another player joins after that, they should be dead already, would a simple begin play event work for updating them? I know most games would use a lobby before the actual level starts so that everyone gets in at the same time but Im wondering if thats the only way
So I started to write my own network segment and using UE only as a client. I think movement replication can be done easily through TCP, like sending every 0.05 sec to smoothly replicate other players around our player. Then I made a decision to pass the data in binary protocol. It is working fine (partly), I'm sending the TCP package to the C# server that listens to that TCP port, but there is a catch. The first package arrives without any error, but from the second package, the data is kinda corrupted, there are missing parts in it. I can't figure out why. This is how I serialize the data before sending to the server: ```c++
void AConnectedCharacter::SerializePlayerState(const FString& Context, const FString& PlayerName, float x, float y, float z, float rx, float ry, float rz, float vx, float vy, float vz, TArray<uint8>& Buffer)
{
uint8 MessageType = 1;
uint32 DataLength = 1 + 4 + 1 + Context.Len() + 1 + PlayerName.Len() + (9 * sizeof(float));
Buffer.Add(MessageType);
Buffer.Add((DataLength >> 24) & 0xFF);
Buffer.Add((DataLength >> 16) & 0xFF);
Buffer.Add((DataLength >> 8) & 0xFF);
Buffer.Add(DataLength & 0xFF);
Buffer.Add(Context.Len());
Buffer.Append(reinterpret_cast<const uint8>(TCHAR_TO_UTF8(Context)), Context.Len());
Buffer.Add(PlayerName.Len());
Buffer.Append(reinterpret_cast<const uint8>(TCHAR_TO_UTF8(PlayerName)), PlayerName.Len());
Buffer.Append(reinterpret_cast<uint8>(&x), sizeof(float));
Buffer.Append(reinterpret_cast<uint8>(&y), sizeof(float));
Buffer.Append(reinterpret_cast<uint8>(&z), sizeof(float));
Buffer.Append(reinterpret_cast<uint8>(&rx), sizeof(float));
Buffer.Append(reinterpret_cast<uint8>(&ry), sizeof(float));
Buffer.Append(reinterpret_cast<uint8>(&rz), sizeof(float));
Buffer.Append(reinterpret_cast<uint8>(&vx), sizeof(float));
Buffer.Append(reinterpret_cast<uint8>(&vy), sizeof(float));
Buffer.Append(reinterpret_cast<uint8*>(&vz), sizeof(float));
}```
And this is how the server processes the data: ```c#
private void ProcessBinaryMessages(List<byte> messageBuffer)
{
while (messageBuffer.Count >= 5)
{
byte messageType = messageBuffer[0];
int dataLength = (messageBuffer[1] << 24) | (messageBuffer[2] << 16) | (messageBuffer[3] << 8) | messageBuffer[4];
int fullMessageLength = 1 + dataLength;
if (messageBuffer.Count >= fullMessageLength)
{
byte[] message = messageBuffer.Take(fullMessageLength).ToArray();
messageBuffer.RemoveRange(0, fullMessageLength);
ProcessMessage(message);
}
else
{
break;
}
}
}```
private void ProcessMessage(byte[] message)
{
using (MemoryStream stream = new MemoryStream(message))
using (BinaryReader reader = new BinaryReader(stream))
{
byte messageType = reader.ReadByte();
int dataLength = reader.ReadInt32();
Console.WriteLine($"Processed MessageType: {messageType}");
Console.WriteLine($"Processed DataLength: {dataLength}");
int contextLength = reader.ReadByte();
string context = Encoding.UTF8.GetString(reader.ReadBytes(contextLength));
int playerNameLength = reader.ReadByte();
string playerName = Encoding.UTF8.GetString(reader.ReadBytes(playerNameLength));
float x = reader.ReadSingle();
float y = reader.ReadSingle();
float z = reader.ReadSingle();
float rx = reader.ReadSingle();
float ry = reader.ReadSingle();
float rz = reader.ReadSingle();
float vx = reader.ReadSingle();
float vy = reader.ReadSingle();
float vz = reader.ReadSingle();
PlayerState playerState = new PlayerState
{
PlayerName = playerName,
Position = new Vector3(x, y, z),
Rotation = new Vector3(rx, ry, rz),
Velocity = new Vector3(vx, vy, vz)
};
Console.WriteLine($"Received CONTEXT: {context} for PLAYER: {playerName} and POSITION: {playerState.Position}");
}
}```
(refactoring is on the way after I successfully implement the whole TCP system 🤣 )
I'm curious why you dont just use unreal networking?
I'm planning to create an MMO and as far as I know, built-in UE networking is not capable of that.
That's why like Fortnite can handle only like a couple of 10 players (100 perhaps) inside a single session. At least I know this way.
Hmm, well, I don't know how well it works at scale, but it's pretty good, and what you are doing.. is not really. There is a reason UDP is generally used (that being TCP is always ordered and reliable, which isn't always needed, especially for moment replication, where old packets can just be discarded). Making it terrible for bad connections. (extra terrible)
Yeah, but to do that with UDP, interpolation is well needed to avoid false movement. And most of the MMOs out there use TCP for movement replication as well.
And yeah, my solution might not be the best, that's why I take the time to experience the best possibilities 😄 But hard to track down, since there are lack of information/example on custom networking build.
by the way, why is only one of the parts cast to a pointer? pretty sure they all need to be
Buffer.Append(reinterpret_cast<uint8>(&vy), sizeof(float));
Buffer.Append(reinterpret_cast<uint8*>(&vz), sizeof(float));
ah I suppose that makes sense, *makes things italic* and would need to be escaped, I suppose that is what is happening, but cpp formatting is overwriting the italic. (Probably what is happening)
Yeah might be 🙂
Personally I'd write it into a struct and then serialize that, less prone to failure, and typing mistakes. Like uint32 DataLength = 1 + 4 + 1 + Context.Len() + 1 + PlayerName.Len() + (9 * sizeof(float));
Yeah, basically the whole part needs to be reworked, I just want to make it work and once it's working, I'll refactor it 😄
Still if the first packet goes right but the rest goes wrong the issue is likely not here. But elsewhere in sending or receiving, at least I don't see any clear error, something that would just need to be debugged. Also I feel your message buffer thing is not really done right, you are removing elements from the array, that is just slow and unnecessary, same with copying the elements to parse a part of it, unnessarily slow.
This is the listening part on the server: ```c#
private void StartListening()
{
try
{
listenSocket.Bind(ipEndpoint);
listenSocket.Listen(10);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("--> [PlayerDisplay TCP Server] is running...");
while (true)
{
Socket clientSocket = listenSocket.Accept();
_ = Task.Run(() => ProcessClientAsync(clientSocket));
}
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}
private async Task ProcessClientAsync(Socket clientSocket)
{
try
{
byte[] buffer = new byte[4096];
List<byte> messageBuffer = new List<byte>();
while (true)
{
int bytesRead = await Task.Factory.FromAsync(clientSocket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, null, clientSocket), clientSocket.EndReceive);
if (bytesRead > 0)
{
messageBuffer.AddRange(buffer.Take(bytesRead));
ProcessBinaryMessages(messageBuffer);
}
else
{
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Exception handling client: {ex.Message}");
}
finally
{
clientSocket.Shutdown(SocketShutdown.Both);
clientSocket.Close();
}
}```
Just to give an example for this part: c# Console.WriteLine($"Received CONTEXT: {context} for PLAYER: {playerName} and POSITION: {playerState.Position}");
1st package:
Processed MessageType: 1
Processed DataLength: 1526726656
Received CONTEXT: UpdatePlayerLocationOnServer for PLAYER: Szabii-E361A3E9492AA and POSITION: <900 1110 92,0126>
2nd package:
Processed MessageType: 0
Processed DataLength: 475725824
Received CONTEXT: pdatePlayerLocationOnServerSzabii-E361A3E9492AAaD??Dt?B for PLAYER: and POSITION: <7,246102E-22 2,63372E+20 1,0077427E+27> ```
The initial data length clearly isn't right
Now that I see this high number, I agree xd
Don't really understand the cause of it, this is how the dataLengh is calculated: c# int dataLength = (messageBuffer[1] << 24) | (messageBuffer[2] << 16) | (messageBuffer[3] << 8) | messageBuffer[4]; int fullMessageLength = 1 + dataLength;
Endianness?
Tried with the reverse order but that was a bigger mess 😄
That message you display doesnt use that calculation
int dataLength = reader.ReadInt32();
I can try that
That is what you are doing
I mean the conversion from big-endian to the host’s little-endian format.
in fact would that even work? if a variable is changed on the server, is it even stored on the server for a player who joins later to be able to see correctly
What type of scenario are you talking about here? because any actor that the server has authority over will be spawned by the server and replicated, if it is the destroyed it simply wont be spawned for new joining players. And if you want to create things like dead bodies then you'd either have a seperate dead body actor, or the same actor that simply has a replicated variable that says isDead or something, and have a repnotify on that sets it to ragdoll or whatever/
yeah, Im doing some more testing and it seems most things like enemies health replicates fine in this case, so it could just be that I havent replicated the death events properly. seemed ok since they die correctly for both players when theyre in the server, but I guess I havent updated any variables that would let it know after the fact
Maybe you are using multicast
but are there any other problems with joining an in progress game that I should know about?
Also only server should call destroy actor
If the server destroyed the replicated actor, the client copy will eventually be destroyed
Ofc late joiners won't see it either because it no longer exist in the server
yeah, noticed it works fine with my health/ammo pickups
Just be aware to not use multicast on any stateful behavior
so right now Im testing with setting "dead" to true on the server when an enemy dies, and then when the player joins, I have begin play on the enemy to check if theyre dead and then just destroy actor for now, but Im getting 2 different results on the dead variable
Hmm I never experience with placed actor in the editor, will find out after work.
Though I do expect the enemy to not spawn at all if you already destroy it
Make sure the actor is replicated
And toggle client load or something and see the results
Net load on client*
yeah destroying works fine, but the enemy is supposed to ragdoll, however I wouldnt mind if it just didnt spawn in the first place if it was already dead when the other player joins
Ragdoll can be a state imo.
bRagdoll on rep. If true, do your Ragdoll logic
Not sure how to sync them tho (having client and server see the same thing)
synching them is pretty hard, and is pretty much never done, ragdolls are 90% purely client side and different per client, its just that people dont notice.
I mean like the first player would see the ragdoll as normal, then the second player to join just doesnt see the enemy at all because they died so its not important. Im certainly not gonna try to accurately replicate ragdolls themselves lol
I think randomly result is more or less the same when players are in the game
For late joiners, that do be tricky to get the initial state the same
Like when you play in game your character might get catapulted by a force but when late joiners join, they just face plant to the floor
Not worth the problem anyway imo
Pretty sure in counter strike they just rag doll locally
yeah I noticed in tf2 as well, Im not worried about it
I do have a thing that kinda drags players ragdolls into place but its a bit jank looking, kinda funny though
Meshes are easier I guess, you can get the current velocity. Skeletal mesh ragdoll, I have no idea
I tried a thing with having a fake ragdoll on the other end thats updated in its anim blueprint, which I could get 100% accurate but only by making this big horrible script that replicated way too many variables to be usable
this was a different project just for a test
@bitter robin I'm trying to learn seriliazation, what sort of exercise or examples I can look at as a complete beginner?
Sounds like the path of least resistance, I would totally opt for that.
OnRep_ is called before BeginPlay ?
yeah its just being annoying, the death events are in fact replicated but it doesnt seem to know that when I join
I don't really have any good ideas about that, that said, Serialization itself is quite broad, since it's not just gaming (network) serialization, but also any type for data format...
You'd probably want to look for a tutorial for you specific usecase 🤷
Yeah I guess gotta start looking at bit wise operator
Ty for the insight
hmm so yeah it seems whatever I do, setting "dead" variable wont be on the enemy on the players end if they joined after it was set
variable is replicated, tried setting on server event and multicast, but just comes up false
Don't use multicast
Only server should handle dead event
And only server should set the bDead replicated variable
Server RPC is used by client to tell server to do something. In case of death why is client telling server hey this enemy is dead?
A.I is server bussiness
Changing a variable on client will only propagate the change locally.
For something to be replicated, the server has to set it. It will then update clients version eventually (or on net update, not sure)
yeah Im mostly used to that but for some reason things like playing montages has only worked on multicast on enemies
Rep notify
Though I would just say use GAS
Just started my project but I have 0 thing on multicast
Only use it if you know what you are doing imo. Is something need to be in sync? Yes? Don't use multicast. Period.
but enemy montages and other effects literally didnt work with server events
other than that all my players events are appropriately multicasted only where needed
Because you are only running it on server machine
Hence use repnotify
You will need a variable that drive those montages
To make your life easier, use GAS it already handle playing montages.
There's even a dev that have published a game that says he has 0 multicast in his game.
While multicast has it uses, I can see that you are using it for the wrong reasons. Eg playing montages when you want the montage to be seen by everyone.
Just imagine you play dancing montage with multicast. What happend to the late joiners or player outside relevancy?
The character won't dance in their machine.
in that case, whats the variable thats being set? are you treating the variables like events at that point?
instead of activate event, set variable with notify
oh thats so weird, making the dead variable notify makes it automatically kill them when you join, thats pretty funny but I can see why thats happening
As long it's replicated the variable will sync on join
If u have it on replicated only, the value will still sync. Bdead is true
But you are not doing anything meaningful with the variable?
That's why repnotify exist. Basically can be translated to, when the value change or when the server update this variable on my machine, do this function.
yeah, it mostly works now, although they die at their starting location and not where they were killed by the other player, and with these functions its a little inconvenient not being able to use any delays/latent actions
Try to avoid delays
Well I shouldn't say that but
Know when to use it
Especially in multiplayer, latency exist. Order is not guaranteed too
actually on the subject of that, I often have to use tiny delays for things like applying velocity to a ragdoll for example, if it happens when the enemy is alive, it will throw up an error because in that frame theyre alive (and not simulating physics), but if this is the hit that kills them, one frame later theyre dead, so I have to add the tiny delay to then check if theyre dead then apply the velocity. is there any proper way to check for like the next frame? not sure if Im describing it right
Delay until next tick?
Sounds like you just want to check if the component is simulating physich or not tho
Not that I ever touch physich stuff
this is just an example, but its a very annoying little thing because in the frame a bullet hits, the enemy is not ragdoll. in the next frame they are. sometimes I just need something to activate as soon as its able to do so
something like that would probably work in most cases like this
so yeah I just cant get it to set to the correct location
even though their location updates fine if you join after theyve moved
but triggering the death when you join, well that STOPS them from moving, so they wont even go to the location they were actually at, just die where they spawn
this is another thing that I would ideally delay so that it at least gets a chance to update their location, but I cant delay that because its a function and it has to only delay for the player who just joined
the point is I clearly need something different to happen between players, but how am I supposed to do that when its a serverside enemy
Hi all -- I am designing a system where a player can mount a cannon, which lets them aim and shoot it.
I'm wondering how to approach the rotation of the cannon when a client player takes control of it. If the cannon is owned by the server, I don't think the client can rotate it without the server correcting it back.
I was thinking the client might need to send RPCs on a timer to tell the server where the cannon is aiming. Does that sound right?
And for the client, it might need to somehow prevent the server from trying to correct it.
Any guidance is appreciated! Thanks!
attach playerpawn to the cannon, and possess the cannon, maybe?
I'm trying to avoid possession as it creates some other issues. I'm doing input forwarding instead.
Hey guys, a question... is there a way to make nearby clients in a game with a dedicated server see the animation I'm running without having to use multicast? Because I have a notify inside the animation that spawns an actor and it spawns me an actor for each client, it also adds to the server, for example if I'm testing the game with 3 clients it spawns me 4 actors, why does it also count to the server? Thanks
Whats the montage? Usually montages are things that get piggy backed but happenstance, not usually needing an explicit RPC.
Taking shooting or hitting with a knife, you would do an attack function that does a whole lot and just but "attacking" you play the montages and then it would normally (if its something common) be paired with a replicated value that represents the state, like bIsShooting will start the loop animation on other proxy clients
this is really annoying me now, when using a repnotify, if thats gonna be what causes the death events, but its also gonna happen automatically on other players when they join, how am I supposed to make a one size fits all event for two different situations?
you know what I think Ill just duplicate the entire script and activate separately somehow
EVERYTHING I TRY causes a problem in something else
even when I find a way that should logically work it then just breaks for one client somehow even though its a serverside enemy so that makes literally no sense
I keep getting this damn thing where the enemies "ragdoll" BUT STILL IN THEIR ANIMATION? they just fall over like a statue and I have no idea how the hell thats even happening, its not their capsule simulating physics I have that set to show in game
why can ONE player activate all the death events properly and not the other
ridiculous
oh and thats only for one player by the way, its a normal ragdoll on the other
put it back to a multicast like before and it works again

Hello Guys,
I need your help with understanding multiplayer concept, I am not sure why this is happening.
Note I am Using 5.3 Engine
What I need to do - I want to control an AI in Multiplayer setup, where player select a destination for AI to Move using widget.
What I have done -
I have created a AI which is set with replicated movement and replicated as true.
I have create a UI, a combo box and AI is Waiting for player to select a Destination where a Ai will move,
As AI is Controlled by Server and Widget are spawn for Particular Player Screen, I need to send selected location details to server,
I am using Event which is run on the server to send the data Server
When I am testing it in multiplayer, for some reason, I am not sure, "Client Sending data to server" is printing for client, but "Server Received Data" is not printing for server (Event not getting called).
Please help me understand this, Thanks for your support
Rip
Which Actor is this Nodes in?
With this I have also found this with unreal 5.3 , 5.4 and 5.2
Testing - a simple thirdperson template, where on a input press "Q" I am print Hello, test is done for multiplayer with 4 client
For Unreal Engine 5.3 and 5.4
when input is press - print string always happens for client 0 for some reason,
For Unreal Engine 5.2
When input is press - Print string happens for the Client for which the input is pressed.
Please let know, If there is a setting that needs to be changed
Thanks Matt for your quick reply,
This node is place in AI Itself, When A player is interacted with AI which is done using Interface
The only Actors that can call RPCs to the Server are the PlayerController and any Actor owned by a PlayerController (such as the Controlled Pawn or the PlayerState).
Since the AI Actor is not owned by the PlayerController, it cant send an RPC to the Server.
Your PlayerController should be responsible for sending information to the Server about commands you want to give independant AIs.
That's a bug on that got introduced in 5.3 or 5.4
The only fix is to dive into cpp and edit the source code. Changing the part where it get the client Id
okay, So what I can do, is when a AI is Interacted|
AI Code -
Interface Event - Interact -> call a function of Player Controller - which will create widget
Player Controller -
Create Widget - on selected - " On Server Event" which is created in Player controller itself, Need to be Called
Right?****
Doesnt really matter what you do, the point is, the PlayerController needs to send the RPC to the Server.
WidgetEvent->PlayerController->RPC->(Server)->AICommand (something like, MoveToLocation 🤷 )
This thing got me confused, As it changed my thinking, I thought "On Server Event" is only called by owning client.
Why Client 0 was printing, for different client
Thanks for the help, I will test it out and let you know
They messed up the data type or something. Changed the int to struct can't remember. But basically everything print as 0
Thanks Guys, it's working 👍
Hey there, I have a question regarding ownership and some workflows with it:
I have written an actor, lets call it DataManager, that is responsible to import/convert json files to my data structure and store this data in an array. That actor and the array are replicated.
For each entry in that array, a world presentation in form of a replicated actor is spawned. I got to the point, where I want to give the client the option to locally import jsons as well.
So he presses a button, the file browser opens and he can select a file. After the conversion, I wanted to use the local instance of the DataManager to invoke a server rpc to tell the server, "Hey, here is new data I have converted, put that into the array and replicate it alongside its representation to all other clients".
Because the local instance is still owned by the server, the Server RPC fails silently. Therefore, I rerouted the Server RPC through my PlayerController, which worked, but left me wondering:
Is there a better workflow so that I can prevent bloating the PlayerController with RPC functions? I have read that I could set ownership when spawning the DataManager, but can't really get
my head around how that works with multiple clients, as the server can only set one client as owner?
Or would it maybe be better to let each individual client playercontroller request the ownership of the local instance of the DataManager after initialization? Any hints would be appreciated!
Probably pass it to a component owned by an actor that the client owned (controller or character)
_
From my understanding PostLogin only get called once when clients join.
Is there any callback I can use when a player loads the level?
I would need one to work at the start of the level regardless using Hard or Server travel
How would I give each player a different tag for instance player ones tag would be player 1, And player two`s tag would be player 2 and so on
assigned them tag when they join the game?
Game Mode -> Post Login
or do it based on slots in the lobby
really depend on the context, I guess.
Hiya, when using the server travel node with advanced steam sessions, is there a way to add Options like you would with the Open Level node?
Hello Guys,
I have a question regarding Gameplay Ability System,
Can we use Replication RPC Event inside Ability Class,
For my Ability Class, I am using "Wait Gameplay Event" to trigger, Once Trigger, I am creating a widget for the owning player, Once the player select option form widget, I need to send that data to the Server as well as Other Client.
Is it possible to do all in Ability Class or Do I have to send the info the player character/ player controller to handle the RPC Event
Hey!
I have a question regarding networking, and how I'm doing some things. I'd like to know if my approach is correct, and if not, how to improve my setup.
The idea is to have player pickup items from the floor, and have this items move to their model (like carring it on the back or their hips). I created a component that defines what the player is carrying, which just has 4 different actor references: hands, back, left and right. When an item is picked up, a reference to this item is assigned to the slot the item is stored.
When a player press the pickup item button, a call is made to this component, which runs only in the server, and after some logic (like detecting which item to pick, and where to store it), the item in question is assigned to one of the slots.
This assingment is done with RepNotify, and inside the OnRep_{slot} I attach the item to that player's socket
This is working fine, but I have~~ 1 issue, and~~ 1 worry.
The issue: the inventory components and its slots are only updated in the server. Which makes sense since the function that assigns items to slots, is set as "Run on Server". But I though the RepNotify also propagated the value assigned to the clients, but it seems its not the case. I don't know if this is by design, or that I missed some configuration. This means the inventory component is only updated on the server, and the clients see their (logic) inventories as empty, even if they see the items attached properly on the players' models. I was replicating the items, but I was not replicating the inventory component!
And my worry is that since this all runs on the server, it can make item pickup and switching kind of sluggish for clients if there is lag, since AFAIK there is no prediction in this setup. How could I improve this?
I personally wouldn't worry too much about that, it's not like you are playing with 500ms, and even if you are if you do prediction with that much latency the chance of it going wrong is much larger as well, so if you were to instantly display it on clients then find out it failed it will probably result in much more janky looking effects then the small delay.
Of course you can play around and see which works best, I also don't know how you equip things, if they are just you touch them and its auto equip? meaning its instigated from the server side, or if you are like equiping someting on an inventory screen (in which case directly doing it client side and then replicating the same action will probably feel much more responsive)
currently, you pick up items by looking at them and pressing E
if your hands are free, it goes to your hands, it not it fills one of the other 3 slots
if all slots are filled, it swaps the item in your hands
i still have to implemente switching between items, and that really needs to be responsive
is there any tutorial/documentation about handling prediction? I have no idea how to implement it on UE
Prediction in this case just means you do on the client right away what you expect to happen, like equipping in hand or in one of the slots. Then proceed to replicate it normally
mmmm, i just do it in the client, then call the same logic on the server? when the server updates the client, the client will already be in the state the server notified right?
Hi, are overlaps supposed to be called on every single player? ive got a box overlap used for interaction but when any player steps into it, it prints out for every player in the game? That seems odd...?
and it says client 0 twice.. shouldn't it be client 0 and client 1?
The overlap occurs on all copies of the game. So if you have 3 players in your game and one of them triggers an overlap, you can expect to see 3 prints as the overlap was detected on the server and each client's end.
This is a known bug with the latest versions of Unreal due to a small change with how they identify clients. I believe it's been fixed in the upcoming version.
I am still having an issue tho, I've got my interactable base class which has 3 different overlaps, one that when entered will display an indicator widget indicating the thing can be interacted with, the other 2 are pressed interaction or hold interaction as the widgets displayed are different
I was having all this timer code pretty much running on the characters tick before but decided to do it as a timer on the interactable base class instead so it wasn't running constantly on tick all the time, but now the widgets wont display for clients anymore, how should i be handling starting the timer so that it works properly for everyone? Works on the server of course lol
Ahh okay thats nice to know for both of those, thanks!
Is there a way where I can make the variables I set in the gamestate persist when server travelling?
They seem to be changing fine in my lobby map, but then are reset when I change level
You can either put them in the game instance since that persist anyways or if you can use the player state instead of the game state there is a CopyProperties function/event that you can use to send over the data to the new player state
Im not sure about the game state
Oh interesting, I'm staying away from the game instance because I need to replicate it to everyone else, but I would have figured the game state would have been fine :/
GameState doesn't persist. So yeah, put it somewhere else.
Is there anything that does persist other than the game instance?
If you SeamlessTravel, you usually only get the chance to persist data between PlayerControllers and PlayerStates.
You can persist your own actors too, but that needs C++
Gotcha, basically i'm allowing a host to change the match length in the lobby, so that's probably better in a player state than PlayerController* right?
How do you travel to the Gameplay Map?
I'm using the Steam Advanced Sessions server travel node
Does that allow options to be specified?
Sadly just the level URL, Absolute, or should skip game notify