#multiplayer
1 messages Β· Page 100 of 1
my player starts arent loading in on time Actor channel failed: [UActorChannel] Actor: Replicated_PlayerStart_C
Hello, I have a general question about actor and component replication. π
When designing an enemy that is composed of multiple separate meshes whose movement will need to be replicated, are custom static mesh components preferred, or is it better to make each piece a separate actor?
I see that bComponentReplicates will replicate the component transforms as well but I wonder if there's a catch I might run into.
Any advice would be appreciated. π
Cheers.
are there any references available for built-in and on-the-fly server changes without reloading the level on the client?
getting an exception here, why? Only happens if theres more than 1 player in the game:
Beause there is no controller for the second player on each client, therefore you won't get a widget
if you absolutely can't use animations for this, i'd say have multiple mesh components under 1 replicated actor and replicate each position / rotation all at once, having a seperate actor for each will be some major overhead
Thanks, Omnicide. I think that's what I'll try first. π
oh right thanks
HasAuthority might return true for clients in the GameInstance, since authority doesn't mean server. So you'd want to test for server instead. And no, you could only try to package the project with a different GameInstance, but I wouldn't advice to do that
Also keep in mind that the GameInstance is not meant for gameplay code
π² I thought that was the whole reason for switch has authority
How else can you check for server?
Ah nice
Or IsServer fwiw
Authority means the connection has authority over the object/actor. A locally spawned actor for example. The client has authority over that.
ah that makes more sense
That's generic enough to fit more into #programmer-hangout #lounge or maybe #ue5-general (only one of them). Multiplayer seems a bit out of place or?
I would replicate the state that DRIVES the mesh movement
What's the use case, humanoid?
Hi Adriel, thanks for your interest. π I'm building a boss with an arm with a magnet on the end. The magnet will pick up other actors via component attachment. I'm wondering if my magnet should be a component of the larger boss or a separate actor attached to the boss. π€
are there any references/resources to run a custom server (for instancing + fast movement replication) together with a dedicated server (for pathfinding and maybe player information&inventories)? i found a guy who does that with his own java server (yt: Unreal game dev with Yaz) and i find the concept pretty good for scaling users in a (massive) multiplayer online game
i wonder if more people explored this concept already
hey guys
two problems
its only replicating on one of them ? (playing as ListenServer)
Hello, I have a bit of an issue with the outer of a replicated UObject. My current setup includes an actor component that houses a replicated and instanced UObject. I add the UObject to the Replicated Subobject list on the actor component's owner.
This works the way I want it to; however, after the client goes out and in of the net cull distance, the outer on the client still points to the original actor component and actor, and not the newly created ones. From what I have learned, I believe this is due to me having the outer as the actor component (due to instanced), and the UObject being added to the actor's subobject list.
I know the simple solution of getting rid of the instanced property, but it is very convenient for my situation so I am looking for a way that keeps my current implementation. Thanks in advance!
anyone :/ ?
My Mesh_3p animatino montage never fires. Anyone have any guesses?
Depends on how reusable it has to be
Just adding components to the boss is fine but if you want something other than a magnet sometimes or want other dudes to have the magnet then consider making it an actor, just like a weapon
@ivory bear are u even calling the event ? that image gives us nothing really :/
Adriel could u help me π u know this i know u do
apologies, here is the top half. The E key is calling it. The Mesh_1P montage plays on click, nothing happens for the Mesh-3P
can barely see the text tho, did u try printing all the way and seeing where it dosent work ?
Yes, the string after the Mesh-3P call shows on screen.
Here is my character setup
This is the multicast and the print string at the end fires, just no animation plays.
yes
then its something wrong with the animation or whatever
not in the code
or what is it suppose to do ?
yes, the MC fire montage appears to complete and reach the print string, but the animation does not fire on screen
Its funny, because I got aim offset and projectiles replicating...just not the ^&%$^$ montage that fires and the muzzle flash.
listen server ?
got all that working when 2 players and play as client
when I switch to Listen Server, my aim offsets work, but line traces (projectiles) do not.
After moving very close to each other, I can see that the anim montage is firing...jsut so slight you cant see it unless you are on top of each other. Odd, but promising.
well, ive only done dedicated server somehow everything works there , but im trying with the listening server now abit more trickier
however ppl in this channel usually is very helpfull just today ppl are chilling i suppose
yeah gotten some good help and other days things fly by so fast people miss it.
"play as client" creates a "dedicated" server for you, right.
well your playing on the "dedicated server"
client is both server and client
the "host"
I get 2 "clients" and neither is server. Listen server is both a client and server, right?
one of them are both yes
No, listen is a server that also plays the game. The other is a dedicated server which is just a console without any GPU or audio.
Listen is not also a client.
well couldent u just call it that tho ?
Because a client doesn't have authority but a server (dedicated or listen) does have authority.
UE uses the server authoritative approach instead of Peer 2 Peer networking.
aye
If you were to create a radial 'force push' that emanates out from a player character, would simply creating a blocking volume and scaling it to push the opposition character away from yourself suffice?
or would you do it with a more deterministic method?
For 2 players:
Play As Client means a hidden dedicated server and 2 clients
Listen Server, the editor is both the server and the client.
void AMeleeBase::NetMulticast_SpawnAura_Implementation(UNiagaraSystem* _EffectToSpawn, float _LifeTime, FName _SocketName, FVector _SpawnLocation, FRotator _SpawnRotation)
{
UNiagaraComponent* SpawnedEffect = UNiagaraFunctionLibrary::SpawnSystemAttached(_EffectToSpawn, GrippableMesh, _SocketName, _SpawnLocation, _SpawnRotation, EAttachLocation::KeepWorldPosition, true);
SpawnedEffect->SetVariableFloat(FName("LifeTime"), _LifeTime);
}``` ```cpp
UnrealEditor_Niagara!UNiagaraComponent::SetVariableFloat() [D:\UnrealEngine-5.1.1-release\Engine\Plugins\FX\Niagara\Source\Niagara\Private\NiagaraComponent.cpp:2293]
UnrealEditor_ProjectVR!AMeleeBase::NetMulticast_SpawnAura_Implementation() [D:\5.1.1 Projects\ProjectVR\Source\ProjectVR\Private\MeleeBase.cpp:1043]```
Im trying to set a variable in a spawned niagara which sets the loop duraction. But if I play as a client it crashes and gives me that crash report. When playing as the server it works as intended
Edit* Its: ```Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000000008f0```
Got it working! Seems my values on the montage we not right. Changed them to what you see here and I see my rifle fire montage animation!
They were something like 0.25 and 1.0 ( I think)
You said code looked right, so I dug into the animations...thanks!
Now to figure out he daggone muzzle flash replication!
I launched with debugger and got this
Edit*: SetVariableFloat() is UE engine function
You could try IsValid(SystemInstanceController) instead
I should have been a bit more clear, that is the function in the engine
How others set niagara variables from C++ then? cpp void AMeleeBase::NetMulticast_SpawnAura_Implementation(UNiagaraSystem* _EffectToSpawn, float _LifeTime, FName _SocketName, FVector _SpawnLocation, FRotator _SpawnRotation) { UNiagaraComponent* SpawnedEffect = UNiagaraFunctionLibrary::SpawnSystemAttached(_EffectToSpawn, GrippableMesh, _SocketName, _SpawnLocation, _SpawnRotation, EAttachLocation::KeepWorldPosition, true); SpawnedEffect->SetVariableFloat(FName("LifeTime"), _LifeTime); }
Is it not like this?
It works playing as the server but not as the client
I also tried replicating the float I input to the _LifeTime
Also doing the variable change with server RPC didnt work
Whats the correct way to move all the players to a new map?
This puts them all into their own map not the same one
Connect to dedicated server IP
ahh got it with the server travel command
@ivory bear nice π
I want to set chest opened/closed for each client based on a bool.
For example: Client 1 ChestOpened bool is true when connected to the server they see the chest opened and if Client 2 Connects with ChestOpened bool is false they will see the chest closed so its client specific
how can I do it?
Im a big noob, but i think a repnotify on the bool would work?
I also have a question. I have a lobby, you can select a character, it sends the character you selected to the game instance. The game starts, it moves everyone into a new map, in the game mode, i use spawn default pawn for override and cast to the player controller, run a function on the player controller that grabs the selected character from the game instance and passes it back, then spawns an actor in the game mode. This is working well but only for the host, not the clients, they all seem to not be able to read the variable. any ideas?
i want each client to be able to get their selected character from the game instance when they spawn
Game Instance only exists for the local computer. It's fine if you want to store the selected character class there while they're moving to a new level, but once the transition to the new level happens, each player controller would need to send an RPC with their selected character class to the server and once they've done so, then you can spawn their actor for them.
An array of some kind that is associated to the players. It can be replicated w/ notify, and the OnRep function you can loop through the array and determine if the local player's on the list, and if so, the chest is open.
The server can also use this array to validate if it can be opened by a player that is interacting with it.
But how will the chest have the player reference if the player has just connected or became relevant π€
another solution I thought of would be the chest on begin overlap check if the client character has chest opened bool set to true then play the animation to open the chest..
Is Anyone looking for Unreal Multiplayer Developer ??
what does it depend on if the chest is opened for a specific client? Does every client start with the chest closed unless they open it themselves or?
yah I mean i'm looking for job opportunity as an Unreal Mutiplayer dev
oh ok well i mean there is some jobb channels id think you would have more luck there
if you dont wanna work for 1$ a day helping me lawl
@queen escarp π okay
So in the level the chest is closed, I want whenever the chest is relevant to the client it will check if the client has chestopened bool set to true, if its true chest is opened if its false it stays the same
is there a way for me to exclude the owning client from this equation? i want the code to run on server and everyone elses client using a multi but not locally because its already done earlier
Where is the best place to get player state as a client as apawn? I'm trying to wait until the player state is set up so I can bind a delegate, however I can't seem to find a good place to set it. PossessedBy is where I'm setting it on the server but that's not being called on the client
check if the pawn is locally controlled and if it is, dont execute logic on the mcast
see OnPlayerStateChanged delegate on the Pawn
its called on client/server
@pallid mesa Thank you! I will try this, I saw that but didn't think to use it as I was looking for something like Init!
yeah that's the best one you got
in fact Epic added that after my PR of suggesting making "SetPlayerState" virtual
haha
we all wanted something like that for a long time
@pallid mesa You said in Pawn right? I can't seem to find it, looking over Pawn.h I can't see it anywhere
What the... I'm running 5.2.1 and my Pawn.h is different. Thanks for pointing me in the right direction though! Appreciate it, that'll be really helpful! π
well u can override OnRep_PlayerState if thats virtual
Yeah, I'll just try that for now, but its good its coming. Will be super useful!
π π
remember that onrep_playerstate is not called on the server
so.... be aware of that!
Thanks for the info dude! π
Guys i need help, me with my frind try to make multiplayer game, using listen server,but unfortunately our your session not visible and can't be found we using Advanced Sessions Plugin and Using Steam Sockets (app id 480 ) i using Unreal engine 5
yup that worked though i swear i tried it before and i got very weird results :d must have been something else wrong with the previous code
heheha oki! Glad it helped ^^
How do I get access to different variables on my character controller?
I have two seperate values on chrCon1 and chCon2 but my keypress is logging the same value on both the serverClient and the client
the other player has a y of 0 and it logs 0,0,0 on both clients
Am I wrong for setting the value on the controller or does it need to be state somewhere
not sure what the screenshot is supposed to be showing us.. maybe reformulate your question in a more coherent way? Also you could post the code for the logging you're doing.
Figured it out
I wasnt using the playerState blueprint
I just had variables on my character controllers and thought ue5 would know which client is asking for the data
how would I do a dedicated server list?
Well again you need some kind of reference to a player who has opened the chest. So like... Their unique net ID or some other thing that won't change every time they connect to the game but can be uniquely attributed to that player.

vori have you been enjoying Iris lately
a bit yeah
i'm glad π
and do you?
i haven't formulated a good opinion of it yet, maybe when 5.3 drops i will post up some benchmarks vs custom backend
we should all strive to be liberated from FRepLayout
maybe write about your custom system
Iris is still buggy enough to not really be comparable to anything else sadly. Just ran into a fun issue with their method of caching ustructs being dependent on module load order. Fixed in main (and maybe 5.3?) but it's enough to make me concerned about doing much with it right now.
π€¨ dubious
very well I will think on it
thank you vori
yeah dont put that on production, I have it enabled on my playground project
I hope it will be more stable on 5.4
Also there's a fun issue where you can't use a server rpc from the beginplay of a component that just replicated. I have no clue what causes that one.
I am also willing to learn from it, i think others will aswell
in main aswell?
I don't know if that one is fixed in main or not
Hard to track down commits relating to that
(and I don't have a main build right now)
π thanks for sharing siliex
hopefully we get a more robust set of test cases before it replaces current replication system
damn wtf is that super react bs
my muscle memory sabotage me
ah well, to a good cause it went
i could it explain but get you wouldn't it
it's not a network ordering issue if that's the joke, probably just iris not setting up some replication state until after BeginPlay which is clearly incorrect behavior
hmm
it just hasn't been applied before beginplay for some reason
i guess it depends if ur -Wpedantic
it's an ordering issue, just not a network one
-Wextra
hey guys
https://gyazo.com/17d04b8c5c5d68ca214a9128115f08ba
its only replicating on one of them ? (playing as ListenServer)
anyone ?
It would be good if it was clear which one was the server and which one was the client, and any actual context about how the rotation is networked
yes but how is the look rotation setup
a crumb of context please
how is the input sent to the server, how is it replicated, etc
waiting for the networking part to come in
no, and it can't even be replicated
oh okey, but how come its being replicated on the client from listen thyen ?
again, I can't tell you this with actually knowing the networking part of what you're talking about
ABPs have no replication, and rely on other networked state to look consistent between clients
think of them as running on each machine individually
so it uses the state of the character which is replicated to make the local animation state
Hey all I'm working on replicating swimming and currently I have a function in tick to check when to set the movement move to swimming or not but this seems to swap all clients movement mode instead of just that players.
Here is the function:
https://blueprintue.com/blueprint/8hd5vdtb/
Any help is appreciated guys, thanks!
When another player tried to enter the water, any in the water will temp swap to falling until the player enters the water. It's driving me nuts
yeah but as u can se on the 2nd video when aiming it shows on both
but not from the left one
Had an issue like this for replicating aiming up and down. Had to cache the y axis from the mouse input and send it to the server for it to replicate properly
This is why I was asking how it was sent to the server and how the server networks the rotation
All I got was a zoomed out ABP snippet
oh
hmm ok
ill look into that
@grave kestrel how would i do that did u use a tutorial or something or ?
created a server function to pass the camera's pitch in and referenced that in the anim bp
@queen escarp How are you setting your ReturnValueY and Z. I assume you are using GetControlRotation which if I am not mistaken is not replicated. Try using a combination of GetActorRotation and GetBaseAimRotation, those should work.
yeah
so im setting this in the playeranim_BP
but i need to calculate it inside the player and send info to server then send it here instead right ?
I would think so yeah, just get a reference to the player, and cache it to save on casting constantly in the update animation event, and set the same values in the bp animation
I have a pitch value both in the character and bp anim, and the bp is set on the server for the character and in the update animation event I set the bp anims pitch to whatever the characters is and have that set to replicated with a constricted range from -90 to 90
but that's just for replicating up and down, I had no issue with aiming left and right
@grave kestrel wdym cache it to save on casting ?
ok now i got it working
however
nah i think were good thanks π
When you init the bp anim you can cast to the character and save that as a reference, or cache it. That way you're not constantly doing a cast to the character on the update animation event. Glad to hear you got it working!
Yeah i know that part o though cache was a special function or somerhinf
However now in updating to the server each anin update frame
Isent that lag causing ?
I've never experienced any major lag from it, I'm just passing the float value to the server and using that to set it on the anim bp, I wouldnt' think that's very resource heavy
Oh okey
and the pitch is only updated on the mouse input axis events so there's that too
Each float is like 8 bytes. 60x per second = 480bytes/s which isn't very much. You could save some of that by updating it less frequently and interpolating.
Well idnno what interpolating means really but i changed it so it onΓΆy updates while im aiming aince its when im using it but
Eg. On the server you could be setting the replicated values 15 times per second, putting the cost per float at 180bytes/s.
On the clients however, you could be using tick to transition between the replicated value and whatever the current value is every frame, so it smooths it out for you making it look like 60 FPS. You can do this using FInterpTo Constant with the target being the new value and the current being whatever the current value is.
when using the push model, MARK_PROPERTY_DIRTY_FROM_NAME makes a property replicate immediately right? similar to RPC behaviour Im assuming
Hmm i think i understand never done it obvi ill try it tomorrow
hoping to get some help on figuring this out. Thanks
show where you're calling that function
from what I gather somehow when calling the set character movement mode in it it's setting it on all clients, it does this when swimming and I attempt to jump when at the surface of the water
as I change the movement mode to falling and call a server function to launch the character
I would start by testing to see if set movement mode should happen on owning client, server, or everywhere
I see no filtering on authority or locally controlled so your logic is running on all machines
I've tested adding in an authority switch as well, same result
@grave kestrelshow what SR Update Movement Mode does
but this code is goofy, you're just trusting the client to set swimming or not
I'd test by hooking up a button to ServerUpdateMovementMode
Yeah started single player side and I'm migrating it to replicated so it works correctly lol
check that you can start swimming without affecting others
funny thing there
Also Water Volume is not a good name for a boolean
Booleans should be questions "Is in water volume?" "Wants to sprint?"
if swimming into a water exclusion zone and dropping back into the water volume it works right
I don't see anything that would obviously communicate with other instances of this character but it's all kinda goofy
nothing I can do about the bool, that's epics lol
What's the test for if should be swimming?
"Character should be swimming if ................ and .............. and not ............"
ooooooooooooooh ok i think i know
you are changing the properties ON THE VOLUME
anyone else IN THE VOLUME will be affected
You aren't just checking stuff and deciding if you are swimming, you are actually setting state on world objects
however a player standing outside can jump and will change to swimming after landing if someone is in the volume
whatever you're doing here, don't do that
are you intending to change the state of volumes at runtime?
Start with:
Tick -> select movement mode based on CMC.PhysicsVolume.WaterVolume
that should put you in swimming when in a water volume and not swimming when not
hmm, thing is the new water body system doesn't have any water volumes afaik
it won't handle the literal edge cases (getting out of water) but it'll be a start. You should not be changing whether or not a volume is a water volume
You might be saying the entire atmosphere is a water volume
what does get physics volume return if you're not in one?
why do you even care about water volumes if you aren't using them? What is your actual test for if you should be swimming?
"Character should be swimming if ................ and .............. and not ............"
looks to me like character should be swimming if sphere trace hits a water body
so just stick to that
none of this volume stuff
yeah I realize, however the characters physics don't change to swimming unless the implementation of the water volume is changed
What happens if you just set movement mode to Move_Swimming in midair?
I'm not sure if the CMC does volume property checks or not, if it does then just add physics volumes to your water areas
you probably don't have to do half of what you're doing here
either way, setting the properties of physics volumes at runtime is not the approach
That is generally the case, I tend to be too literal and less abstract about the approach sometimes. Physics volume is showing default physics volume regardless of location so changing that to a water volume is probably is what's screwing up the clients
THE WORLD IS NOW WATER
yes I have a player id, but how will I initiate the check for it when the player connects or become relevant to chest?
You would need to save the state of the chest somehow on the server I imagine and so, when loading the data into the chest, you'd set the array. The array being set as replicated w/ Notify will give you a means of checking - in the OnRep, you can check if the local player is in the array, if so, they've already opened it, so it should show opened, if not, then they haven't opened it so it should appear closed.
When a player opens the chest succesfully, then they would be added to the array as well, and again, that would fire the OnRep which would then be able to show the chest as open.
Okay I will check thanks!
If A Server event executes a server event within it does it effect anything performance wise?
great, if a server event is set to reliable, and executes other events that are just normal custom events not marked reliable, everything will be reliable still right?
Correct
As long as it's the server that's running them.
If a client calls the unreliable server event, it will not be reliable.
It does make me wonder why you would even mark something as a "run on server" event in this case (except the first one)
can you give an example?
Not really
If a client calls a function marked as "run on server" and "unreliable", it will not be... reliable.
i read it as if client called reliable server event it wont be reliable sorry haha
Why do you have a Server event calling other Server events?
Why are the subsequent ones also marked Server?
because that subsequent event sometimes can be called by its own
Fair enough.
There will be a tiny bit of overhead to check it's a server before running it, I expect.
But nothing to worry about.
Like you want to filter your list of widgets?
in the editor, if i open 4 clients, make 1 host a lan game, the other 3 have to refresh 3 times before it shows up. Is there any way to make it show up straight away?
doesnt matter how long i wait, always need to refresh 3 times
I just want to create a server list
For dedicated servers
You can change on your find sessions node the "Server Type to Search" to "Dedicated Servers Only".
Datura do you remember my question yesterday about the character classes?
A little bit.
so i added an event to set the class on the server aswell when it gets the class from the game instance and both of those print the correct class.
But in the game mode on the override for SpawnDefaultPawnFor function its still not getting the correct info. Is it because its not updated fast enough?
More than likely. "GetCharacterClass" will take time for the client to actually receive the RPC, then it takes time for the server to receive the client's response. It doesn't happen instantly.
So that means you may need to put in some coding that handles when the server is receiving the class that it should also spawn the actor for them.
Like Datura said, you have a race condition here. You'll want to do something once you have all the info like call RestartPlayer or something
yeah i had Event Handle Starting New Player which gets the player start, then runs Restart player, which then fired the rest off. Ill try re arrange everything to call it after it has set the class. cheers
P.S i hate race conditions xD always getting stuck with them
Yep that seemed to work much better. It got 3/4 of the characters right π one of them is a dupe of another though
this didn't work
hi i creat multiplayer with aws on UE5.1.1 Source Build Engine . So my both player joing the lobby or same session But when i try server travel map they are not in same map , Do anyone know what is the issues ?
How are you trying to change map? Are you using the console command with server travel?
yes
That is how mine is set up, i just got it working yesterday
When that runs, what does it say in the output log?
Is this on a listen server, and if so, is it the host clicking the button?
Then this won't work. Clicking a button on a client isn't replicated to the server automatically and you want hte server to execute the "Server Travel" command. Additionally, you want to add an additional space after the "servertravel" in your append.
so on append wite this Server Trave
no "servertravel "
Basically this is considering "servertravelAWS_Lobby_Map" is the command.
you need to call it on the server
Clicking a button on a client isn't replicated to the server automatically and you want the server to execute the "Server Travel" command.
You need to RPC the request to the server and have the server execute it.
how can i do that ?
click the custom event, then on the right in the details panel where it says replicates, set that to server
(Except do it on an actor that is actually replicated, not a widget)
OH OK
I DID
working?
u need to add the space
"servertravel "
yep
nope sir didnt work to
What's the output log say when it runs it
not shwoing any log
Are you sure that events being called?
i write this
can you come in call and help me to fix it , I am ready to pay for the help
I am suck on this last 8 days\
ill give it a go but i dont want any money, im very new myself though and ive never used dedicated servers
Put a print string immediately after your "V" input. Press V. Do you get a print on screen?
go to the feedback and support channel if you want
Maybe disconnect the player controller from the console command. Shouldn't be necessary if you're trying to run it on a server.
ok
Are you using GameLift Anywhere? I mean, when you upload your server executable to GameLift it takes some time for GameLift to normally receive the executable and process it to make it ready.
yes
No. You have to upload a new executable.
You've changed the RPC functions.
The server doesn't know about it unless you've uploaded a new copy to GameLift
Yes.
Look into GameLift Anywhere.
It's supposed to be a thing to allow you to run the executable locally and still have it connected through GameLift
Lets you test dedicated servers through GameLift easily without having to go through the 2 hour wait process for GameLift to do it all XD
Hi lads, how would one smoothly interpolate character location/rotation that implements CMC?
I am creating a session and travelling to a game map lobby with Game Mode of Gameplay. Here I need to override ChoosePlayerStart so that the two players joining the session can spawn at appropriate player starts. But then when I travel to new map of Gameplay using seamless travel, I know players are persistent but I want the effect so that it is like spawning players at the player start of the new map using a function same as ChoosePlayerStart. How can I do so?
Wdym with Players are persistent?
They will respawn on the new map with the given GameMode and its playerstart functions
You shouldn't need to do anything special
But what if I want to use different ChoosePlayerStart function logic for different maps? Would I need different Game modes? Or should I use a boolean to track which map the game is in right now?
Different GameMode is cleanest
A child class fwiw
I usually have BaseGameMode and the 2 child classes: GameModeMainMenu, GameModeGame.
And then Game has Child classes like GameModeLobby and GameModeGameplay.
And Gameplay can then have even more fine grained children like Deathmatch or whatever fits your game
I am using seamless travel. So GameMode is persistent right?
Each of these having if needed matching PlayerState, GameState, PlayerController versions with same inheritance chain
GameMode doesn't persist
is it ok in general to send actor/component pointers/TWeakObjectPTrs and TSubclassOf of any types via RPC? I'm examining some profiling results in unreal insights right now and it seems that this kind of stuff has some considerable size so I wonder if one should avoid it in general π€
Actor and Component pointers just replicate as ints fwiw
WeakObj probably too
TSubclass could be a path string, not sure
hm π€
Can you help me understand what does this mean?
But those are the whole components and actors, not just a pointer to them or?
Those are TWeakObjectPtr
Okay. I did exactly that earlier. But it used to travel on server and then hang on client. But now it hangs on client for a sec or two and then travels cleanly. Thank you for your help.
from what I remember, what actually happens in seamless travel, when server travels first to transition map, a new game mode is created before original is destroyed. it then copies all actors that should be considered persistent (idr for sure but i guess those are player states and/or player controllers), then server travels to final map and somewhere here old game mode is destroyed and new one comes into play. It sounds reasonable if you think about a case when menu map has BP_GameMode_Menu and the actual game map has BP_GameMode_Game so it can require actually different game mode actors
WizardCell actually wrote a good article on that matter, you should check it out https://wizardcell.com/unreal/persistent-data/
Does anyone know where exactly in this spawn actor process (using the blueprint spawn actor node) the expose on spawn values are actually set on the actor?
I'm trying to use a value in my replication graph but it isn't there....
So it seems like AddNetworkActor is being called first but I can't see where those values would be assigned anyway π€
Bugger... I think I found it
Right after .....
RIP
Oh nevermind, that's pins not actual values
I'm lost π€ͺ
I found the code
Yea as you said after the spawn before the finish
Unfortunately rep graph add network actor is right away
hmm
I wonder if there is a FinishedSpawning event I could use or something
PostActorConstruction maybe
A shame that they have an end play event but not a begin play one
Woah. This is a really detailed guide. TY. I'll read it bit by bit.
What does exactly mean net events color in unreal insights? I mean I understand that red probably implies "bad", yellow is "cautious" and green is "good", but What is the exact rule that gives these categories? I mean do red events simply imply that out of all traffic these exact sources take more than 10% or 40% or 60%? Or is it more complex like "for an event of this type (replication, reliable/unreliable server/multicast rpc) in general such packages that are sent with this exact frequency should consume that much bandwidth?
Is this the right way to end the game? I'm not sure because if I server travel then the game mode changes, so does the end session and destroy session gets called or not?
Good question, that I always asked myself, but never really got to look for the answer. I think if you use the widget reflector tool, to find which widget it is and then start looking based on how they are setting the color, then you'll have a clue. Sadly within the really short official doc they have, they don't mention the colors... but that page is under construction as it seems...
yeah I've thought about it myself today to just open insight's source code and just look for enums or anything like ::green, ::red, ::yellow. too bad i'm a lazyass
hello everyone. im having some problem in understanding how multicast works in UE. what i know is that you multicast should only be called from the server. but im have this issue while calling a multicast event. i have this lobby menu, and when press one of these 'Hero xColor' buttons and it calls this event 'SpawnSelectedCharacter' on player controller.
what i want to do change skeletal mesh on all instances of the actor when i press any of those Hero buttons. but it only works correctly if i call the 'SetActorInfo' on the actor i want to change skeletal mesh on
if i call the 'setActorInfo' from the controller, it only changes the skeletal mesh on the instance of the game that calls the multicast event and on server
what i thought was both of these would work
but can someone please explain to me why 'setActorInfo' event being called on the controller does not work?
can someone pls help?
Do I need to call destroy sessions on clients from their player controllers? If so how do I get reference to their PCs since a NetMulicastRPC won't run from a GameMode because GameMode isn't replicated, right?
AFAIK - no, since clients neither create nor own the session. A lot of stuff with online subsystem sessions is actually handled by AGameSession. You can also check how epics do it in Lyra's common user plugin
I found this in the tutorial
Try looking into AGameSession source code, destroy session might be called in end play there
However I don't remember if game session exists in clients π€
Hello guys , I have 2 questions I will be appreciate if i got an answer .
1- If i want to create a multiple servers each server have its own chunk ( part ) of a map . Can i Initilaize them in one huge map and players travel between them when they reach specific location ? From where should i start .
2- If I want to connect my game or server with database such as MongoDB which one is the fastest way .
- Websockets
- APIs
- Custom TCP tunnel ?
Thanks in Advance
The server question already exists in a game called ATLAS the game .
I am able to destroy session in game mode on server but then the client losts connection and starts throwing error
Destroy session will kick clients yes.
The "session" is the engine-level wrapper for the online backend "session". If you destroy it, it terminates the session online too, which will kick any connected players
Game Session does exist on clients also.
The game ends after a time which is tracked in game mode. Because GM exists only on server how do I communicate to clients that game has ended. Using GameState? and from where should I call destroy session on clients?
was this answer for me?
in response to this?
Controller only exists on your computer and the server
Your controller doesn't exist on my machine
You shouldn't be multicasting though. You're trying to sync state. Use repnotify.
but im calling the event from server, shouldnt that solve the problem?
like game mode doesnt exist on my machine but i can still access it if im on server
I server travelled and then using GameState destroyed session on clients as well as on server.
The problem is when I create a new session on Server which is successful, then there is connection lost error on client again.
@ivory dagger zero playercontrollers exist on all machines. A multicast inside a playercontroller makes no sense
Your selected asset should be a repnotify variable in PlayerState or the pawn itself
Someone pin this
It's pinned in form of the compendium. That should be enough
You can link to it directly
can you use EOS in editor, or does it have to be packaged?
After destroying session on client, how to open another map on client?
Because if I use OpenLevel after destroying session, it works for server but not for client.
I was thinking of using UEngine::Browse which seems appropriate here, but is it the right way do it?
One of the selling points of EOS was that it was supposed to work in editor. Haven't tried myself though.
Why does the animation and sound effect play for the player who did the action once, then after trying to do the custom event again it doesnt?
The mind subvertion widget works on the enemy player even without the animations and sounds though
please help π
im sorry if my questions are super dumb but does 'zero player controllers exist on all machines' mean that player controllers only exist on the server and one per each client. and why does multicast inside a player controller make no sense
Yes that's what that means
How do I come up with network budget for clients and listen servers? Or maybe somebody can suggest me an article on that matter. Like say I have a coop game with 4 players, I've profiled a couple of game sessions and I can tell that in 10 minutes the server sends 4MBs or ~7 KB/s per second on average. How do I understand if it is good or bad in my case? I mean I can tell by the insight's profile results that there are things that could be optimized but should I spend my time on it? Can I reliably derive approximate ping clients and listen server will have based on insights data? I mean I know that there are parameters like MaxClientInternet rate and speed and something like that for server that set the amount of bytes client/server can send ber second but I've also read somewhere that just kicking that value up can backfire with some other connection issues π€
At my wit's end here and I think I'm overlooking some basic concepts.
I have an Armory Component. It's attached to my Character. On BeginPlay(), the Armory Component receives which weapons to spawn from the GetOwner()'s GameInstance and then spawns which weapon is in the player's Game Instance.
This works just fine for the server. But the clients will always only spawn the server's version of the GetOwner()'s GameInstance versus the version of the Game Instance weapon that they chose prior to server travel where they chose their weapons.
What... what am I missing here. How do I have my client's Armory Component properly recognize which weapon they have selected from their GameInstance ?
Using Browse doesn't work
Does it not exist in the editor as a whole as well?
Like an editor copy and a PIE copy?
That might well be true!
Yep I understand that there is a Game Instance, only one, per each player- however as I understand it, despite not being replicated, the Game Instance exists on the server as well as the client.
However the Armory Component isn't accessing the player's Game Instance to determine which weapons to spawn, it's accessing the server's version of the GameInstance.
Every PIE instance has a game instance. Not per player, per pie.
(in pie at least)
You'd need to do the 'run in separate process' thing to get more GIs.
^
Err, no?
Every PIE instance has a game instance
the editor itself does not, but additional PIE windows (and, if enabled, the in-process dedicated server) do
separate game instances
/**
* GameInstance: high-level manager object for an instance of the running game.
* Spawned at game creation and not destroyed until game instance is shut down.
* Running as a standalone game, there will be one of these.
* Running in PIE (play-in-editor) will generate one of these per PIE instance.
*/
UCLASS(config=Game, transient, BlueprintType, Blueprintable)
class ENGINE_API UGameInstance : public UObject, public FExec
What you just said is likely the problem - the server has one game instance. It does not have access to any client game instances, game instances are not replicated. You get one. Period.
Every PIE client gets one of their own. The server cannot access client game instances, clients cannot access the server game instance.
It doesn't matter how many clients connect to the server, from the server's point of view there is only one game instance. Game instances are not related to players, they are the representation of the local copy of the running game.
Understood.
Here's what is happening though.
On Server player if I choose, say, the Shotgun and spawn, both the server and the client will both spawn with shotgun.
if as a client I choose, say, the Assault Rifle, it doesn't matter - the client still spawns with whatever the Server happened to choose.
Well, if you're storing the choice of item on the server's game instance then that's why
A client storing some data on their own game instance doesn't tell the server anything, and the server is what has to authoritatively spawn things.
When I make the choice and then review the choice on the client, the choice appears correct.
I think what's happening is I'm spawning with authority and it's thereby only spawning the server's choices
Yes, that is what I'm saying.
Game instances are not replicated, they are not shared in any way.
The choice is set on the Game Instance, but then the Armory Component, prior to spawning, obtains that information from the game Instance. It then calls the spawn gadget method which is obviously done via authority with the server as an argument.
Yes but the choice is set on which game instance
if you never replicate that choice to the server then the server can't know what you've chosen
The player's
so you never tell the server
Gotcha...
the server knows nothing about a client's game instance
it does not exist from the server's point of view
The server receives which weapon to spawn from the Armory Component, however... and the Armory Component gets its chosen weapons from the Game Instance.
The server and Game Instance never actually communicate directly - the Armory Component is replicated and that's how any spawning functionality occurs
Ok but are you actually replicating the choice on the component
Okay I think this is the direction I needed
I think that's the link I was missing... I'm going to try to implement, thank you for your time
Are you trying to replicate the weapon choice back to teh server via the armory component?
Yes
Like with "Replicated" in the UPROPERTY?
I wasn't prior but that's my plan moving forward
So you aren't sending an RPC?
I wasn't but that's what I plan to do
(A "Server" UFUNCTION)
Prior the Armory Component was just getting the GameInstance's weapon choice in the Begin Play function
Okay, so, "Replicated" only works 1-way. Server to client. Nothing you set on the client is "replicated" back to the server.
You can only send data via an RPC
Yeah my plan is to replicate the weapon choice for a Server RPC
Okay. Just so we're clear.
Should I be calling this RPC during BeginPlay?
Depends on the flow of your game.
But bear in mind the server will spawn your player and (if you have it set up as such) spawn your weapon before your client ever gets to beginplay.
Yeah that's now what I'm trying to wrap my head around
You have 4 options:
- Somehow set the weapon you want on a previous map
- Send the weapon you want with the options string (blank giving you some sort of default weapon)
- Have the server spawn you with no weapon/default weapon and wait for you to rpc your choice
- Spawn in some sort of "observer" mode and the server will wait for your weapon choice
Thank you very much, very much appreciated
If I create an actor serverside and immediately send a reliable multicast through it to all clients, how likely are they to properly receive it (assuming it's relevant)?
what you multicasting?
Hard to really say, but first thing to note is that only the Server should be marking things dirty. If the member property needs a reference to it's "owner" to work properly, I'd suggest setting it in the constructor of the class (and making it a transient UPROPERTY)
I have this strange bug where the online subsystem works fine for first time. I create session and then join it. destroy session on client and server successfully. No errors in log. Then On Client when I try to Find Session again, session search is created but Find Session Complete doesn't get triggered and it isn't even failing. It just gets stuck
Morning all.
If I want to have an Doorway appear open or closed to ALL connected players (ideally they'd see the door animate open/closed even from the other side of the map). How would you go about achieving this?
My initial thought is that you'd use a repnotify and make it always relevant, but I'm just guessing at this point.
A rep notify is the way to achieve it certainly. If you wanted to see it all the way across the map, then always relevant is the simplest way to achieve that for sure.
Ah thanks. Glad I was on the right track. I'm just never sure if there's a better way of doing things. I'll continue to bumble along.. cheers Jambax π
Oh. here's another related question actually. If it wasn't necessary to have a player see a door open in realtime BUT they would need to see the door in it's open/closed states when they turn the corner.
What would be the correct setup for that?
Well, it'd be hard to achieve in practice. Line-of-sight relevancy is much harder to do because a) it's expensive to compute and b) relevancy is too "laggy" to be as responsive as that.
You can only really achieve it in very controlled environments.
ah. so there's no way to set a radius around an actor for network relevancy?
Well there is a radius, which is what Net Cull Distance is for - but there's no line-of-sight check, it's just a radius
so if a character enters a region it would set all the 'states' of the actors
Ah gotcha
If you check bAlwaysRelevant, then it disables that radius check
ok nice one, that's pretty clear to me now thanks
Besides line of sight relevancy, is it possible to determine if a property replication occurs because the value is changed vs because it become relevant again?
Maybe checking the old value vs new value for OnRep functions in cpp?
Hello, what is better, als or lyra? I found a custom version of als which is called ALSXT
I want to make an Arcade FPS/TPS
when u enable voice chat, does it come spatial or non spatial by default?
Hi! does anyone know if there's a way when replicating an array, to know only the element that got modified?
Yes and no. You'd need to use a FastArraySerializer (C++ only) for that
Otherwise, you could still do it with a normal array and pass the old version in to the OnRep (if you have one) and manually compare (I do that for something that is small and doesn't need replication often), but that still needs C++
dumb replication problem, i have a struct with some variables. replicating correctly. the moment i use a map in the struct it wont replicate no matter what i try?
the map that is
the other variables remain replicated
been busy over a day, is it some weird issue that im unaware of with maps?
TMap and TSet do not support replication, yus
ugh
does any 1 have any good resources on ue4 voice chat stuff? im very confused and i cant find any proper documentation
The solution is to do 2 arrays, one of keys and one of values. You loose your lookup powers, though.
You can recreate teh map on the client end when stuff is replicated, if you want.
Hello, I am trying to start a deticated server in vs and its giving me the error code on-agnostic games on cooked platforms require a uproject file be specified.
anyone knowing how to fix?
Have you tried specifying the project file on the command line?
Have you built a dedicated server using the UE5 project instead of your specific project?
Hey, anyone know why clients dont hear this sound played? The sound gets called when the player interacts with the actor to pick it up, the server player hears it but client doesn't
In my FPS, I have an inhertid Fire event on my weapon bp. My character has a first person weapon and a third person weapon (for others to see). In multicast, I call the Fire events of both guns. The one for the 3rd person gun never fires/runs.
WeaponBase_3p>WeaponRifle_3p and WeaponBase_1p>WeaponRifle_1P
Other than a special material that handles zoom and prevents mesh "pass-thru" they are the same BP code
What might cause this to not get called?
Might be an inheritance issue as the Fire event runs in the base class for the 3P gun
How can I loop through all the players to see who is the winner and loser?
I have a variable for the winner and its set to playerstate atm
Fixed it. It was an inheritance issue.
Now it animates and shows a muzzle flash...but when it runs the fire rifle ironsite anim, it pops to center aim during animation...if you are aiming up 30 degres it shoots, but the recoil animation snaps the gun to level aim then back up. Aiming level looks great though. LOL Any ideas?
Here is what my fire animation is doing. Using the anim starter pack and ironsite fire (as a montage).
do the aim offset after the montage player
assuming your aim offset is additive
Thanks. I will take a look. Had such an issue with a true fps, went back to arms and full mesh for others to see...and not easy either.
I am using raw anim starter pack so I havent done a true aimoffset for the ue4 mannequin for the full mesh ( I dont think)
Yeah the animation setup for something like that is certainly not trivial, you need to understand your anim bp setup inside and out
...and I am a rookie (Unity convert). This is how my 3rd person mesh is rotating to handle look up and down that my first person arms do.
replicated look rotation
So where is the montage player that's playing the fire animation?
before or after this?
Dont laugh at me, I am calling it in the weapon Fire event (from a tutorial I found)
I mean where is the recieving end of that
in the anim BP
that's saying "play a montage"
where is the montage player used to calculate the final pose
Show the rest of this
I call it from the Character
As for the anim bp, nothing there for it
This is the whole thing that Fire calls
Show the whole pose graph in the anim bp
From the default Locomotion node...
ahh, ok. This is the montage set to Upperbody slot
like this, even though the fire montage is set to the upper body slot?
Yes, the montage overwrites upper body bones
what you had been doing was adjusting the bones based on aim, then overwriting with the animation
now you'll animate, then adjust based on aim
wait
I ran the updated version and no change
yeah, move the aim stuff to after slot upperbody
whole body doesn't get messed with
upper body is
Whole Body -> upper slot -> aim stuff
let's see it if it works
Works like a charm! You rock!
Does it make sense to have that montage call in the gun with the muzzle flash?
Sure, that's a fairly normal way to do it.
Thanks again!!!
I also tried changing them to just directly call the multicast event to play the sound but same thing happens, any ideas?
Show the rest of the pickup logic
Just some checks confirming the player can interact with the actor
Are you intending that to be clientside or serverside?
This is how my interaction gets called
so serverside right?
You are already doing interaction serverside, why are you calling a run on server event inside it?
It should just be:
InteractEvent -> ??? -> multicast play audio
axe can play the audio
no need for character
assuming axe is a replicated actor
I updated it too this but client still doesn't hear anything but server does
What does On Axe Pickup do?
So the way ive got it set up is that i have BP AxeSpawnLocation actors placed around the map which spawns the BP Throwing Axe Pickup actor which happens from the game mode at the start of the game
Think ive figured out whats happening, in my Increment/Decrement event im destroying the axe actor when the player picks it up, even tho that happens after the sound is played it still must be destroying the actor for the client quicker than it can play the sound
When I seamless travel, do I need to override any functions on the components on the player controller to prevent them from being reset?
You don't prevent them from being reset, you will usually want to pass on state.
Check these out
/**
* Called when seamless traveling and we are being replaced by the specified PC
* clean up any persistent state (post process chains on LocalPlayers, for example)
* (not called if PlayerController is the same for the from and to GameModes)
*/
virtual void SeamlessTravelTo(class APlayerController* NewPC);
/**
* Called when seamless traveling and the specified PC is being replaced by this one
* copy over data that should persist
* (not called if PlayerController is the same for the from and to GameModes)
*/
virtual void SeamlessTravelFrom(class APlayerController* OldPC);
/**
* Called after this player controller has transitioned through seamless travel, but before that player is initialized
* This is called both when a new player controller is created, and when it is maintained
*/
virtual void PostSeamlessTravel();
These are in APlayerController
APlayerState::CopyProperties
APlayerState::OverrideWith
I have a component that holds the pawn class that I want the player to spawn in with, would I use these functions to handle this?
Essentially yeah.
You would probably use SeamlessTravelFrom to pass that variables value into the new PCs variable.
So effectively its "Copied" over.
Assuming the old PC is being replaced of course.
Which could happen if its a different type, because of a different gamemode or something.
That makes sense, I could just use GetComponentByClass to get the component and copy over the properties
That seems to have worked, I'm testing it with my custom EOS subsystem to ensure that it plays nicely
Niagara Fluid does not interact with the second collider tagged actor. So I chose to use global distance field in the niagara option. after that, it reacts with collision even with actors that do not have a collider tag attached. However, in multiplayer, there is a phenomenon in which the Niagara Fluid of the second user does not come out as the set speed and keeps coming out very slowly in a strange direction.
@latent heart thx for comming back, i implemented it that way thx
Does.. putting a map in a struct to replicate it not work on blueprints?
Wait it doesn't work if I put it in a struct as well
I thought that was the workaround
No
I don't know how I never came up on needing to replicate one
You cannot replicate a TMap or a TSet directly
I guess I would need to create a pair struct and make an array out of it then?
You could get around it by creating a structure containing your key and value pair, and then making an array of it, populating it and replicating that instead.
The workaround is to make a struct that has the Key and the Value and to use an Array with that struct
Got it, thanks
Goodday guys I have a question,
If I want to separate a map into separated server instance each part.
Can I merge them in one big map ?
And make players travel between them seamlessly 
Not using Unreal's native networking solution.
Any ideas ?
You'd have to code your own networking system entirely. There's no way around it. Any time there is a transition to a new server, there will always be a hitch and at the very least a loading requirement of some kind. It's just how the engine works.
To facilitate moving seamlessly, you'd have to have your clients completely ignore Unreal's netcode and not really "connect" to a game server in the same way. Then you can have the client do whatever and it won't have to hitch/load. This means you'd have to facilitate replicating everything that Unreal does in your own unique method, like using TCP or UDP servers that your client could connect to send and receive the information that needs to be replicated.
Thanks for explaining this ..
Then if we made the player loading can we at least init the maps letting them see it but when they enter the edge they will start loading ?
In default engine client code
Graphically you should be able to make any level look however you want, then it just boils down to where you put your overlap check to start the transition process of that player to the new server. Transitioning to another server would still be sudden and likely take a few seconds and you probably won't have a "seamless looking" transition as the original server would have to notify the other server of the player's location, control rotation, etc. and the receiving server would have to spawn the player and load all the data about them before allowing the player to be back in control and everything may not exactly line up with what the player was last seeing. I'm not sure as I haven't tried to do something like this myself.
Yes me too havent try this i wanted to learn it good idea .
Also I will use MongoDB with websocket for data transaction so i will just transfer the player data easily by updating server ID " foregin key "
is there not a function to get netmode for BP.
i have some code that ive been working on for a while. and it runs great. but now i want to optimize it. and in doing so id like to handle single player a little differntly than multiplayer, and i cant find an easy way to detect what mode im running in
I think IsStandalone should do it?
Hi guys, is there any reason why this gives errors? Just trying to understand how to do "Blueprint Run On server option" in c++
UFUNCTION(Server, Reliable, WithValidation) // in .h
void Dash(const FInputActionValue& Value);
void ABaseClass::Dash_Implementation(const FInputActionValue& Value) // in .cpp
{
//code
}
Do you have your _Validation Dash_Validate version of the function as well?
Like @ Layso also mentioned there are some BP nodes like "Is Standalone", "Is Server" etc. but the actual Netmode is not exposed directly to BP no.
If you put WithValidation then you need to have _Validate as well, I don't know what error you're getting but maybe that's the reason
ah I see, tbh I only copied this from UE doc, the only thing I know is the Server client multicast part, but even with just UFUNCTION(Server) it still gives error
What kind of error? Does it not actually compile or is it just a red squiggly line in your editor? π
I think Reliable is also required
Or was it required to specify whether it's Reliable or not
Reliable is not required, it can also be Unreliable. But it will need to be one of both (although there's also a default fallback I believe?).
thanks guys, indeed one of these is required, it works now
that is unfortunate. but its what my research was yeilding.
will standalone at least tell me if im playing offline. and that will do what i need at least
Generally I had a difficult time doing this specifically in BP. To my knowledge these are the ones available:
Hello, I'm currently working with UE5 and i'm trying to Join a FOnlineSession.
But I need the session name in order to match the implementation:
virtual bool JoinSession(int32 LocaclUsserNum, FName SessionName, const FOnlineSessionSearchResult)
I might have misunderstood, where the "Session Name" = the "new user" session name ?
but it's weird
@last storm I would recommend looking at Cedric's article about it: https://cedric-neukirchen.net/docs/category/session-management
It has everything you would ever need for this in specific. There's also specifically a C++ part: https://cedric-neukirchen.net/docs/session-management/sessions-in-cpp
Quick overview over Sessions in Unreal Engine.
This post shall give you a short introduction to handling your Multiplayer Sessions via your own C++ code. Most of you probably either started with the very limited native Blueprint Nodes or fell back to using Plugins like the Advanced Sessions one.
But I believe all you want to put there is NAME_GameSession like:
JoinSession(*localPlayer->GetPreferredUniqueNetId(), NAME_GameSession, SessionResult)
I'm gonna dig it all the day lol, thansk alot
yes but, how to get this "NAME_GameSession", since you can't get it from the "FOnlineSessionSearchResult" nor "FOnlineSession"
that's where I'm struggling
It's defined in a large enum with a bunch of other ones: https://docs.unrealengine.com/5.2/en-US/API/Runtime/Core/UObject/EName/
But I don't think you have to specifically include the header for it if that's what you're asking for π
thanks a lot
Hi, also wondering about this, do I just put Dash_Validate(const FInputActionValue& Value) in .cpp? I've tried adding it in .cpp or adding it in both .h and .cpp but they both fails, I've also tried changing it to bool, not sure what the correct way is
Seems like you are stuck in the basics. I suggest watching and understanding these
https://m.youtube.com/watch?v=UmJzuRO4Qjs
https://m.youtube.com/watch?v=JOJP0CvpB8w
Try my C++ Survival Game Course:
http://bit.ly/unrealsurvival
Discord:
https://discord.gg/meFRZfm
Today I do my best to teach the basics of networking to you in under 30 minutes. Enjoy!
Business Email: contact@reubs.io
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...
thanks, was following https://docs.unrealengine.com/5.2/en-US/networking-overview-for-unreal-engine/ but they didn't show the full code
https://docs.unrealengine.com/5.0/en-US/multiplayer-programming-quick-start-for-unreal-engine/
This is C++
thanks, didn't know they separate bp and c++ tutorial, will look at thatπ
if(GetLocalRole() != ROLE_AutonomousProxy) this check works fine if i am running on a dedicated server, but with sessions the client that is runnign the server still passes the check, whats the best way to make the client playing on the server not pass the check as well?
Need more info. What is this actor?
a character
basicly im trying to spawn a blood effect everytime the hp changes
it works fine unless the player is the server
Makes sense. Server player is authority.
What is the blood effect? Chances are the call is probably already tossed on dedicated servers if that is your only concern.
its a niagara effect
so is there a way to check for players that are the server?
and blockign that?
You don't want the server player to see the blood? O.o
i want him to see the blood on the other players
i dont want him to see his own blood
cause thats just visual cluter
Then just == Simulated Proxy probably I think.
i think i tested that before but i will do it agian
Well. No, that won't really work for that on server. They're all authority.
Could just do an IsLocallyControlled check.
Or actually
Better yet, spawn the system regardless. And set it to OwnerNoSee = true.
i tried that but i dont think it worked
i will try agian
It needs to be attached to the pawn the player is currently viewing.
ye its not attached
UNiagaraComponent* a = UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), bloodParticles, GetActorLocation());
im gonna try the IsLocallyControlled
Why don't you want stationary blood to show for the local player? O.o
I could see if it was an annoying effect you didn't want the player to see when playing in fps mode, but not seeing their own blood spots is odd when it's stationary.
because in an fps it might block the view if ur looking down
Stop getting shot? π
LOL
Could always material it too. Opacity by range.
is locally controlled is not working
I would just go with the IsLocallyControlled check, it's a character, also saves you from having to spawn a particle system that doesn't do anything on a client that can't see it anyway π
They could see it though. It's stationary. They should be able to see it when they move away.
the Islocallycontrolled check doesnt work when the client shoots the server
wait
i might be doing somethign unescessary
Imo this isn't really a networking issue as much as a designer issue. Dedicated server is the only place it shouldn't exist and it already gates creating particles internally. I would just make an opacity by distance to camera and set it just outside of the range of normal camera view. Bit more normal to still be able to see it when you're moving away, but it isn't in the player's face at any time.
nvm its working
so it was the IsLocallyControlled() function that i was missing
thanks
So how do I fix animation movement on multiplayer??
When I walk Left or Right my character just walks forward and slides left or right, which is due to me not having an animation, but in multiplayer the walking forward just loops the first frame constantly.. Is this cause there no animation or do I need to do more then just set the player replicate true in the bp?
Need info please if anyone can help
if im using seamless travel on a deciated server do I need to bring over my player starts and weapon pikcs up? how does that work, does it do it automatically?
I thought BeginPlay() ran as both Server & Client? Is there some other form of AuthMode checking I need to do in C++? I've tried:
HasAuthority()
GetLocalRole() == ROLE_Authority
Neither work :/
What indication do you have that BeginPlay isn't being called?
i never said it wasnt being called - sorry i implied that its not running as Authority with the 2 checks there.... hence the question of if i'm checking the right check?
The beginplay on the serverside version of the actor should be authority, show your code for how you're testing.
if(HasAuthority())
{
blah();
}
Never hit
same said for GetLocalRole() == ROLE_Authority
its my assumption i'm not doing the right IF logic check there
i'm trying to save an RPC - i can do it if need but ... but i thought that BeginPlay ran AsServer - which would allow me to do some preliminary setting of replicated variables right off the bat.
BeginPlay runs everywhere the object exists
i'll read between the lines i guess :/
fwiw - removing the if branching shows a netmode of CLIENT - i was expecting both CLIENT & SERVER
How do I play a widget on the respective player who lost/won the round?
or is it like this?
Is ReplicatedUsing uncommon practice or something? haven't heard of it once until I started looking at GAS, nowhere in the replication docs
Very common.
What actor is this and how are you spawning it?
Do UFUNCTION(Exec) functions only run on the server? Is there a way to get it to run on the client?
They will run on whichever instance it is called on
Does anybody know anything about this, got it to build the server, but the strange thing is that the instructions said to do it from the projects VS project (which didnt work), but when I build it from engine source VS project by building just the game project that is listed in that, then it builds but gives this error when running it ,Tempted to just wipe and start fresh with a new project tbh because it seems there may be some config issue.
What functions / events are triggered when a multiplayer client leaves the game (either by quitting the session, or hitting Alt+F4) ?
We're working on a bug that only occurs when a client crashes. If they disconnect "safely" (either Alt+F4 or using the UI to quit), the bug does not occur. If they crash (we added a button that can crash the client, to make this easy to test), the bug occurs.
Hey, im trying to make a local multiplayer system in ue4. when i create the player both keyboard and controller inputs posses the same character. any fixes. im using ue5 and the create local player
There is OnLogout in the GameMode. It could also be EndPlay on your character or player controller.
There should be a setting somewhere saying Skip Assigning Controller to Player 1 or so
Either in the play settings or project settings I assume
Could also be editor preferences. Been a while since I had to use that
I already have the boxed checked
ok figured it out... I guess a skipped the package project step and just tried to launch the compiled server... oopps
am I suppose to add or click something to actors when using seamless travel?
I need to mark actors for seamless travel but I dont know how
There's some C++ code further down that looks like it's how you handle adding actors to the persistent list.
Hi, would you have any lead Regarding this jitter in my aim offset ?
Using lyra stuff, and trying to find the root cause
Anim blueprint, character, controller and some network settings have been ruled out
Any lead or test cases would be appreciated!
@sinful tree is there anyway to do this in blueprints? how can I find GenericPlayerInitialization and HandleSeamlessTravelPlayer?https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/GameFramework/AGameModeBase/GenericPlayerInitialization/
Handles all player initialization that is shared between the travel methods (i.e. called from both PostLogin() and HandleSeamlessTravelPlayer())
if someone were to use hacks in my game, would they be able to send an RPC to the server with whatever arguments they want?
Then you need the validation on the server side. They may send, but how it is accepted is up to you (Server)
lets say I wanted to make a game like cod and I use RPCs to purchase a weapon
Would it be a good idea to just run the interaction line trace on the server and do whatever needs to be in via a multicast?? From my basic understanding this should stop any cheaters from being able to just do like GetWeapon(RayGun) without having to hardcode a billion things
From the way I see it if I don't do that I have to do a billion checks to see if the wallbuy exists on the map, and if it doesnt is the mystery box open, and is the user in question opening the box, and if it is what weapon
1st method sounds really good but idk exactly if its fool proof, would a hacker be able to call multicasts? Or basically impossible
No, they can't. It is only on server side.
But if they installed something backdoor on your server, then...
so in this case would first method be "fool proof"? Just do a check to make sure that the client in question sending the interact actually owns the player?
Ok, lets say all the in game currency is stored on server. And the client just get the replicated number from server. If they hacked the game and modified it to, for i.e 1 trillion, then when they request RPC running on server to buy a very expensive equipment. You'd definitely check the currency on server for his profile instead of just because he sent enough currency by the RPC request. Something like that.
well in the first case the server would be doing the interact function completely, so it wouldn't have access to any fake gained points
Yeah, I mean it is just an instance. Or like client side says I hit the enemy by tracing, but you need to validate on server that if he has some abnormal or definitely not regular movement/behavior, you could refuse to accept hitting and etc.
How would I even check if a client owns a player in an RPC to the server?
Oh actually I think I answered that myself
Actually, is validation called on the client or the server?
makes more sense to be on the server actually π
I keep getting UActorChannel::ProcessBunch: SerializeNewActor failed to find/spawn actor. Actor: None, Channel: 42 for actors like player starts on my dedicated server ofr SEAMLESS TRAVEL, do I need to mark things to let the server know to bring them over?
so yeah not sure on the actual solution on how I could verify the client actually owns said player
In order for a client to communicate to the server an RPC must be sent by a client. Just creating an RPC function itself is opening up a door to allow someone to call that RPC at any time, even if you don't have any code anywhere that actually calls the function, the fact is, the RPC exists and is waiting for the signal to be received. Adding inputs into the RPC add an additional level of "insecurity" as you're then allowing someone to feed data into the server.
So, if you're wanting to allow someone to buy a weapon of some kind, your best bet is usually to call an RPC and send the absolutely minimal amount of data possible to allow the purchase of that weapon.
So if the identification of the particular weapon to buy is being done by an actor reference, your RPC then can include the reference to the actor you're trying to buy. If you're wanting to limit how far away a player is from that actor, then when your RPC is received by the server you should validate if the player is within the desired range of the actor they're attempting to buy. If they are, then you can deduct the currency from the player and have them "buy" the weapon (whatever that entails).
Probably not. I haven't done anything with Seamless travel and persisting actors, but I do know there's a lot of multiplayer stuff that is only accessible VIA C++.
That smells like locomotion blend space 180 / -180 things
show your locomotion blend space
@sinful tree it seems like my player starts are falling to spawn on seamless travel, should they be place on the map or spawned in with code in the level blueprint
Am I going insane? Testing a scenario where client 1 damages client 2, but the on rep notify calls on client 1. And then I'm getting the progress bar set on the client doing the damage
Hey all! Does anyone have any GOOD resources for multiplayer / replication (Other than Unreal Docs) that can help to make more sense of multiplayer? Any help is very much appreciated.
Likely because your "Hud Reference" isn't directly related to the character receiving the damage?
Maybe I'm daft, but it's a widget reacted on begin play, and they're not replicated -- Shit that's called for everything I feel dumb.
Check the pins on this channel. Lots of non-Unreal docs related information pertaining to multiplayer.
Thank you so much
Thanks BTW, 100% a rubber duck moment
im confused, does the engine automatically provide this I don't see it being setup anywhere (GAS example project)
APawn has OnRep_PlayerState, yes
lifesaver
Hmm, any way to replicate TOptional<bool> or do I have to roll my own implementation?
I think you need your own
thanks
There's a neat method from Epic to optionally serialize values. It uses a single bit to indicate whether or not the value is valid, if it's not valid then all it ever sends is that single bit over the network. If it's valid it serializes your value + that single bit to indicate it's valid. See:
https://docs.unrealengine.com/5.1/en-US/API/Runtime/Engine/Engine/SerializeOptionalValue/
And as an example of it being used somewhere (assuming you have Github access):
https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp#L9071
@crisp wraith ^
sweet, will check it out
thanks
Whatβs the best way to access the current player controllings state on a bp?
Has anyone profiled while playing as a client and can explain why the client has 2 world ticks in a frame essentially doubling frame time in multiplayer
Hello, I just created a deticated server, on the default ports and ip, but when I try to sstart a client, a client is starting in standalone mode, its not connecting to the server, anyone knowing what I am doing wrong?
There are a couple of ways. It depends from where you want to get, a couple of examples are these:
Which I took from here: https://wizardcell.com/unreal/multiplayer-tips-and-tricks/#2-beware-of-getplayerxxx0-static-functions
It's a neat article if you're interested ^^
Thanks, I was looping over get all actors and checking if it was itself lol
these seem better
On what exactly is this based? The engine simply runs as often as it can or as it's allowed per second. If it were to tick twice per frame then that would be a MASSIVE performance issue and I kind of doubt that's the case honestly π
How are you connecting? There could definitely be several problems here. Some things to check:
- Can the device your client is running on ping the actual server where you're hosting the dedicated server?
- At what exact part does your logic refuse to work? (Attach a debugger or just print some messages to the console).
- Any errors / warnings in your logs?
π
I am connecting to a local server for now, means I am connceting with the IP 127.0.0.1 i am doing this per CMD command, the server is starting, its telling me session started n all, trzing to connect a client to it via the cmd command, nothing happens, a instance is started localy, without even attempting to connect to the server
No errors, and i am just outputting the logs to a cmd window
if its localhost that rules out any connection problems, what command are you using, out of interest
in the folder where i build the client,inside of cmd: GameClient.exe 127.0.0.1 -WINDOWED -ResY=800 -ResX=450
Just to make sure, you checked both the client and server log right? Not just one of both? π
Essentially in one frame there are 2 world ticks each with similar calls my guess is one is sent and the other is received. Only guessing this because when playing as standalone there is only one UWorld tick in a single frame. In my client session each world tick is taking 4ms plus shit like slate tick and random stuff for landscape. This is playing as a single client with some mass entities running around in editor. Havenβt tried a compiled build yet.
I have not connected that way yet, I have been using loadlevel (which might be worth try) so I am not sure about this, but all the examples I seen had -game after the ip, not sure if that is required or not
lemme try it out
what do you exactly mean with loadlevel?
open level, sry
I am connecting through cmd tho..
I know, and its not working
How to set up and package a dedicated server for your project.
try connecting like this and see if it works
Hi ! Thanks for helping
is that what you were looking for ?
What I don't understand is: this is Lyra stuff. It works well in lyra. I just migrated the C++ classes and some of the assets from lyra (for instance those anim bp etc) and I have the issue
Understand that
it has been hard to make it work well at first but in the end, everything is working as Lyra intended to, except for this ...
I wanted to be able to understand those dependencies and see for myself what was working or not, and deal with it, to get a better understanding of the Lyra framework
basically rather that just use something: learn from something
looking at github it seems like Iris isn't being actively worked on much anymore, was looking through @fathom aspen wonderful information here: https://wizardcell.com/unreal/multiplayer-tips-and-tricks/ and wondering if we're still expecting iris to replace the replication graph
I doubt they're just going to be dropping work on Iris.
It's just something that takes time.
They might just be focusing on 5.3 atm.
maybe something they'll combine with the push model
even about the push model there isn't many people that know about it and its a bit old at this point
This is on the gamestate btw
If anyone could help β€οΈ
Which variable?
β¬οΈ
You generally don't want to use multicast unless there's a reason to specifically use multicast over regular replication.
Sure.
Use an OnRep on the gamewinner variable.
In that onrep, check if game winner == me
If so, display the widget.
is this with a loop?
Why do you need to check all players? You already know who "me" is.
It's the person receiving the OnRep.
You should be using the player state.
No
No
Just ignore everything I've said, I'm just confusing things.
And I don't have time to explain!
Ok
Dm me if you can
Later sometime
I mean i'd pay you if you can explain what i'm doing wrong with the multiplayer on my code
I can't even begin to say how many times i've been stuck
No
Learn how repnotify works
Then in the onrep for WinningPlayer (a PlayerState variable in GameState), check if the local players PlayerState = WinningPlayer. If so, show the you won widget.
To reiterate:
Server:
Someone wins -> set WinningPlayer
EVERYWHERE:
OnRep_WinningPlayer -> if local player = WinningPlayer -> show widget
It's that simple
I'm making a VR game and want to make interactions as responsive as possible whilst keeping parity and syncrhonization. What would be the best way to go about picking up an item and notifying every other connected client that it has been picked up?
Not asking for anything complex- just some psuedo code. My current setup is
PickupClient
{
if authority: PickupMulticast
if remote: PickupServer
}
PickupServer
{
PickupMulticast
}
PickupMultiCast
{
AttachItem to motion controller
}
the thing i fear about this setup is that if you have a latent connection, picking items up will feel delayed and sloppy- i would prefer picking items up to be instantaneous on the client
@naive wind Having an Item picked up and attached is State. That should not be done via Multicast.
This indeed will be latency depended. It kind of simply depends on how far you want to go with making it feel smooth I suppose. One thing I would like to point out is that you really shouldn't use a multicast for the "this person has picked up this thing" state. If either a new person joins or the current actor associated with that player becomes irrelevant and after some time relevant again it will be out of sync. For things considered "state" like in this case I would absolutely recommend replicated properties π
The most easy solution is what you described above yeah. If you want to predict clients being able to pick up items you could consider "locking" the item until the server verified that whatever they picked up actually belongs to them. (Preventing duplicating items / cheating in general). Which could for example look in pseudo code like:
PickupItemClient
{
if server -> SetPickupOwner(the server)
if client -> PredictItemPickup
}
SetPickupOwner(TheNewOwner)
{
CurrentOwner = TheNewOwner // The replicated variable / "state" I was talking about to prevent new people joining getting desynced etc.
}
PredictItemPickup
{
LockItemForThisClient // E.g. make sure they can't "use" it (if a gun don't allow to fire for example) or let go of it again.
SendServerPickupRequest
}
SendServerPickupRequest
{
bHasClientAcquiredOwnership = false;
if NotAlreadyOwned ->
{
SetPickupOwner(whoever called the RPC)
bHasClientAcquiredOwnership = true;
}
RespondToClientPickupRequest(bHasClientAcquiredOwnership) // If true "unlock" the item, else remove prediction as clearly something failed and the client didn't ACTUALLY receive ownership!
}
This is simply what my mind quickly came up with. Again, it might have issues or whatever and is generally more work but that's up to you to decide what fits or not ^^
There are a lot of edge cases with this
E.g. what happens if two clients pick it up at the same time
It's sadly not so easy :D
The easiest solution is to just have it ServerAuth, but that's of course not snappy
thanks for the help guys.... like you said there are a lot of edge cases.
That's why I suggested "locking" the item and sending back a response with if the ownership was actually given yes or no. But I didn't say it was "easy" π
gotta decide if i want to bite the latency bullet and have an easy time
which, shouldnt be TOO big of a deal i hope
I know, but they said they don't need anything complex :P
I recently had to deal with predicted attachment. It's a pain
who knows, it may even be better to punish latent players to drive them away lol
That's why it's a suggestion. If it's too complex, don't use it. I did suggest it however because latency like that is VERY noticeable in Virtual Reality programs. But yeah.. It can definitely be a pain, but IMO kind of a must have with VR because again it's extremely weird to "pick up" something with your actual hands right in front of your face and the nothing happening.
But again.. Totally depends on their game etc. xD
anyways thanks again guys
I should probably have pinged Ryguy directly. The "not easy" etc.stuff was not directed at you, Thom
Oh no worries, I was just clarifying just in case π
We actually ended dropping the "feature" (was an ability) completely, as it was causing too many issues
There were so many edge cases that happened during actual gameplay, where packages were dropped, or multiple things happened so closely to each other that predicting actually also needed reconciliation etc.
Hi, I'm trying to use Rider with an expression to find out what client or server I am
however I keep getting UnrealEditor-Engine.dll not found.
the project is source build and I find the dll and pdb in Engine\Binaries\Win64
I tried {,,UnrealEditor-Engine.dll}GPlayInEditorContextString and {,,UnrealEditor-Engine.dll}::GPlayInEditorContextString
anyone able to help here? would help me immensely for debugging
@hollow eagle still getting this sadly
are you on UE5 or UE4
5
using debug editor configuration
is there some other setting / step I should do that you're aware of to find the module? @hollow eagle
I'm not sure if I need to have rider configured in a way?
Yeah but this doesn't work for the clients, only the server
^ re my issue
it seems like GPlayInEditorContextString + NetDriver; ServerConnection reproduce valid values only on debug when starting up the editor, but then fail afterwards 
the pie session ingame says these values are invalid or when putting a breakpoint with the editor open in UUnrealEdEngine::tick
anyone any idea why it doesnt work ?
why this variable does not replicating?
actor is replicated
Replicating a variable on tick? Bold move. Is the actor set to replicate?
Do not do a reliable RPC on tick.
Hi. I have this in a repnotify, which is based on a bool, however it won't set on the clients, only the server..
I have the bool getter variable connected to the SetSimulatePhysics node, but for testing I unplugged it again.
Only server got it false, all clients still have it enabled. I am really puzzled about this. Any help is greatly appreciated.
Sincerely, Matias
when using seamless travel my actors placed o n the map arent making it over
is there a list I am suppose to add them to?
@thin stratus Im confused how do I mark my player start to persist into the new level? Any Actors further added via 'AGameMode::GetSeamlessTravelActorList'
how do I add actiors to the list?
The persistent data compendium has an example
hi, sorry to be a bit annoying with this question but im really struggling to get online sessions to work with online subsystem steam. Is there a full tutorial somewhere? ive followed about a million but i swear i cant get it to work for the life of me.
Try the #online-subsystems channel.
@tranquil vine I checked but it doesnt have any example, I need to know how to mark actors
in blueprints not c++
]
i dont think u meant to tag me but no worries
You cant, its C++ only.
Only if you searched the webpage for the function name you posted earlier, you would have passed by: https://wizardcell.com/unreal/persistent-data/#5-getseamlesstravelactorlist
And yeah BP is so effing limited in terms of networking https://wizardcell.com/unreal/multiplayer-tips-and-tricks/#3-be-aware-that-blueprint-only-multiplayer-is-limited, so you can only dream about doing this in BP...
That's the first PlayerState (probably the server/host if listen server)
hello, i need some help with a replication
can some1 join feedback and supp channel?
Hello, iΒ΄ve set up a Deticated server, the server starts up fine, but i cant connect to it, no matter what I do
And the logs say what?
Hello, does anyone know how to know whether local machine has internet connection, and how to get the connection/disconnection events?
that the sessions started and is on Port 7777
"A way" to do it is to occasionally send some requests over the internet. Maybe try and see if you can ping google's server, cloudflare etc. you could also rent a server of your own that you can ping along with those. Then if too many requests fail within a certain given time you can reasonably assume that the internet connection is unavailable.
There is supposedly also platform depended ways to do this, iOS and android as an example should have them but I'm not quite sure if Unreal provides anything for that in specific π
Regardless of that. Internet availibility is unreliable and can change on a per request basis. If it's for an indicator you can use something along the lines of what I just mentioned. But don't ever assume that because your previous request worked the next one will too π
Thank you for a reply. Yeah, apparently that is the only way, which is kind of weird. I would imagine that it's possible to get that information from the OS. π¦
