#multiplayer
1 messages ยท Page 717 of 1
Anyone knows what plugin i need to use for UE5, when trying to make multiplayer? Do i need the Online Subsystem Steam or the Steam Advanced Sessions Plugin ??
To do multiplayer, you don't need plugins.
Online Subsystem is one thing, and a plugin is something else.
Online Subsystem Steam lets you ship your games to Steam, so it's vital!
Steam Advanced Sessions plugin is an addon functionality to ease up the process of creating/joining sessions etc.
For more info about both, either search the web or see #online-subsystems
Thanks, Iโll do that
Hi all, I've created a small multiplayer game but I'm a bit confused on how to save my player to an external database and create a login menu and load my character. I have a website with a mysql database so I guess that should be enough to store the player information. From what I've read, I need to create some sort of lobby/login but I don't know where to start? Are there any tutorials on this subject? or examples. maybe so I would like to find the right security way to not get hacked from the beginning lol. I was thinking of creating a login page on my website and with a confirmation via email a code will be sent and the player will have to enter this code when he starts the game. I know that some games already use this method... but what bugs me is how to save and load the data.
Does anyone have Network Prediction working in 5.0.1?
Does it actually work? I thought it was vaporware by this point.
Was "working" in EA, now it's an instant crash when used with a client
And the crash is?
something about the rewind data not having any frame history, I can't make much sense of it
set your default pawn to NetworkPredictionExtras_ControllablePhysicsBall with >1 players and try to PIE boom crash
I always thought one had to layer it once more due to some ownershiprules and whatnot (not my area tbh), but cool to know that it can be called directly like that!
You can try a rep-notify bool called something like "IsOpen". Rep-notifies will create a function which is executed whenever the variable is changed. You could then put the timeline on a separate custom event which is called in the notify function. Whether the timeline plays or reverses would then be based on the value of "IsOpen". And after "Event Interact", you could get "IsOpen" and set it as the opposite of what it currently is.
wouldn't put the timeline in the onrep. On the OnRep I'd simply pop-open the door
let the fvx and sfx and smooth movement be processed by your non stateful code
Yeah you can't put a timeline in the function anyway. Or do you mean a timeline shouldn't be used at all?
onrep shouldn't call an event that calls the timeline, that's what I am saying ๐
but timelines are okay for this use case, you can make your door open in a nice way with some awesome curve
why this
because if people join the match/game or if someone enters the relevanvy sphere of the door
they will get to see the doors making noises and smoothly opening/closing
which is not needed
And probably not desired
True, but on the other hand its now client-side so any lag won't affect the animation
noo
its not client side
overlaps run separately sv and client and on authority you can pop open it after the fact... take a look at UT doors code
their impl isn't perfect but the concept is there
I'm not sure I understand this. Do you mean it should be done with an rpc which does the anim, with an onrep that switches on authority to pop open the door?
no, no rpc's needed
remember that overlaps get called in the server and client
you can check for authority and swap an onrep whenever you want
ie: exec timeline -> on finish -> authority -> onrep to true/false
Since this isn't an overlap, wouldn't on authority fail?
Yes. Try doing the same thing in the door blueprint, but also once you've done that send a screenshot of your blueprint here since it sounds like something isn't quite right
if this isn't an overlap then you'd need to bring this behaviour to the server somehow... by means of a server RPC
but interaction needs to pass by the controller
noo, you did very good looking into interaction interfaces
buut your character shouldn't know he's interacting with a door
basically all the character should do is to handle the replication bit
and the door is going to be your interactor
so these events you have there in the character
should be moved to the door
so now the task is
you need to find a way to bring this server/cli interaction calls to the door BP
and the door bp is going to do the rest
and by doing it that way, you'll be able to provide a more generic and encapsulated view of how to interact with things
now give it a try ๐
ye
but remember your door needs to get the server and client call for your interact event
so you will have to handle the replication bit in the pawn
Why can i not set bReplicateMovement = false? It just says Member is inaccessible. I Have incluced the actor.h and ye
Yeah i just tried that
Show the code, show the output log.
can someone tell me how are lobbies created does anyone have experience with it ?
like lobby with team a and team b and 5 and 5 players and they have readinness status
ready or unready
i have eos i dont know if lobbies are included there
I did the SetReplicateMovement and it worked
that looks much better! @feral narwhal
There are ofc things to improve but the key ideas are there
now... remember that we might be interested in letting the door have the client call aswell.. listen servers don't require to server rpc as they are authority already
so in listen servers the server is a player, thus you won't need to do any RPC in such case
so something convenient is two check authority and only issue the rpc if you are on a remote connection
- giving the door the client handle opens room to prediction
so its convenient to have ๐
Can you have beacons between two standalone clients?
I have a question regarding this picture:
https://cdn.discordapp.com/attachments/972589172571398174/972831632421687306/unknown.png
Pawns are listed in the intersection, but that depends entirely on how/where you spawn them, correct?
If you spawn a pawn in server-only code, that pawn only exists serverside. Likewise for client-only code. I've got that correct, right?
Yes, only if the pawn isn't replicated
if the pawn is replicated when you spawn it on the server, the pawn will replicate to the clients
So what this diagram means is that replicated pawns are in the server and in the clients (without making distinction on local client or not)
So I'm doing what the docs says to do but I can't seem to be able to override certain functions.
The "serialize" when overriding returns a Linker Tool error (LNK2019).
Another Issue I found when following the instructions is that my game freezes completely. I seem to be able to join but nothing works, even the editor completely hangs up.
It would have been great if Epic actually would have done a real guide to that instead of a very small side note that even has errors in it (like the FCharacterMoveResponseData doesn't exist, only the Container does).
I guess I'll be stuck on that issue for a while until I know how to fix that LinkerTool issue.
Hey so just a question, If i set something as replicated and do if (HasAuthority() Destroy(), Shouldnt it destroy on the server and then replicate for every client?
Im still learning this so yeah
Yep, it'll destroy it on clients as well
yeah but i did a fast if statement and i dont have authority which i wonder why, And in a tutorial im looking at he just uses SetReplicates(true) and nothing more then he jsut does a if statement and destroys it
Heres like how i kinda did it, Im still very new to this so dont judge ๐
You need to call Interact on the server
hey, I may be missing something here but I'm calling to the player controller to create a widget in a session and the host creates the widget no problem but when the client creates the widget it's added to the host's screen. any help would be amazing. here's some screenshots of the setup. I'm using UE 5.0.1
If I want to represent a state machine on the server via a replicated enum property in the GameState, with the guarantees that 1) every client sees every change (none are skipped) and 2) the changes happen in the same order, what approach should I use?
I've found that regular replicated variables will skip intermediate state changes if they happen quickly.
Double check that the Possessed event happens on clients
hmmmm that appears to be an issue, the server is responding to both the host and client joing the session
So I created the using the event begin play instead and that seems to work really well
ah it makes the widget on the client but also make another one on the host
yeah
how would I go about this?
I think you should use the New Controller pin from the Possessed event
well i'm a little closer now haha
Click on the red CreatePlayerCounter event node in the player controller
And you should be able to change it in the details panel. I am on a phone and don't recall exactly where it appears in the UI
There's a really good PDF that Cedric Neukirchen wrote
That's great! I've got them created not I just need to replicate the variable, thank you for the help and I'll give that a read
But i still quite dont really understand, Does everything that should replicate be connected to a rpc? Well i guess yes now since this worked but OnRep etc i understand what it does, When the replicated variable changes the onrep gets called but when should i use OnRep and just HasAuthority? Its a bit unclear in my head still
And doesnt RPC's need to be bound to the character also?
You'll need to call it on an actor you own, so PlayerController most of the time
You want to execute most things on the server since in the end, it has authority over the game
So for this example i have a delegate that my pickup binds too in the constructor and via that the character gets called, And since that is called the main func will also work like that, So doesnt that mean everything almost has to be called on the playecontroller / pawn+
yeah, Because im taking some course for multiplayer rn where he makes inventory etc all of that, And inside the weapons it has a bunch of RPCS but last time i tried to use RPCS on this actor / pickup i just got a bunch of errors
Unless you own an actor, you can't call a Server RPC on it as a client, so yeah you might have to route things through the PC/Pawn sometimes
Soo, The Pawn / PlayerController has the own the actor?
If thats the case i got no idea how this works XD, Since the videos im following he just made the weapon system and its an Actor class by it self it isnt childed or anything just a brand new Actor c++ class with a bunch of code and it has a bunch of rpcs
does seamless travel using the server travel node (advanced sessions with steam subsystem) not work in the UE5 editor?
I have play as listen server with 4 clients and using ServerTravel does nothing but return "true"
Oooh
I thought that green leaf thing was some new trend.
It's just a new person indicator. ๐ฆ
Are you talking about the serialize in your struct that inherits from FCharacterNetworkMoveData?
Have you implemented the function in your .cpp? That error means it cannot find the function. Either it isn't implemented at all, or maybe a typo in the name, or the parameters don't match, that sort of thing
I still dotn get how this works, Clients can see whats happening even tho it isnt going through an rpc?
That's why it's weird. I have copied the definition from the "CharacterMovementReplication.h" and pasted it in my custom CMC class
(Picture One is my Class and Picture Two is in the CharacterMovementReplication.h file.
Can someone tell me why this will work with HasAuthority() even tho i havent made a Server function for this?
Do you have a version of FStylzNetworkMoveData::serialize(...) implemented in the .cpp ?
Depends what you mean exactly. But has authority doesn't mean that you are a server necessarily. If you are playing standalone your actors will return true when asked if they HasAuthority()
But in this case it means im on the server right? Since im on a dedicated server
Im doing all of this using a dedicated server
I have it like that in the .cpp file.
Yes, if you are running dedicated server only calls on the server would have authority. Any clients connected and calling the same function would not
Hmm, sorry it is a bit hard to say what your problem might be. Maybe you can post the full error?
Yeah, But i got no idea how that works since the EquipWeapon function is only on my character, Doesnt get have a server implemented function or anything so i dont understand how that works
The original was on German, so this is a translation
LNK2019 Reference to unresolved external symbol ""__declspec(dllimport) bool __cdecl UE::Net::WriteQuantizedVector(int,struct UE::Math::TVector<double> const &,class FArchive &)" (__imp_?WriteQuantizedVector@Net @UE@@YA_NHAEBU?$TVector@N@Math@2@AEAVFArchive@@@Z)" in function ""bool __cdecl UE::Net::SerializeQuantizedVector<10>(struct UE::Math::TVector<double> &,class FArchive &)" (??$SerializeQuantizedVector@$09@Net@UE@@YA_NAEAU?$TVector@N@Math@1@AEAVFArchive@@@Z)". StylzMainProject F:\Projects\UE5\Stylz\StylzMainProject\Intermediate\ProjectFiles\StylzCharacterMovementComponent.cpp.obj 1
Never saw an error like this before, so it's pretty cryptic to me.
The error appears twice. The same one.
Chances are you are missing a module dependency. I think that kind of code resides in NetCore but you would need to check to be sure.
So adding that in your <ProjectName>.build.cs file to the Dependency list
Right yeah I think you need to get your head around the general multiplayer concepts a bit further ๐ But any function you create can be called on either the client or the server (but not called on the server from a client, or vice versa unless it is an RPC). In your case the client can call that function locally (no communication with the server), but it won't do anything due to the check for authority. Hopefully that makes some sense ๐
Okay. I will try that. Thanks.
So like, That if statement wont go through or what?
Cause im getting a bit confused rn, I only have a few RPCS inside the character and none of them connects to this function
Okay that fixes the issue with the compiling. Now I need to find out why the whole game + editor freezes when joining the server.
[2022.05.21-18.08.19:813][520]LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 0.70, Realtime: 21.00. IpNetDriver_1
[2022.05.21-18.08.19:813][520]LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 0.70, Realtime: 21.00. IpNetDriver_2
[2022.05.21-18.08.19:824][521]LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 21.00, Realtime: 21.01. IpNetDriver_0
Okay I found the issue
Thanks for helping me ๐
No problem, good luck with your game ๐
Like this Inside my weapon is a function called OnEquip that just calls the attachmeshtopawn, And that func looks like this
But there is not a single rpc that calls these functions so how can the other player see that it is in the hand
So how can the other players see it i dont understand
This is the character function btw
I'm calling this function when the host quits the game so that the client will be disconnected properly and then will be allowed to connect to another session but the session isn't destroyed on the client side. can anyone see something I missed?
Yes ik it has OnRep_EquippedItems() but should that really make a diffrence so all the others player can see it?
Will HasAuthority() return true for autonomous proxies too?
Depends what you do in there ๐ It's very hard to say what is going on for you, but I'll throw out some random suggestions.
- Could be a replicated property
- Could be one of your RPCs telling them to equip
- Could be your MeshComponent is replicated
- Could be all your clients are actually equipping locally (say when you run over a pick up, for example)
- Could be something else ๐
depends โข๏ธ
Yes it is a replicated Property yes, I can send some more pics if you want 1 sec
And all that happens inside the OnRep_EquippedItems is that it calls OnEquip
if you are setting that replicated variable in the server, there you have it
this is the typical ShooterGame style weapon equipping code
So if i do like in GetLifetimeReplicatedprops, DOREPLIFETIME(ASurvivalCharacter EquippedWeapons) will that automatically be on the server?
Like this
yeah i understadn that
onreps triger behaviour when the variable value changes
yeah
so you can put a breakpoint and use the debugger to find out the role
callstack will provide the execution flow
so you can figure out where this server execution comes from
it's a bit - advanced... but the sooner you grab the debugger the better
So wait wait, ah idk how i should say'
It isnt getting called from any rpcs thats all i know
well the server flow should come from somewhere you know
debugger is the solution in these cases where dry reading the code is complicated
but yeah dry reading the code can be a bit complex as you are seeing here
probably the character handles parts of that
ie: switching weapons ect.
yeah
my suggestion is for you to explore what happens when you press the switch weapon button in your character
maybe that's insightful
yeah it happens when i pickup the weapon / equip the weapon
mhm then track the switch weapon behaviour starting in the character
because when you press a key in your KB from a client, that's client code that needs to be brough to the server
yeah
The interact function is not going through a rpc but it gets called inside a function that goes through a rpc so i understand how that works
ahh i found it im pretty sure
oh!! Good job!!
Its just it is such a dynamic system so it was hard to find
Since it has an inventory etc, It has its own UObject then its own Actor that is actually spawning etc, And the uobject is based of another class that has everything inside it im pretty sure
or no wait what
Some multiplayer articles I wrote:
-
Multicast/Client RPCs VS OnReps (Towards stateful replication):
https://vorixo.github.io/devtricks/stateful-events-multiplayer/ -
How to replicate thousands of Actors efficiently (network managers):
https://vorixo.github.io/devtricks/network-managers/ -
A better and non-destructive synced network clock:
https://vorixo.github.io/devtricks/non-destructive-synced-net-clock/ -
Understanding replication atomicity (why you need
NetSerializeon some critical structs)
https://vorixo.github.io/devtricks/atomicity/ -
Rewinding in multiplayer games:
https://vorixo.github.io/devtricks/simple-rewinding/
Sorry, What does explicitly mean? Im not so good at these words in english since english isnt my First language, Is it if we call if like OnRep_TheName() inside a function or
So it is like this void functionName() { OnRep_OnRepNameHere() }
will this call on the server too? I just realized im not so good at english after all
haha in this case it means that server onreps won't get called in C++
unless you call the function
yes correct eggo
No it won't..
but usually you'd do a wrapper
2 answer now my brain is twisted
if you call the onrep function explicitly from the server
it will execute the code of inside the onrep function
what @latent heart says is that this doesn't imply any RPC
or any... client->server
But just running that function from anywhere won't call it on the server. It will call it locally.
correct!
You need to call it from the server to run it on the server.
yes
So this wont be called on the server too short this up
no
It was thist part i got a bit confused at what you meant
That is there because, in BP, OnRep functions are called on the server automatically when you change things on the server.
In c++, you have to call them yourself on the server.
yes, but he's right
it's not very well written per se
let me try to write it better
ah alr, Now my brain got even more confused cause im trying to search for where this get's called on the server
Basically you have some sort of code pattern like this
It has to be inside EquippableItem or something since that is literally where all the equip items are a child of
{
MyValue = NewValue;
if (Server)
{
OnRep_MyValue();
}
}```
correct
actually... sometimes
SetMyValue(int NewValue)
{
MyValue = NewValue;
if (Server)
{
MyWrapper();
}
}
OnRep_MyValue(){
MyWrapper();
}
I've seen that also lots of times
which is also valid
Yeah.
yeah i asked inside the discord server where the tutorial / tutorial dude is at rn
I asked him about this how does this HasAuthority() go through
I mean without context, clueless
anyways I gotta do a revision based on your feedback eggo
trust me, it was great!
alright :D, No worries i guess
Alright im just gonna ask some more questions
So this whole function is actually coming through an rpc from the character, And the rpc does the useitem on the Item.h which this equippable item is a child of so i guess that would make this use also through the server
And does that make every other function inside this one also go through a rpc? So like Setequipped also gets through the server?
cause then everything i understand how it goes through, Cause then the bEquipped that is replicated gets set to a new value and if that is also on the server then everything makes sense
seamless server travel seems to persist the player controller through levels, which is behaviour I wasn't expecting.
Is this reliable? Can I store information such as player cosmetics on the player controller and have it apply to the character on spawn?
I was originally going to save that information on the host and on level change I would deliver that information to each player controller manually as I didnt expect it to persist
@marble fox @latent heart A bit more verbose, but does it now read better?
not through an RPC, it means that at that point you are in the server!
the RPC gets you to the server
it's like taking a ramp
Yeah yeah, But does that mean the SetEquipped func will like everything in there will be on the server etc?
"to the server I go"
yes everything after the server RPC that follows the execution flow will be on the server
ahh then it all makes sense
๐
Its calling so many functions tho so in the end after tracking i got to the equip function which pretty much does everything
As you can see here
and all this comes from the use function
So its like idk how many functions it goes through
Calling OnRep on the server? That would be super confusing when debugging. Why not have a shared function for server and client that OnRep calls?
Most of the times you'd wish to store cosmetic choices in the PlayerState... for that, take a look at APlayerState::CopyProperties
that's a wrapper
alr let me read 1 sec
Yeah this makes more sense
But that can get pretty verbose I fear
that's the pattern I follow the most
see here
Where is this written?
.
Keeping things descriptive and concise is so difficult with programming
Are there benefits to seamless travel outside of transferring player information? I would prefer to not use it.
Like performance benefits, or maybe not using it results in disconnects on map change sometimes?
TBH @compact talon haven't dug much into the benefits of seamless travel, so I cannot give you a proper answer
I see, I am very new and I dislike behaviour that I don't expect. What I was expecting is on map change everything to reset and then I would manually transfer over the information I want into the new level.
I am having issues with seamless as it keeps the player controller persisted so information I don't want passed is getting passed etc
I should probably just change my game so it works better with seamless travel, but it is very intimidating
"...to call the contents of the onrep..."
eeeeh not too sure
๐ธ
writing this down so its super duper clear is hard haha
How about "The server won't and shouldn't call OnRep. If the Server needs to do the OnRep behavior, move the behavior to another function and call that function from both the Server and OnRep."
Gah, handling the OnRep / RPC order of 3 interrelated things is a pain.
I'm basically following the the pattern (pseudocode) OnRep_ThingA() if (!ThingB || !ThingC) QueueForLater()
It kills me that I know I'm going to do a lot of Queueing when the data IS THERE, but the RPC / OnRep fired in the wrong order.
yeah those are implementation details
I'm fairly new with network programming. Is this a common situation to resolve?
I know you can wrap it all in a structure to force arrival at the same time
But that's not really a solution in this case
I fear it would make packets too large.
In my case ThingA is an event (RPC, reliable) that affects a few dozen things (replicated as index + eventID pairs in a FastArray). And ThingC only happens very rarely.
A Reliable RPC with an array of potentially hundreds of ints sounded like a problem.
I mean, depends โข๏ธ on what you do with it
but we've spoken a lot about arrays/fast arrays in here...
it's quite a topic x'D
Hey all,has anyone tried replicating advanced arpg
Currently giving it a go as it a needed for my game but Iโm having the worst luck
Any help would be greatly appreciated
Yeah. I like the simplicity FastArrays offer in regards to diffing.
but at the same time TArray replication can be more benefitial
that's the big depends โข๏ธ clause
I'm gradually mutating my code to be more similar to how GAS GameEffects are replicated
But GAS replication is very complicated
it is, yeah.
They have really clever usage the NetSerialize UPackageMap to allow server to filter data sent to specific clients
I'm too much a novice with networking to give real advice, but you might get more help if you narrow your question to more specific problems.
mind telling me which file is this in?
I want to take a look aswell
It is all wrapped in the FPredictionKey
It is one of those things that is genius in the simplicity
Though I was wondering if it was a problem to keep a long term reference to UPackageMap
Given GAS is used so heavily everywhere it is apparently not an issue
that's deprecated in 5.0 @obsidian cargo
Ouch! Shot to the heart!
Guess I should see what they do in UE5
I need similar behavior in one of my inhouse plugins, but don't want to add GAS to it.
UPTRINT PredictiveConnectionKey = 0;
what is this ๐
ah an unsigned int pointer
so it's equivalent but now its using an unsigned int pointer to avoid holding a direct reference
๐ง
@obsidian cargo
Oh so kind of holding a handle for it?
Oh I see, they only care about the address
basically this is simply to avoid hard referencing the UPackageMap
I noticed UPackageMap could cast to UClientPackageMap (?) which has a connectionId
my first reaction was: what's "up trint"?
But that is a lot of extra processing if the UPackageMap address isn't volatile for a connection
More generic to use UPackageMap directly (avoiding the cast), but I'm not sure how many times you would have a non-client connect to the server.
Or if the concern is from the client connection's perspective
My issue is maintaining state variables
As they determine montages and stuff
At first it was working with no replication of variables needed but for some unknown reason it just stopped,my guess is I have to replicate it
So, I'm experimenting with the way I want to do shooting in my FPS. I would like to have actual projectiles because it's a sci-fi game with blasters and plasma cannons etc. My ADS function moves my weapon to a slot at the center of the camera view which misalignes the weapon location vs where it exists on the 3rd person display mesh. Should I move my camera to the weapon instead? Maybe I just answered my own question.
Is there any decent macro for minimizing whole declaration of multicast delegates?
Is there no way to get seamless server travel working with PIE?
weapon can have its own camera attached just the way it needs to be
Ohhhhh. Ok that makes alot of sense. And then just do a blend to view
Genius. Thanks m8
never looked into it, since i was expecting a very painful experience if i try
but out of the box, no
fair
source engine editing, maybe
also does this event run when loading a new level with seamless travel? As they don't reconnect, they are taken with the server
so I would assume not
it doesn't use HandleStartingNewPlayer instead
works for login and for seamless
as its called from both PostLogin and HandleSeamlessTravelPlayer
its blueprint native, default _Implementation calls RestartPlayer() which spawns the Pawn in default operating mode
so if you want that behavior, you need to call Parent function from BP
if I want to use exclusively for seamless I assume I would want HandleSeamlessTravelPlayer then, is that even a BP event?
don't think thats exposed
ouch
I want players logging in to be auto kicked (game started), and players already in to have stuff happen
but you would generally use a different gamemode on lobby and game levels
I can just loop through existing players though as I store it in an array
yeah I have a lobby gamemode and base gamemode for all my minigames
if you want to autokick anyone joining in late, you should really refuse login
via GameSession class
at least they get a proper network failure reason from the engine then
I see, I am not sure how to implement that. I did want to refuse login but it didn't seem possible
Yeah, this is my first game and I am trying to avoid C++ where possible. For future games I do want to get very involved with it tho
Hey y'all, I'm trying to access the keys from a map (its on the game state) on a local UI, but the keys come up as null when I try to access them. How can I get around this?
It's rare for players to join post game anyways as I don't list it in the server browser, so they would need to load the browser then the host starts before they login.
overriding a function or two in c++ is hardly rocket science
it doesn't involve you designing your own code structure
I think I had to override a few for GAS
which is kinda the hardest part
you'd probably be just fine to have it return TEXT("Insert your custom failure string here");
would exposing the seamless travel player event in C++ be complex or is that also relatively simple?
do note that when HandleStartingNewPlayrer is called
so I can use it in BP
the controller parameter will have a valid PlayerState already
and that PlayerState will have called CopyProperties before that
hrm, yeah I have seen people mention PlayerState. Currently I just use the default and haven't made my own
so any data you transferred via PlayerStates from lobby to game via CopyProperties is available at that point
which is very, very convenient
i carry over my character setups/loadouts via PlayerStates from lobby to game
and much more, but this seems like a reasonable first step
I see, my game is extremely simple so all I need to carry from lobby and throughout the game is player skin + score (which is stored server only)
PlayerStates can keep scores and you can show the leaderboard ingame that way on clients
as long as the scores are set only on Server, its fine
Interesting. My score only updates at the end of each level so I didn't consider using player states for it
PlayerStates persist through seamless travel
Should I be using a separate player controller for lobby and game? I currently do but that breaks the seamless travel as it changes player controller
weird, what happens then?
depends what you do
but if controller class changes it will just instantiate new one
prior to calling HandleStartingNewPlayer
So information stored on the Lobby player controller would transfer to the Active player controller?
like cosmetics
So I should have a custom player state and use the same state for lobby + game
and transfer it via CopyProperties function (it has access to both old and new PS when called)
ah
it still works just fine
yeah I really need to try and wrap my head around player states
I wasn't going to use them but they seem like they would make my game a lot simpler than it already is
its designed to work with them, the multiplayer framework
so its generally easier to just use them
Can clients mess with player state? I was going to exclusively store player scores on the gamemode and hosts game instance because I didnt want clients to be able to manipulate scores with cheats/hacks
assuming only the gamemode sets the score
to do a server RPC, clients have to own the object they're calling from. Clients own controller and default pawn only before you start messing with things.
anything clients do is always local, to do anything non-local, they have to make an RPC
so you can do something along the lines of Player State -> sends stuff to client, and Player Controller -> sends stuff to server
since the server can use state to RPC to the client since it owns the player state
it doesn't matter if the PC or PS send a RPC
security is exactly the same
and client can use Server RPCs on PS
So long as the original call is made inside something the client owns right?
there is no serve or client side to ownership
Would there be an issue with having the same PS used in lobby and game? That way I don't need to transfer information over to new PS
sorry, I meant owned by the server*
its literally few BP nodes, and you should have a base PS with transferred between levels data
replicate: doesn't buffer, repnotify: sends the new value if it's changed from default when player enters relevancy range. Player doesn't receive the history of the changes.
Is my understanding
and CopyProperties implemented on it, even if you need different PS classes
I dont need the copy properties event do I with seamless travel as the PS persists?
assuming I use the same PS
void AController::InitPlayerState()
{
if ( GetNetMode() != NM_Client )
{
UWorld* const World = GetWorld();
const AGameModeBase* GameMode = World ? World->GetAuthGameMode() : NULL;
// If the GameMode is null, this might be a network client that's trying to
// record a replay. Try to use the default game mode in this case so that
// we can still spawn a PlayerState.
if (GameMode == NULL)
{
const AGameStateBase* const GameState = World ? World->GetGameState() : NULL;
GameMode = GameState ? GameState->GetDefaultGameMode() : NULL;
}
if (GameMode != NULL)
{
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this; <<< note this line here
SpawnInfo.Instigator = GetInstigator();
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
SpawnInfo.ObjectFlags |= RF_Transient; // We never want player states to save into a map
TSubclassOf<APlayerState> PlayerStateClassToSpawn = GameMode->PlayerStateClass;
if (PlayerStateClassToSpawn.Get() == nullptr)
{
UE_LOG(LogPlayerController, Log, TEXT("AController::InitPlayerState: the PlayerStateClass of game mode %s is null, falling back to APlayerState."), *GameMode->GetName());
PlayerStateClassToSpawn = APlayerState::StaticClass();
}
PlayerState = World->SpawnActor<APlayerState>(PlayerStateClassToSpawn, SpawnInfo);
// force a default player name if necessary
if (PlayerState && PlayerState->GetPlayerName().IsEmpty())
{
// don't call SetPlayerName() as that will broadcast entry messages but the GameMode hasn't had a chance
// to potentially apply a player/bot name yet
PlayerState->SetPlayerNameInternal(GameMode->DefaultPlayerName.ToString());
}
}
}
}``` @magic yoke
it will still get reinstantiated if controller class changes
I see
but you can use same PS class, just implement CopyProperties
Hey, does anyone know a solution to my issue?
anything you need a player to know when they enter relevancy range should be repnotify. Anything that's one time/temporary can be just normal replicated
do note: that means anything that won't be default
so for handling stuff like players loading cosmetics I would save the information to the player state in the lobby, and whenever the player state begins play it gets the mesh and modifies it with the cosmetics?
like a player changing colours
if you leave relevancy and come back, they will be default colour again
@tulip ferry non relevant Actors don't replicate to clients if they are static (loaded from level), if they are Dynamic (spawned at runtime) they are destroyed while not relevant and respawned when they become relevant again
GetOwner is a function, not a member variable
also, especially while still learning, avoid auto like a plague
Because you are trying to destroy it twice on clients
So second time, it will fail to destroy because it's already destroyed
And anyways such session related questions should go to #online-subsystems ๐
anyone know how to fix this i'm trying to make a dedicated server and when i build in development server this errors apper
Thanks you very much bro i try this
Hey people, if I trigger a Client replicated event from local player, would it completely ignore replicating and just trigger the event or still use network to fire action? The reason I'm asking is, I normally have a normal function which controls if it's locally controlled. If it's locally controlled, it triggers the logic. If not, it sends the data to client replicated function and trigger that way. So I'm wondering if it's unnecessary or not.
there is no drawback in just using a client RPC
Thanks, will stop doing the thing I do then.
is it possible to disable player collision so players can walk through each other ?
Set Collision Channel to Ignore Pawns or w/e
i just tried that in the player BP, in the Capsule Component, that didnt work, is it some where else i need to set it ?
no, only BP :p
got enough skills to wrap a function an expose it to BP?
haha no :p
/** Add an Actor to ignore by Pawn's movement collision */
void MoveIgnoreActorAdd(AActor* ActorToIgnore);```
this is the function
you just need
UFUNCTION(BlueprintCallable)
void MoveIgnoreActorAddBP(AActor* ActorToIgnore) { MoveIgnoreActorAdd(ActorToIgnore); )```
oh
no you don't
xD
okay, i have no idea what you just said tbh :p sorry, im an idiot programming
i can only repeat it
np ๐
CapsuleComponent -> IgnoreActorWhenMoving
ty ๐ ill try look into that ๐
oh got it woking ๐
But now the camera is going into the player xD
know how this can be fixed ?
its only going into the player, when they collide
nvm, got it working now, thanks for the help ๐
it means SetOwner was called, or set in FActorSpawnParameters
I am? would you be able to tell me why that's the case please? Also, sure I'll post my next questions there from now on
Yes. If host(server), you are calling a multicast RPC, which executes on host and all connected clients, and it destroys the session. You also destroy the session in case this is not the host(client). So you are destroying twice on clients. Now I can't tell if this is really an issue(sometimes that's safe to do), and I don't know what's the right way to do such stuff
does server travel use a transition level if I dont use seamless travel?
ahhh I see! Thank you for explaining that. It still fails to destroy the session on the client side when the host calls this function however
It clearly doesn't. Transition level is what makes seamless different from a non seamless one
I see, I was going to not use seamless as it's giving me issues but I like using a transition level.
I'm really not sure if you this function can be called client side, or it's enough to be called server side. Hasn't got my hands dirty enough with sessions yet ๐ฆ
ahhh okay that's fine, I've just had another look and think the flow of this mean that it should work as it shouldn't be called twice but still doesn't do much. If I attach a print string then it only fires once and never on the client side
I'm not sure I understand what the change you made there
But anyways how do you call DestroySessionNicely?
Object->DestroySessionNicely() ? ๐
Also it does seem like DestorySession should be called on both hmmm
Lel
I'm still not quite sure what type of PlayerControllers should be provided there though. server-side or both?
It's an RPC I created in the player controller, in the image you commented under there's no change just some scribbles over the top
That's the issue I'm having, this should call to the clients to destroy their session too (when the host leaves) but nothing happens client side. If I try leave the session as a client then the session is destroyed correctly and I can join another straight after
This is exactly the issue
I get the player controller and cast to the correct class and then as that class I call the function. I'm not at my pc anymore.
That's it. It should be called on both. So calling it on both worked for you I assume
I have a data asset being replicated. But I then have an asset from a child class of the main data asset class which fails to replicate and outputs the error: LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: NewContainer_C /Game/ObjectInventorySystem/Inventory/Data/Assets/TestingContainer.TestingContainer NOT Supported.
Children of the main parent class replicate, but if it is a data asset from a child primary data asset class it fails until I resave the assets (the asset is already in memory/loaded), and issue comes back if editor is closed. What is going on? If I were to package and clients were to play my game would it fail to replicate to them despite the issue being fixed by saving the assets? (Cant test that because dont have an actual flow for such a test yet).
Is it possible to connect to a host but not sync anything up? I really just want the connection to send commands from server to client and vice versa but my understanding is all things Unreal Networking related are with the context of things being synced up, same map, same actors etc...
Okay well nevermind this seems to be a bug in 4.27 which I also think is in 4.26, but not in 5.0
hi, have following code running inside of component and i dont understand why rep notify doesnt fire up on clients after begin play
so text still not changing ๐ญ
i can fix it by putting same code as in rep notify on remote
but shouldn't it work so?
when i change variable after begin play somewhere on server side it works perfect
for example when collision overlap happens but not on beginplay
Did you figure out the limitations of sequencer and multiplayer? Voice is synced up and so are material parameter collections but the niagara particle FX and animations are not. Looking into it as we speak.
Hello everybody.
I'm looking to make a dedicated server using Java and I'm following this course: https://ylazarev.com/2021/03/31/3-java-game-server-movement-in-ue4/?fbclid= IwAR3HhWq1DkpRly6xH__Lr_oeWaL-UcY8NeGcYaZ5pjdi3efTxeYOTqhlUUo . But for me it lacks quite a lot. Does anyone know a more complete course? And I want to deploy my server after finished to AWS but I can't find any documentation about it. Can someone help me ?
Does the component replicate?
@fathom aspen In Class Settings Component Replication is True
i though post login issues should be solved by using repnotify instead of multicast
or am i doing something wrong
Correct. Such stateful stuff should be done using onreps
Something interesting but I guess it's just left over and not intended to work is you can set variables inside the animation blueprint to replicate but they will never replicate right? Even if their owning character is set to replicate?
No it's ok
hmm weird
Yes, Anim BPs don't replicate
Does the health get replicated?
ok, my bad
default value of variable was already max health
if i change it, it works like it should ๐
Should the sequencers replicate playback handle the life time triggers of a Niagara particle emitter put inside the sequencer? You'd think that if it at least tells the client which part of the sequencer we are in that we should see the same stuff happen? It's odd that the client doesn't see those results from sequencers replicated playback no?
It seems pretty straight forward though. All the information is there in the sequencer, just replicate the passing of time through the sequencer and things will more or less look right on both, its doing it for audio, but not for the Niagara actors in scene and they have no replication flag sadly even if just for this purpose.
it does look like that is what its trying to do void UMovieSceneSequencePlayer::UpdateNetworkSyncProperties() { if (HasAuthority()) { NetSyncProps.LastKnownPosition = PlayPosition.GetCurrentPosition(); NetSyncProps.LastKnownStatus = Status; NetSyncProps.LastKnownNumLoops = CurrentNumLoops; } }
After more testing I have a new question: Is it possible to add components with maps to a game state? I have a component for an inventory that I wanted to be shared among players, but the map attached to that component keeps coming up null in the game state. Anyone know what might be happening?
Maps don't replicate
maps don't, but a struct with an array of strings and an array of (whatever you want) does
๐คก
Looks like I'll have to pivot then, thank you
I think what I'll do instead is add a "quantity" variable to my item structure and just get an array of the item names
using c++?
Does any one have any reference or tutorials on adding abilities when using a server character AI character (Seems to make a difference with message calls on other tutorials) ? Was due to reliably replicating the top down template or let me know if this belongs in another channel?
Actor component exist both on server and client. Check if actor is locally controlled would be better
There should be a IsLocallyControlled() func when you cast the owner of the comp to a character
I have a variable on my BasePlayerController.
I seamlessly travel from Lobby > Transition > Game, the lobby uses my Lobby Controller and the transition/game level use my Active Controller (both children of BasePlayerController).
I store player information on the BasePlayerController, as the controller persists through seamless travel. However it resets my player information structure variable on my base player controller, instead of persisting it.
Does seamless travel just not work how I expected?
or perhaps I am missing a setting, maybe I need to check replicated for the player info var?
use PlayerState for storing that information, overide CopyProperties
PCs having the same base doesn't help one bit, its not the same instance
and copying their data would require overriding HandleSeamlessTravelPlayer in c++
PlayerState data transfer works out of the box
I see, I did try using player state as per you recommendation yesterday but I was having a bunch of issues with it and I wasn't able to resolve them
let me try something else and see if it works
Hi how do I prevent the pawn from being destroyed when the client leaves the game?
you override AController::Destroyed
Is this not the right way to set a variable in a player state? The target is my lobby controller and this is happening in a loop for all players within the lobby gamemode
It just keeps using default player info from my state
hrm, I will finish my lunch and come back with better information.
I was just being a dumbass, I missed a small connection somewhere a lot earlier in my BP...
What do I override in the function?
its overriden in PC
it calls the PawnLeavingGame
which destroys it
you need to stop it from doing that
Unposses the pawn and then just call Super::Destroyed
it didn't. the multicast is only called by the server and only works on the server. The event isn't sent to the client. I'm going to try another setup today and see what I can do
so I moved this function over to the widget that calls it instead of having it in the player controller and it works great
Can you not use world partition with a dedicated server yet?
tried?
I was about to setup an experiment, literally now
like - I was opening UE5 to test this
hello friends i have created the code but when it plays it only shows the scene2d component for the first character I've tried for each looping it and it didn't work so does anyone have any suggestions on how i can get a different scene 2d capture to play on a widget for each player in a multiplayer game?
are you wanting the widget to show on your players screen?
I have a replicated actor containing a 3d widget and a sphere collision. When a pawn overlaps with the sphere collision, I want the widget to be visible only to that pawn. Any ideas?
yes its possible but.... TLDR:
- DC server keeps all the cells loaded at all times
- Listens erver keeps all the cells loaded at all times
this can get pretty expensive specifically in the listen server use case
server streaming unfortunatelly isn't supported and I believe it won't be supported
correct i want it to show up for everyonre and also be there own 2d scene capture
Can someone tell me how computationally expensive dedicated servers are/will be for a simple 3d board game? I heard even baseline server binaries are pretty expensive for UE5
try setting up the RPC to run on owning player to create the widget and then you might have to play around with what's shown on it
I just was curious because when trying to host a dedicated server using the 5.0.0 release code
it crashes and it seems to be world partition related
Okay, all I mentioned is on PIE
let me cook a dev build and give it a try on localhost for at least listen server
@crystal crag according to your experience this would crash, right?
or you only tested on dc server?
i tried a bunch of different cycles of this where i even set it up for the server to then replicate to the player but nothing worked for me was trying to see if anyone else has had this problem
ill try creating another function for it but it is not creating and assigning more than one scene capture
@pallid mesaIt seems to not happen if I use a standalone game and open up a listen server
but if I use a dedicated server, then attempt to join as a client, then it crashes
I can also have a client in PIE join the listen server and I don't experience the crash
only when joining a dedicated server in PIE do I get the crash. I haven't tried packaging it up and testing that way
Ugh weird
I don't get the issue on PIE dc
@crystal crag this is a new project, blank with barely any stuff
Be sure to update your UE, I'm in the last hotfix
maybe that's the case, try updating first and then check if you still get the issue
nothing on my side
Ok
No BPS on this project
Hello all, I'm working on an inventory system and encountered an issue I am trying to resolve. When a player picks up an object of the ground it is placed in their inventory. During pickup, I Rename() the component to set it's new outer, then Destroy() the Actor which represented the item sitting on the ground. On the client side this component is unfortunately destroyed as if it never recognized the Outer change, on the server it exists as expected. Is there something clever I can do so that when I call UActorComponent->Rename() on the server, clients can be made aware that the ownership has changed and to not Destroy along with the Actor?
Trying my best to illustrate the problem :^)
Wrapping the Rename() inside of a NetMulticast, Reliable function resolves the issue but this seems incredibly sketchy
Another potential solution would be to make the InventoryItem owner some other Actor that is always relevant, that way Destroy() would never affect the InventoryItem to begin with..
I'm adding actor components to a replicated array. This crashes unreal instantly. If I turn off replication, it doesn't crash.
Has anyone had this bug before?
I can set the array in question fine, it's specifically when I try to add to it piecemeal that it crashes
(blueprints)
are you checking IsValid() on the clients before accessing the members of the array?
that should give ma a printout saying access null
it shouldn't crash unreal itself
but yeah lemme do that
no but if you are accessing a pointer that is not valid on the client you're likely getting a null pointer
right
but this doesn't give null pointers
it crashes the unreal editor entirely
lol
for curiosity's sake
I made it so the repnotify code doesn't do anything
still crashes
even though the replicated array isn't ever interacted with
the repnotify would be on the client side, i would expect the replicated array to be interacted with from the server?
I dont understand whats going on here, when one client shoots it takes away ammo and adds screen shake to the other:
Does anyone know whats going on here?
If you replicate an array of structs, does a change within a struct still trigger replication?
does anyone know if there is an Actor in the world that is replicated to all players by default?
thank you
hey all, noob question but the count column in the network profiler tool is that a count of how many times a actor was checked for replication?
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/NetworkProfiler/
That sounds correct
Does it seem reasonable that the GameState Actor would be the owner (or maintain a list) of all UObjects in gameworld that represent Inventory Items?
APlayerState is always replicated and relevant using default settings I believe
Characters are replicated, but they have rules that determine relevance and will not always replicate (again, using default settings)
I haven't played with the replication graph, so that might completely change things; not sure.
No. By default the GameState owns nothing
It was replicated** as told in the post. A specific actor is checked for replication on a fixed interval, and if the value did change then it replicates and that's what the count is
So my next question is I should be trying lower the amount of times an actor is being checked for replication? I assume I can push updates via code with force net update?
If your actor doesn't change stuff that much then that's something you should really be considering. Also ForceNetUpdate doesn't really force anything, all it does it resets LastTimeActorWasCheckedForReplication(I made up the name, can't remember what it's called)
What you can also consider is to use the PushModel, which lets you replicate stuff only when you want them to replicate, so there is no checking on an interval
Another thing you can do is make the actor Dormant and FlushNetDormancy when you want it to replicate(also if it doesn't really change that much), but that's far too extreme for what you want to do I assume
Why are your items Actor components? That seems weird
Is there a special trick to replicating arrays in BP?
Cant get it to work with a simple rep notify when adding stuff to the array.
for starters, Unreal does funny stuff with Outers, which are not replicated
on clients, Outer tends to be the Actor that replicates the object via its ActorChannel, even if server has different ideas
note that you have not changed the Owner here, nor did you re-register the component
which i really wouldn't do anyways, as adventures like that that so often lead Unreal into undefined behavior
install editor symbols for debugging if you haven't already and provide the assert + callstack from crash reporter
given your adventures with Rename, im guessing you are using c++, if you want to go that way, have a AInventoryManager Actor, then use FFastArraySerializer to replicate the inventories - read NetSerialization.h header for documentation on it
Are you meaning to have non-replicated units?
Holy necro lol, Just noticed that was 2 days ago. Anyway, are you meaning for your spawned actors to NOT be replicated?
I considered using UObjects, but replication was already built-in for UActorComponents. AActors seemed wasteful since the objects won't always be visible
Thank you I will check that out
It certainly didn't feel like the best implementation, thanks for the feedback
I am using seamless server travel and storing player information (such as skin choice and username) in the player state so it persists through level change.
I loop each player controller in the lobby, casting to the state and setting the information inside said state. Then when the level swaps and the player character is spawned it reads the information from the attached state to get the skin to use.
The issue is, this is only working for the host. The host will have their player information in the state from the lobby, but the client loses it.
I think I am not setting it correctly.
This is something that happens to all player controllers in the lobby before the server travels to the new map This is within the lobby gamemode BP
This is the player state BP and I use copy properties to copy the properties to the new state as the level changes
This is the player character, and on the server player it pulls the information set within the lobby gamemode.
For client's the circled red area doesn't have any information so it is using the default values
Are you sure PlayerState isn't null for client? It takes time to replicate, and that could be an issue
I wouldn't wait for the info to replicate just to change some other info on the server side character. I would stay on the server and change all the stuff there
I am not sure what you mean by this, as for your first line that could be an issue as I didn't consider it being "ready" to use on the client.
Also BeginPlay runs on both server and client, so such code should have a switch has authority(remote pin) before it
Is a switch has authority necessary if I want both the server and the remote clients to run the event?
Yes that's what I meant, you can't assume it has replicated
Yeah, I will quickly test that by adding just a long delay to see if it's the issue. I will need to package it tho because I cannot test server travel with PIE
Well character exists on both server and client. So all characters in the game will have this code run on both
oh I see, yeah that isn't what I want to happen
It's not that if client 1(not the host) doesn't have a server instance of that character
Yep. I understand what you mean now.
You can do that, while as I said, I wouldn't run such logic on the client, for the replication issue and because it's unnecessary(not performant)
I would pull the info from the server side PlayerState and change the skin on the server side Character
I see, to have that occur all I have to do is plug the last screenshot into authority instead of remote or is it not that simple?
Plugging is first step. Second step is to get rid of that RPC(just run normal function). Third step, make sure that RemoveAllWidgets runs in Remote pin as it runs on clients as you see
I see, as for running the normal function I am not sure if you mean the on client function instead of on server as I dont run the on server with authority?
This is that section of nodes
Oh I see that's another problem. A skin is stateful event, it's not a transient one. Multicast events are transient not stateful
So changing a skin that way would be a problem if there's a player that's not relevant at the time the change occurs, and then becomes relevant
He won't see the new skin
Same thing for late joiners...
I think I have something set for that, as late joiners do see the new skin
Oh wait, I just saw that the texture is Replicated(RepNotify)
Ok that's why
So you don't need to Multicast
What you can do instead is just run a normal function that changes the skin and OnRepNotify change the skin for clients
Alright, let me try and get these changes and find someone to test them out. Thanks for the help
@fathom aspen Alright, I figured something out with all this mucking about.
You are right with the switch on authority thing. I removed it to just test the delay and it changes the host skin fine and it changes the skin for the client for a few frames and then it resets. Presumably because, as you said, it is running the event twice on the player. One is right and one is wrong.
However I am not too sure as I tried changing the skin on authority and removing the widgets on client but it caused issues as the widget removal wouldn't occur on the host, and the skin wouldn't change at all. Which surprised
This seems to have fixed it, not sure if its unoptimal but at least the skins and information are transferring properly
Right RemoveAllWidgets is a BlueprintCosmetic so it doesn't run on dc server so it seems like it should still be run on listen server 
As for changing the skin, did you set the texture/material on the mesh in the OnRepNotify function?
Yes
Can I see how you do it?
or to be more clear, my base player creates a dynamic material instance on construct and changes the mesh to use it. Then on the repnotify I change the texture parameter for this material instance
sure
Construct
RepNotify
Why do you SetMaterial each time the texture replicates back? Setting it one time should be enough
ยฏ_(ใ)_/ยฏ
Good point, this is my first ue game so I am just kinda throwing stuff together that seems vaguely right and hoping it works lmao
Haha it's okay, been there, though I would suggest to not roll with stuff because they "work" ^^
I think when I did it, it was because setting the material in the construct wasn't replicating properly, so I set it on the rep notify as it calls the rep notify from the construct
Repnotify doesn't fire if a value hasn't changed
I could perhaps check if its already valid/set though, and if it is then skip re-setting it or something
so his implementation is fine
Yeah. The construction script has some gotchas. That's why I tend not to use it if I can
Mostly using this game as a learning experience to learn the basics of a wide variety of topics in UE, such as blueprinting; GAS; multiplayer; online subsystems; how replication works etc.
Then I will get more advanced with these topics in my second game and hopefully by my third game I will have enough knowledge to consider releasing a game. These are just private learning experiences to play with my friends.
Though setting same dynamic material instance each time the texture replicates is unnecessary
You are on the right track. Learning by doing is great. Asking in this server when you're stuck is great too ๐
I felt pretty intimidated starting with a party game but it's honestly a lot more relaxed than any other game. There will for sure be a ton of bad optimization but because it's a small party game they will never really see noticeable impact on performance in game.
Optimization is just such a huge daunting task that I want to spend a huge chunk of time learning it for my second game, as well as making high ping multiplayer feel less jank.
Anyways I am going to head to bed, it is 3am and I have work in the morning. Thanks for the help ๐
As for SetMaterial you can move it to BeginPlay I guess
It looks like I can use this to provide more granularity as to what I am serializing. It's still a pretty thick read though, are there any examples I could look at to help me understand it better?
they even have an implementation example in that header
you do need your FFastArraySerializerItem
which would probably have a pointer to the InventoryComponent, your FItemData or equivalent, and the inventory slot information
then on PostAdd/Change/Remove, it "contacts" the InventoryComponent it has a pointer to, and informs it of what has changed
obviously, all your InventoryComponents would have to register themselves with the AInventoryManager
and all of them would have to (on server) update their information in the fastarray on any change
No thats fine, i got it working as intended, the spawned actors are replicated
Can someone help me with a really basic question? im in a vc
Hi guys I have a quick question based on security.
When we say run on server, I know the code is exclusively run on the server. But does client have "visual" of this execution as well. I know this seems vague so let me give you an example.
Say I have an early access system and the keys for early access is saved on a server somewhere. If I wrote a "Run on server" function which obtains these keys from the database and checks it, will the client be able to access these keys for that time period as well? or is this completely happening on the server and the client had no idea what these keys are.
The client won't run any of that code
If you have dedicated servers and aren't shipping the server binaries to end-users, it's worth compiling the sensitive code out altogether.
Ah okay awesome thanks.
So this works out pretty nicely as far as camera functionality goes, but how does one make sure the gun is aimed where your FPS center screen is so that when you zoom in, its at the same point of aim? That is currently boggling my mind. And then how do you continue to control the camera's pitch?
Can I have an actor-instance stored in e.g. the GameState (without being spawned), have it replicated to all players, and let clients decide for themselves where and if it should be physically spawned for them?
And if that is possible, when playing on a listen-server and the host spawns it in their world, can I prevent this action from being replicated, while still replicating other properties on it?
Well you can't have a non-spawned instance, that makes no sense
And no you can't replicate it's properties if the actor itself is not replicated
You can just turn off replicated movement then move it where you want it to be client-side
Strange use-case though
Yeah.. It's a very client-authoritative game, where the dynamic world is built in runtime on client-side, and not necessarily the same part of the world as other clients (e.g. they're on two different planets). But there's always exactly one "home base" (one actor, with several sub-actors), which exists one place. All players must know of the base and its properties/states at all times, so I was hoping I could just instantiate the actor with NewObject in the GameState and then decide on client-side whether or not to spawn it (based on where you are in our own coordinate-system), and was hoping that it would be as easy as just saying something like BaseActor.SetWorld(GetWorld()) or something.
I was initially planning to create a thinner replicated data-layer struct describing the base, with all information necessary to reconstruct it anywhere, but I had to keep adding a bunch of information to it and would need a sort of diff-tool to avoid recreating it on every change, and got a lot of ugly hard-coded properties between building-actors and struct-layer, and in the end I felt like I was about to duplicate the entire Actor-lifecycle and re-invent the wheel so to speak.. Was hoping to just use the Actor.
No that's not going to work
You need to spawn the actor server-side and replicate it
NewObject won't even work with AActor derived types anyway
Hi, is it okay to use this delay here? this is running on the game mode and gets called when players have loaded into the map, the player state cast sometimes fails on the first attempt because it can be called slightly before the players have loaded in, the full logic is I have a timer thats ran every 10 seconds checking if all players have loaded, if they are all loaded it'll then check to make sure we have the expected amount of players that travelled over from the pre lobby, if the expected amount of players are reached a pre game timer is started and the AssignTeams event is ran
If you set NumPublicConnections to 3 when creating a session, it is impossible for more than 3 players to join a lobby?
Or do you have to manually disable joining in progress when 3 players have joined?
you aim with the camera, then make a weapon fire at camera hit location
its slightly more complicated for TPS
as when close to an obstacle, the weapon shot can be blocked where camera shot isn't
but that is typically solved by drawing a red X widget where the weapon trace to camera hit location is blocked
Ok so this is how I would set it up as well for a weapon that actually fires a physical projectile too? I'm not currently using a line trace for firing because I'm just spawning a projectile actor at the muzzle location/rotation.
then its camera trace and you set the bullet on its path to camera hit location
Ok. Makes sense. I'll figure that out. Thanks m8. Any suggestions on controlling the camera pitch? When I blend into the weapon camera, I lose the ability to pitch the camera though I still have control of yaw (through the player controller I assume.)
Hello! I have a beginner question - my characters are controlled using floating pawn movement but it seems like the client can't send inputs. I have tried putting the input axis value in a variable and using repnotify to actually call the movement code but it doesn't seem like my client is updating in any of these cases. Any tips? Thanks!
I followed a tutorial where you use ip but i when i send the package to my friend and gave him my public ip he did not connect. Thanks
anyone?
You probably need to forward port 7777 on your router to your PC
Yeah but then i also need to put in an ip address
You're best off following a tutorial on port forward but it will probably be your local lan IP address of your PC
say your IP is 192.168.0.90 you want the router to forward incoming connections on port 7777 to your machine which would be 192.168.0.90
so ipv4 or public?
is it only 7777 or are there more?
7777 is all you need unless you have changed the port it is listening on
UDP
between UDP and TCP? best off googling it, but they are quite different. fast paced games always use UDP
Sorry I'm about to go out, could be many things! Did you test on your local machine? Two clients.
Do you have another machine on the lan you could test with
So much can go wrong, you gotta simplify first
No. Im doing it with my friend over discord
Hello, ive got a bug with raycasts and that they do not want to sync, is this a known issue and is there a fix?
(it is fully replicated but idk what ive done wrong lol)
never mind im just dumb i turned on componenet replicates on the scene componenet the raycast shoots from and now its working
hi there, i need to make a video chat inside android Unreal apk, its posible to do that? i know the android camera plugin, but i need replicate the video, its there a way to replicate render target? or material? and then use voice chat?, please i really ned help with this,i am able to pay for the help
If your game requires solo play but also drop in / drop out multiplayer, is there no harm in just creating a private session whenever the user loads up the game and have it available should they decide to invite a friend? Or should sessions only be created when a multiplayer session is definitely desired? Listen servers in this case
no solo, multiplayer with two person, its a video chat like app more than a game
We're doing a seamless drop in/out game and yes, in solo play you technically have a session.
The game is completely seamless from startup to shutdown except when joining another game.
https://forums.unrealengine.com/docs?topic=506005
if I understood correctly this article from knowledge base says that subsystems are not ideal for multiplayer scenarions. Is there any kind of Specialized subsystem that does well in MP?
Programming Subsystems and Replication This article was originally published for UDN. The engineโs Programming Subsystems provide lightweight and easy to use extension points for core engine classes. When using these subsystems for a multiplayer game or other networked project, these may seem like a good place to include networking related func...
Nice that sounds great! Thanks for sharing. I'll create a private session as normal when the player starts up the game and then I guess can easily make it public if they choose during the gameplay (for quickplay) or just let them play solo with it running
I'm not sure if bAllowJoinViaPresenceFriendsOnly and such can be updated on the fly or if a new session needs to be created, but will figure it out!
Worst case scenario they just destroy their current session and create a new one with the updated params. Just one last question on that, travel isn't mandatory for a new session to be created right?
As in they can load in to the starter map and create a session without having to travel to a new map with those session params? Sessions can be thought of separately to the actual gameplay / currently loaded world?
Dude. Syncing the third person mesh with the first person mesh in an FPS is a huge challenge. I must be trying to go about this all wrong lol.
A huge challenge in what way?
Pitch in particular. I can't get the pitch of my third person gun to match the pitch of my first person gun so that the muzzle effects/projectile origin are the same. They are both in the wrong spot if I look up and down at all.
when looking at the character from another client
I'd have it constnatly dumping the pitch out to the log and see if they sync up.
On both clients
The pitch of the 1 specific character, not their own characters.
then you can find out if it's a view rotation problem or a skeletal one.
hmmmm. Yeah I can try that. Thanks
Right, this is the only way I know of if you're project is BP only.
The clean and right way is to use OnRep_PlayerState from cpp
Is there a special trick to replicating arrays in BP?
Cant get it to work with a simple rep notify when adding stuff to the array.
Hello I am working on an online survival game like ark or Conan and im trying to figure out the best way to save world data like player builds so it persists over server restarts
After you add stuff the array you need to set the array
That's a known bug with stuff that are RepNotify in BP
Does anyone know a tehnical document on how valorant does its hot registration?
Savegames
No. The general practice is to use a world subsystem, and spawn an actor that handles the networking portion of it.
I've done this a couple of times, works nicely
Alright, solved the problem while in ADS. So here's the strange thing. It appears to be working while in ADS but not while in hipfire. The strange thing is that I don't have any different code controlling pitch while in ADS.
I'm guessing you do! ๐
I'm using a Trasform (Modify) Bone node in my anim graph which is modifying spine_02. The Layered Blend Per Bone nodes that control the hipfire and the ADS poses are both set from spine_02....
so I don't know what's going on
Is it a pitch value issue?
haha I mean it would stand to reason but I'm going through the code again and again and I am not modifying the way in which the controller is rotating while in ADS
Or a skeleton issue?
Looks like pitch. From another client looking at the guns, they are in the same position and same rotation/pitch. But in the first person view, the weapon is rotating up as well as the camera. I must have something in the code that is locally rotating my gun or fps arms mesh
hmm.... I can't find anything unless set world rotation propogates to children by default or something. I'm not specifically altering the rotation of the gun mesh anywhere... Just the camera that it is a child of.
So, I thought it might be because I'm limiting the angle of the camera but I checked the camera rotation against the adjusted control rotation values and they are identical lol. This is baffling.
I wouldn't replicate the widgets. I would replicate the player name in the player states and have the widgets read the player name from that locally on each client
I quote
The values of our replicated variables are sent by the server to the incoming connections, so if a new player becomes relevant to us, they will set our replicated variables to the incoming values.
Essentially, Multicast and Client RPCโs are for one-off events, meaning that they donโt persist any state. New connections have no clue which RPCs were sent recently.
BenUI has a really good video about networking on his site that covers this. 3rd video down by Omid Kiarostami https://benui.ca/unreal/notgdc-2022/
the article i sent covers in fact that specific issue
I wonder why Epic didn't use their new motion warping in lyra when using melee
Is anything stopping us from using motion warping while running an ability?
Or maybe it's because it's not the best approach just for what they were trying to achieve and it has nothing to do with whether or not motion warping can be used in an ability graph
So - spawn an actor that talks to the world subsystem?
hey everyone,
Is there anyone here that has experience using a custom server to manage game state and connecting a UE 5 client to it? I am currently porting over everything from unity
I think I know what it is but I have no idea at all how to solve it.
So the first person camera is a child of the capsule component. It inherits its rotation from the controller directly. And it's pivot is in a different place than the pivot point of the third person mesh's spine_02 which means even though they are technically pivoting at the exact same angles, they will never match.
And I don't think that parenting the FPS camera to the third person mesh is gonna be a good option because then my camera will inherit all the movement of the character's animations, which I don't want.
I have a replicated actor containing a 3d widget and a sphere collision. When a pawn overlaps with the sphere collision, I want the widget to be visible only to that pawn. Any ideas?
Confirmed it. I attached the FPS arms to the TPS Mesh and it rotates exactly as it should.
But that's not a solution. Hmmm
I always kind of assumed the FP arms would be like "gloves" that go onto the TP skeleton.
Shrug
Make the pawn own that actor, and then SetOwnerOnlySee on the 3d widget component
When the pawn leaves the sphere you can un-own the actor
Yes sounds like a crazy solution, but can't think of anything else, as I haven't done such a thing before.
Well another thing you can do is make that actor only relevant to that pawn and not to the other pawns
That can be done overriding IsNetRelevantFor
Hmm. i must be doing something wrong
As is tradition
I follow said tradition a lot as well
If its only to the local pawn then shouldn't a local event that tells the widget to be created be enough?
Here's a picture of what's going on
client doesn't see anything. server sees anyone overlapping
Here's the logic
I feel like there's some sort of checks related to ownership or local control or something that needs to be done to fix it
Hi guys what avatar plug-in do you guys like the best for human avatar players? I currently have Character customizer
Can more than one player see that widget?
You would also prolly want to make the actor itself OnlyRelevantToOwner. But anyways if more than one player can see the widget, then you shouldn't be going this route
Yeah so the idea is that anyone who is within the radius of the sphere collision can see it.
Yeah then the owner thingy won't work for you. Only one owner at the time can be there
What you can do is have that widget component attached to the player instead with OnlyOwnerSee as default. And when you overlap that sphere you activate the widget component(it starts deactivated)
Yeah I'm trying to figure out how to basically do only owner see for just one pawn, not for all of them
So inside my GameMode On PostLogin I have a bool that is supposed to be set to true after one trigger of the post game login and yet it stays false each post login ? https://gyazo.com/c5cb27855c47e2437f203eec4b76e5cb
Only two player, listen and one client. Post login called twice, both times its false
I just moved it to game instance and it works now but that is confusing
That shouldn't be the case. You are probably changing it back to false somewhere else
o7
Its doing it do all variables inside game mode and I think that is why I have issues :/
moving them all to game instance for now as a work around but yeah I don't think that should happen like that
Maybe its an editor debug thing, IDK atm
Does anyone have any idea where to find AWS SDK for Unreal Engine 5
Yeah. The subsystem spawns an actor, and that manages the network data
world subsystems live in the server, right?
All connections for me
The manager acts as the accessor to the system, the actor registers itself with it when it's received so anybody can easily access the state. Most of the logic is in the manager, the actor just replicates the state
Similar to how GameMode/GameState work
Difference is that the "Mode" actor is the Manager and it exists on all connections, and you access the "State" through it
But the two are coupled
manager is the actor, here, right?
but you mentioned the world subsys spawns the actor
or does the actor exist in the world and fetches the subsystem on received beginplay?
i think it wouldn't matter much in this case
No the manager is the subsystem
ah! okay
The idea being it's always going to exist when you need it client-side, so you don't need to worry about race issues
And it pushes out events when the state actor is received
My command system does quite a lot of that since it keeps track of commanders, commandable objects, the global command "state" and each "division" actor as well
pencils in another blog to write up
Does anyone know why my multiplayer would stop working when I enable "DefaultPlatformService=Steam" instead of NULL? If it's on NULL it works fine but as soon as I try to use steam, game hosting stops working completely. I've searched for days and can't find the answer. ๐ฆ
You can test a game and play together via steam with the default app ID, can't you?
I'm also using the Advanced Sessions plugin on UE5 but not sure if that matters.
๐คฃ
still working on the initialization blog post, right?
yeah, got a few in progress
That would make sense but then you need to parent your camera to the TP skeleton too and then you're gonna inherit all that animation movement which isn't necessarily ideal.
HI everyone im using blueprints to host session and join on lan ..its not able to find session...i dont know what im doing wrong here
Does set view target with blend change possession of controller to the other pawn?
no
Ohhhh - so, the subsystem spawns it. Alright. That's what I thought at first but it saying the subsystem doesn't have network stuff made me think, for some reason, that the subsystem couldn't have anything that replicates, actor included. So - the server spawns it and it'll auto spawn on the client side like normal, right?
yeah
Then the actor can register itself with the subsystem when it arrives client-side
So it's accessible from anywhere easily
hi, I am trying to do some quick MP debugging - I can connect to a dedicated server locally when its built
but if I launch it as a separate process from editor I cant connect with open localhost open 127.0.0.1
There's a good middle ground. Launch it from command line or with a batch file. Sec, I'll get mine
I am using Launch Seperate Server to launch a dedicated during PIE, but Standalone wont connect to it
is there some extra parameter I need to add?
IDK, PIE can get fucky. You unchecked single process?
yeah, its not once process, its opened up the same map, but the dedicated it launches doesnt even seem to listen for connection requests
When you say attached to the player, which player do you mean? The actor is spawned and attached to a player who fulfills a condition, then when another player gets close to the one with the actor, it should become visible only to the one who is close, not the person itโs attached to.
@safe marshJust make a couple batch files like this and try it
Client
"C:\Program Files\Epic Games\UE_5.0\Engine\Binaries\Win64\UnrealEditor.exe" "%CD%\Islandgame.uproject" MainMap -game -nosteam
Server
"C:\Program Files\Epic Games\UE_5.0\Engine\Binaries\Win64\UnrealEditor.exe" "%CD%\Islandgame.uproject" MainMap -server -log -nosteam
thanks, I can try that but it will need to build it, right?
No
its the same as right clicking the uproject file and hitting launch game
or just launching the game
except its launching as server
@dark edge I solved it, needed to add the port as PIE server doesnt use default port >_<
but thanks for that, will try it for automation later
Using VRExpansion, I added the ReplicatedVRCamera and that replicated to clients fine, then I added the Replicated Motion Controllers and now the ReplicatedVRCamera doesn't update its transform for clients
you can try asking in the vrexp discord server, not sure how to fix that issue sorry
Ahow some code and we can look
all instances of every character on every machine call BeginPlay
also, you should use a HUD derived class for widget manipulation
unlike the Character, its there only for the locally controlled PC
Hey I have a question regarding Seamless Travel. The players stay connected to the session when travelling to another map right?
Is there a way to check if all players have finished loading the new map? I want to wait for all players before starting the match.
AGameMode::NumTravellingPlayers will be 0 when they all load
Damn, totally overlooked this. Thanks!
Well this isn't what I understood first time. Anyways, I'm not sure what you're trying to achieve. and prolly you're over complicating things the way you're doing them right now, but you would want to look more into relevancy checks, and trying to override IsNetRelevantFor(I don't think that's viable in BP though).
I figured it out. I had to pass the actor reference to my third person character through a client RPC and set the visibility on it there.
I needed to get the local clients replicated version of the actor
Though Client RPCs are for transient stuff, so that might make you issues down the line.
See here, and read that post
not really clear on how that could cause me an issue
But I'm guessing you want only the client to be able to see it, so that might not be an issue
Hello, I'm having recurring problem with this - can I set replicated variable on the server only and expect it to be set on clients? It doesn't seem to work. I have to set it via multicast...
Afternoon, a quick question. what is the the Red box that appears next to Channel ReceivedRawBunch in StatNet? Is this a problem?
Question, is there documentation for these project settings anywhere?
I cannot find anything
Not really as far as I know. If you dig around in the source code it's pretty well commented though.
The basics are that you have a function to accumulate an error value, and you hard snap if it gets too high. While it's low, you gently ease to match the server's position and velocity
the actor needs to be replicated
It is. I usually end up using RepNotify instead, it always works.
also careful multicasts are for transient stuff
repnotifies are there only if u need behav when the value changes
Yes, my problem this time was probably caused by the fact that I tried to access replicated variable on the client when it wasn't yet set.
Desynchro issue, I guess.
oh yes totally that's a nice race
: )
Yeah
but be careful, you can shoot ur knee very easily with some programming patterns
As a rule of thumb, I try to use multicasts only for VFX and SFX.
But this replicated var being null on client keeps returning. ๐ But I guess it's about latency, as you say. That's why it's often solved by using RepNotify + OnRep combo.
i have an actore where "Send json" are call and "update data" don't want, (call from owning client) have idea why?
Hey guys if only my server is able to move and recieve input what could be the issue then? ๐
How do people test their multiplayer code (specifically with a listen server and one or more clients?) I tried testing in editor with 2 players and one as the listen server... but then behavior is different compared to running two instances of a standalone build on the same machine... but when playing two instances on the same machine, whatever window is not in focus caps it's framerate so testing the client means everything replicated is super choppy and unreliable.
if listen server vs solo server is giving different behaviours
it means you've got a replication issue, things aren't properly being replicated
I've been testing everything on client only, because that way you know for sure you're not making mistakes with replication since the listen server can "cheat" since it's a client that has authority (no other clients will have authority)
I would love some help regarding replicating a door with a dotproduct variable. Everything obviously works for server but clientside the door opens based on where the servers dotproduct float is.
heres my blueprint/ and function
how do I get the client's dotproduct to replicate to the server?
what is the dotproduct in this case?
the position of the player based on their proximity to door
yes/ that way the dotproduct variable tells the door which way to open
so the server doesn't know where your character is
?
seems strange that there's a desync there
I meant more specifically in editor - things like singletons or other actor references (sometimes when server-spawned, sometimes not) - behave differently than two separate running builds. I did have some replication issues - but I didn't find out until testing in separate builds because those issues weren't present when testing in editor.
I honestly dont know
those numbers are what the printstring reflects
you can always just do an RPC that tells the server directly what the relevant value is
but it seems to me that you're calculating the server side info wrong somehow
Oh I definitley am haha
the server knows where characters/pawns are
if you calculated it right server side, the dot product should be what you see client side or very close barring a bit of lag
so sending the dot product over via RPC would bandaid the issue
but underlying there's something else going on
btw
"get player character 0"
Thats what Im trying to figure out by asking. If someone could review the blueprint _ I can provide better quality images
is a bit of an issue server side
since only client 1 is considered player 0
that's my first concern
if your player ref is set wrong, that'd wreck your dotproduct server side
since it'd always be calculating it from client 1's pawn
how do I fix that?