#multiplayer
1 messages Β· Page 659 of 1
You get to decide what the clients get to know and what they should know.
Often that's stuff like, current ammo, max ammo, etc
stuff the client doesn't need to know is, last shot distance, trace parameters, rate of fire, etc
I kinda see.
Guess with enough multiplayer experience it will be easier to know if the client needs to know something or not
Hi Guys!!! I hope you are getting a great day.
Maybe someone have had this issue with a dedicated server in Linux??
When the player chooses the server enter but is kick out immediately.
the Client is for Windows and Server for Linux (running in a gcp vm instance). both built with the same engile, I've deleted intermediate saved and derivateddatacache but the problem is persistent, with a windos server works fine the problem is linux build.
NOTE: the mismatch only happens with characters, we are using GAS for a lot of things
Update: I've cloning the project again in other pc, compile and build but the problem persist, do I don't know the cause of this problem π¦
Any suggestions?
[2021.08.18-04.28.56:227][576]LogNet: NetworkFailure: NetChecksumMismatch, Error: 'GetObjectFromNetGUID: Network checksum mismatch. FullNetGUIDPath: [19]/Game/Characters/Klowns/KlownKlasses/Brawler/BP_BrawlerKlown.[17]Default__BP_BrawlerKlown_C, 2259927734, 2943822821'
so my game play seems to be pretty bad when network lag emulation is set to bad is that to be expected or should i try to get it to work more in bad latancy
hey so ive been following the epicc multiplayer tutorial and then the newer one from devaddict but ive been trying to migrate away from using the save file to persist session data (eg character class and picture). so far its working nicely but im having an issue with clients rendering the Lobby Widget. I've narrowed it down to my use of GameState.PlayerArray in a widget construct event. The array is empty, doesnt include myself (joining the session as the client) or the server host. Is there a function or event that exists in blueprint or C++ that is called when the client is fully networked? (eg playerstate and gamestate w/ players is fully replicated)? i'd like to avoid checking this in tick if possible
its to be expected
just make sure its playable
but it doesnt have to be enjoyable
like its pretty hard to crouch slide like it will just stop most of the time
then it will uncrouch and recrouch repeatedly for a few times
also lots of times if you jump wile running you will just instantly hit the ground
are u testing eith packet loss
as I would recommend to not
this is what im using
i usally use avarage but do test at bad to see how playable things are
dont have packet loss
as u cant really compensate for that from my understanding
but isn't there packet loss in realworld situations
and also these are epics default settings
for bad
if I pass an actor reference from the server to the client, using a Call on Client RPC, does the client get the same actor reference?
like is the ID the same
(ie, i spawned an actor on the server side which is replicated, and I want to pass the actor ref to a client so that the client can set a variable in his pawn that points to the spawned actor)
Sorry for the noob question, but are UniqueNetIDs steam specific? I've messed around with steam multiplayer a bit, but I'm attempting to make a non-steam multiplayer game
im trying to find an easy way to have user-entered usernames
Hey guys, would anyone know where FUniqueNetIdRepl is first defined before anything?
I thought that e.g. PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage) was where it was defined. However, even if we set up a different FUniqueNetIdRepl or just give a NULL value into e.g. Super::PreLogin(Options, Address, ConvertedId, ErrorMessage); the program still runs and I can see that FUniqueNetIdRepl is generated normally for all the clients.
Can ya share some code
I've figured out how Rep Notify variables work in Blueprints. I use them to make sure a changed variable is set correctly for a player who joins later.
But how would I do this in C++?
I just need to check bool on an Actor upon entering the game.
UPROPERTY(ReplicatedUsing = OnRep_MyBool, WhateverElseYouNeed) bool MyBool;
UFUNCTION() void OnRep_MyBool(const bool OldValue <Optional Argument, can have no argument>);```
with special note that blueprint OnRep is a hack
Just bear in mind.. Rep Notify works differently (aka, properly) in C++
and as such it gets called on server as well
in c++ that doesn't happen
the MyBool also needs its DOREPLIFETIME entry in GetLifetimeReplicatedProps override
Thank you all. I'll test it out immediately.
Oh where do I set this?
you override it like that:
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
and then inside you do:
DOREPLIFETIME(AYourClassName, YourVariable);```
hey there π
just wondering if any of you have been using Modular Game Features in Multiplayer, yet?
it seems to me that loading features (even via command line) in multiplayer results in weird and inconsistent behavior.
I'm looking for guidelines what to call locally and what on the client, or if it is even possible to load features only locally.
Is that UE5?
yes
Then please keep it to #ue5-general . UE5 is not ready for production. Until UE5 is released, we rather keep UE5 discussions to the early access channels if possible
got it, thanks
Done. When should I call this?
Happens automatically
It's a functions from the Actor class that you are overriding
Have to get this off my chest.
The logic of FindInactivePlayer is utterly stupid.
What was being smoked when this was written.
So when you log back in:
- The controller spawns a new player state.
- FindInactivePlayer retrieves the original Player State.
- Instead of overriding the
newplayer state properties with the original ones, it actually assigns the original player state to the controller - then calls "OverrideWith" on that, passing in the now unassigned, pointlessly spawned new player state.
And the naming of functions and variables suggests the total opposite.
I ranted the exact same a couple weeks or so ago
Totally confusing
What a utterly stupid implementation.
Yeah I also didn't understand it
This is the sort of crap they should have been fixing/trimming out in UE5. I bet it's the damn same.
I had to somehow handle assigning a team again
And it was so broken cause I read the function wrong
Cause I expected something totally else to happen
Theoretically, if you just give the player the Old, currently inactive PlayerState again, it would already work. But even if not, then overriding the freshly spawned one with the old one would still make sense.
But giving back the Old one and overriding it with the empty new one, that is just chaos

Yeah the way I understood it, is that the "New" player state is kept - and OverrideWith is called to give it a chance to copy properties from the old one. That makes far greater sense.
Yeah exactly
I don't understand, at all, what the other idea was
Like, what data would the new one have that I want to use?!
yeah
If I want to keep a newly assigned team, then I could just make sure i clear the old one when the player is cleared and just give it a new one when rejoining
But well
I'm convinced it wasn't always this way.. I just can't make sense of it.
Honestly
I think the majority of UE4 programmers that do Multiplayer never even used that function
So I believe it has been shit forever
And the ones who find it rant in their internal slack
And cry to their colleagues
Going to whinge on UDN like a madlad
I really wanted this sort of stuff cleared up for UE5... even if it makes porting a little harder.
Probably won't budge though. I'd submit a PR but why bother when it'll sit there for 3 years anyway.
/rant
The only reason I can see for this, is if you have other objects/actors which are referencing the old player state and this therefore makes restoring things easier - but what a farce.
If an Actor is marked as Replicated & uses RepNotify, the RepNotify will only be called when all replicated properties (inc complex types such as UObject) in the Actor are replicated? Or it doesn't care about the replicated properties are replicated yet? π€
Only when that individual property is replicated.
Not for any property
If you need a function called after all Rep-Notifies have been called, you can use PostRepNotifies()
Wait, to clarify, so if the Actor has a say integer marked as Replicated
the Actor's RepNotify is called the moment the Actor has been replicated, and doesn't care about the integer is replicated or not?
It's called on two occasions:
- When a change to that property is received.
- When a new actor is received and the value differs from the "serialized" value.
You can however optionally force it to be called whenever the property is received, even if it matches the current client value, by doing the following:
DOREPLIFETIME_CONDITION_NOTIFY(AMyActor, SomeProperty, COND_None, REPNOTIFY_Always);
When an individual RepNotify is called there is no guarantee that all other property updates have been applied yet, as they are called inline when the property value is set.
Is there a way to know if the Actor's properties have been replicated?
In what sense?
example :
my WeaponActor has a ItemData (replicated) which contains the name and other information
My UI need to display the Weapon's name.
How I am doing it is :
if WeaponActor's RepNotify is called, I will display using the WeaponActor's ItemData's name. But at the moment, WeaponActor RepNotify is called, but ItemData is not replicated yet, thus is null.
So what is ItemData? Is that another actor, a sub-object of WeaponActor, or a class?
sub-object, a UObject
k so it's a UObject spawned at runtime, then replicated via ReplicateSubObjects?
yup
kk so you will get the RepNotify twice I expect.
The first time will be with the sub-object being null, because the NetGUID of the pointer property is set first - but the object has not yet been created.
Then it will be called again, after the sub-object has been created and the pointer populates with a valid object.
Does the pointer ever populate client-side?
Because if not that suggests the subobject isn't replicated properly or instantiated on the client
sometimes yes
More generally though, why is that ItemData a live UObject? Why not simply reference a static data asset
its for storing information such as number of rounds in the weapon in this case.
because my project has the concept of inventory and backpack, and backpack consists of only ItemData, so when the weapon is stashed into the Backpack, the ItemData allows me to know how many rounds was in the weapon
Why not just retrieve that from the weapon actor itself though I mean, why separate that into another object
ItemData can't be replicated without the WeaponActor anyway, so it's dependant on the WeaponActor being replicated and relevant.
Essentially it's like an ActorComponent
Oh, because I destroy the Actor when added into Backpack π
Yeah, that won't work then.
ItemData is a replicated sub-object of WeaponActor - so when you destroy WeaponActor, ItemData goes with it.
Yeah, to work around that issue, I use DuplicateObject and set the Backpack as the Outer so the Backpack gets to replicate the sub-object
Yeah you're in danger-zone territory then really
Here's a more general question : would you do the UObject approach to store data, or just keep everything as Actor, don't bother about destroying at all
My advice would be the simplest approach - keep the data in WeaponActor and don't destroy it, keep it live.
When it comes to replication, you can make an optimisation by only replicating the WeaponActor to non-owning clients when it's "equipped"
We don't have backpacks as such but do something similar, the weapon is always relevant to the owner - but is not relevant to third-party clients unless it's equipped.
So, that means every item in Inventory / Backpack remains Actor but hidden and not relevant to 3rd party clients unless need to?
Yeah, that's how I'd go about it anyway
Doesn't have to be that way - but you do want to avoid creating/destroying replicated actors routinely, that can end up being way more expensive than just leaving them live.
Yeah, that's one of my concern for my current approach as well. It may end up worse than keeping them live.
Probably makes it harder to restore state etc. too
And Sub-Objects like components/objects also have additional replication overhead for RPC's and properties
It's not huge but it's not negligible, but as they are replicated through the actor, there is extra data which identifies the sub-object.
Oh, I have struggled a lot using this approach π
I see, more reasons to keep them live then. Glad to know.
Thanks again for your help & advices! Appreciate it.
oh?
Well, it's already about 10x the workload of SP - and you don't want to make life any harder
When you get into those 1/100 repro cases later on you'll be thankful for it π
Hahahaha, definitely not looking forward to that
Though definitely learnt a lot from trying to do things this way, which makes it a good journey, I guess.
hello, so i am making this multiplayer game which has two teams W1 and W2. The problem is, i just want to enable input for those who contain the tag of W1 and not W2 but it doesnt work. Both of the tags are still getting their input enabled
It's because you use PlayerController 0
Everyone will call this BeginOverlap event
And for everyone, if it's a W1 Tagged Character, it will pass the branch, locally enabling input for their Controller
If at all you need to cast the Actor to the Character (guessing it is one) and use GetController to get the Controller of that specific character
And then you want to limit this to "IsLocallyControlled", because no one else needs the input stuff
Now, the question remains what you want to do with the Input on that actor, because you won't be able to execute any RPCs cause some random actor in the level isn't owend by the player
I want to experiment with PushModel, but as soon as I do anything with it, my project can't compile anymore because of linker errors. So I assume that my engine is compiled without support for PushModel (UE5 EA2 on linux). Can anybody tell me how/where I could enable it?
Hello Guys, I need some help. I have a multiplayer game and the match is composed by 4 Oculus Quests and 1 PC in a Null OSS using LAN. The game needs Voice Chat, I coded all the basics of Voice and it's working pretty well in the first map, after ServerTravel the voice stops. I've tried a lot of things but seems to be impossible to fix this. Anyone knows any about this bug?
Responded in #blueprint - Don't crosspost please
:triangular_flag_on_post: draku#4616 received strike 1. As a result, they were muted for 10 minutes.
I was not aware about this. So I just want to present my use case .
I m working on mobile moba , and mobile network is not that much stable so I m expecting the players disconnect...
So in my case my Ability system and attributes are in PS, if player reconnects then new PS is spawned, then in that case my ability system and attributes are lost?? Is it the case??
No because, stupidly, the "old" player state actor is the one you get back.
But all the functionality surrounding that system suggests otherwise
I'm fine with using the old one, they just need to really tidy that stuff up a bit
The part(s) I don't get (copying from my post)
2) The 'New' PlayerState surely has no data that we are interested in copying to the 'Old' one?
3) The 'Old' PlayerState could very likely be in an unrecoverable or faulty state, especially if functionality is compartmentalised into Components.```
But in the case of GAS, that's one instance where it does make sense to keep the old one. I'm just annoyed by the silly naming convention
Right
Hi, Is there a way to make a component - spawned in a blueprint construction script - network addressable? The actor itself is placed on the level, and the component gets created in the constructor script (its a simple static mesh), but in networked play, when a simulated character is walking on it, the base is always nullptr, because the engine cannot reference that component over the network, there is no connection between the servers version of that component, and the clients version.
Make it replicated
it is marked as replicated, but isnt doing anything
If the component is marked as replicating after construction
Then it should work fine and replicate correctly
Though of course, things like setting the static mesh won't replicate
i dont know, that would mean it gets constructed twice on client side, wouldnt it
Not if the actor is replicated
i'd assume construction script is running on the client side too, so the client would run the AddStaticMeshComponent node, and the server would run it too, then the server would replicate the server's version of component, then client would end up with 2 component, one being without static mesh set up
gonna check if thats the case
it would be nice if i could set like "this component and this component is the same"
Yeah you should probably gate the comp creation with HasAuthority
I'm wondering, is this the only way to do it? It's actually the blockout tool I'm talking about, and every object is created like this. That would mean, initially, there would a huge amount of components to replicate, and complicated code, just so the movement can reference the component it is standing on
Yeah, if you're doing procedural geometry and your movement needs to talk online about which actor it's moving on, two big ifs, then yeah you have a problem
I figure the second part might not be true
well it is not my movement, the default character movement component uses it
it stores and sends over the network what component it is standing on, and thats where it goes wrong
interesting, how did nobody run into this problem
Anybody here ever try implementing slowmotion in multiplayer?
I was just going to set global time dilation on server then rpc multicast it to all clients
But I wonder if anyone has any better udeas
You could save a target value in the gamestate, replicate it, and in the repnotify, set the global time dilation to that value
iirc ue4 has a slomo function?
but yeah i would use a replicated var which adjusts timedilation
Hi!
I'm doing the login system for my game, currently i'm using firebase authentication and it's working ok, but i'm kind of worried on the security side.
I'm just storing my keys and user values on a variable on the widget and than passing that one to player controller/PlayerState etc. Not using Server calls at any moment.
What would you consider could be the problems of doing it this way and how would you do it instead?.
I myself currently have a issue regarding something simmilar but as far as storing user data on variables especially sensitive data and passing it on dirrectly to a server without prior server checking (authentification) can result in some very big problems on the security side. I whould not keep any data on variables (as long as the variables are not seen via multiplayer connection) and all data that the player sends should not be taken granted by the server instead there should be a token or ticket of sorts that checks the user data that the player tries to pass on.
Whats the purpose of CatchupTick(float DeltaSeconds) in UT source code's UTProjectile? What happens when servers DeltaSeconds passed to ProjectileMovement's tick?
Comment already explains the purpose actually but I'm wondering the magic behind the sending deltaseconds
// Move projectile to match where it is on server now (to make up for replication time)
Mind if i ask, what form of database are you using for your data?
i'm using firebase auth for users but i'll have to save/read quite a lot of data and i references would be helpfull, so far i'm thinking on using mysql on the server's machine.
I use playfab it comes with good services for some small indie development although I am still learning parts of it. It has a ue4 marketplace plugin playfab sdk or something like that.
Oh playfab looks nice, do you think the "Data management" feature is meant to be used as a realtime database? (not user analytics, but raw user data)
if so, it would be a nice idea to try with playfab auth and database.
I would take the data at the start of each session and store it on the server
then at the end of the session
send it back to playfab
no reason to do it in realtime i would think
This is one of the issues i'm studying to see how to solve it.
I already created the game in SinglePlayer, now i'm trying to do it with a multiplayer base to expand later. And i already know that there's a LOT of data that needs to be write/read.
My game is something like Art of conquest (https://www.youtube.com/watch?v=v4klOqxePHA&t=732s)
where data is moving back and forth all the time to update the city status.
On a multiplayer basis, do you think it's posible to do it the way you say? storing it all in the session and than saving it.
Or when something specific is requiered, update whatever data we have on the client and than check with the server stat.
#artofConquest #mobilegame #gameplay #moba #strategicGame
to be honest i'm kind of at lost on how to approach the data transfer on a game like that without burning the server to the ground.
Well there are some really crazy fast data bases though I dont think that whould be the way to do it. I think just plain old ue4 dedicated servers are the way to go and the data bases to hold out the more inportant information for your game. But if your game really needs some large amount of data storage and transfer trough a data base you probably whould need some good amount of investment
Is there any way i can control the delay of in how much time each pawn is going to be created inside Editor.. when i test for multiplayer using dedicated server using 2 clients ?
no
For listen servers, my server host is not having any client functions run like OnRep and Playerstate.ClientInitialize. Is this on purpose or am I missing something? It seems like the server host is treated as the server itself instead of a client with network authority.
On purpose, a listen server isn't a client it is the server
my understanding of listen servers is that the host is still treated as a client. thats my understanding from garrysmod anyway. the server is launched in the background and attached to the game
hm i see. that sort of doesnt work with what im trying to do.. or i guess what im trying to do is probably wrong. im trying to make it so that when a client joins and some playerstate variables are replicated it calls a function to update the UI, but since the OnRep functions arent called on the host, the host's UI is never updated
Sometimes if you plan to support Listen Servers it's quite common to manually call the OnRep() when setting properties
oh interesting
I prefer to separate it, sort of like this:
{
SomeProp = 1;
OnSetSomeProp()
}
UFUNCTION()
void OnRep_SomeProp()
{
OnSetSomeProp();
}
void OnSetSomeProp()
{
// Common Logic
}```
id only need to do that for a listen server host though right? for dedicated this is not an issue
Just so it's more obvious and you can still differentiate client vs server logic,
In theory yeah, dedicated server would mean no local players so no UI locally.
i might explore this a little more a bit later on. ive already started a new project with a dedicated server, so i might finish this off, then see about adding listen server support. i guess it also doesnt matter if OnRep is called on the client since it wont actually replicate to the server
thanks for explaining that to me
Anyone here uses Vivox?
hello everyone, I need an answer for a simple question, can smooth movement in multiplayer possible if the character has use controller rotation yaw unchecked?
this is my current rotation code
this is what happens it jitters https://streamable.com/uw14n3
I just need to know if smooth rotation is possible
What is "movement acking" exactly?
@peak sentinel are you asking me?
Nope, it was a general question related with movement components
As for your question, it should be fine if you enable bOrientRotationTowards---- (couldnt remember its name rn) on CharacterMovementComponent
That checkbox overrides pawn's default orientation logic
And smooths the rotation
Though you're using SetActorRotation i guess, I have a very small monitor rn cant read
If you are applying rotation or location on tick, it will take some time to arrive and some packages will drop/loss during transfer and it wont be smooth
Smoothing that requires some additional effort
This option will work when using input bindings or on AI movement
I tried to check this and it made it worse
Probably because of you're adding / setting transform on tick, not sure though
With input and AI movement it works great
Are you good with C++?
no, could c++ solve my issue?
There is a function you can override in C++, not exposed to BPs
That rotation yaw checkbox calls it inside C++
But afaik (i might be wrong) its empty by default
You can add your own interpolation logic there
Though, again, if you're adding or setting location on tick its not gonna work
Because you're just setting a location, not smoothing the distance between A and B
You're just saying "set to B from A"
Its virtual void FaceRotation(FRotator NewControlRotation, float DeltaTime) override; btw
And here is the code you need to paste when you override: https://controlc.com/d93c17fa
// Only if we actually are going to use any component of rotation. if (bUseControllerRot - d93c17fa
If you ever need it though 
ok thanks I will get this over to someone who knows c++
c++ is an entirely different animal
Kind of, dont pay to someone for this though, its pretty simple, just ask from a friend or try to get guidance at #cpp
All you need to do is just create a class in C++, override this function in header, paste this to its definition in .cpp
Then reparent your BP to your newly created C++ class 
ok ill try it out and report back thanks for all the help
Btw... I'm sorry. I just realised you're having problems with player-controlled pawn π€¦ Thats my mistake
@halcyon totem
That function is not gonna work
I was assuming you were having problems with AI controlled pawns before watching the video, I guess I need some sleep
Its still simple to do though, you dont need C++ either this time
I cant see your BP logic because of my small monitor but a method of doing this is
1- Have a replicated yaw and pitch float variables, mark them as OnRep, set their replicaiton condition to "skip owner"
2- On OnRep_Yaw/Pitch function apply the rotation of pawn
On Tick, if you are
Authority: Set float and yaw variables
Client: Send server float and yaw variables with an RPC
By skipping owner, you will let your local controller skip OnRep function and you will be able to simulate the rotation without any lag
And every other connection except server will use OnRep function to set simulated proxies rotation
tada 
ok I will try this out and see if it works and I will report back
I want to dig this up once more, since I am still struggling with it: Does anybody know how to enable PushModel on a custom built engine?
NetCore in Build.cs
I m doing team allotments for my joining players, and as per my understanding the best place seems to be this
virtual void PostLogin(APlayerController* NewPlayer) override;
Is there any other better place other than this?
i prefer to use: GenericPlayerInitialization
it handles PostLogin and post seamless travel
np
There is no Build.cs for the engine.
Or is there a central one I have yet to find?
Does anyone here know a tutorial series for replicating a fps game?
Your projects build.cs
If you look at PushModel.h, itβs in a module called NetCore
That is the most general thing I have ever heardπ
Since I got a linker error (not a compile error), I thought that my engine wasn't compiled with support for PushModel.
how do i make it un general
I think it refers to movement acknowledgment for multiplayer games
Had to recompile the entire engine, but eventually your suggestion turned out to be the solution. Thank you very much for that!
Hello all, how's it going? I'm new here and I have a question. I've been struggling with replication for quite a long time and I can't make it work.
Here's the thing: I'm spawning an axe,attaching it to the server side character and setting the net owner to the axe, replication is working because I can see it in the client. When the axe hits something, I'm trying to call the server to apply damage to the hit object but it's never reaching the server.
I've also tried getting the owner, which is the server side character, and calling the server there but it didn't work either
nvm, I figure it out, the owner has to be the controller, not the pawn
@pure kraken Normally that's not true. You should be able to have a Pawn own a Weapon, as long as the local controller controls and owns the pawn, the weapon should be able to RPC.
have been using Playfab's services to get a player identification method on servers but I got stuck at the part where I gotta authenthicate the session ticket but idk how to do it (if can someone show me a example of how to do it whould be great)
can someone help I am trying to send some repNotify YAW and Pitch Float variables to the client but I dont know how
am I sending the variables correctly?
What "acknowledgment" stands for? If a movement can not be acked what happens?
and ack is sent to the client to let them know the server processed that move.
either successful or not
also SavedMoves gets adjusted to only contain unAcked moves
basically Acked means it was processed.
hello all I have use Controller rotation yaw UNCHECKED for my character pawn and I am trying to smooth the rotation, is this the correct way for the client to send the server the variables ? its still laggy so I dont k now if I am doing it wrong
@peak sentinel I am trying your fix am I doing it correctly?
hey all, do you think a 50-100 concurrent player (per dedicated server) survival game is viable using UE's native networking, or is a custom back-end a must?
have been researching all available BaaS options for the last week
and i would definitely like to avoid writing server code outside of UE
i'm also noticing that every multiplayer survival tutorial/marketplace tool seems to use UE's native networking
but i'm skeptical as to how it'll perform with the high culling distances and many player states required in multiplayer survival games
have been using Playfab's services to get a player identification method on servers but I got stuck at the part where I gotta authenthicate the session ticket but idk how to do it (if can someone show me a example of how to do it whould be great)
Hello guys , I have an issue with replication so outside of servers view equipping of client doesnt work did ever someone experianced this before ? please help me ...
Definitely possible
Check out the Replication Graph
Anyone know of a good set of videos that provide a crash course on UE networking, ideally aimed at someone who understands typical networking concepts (I've got experience with Quake networking.)
Hi, how often is too often for reliable RPCs? When toggling a flashlight, an unreliable RPC gets called locally which calls a reliable NetMulticast RPC so the flashlight is guaranteed to toggle in everyone's game. My concern is if players spam the toggle button. Sources recommend not to call reliable RPCs often like in tick. Should I worry too much?
i had just stumbled upon this but didn't look much further due to not finding many videos on it, but i'll dig into the documentation
thank you!
Why doesn't this use an OnRep? Furthermore, I doubt a flashlight toggle is going to overflow the reliable buffer
Fun fact, Dead by Daylight had that issue
People spammed the flashlight using a cheat, which would end up with everyone being disconnected
But yeah I'd use a replicated variable for this
that would mean they had a replicated multicast function for it
@lost inlet @solar stirrup Thanks for ur replies!
and you could rate limit that on the server
Can anyone explain how RepNotify works for when the variable changes before a client joins the game? Does the RepNotify function automatically run for a client if the variable was changed before they joined?
Yes
It'll run so long as the current value is different from the serialised (default) value
You'll need a lot lot more than that to overflow reliable rpc
I've seen games calling multicast several times a second without issues
Thank you!
And if I reference the variable within its repnotify function it will use the new variable, right?
Yes, but if you add a parameter of same type to repnotify you'll get the last value as parameter
For AI controlled Pawns the vector length is always zero when using MoveTo Node.
Any other way to get acceleration.
Sorry can you explain that more?
In c++
You can do
OnRep_MyHealth(float LastHealth)
So last health is your health as it was while current value of your variable will be latest from the network
Got it now, thank you!
Guys I have a problem when it comes to replicating an address blend space, it does it to me in the local but the user who sees it does not see it correctly because it is I have everything replicated
Hi guys. Do you know where to find some info about animation based combat system for multiplayer? Cause rn I have a huge problem with overlapping when its amazing locally and its totally broken on dedicated server
Easy question: Are you able to open a level with the "?listen" option BEFORE you host a session? or do you have to host a session and then open a level
example would be a single player game level you could decide to host later
Hey, has anyone run into the problem where skeletal meshes that simulate physics on characters start flipping out whenever the host player isnt looking at it? This only happens on non-possessed characters.
is smooth non laggy rotation possible when you have use control rotation yaw in UNCHECKED? I am trying to do a fix someone mentioned but its still laggy is this the correct way to send a variable over RPC??
I tried with both server_rot and multi_rot in different combinations but its still lagggy
supposidly if I have skip owner picked on rep notify local controller skip OnRep function and you will be able to simulate the rotation without any lag, but its still laggy
Hi, can somebody help? I settuped dedicated server with my game, but whenever i try to join it with client via open 127.0.0. 1, i get connection timeout error(if it helps im using Steam subsystem), thanks in advance.
guys how can replicate the axis for example moveForward and moveRight
Is there any online subsystem for mobile ?.
So I created a beautiful networked weapon system where the player spawns a server sided weapon that the client owns and then the player calls a command on the weapon to shoot. then the weapon responds back with a delagate which tells the player when to do animations and sounds for the first person model..
only downside? when actually taking latency and things into account, it sucks
there is a huge gap between when the client fires the gun and when it actually fires server side
so, I'm going to have to probably remake the weapons system so that everything is done on the client.
What is the best way to have the weapon set up? Have dummy models on the rig that switch mesh when using different weapons? Have the same system but only have the weapons spawn on the client instead of the server? A mix of both? I feel lost.
no
You never want things to be done on the client(in the sense when they are critical to gameplay)
what u want to do is predict those things
I'll have everything done on the client and then checked by the server
oof
because I found this chart
so I guess what I'm asking is should I have the shooting logic on the player, or on the weapon. I would like it to be on the weapon itself so that way it's just an agnostic system where I can wildly different types of weapon setups and all the player has to do is tell the weapon to start and stop shooting
I guess I'll try editing my current system before re writing it and if I break it too much then I'll just make a new one.
with that diagram (which is extremely helpful to me btw), you can still have the shooting logic on the weapon.
lets say the playercontroller has an 'OnFire' event that runs locally, at the point in that diagram where 'bisShooting = true', you can can check which weapon on the player is equipped, then call a custom server event that is passed the bullet type as an input
so the 'Create real bullet(s)' event in that graph could be the agnostic system
which can draw upon your weapon types
i'm not sure if that is best practice at all, that's just what i'm imagining
does anyone know if replication is still single-threaded in UE4.27?
How do you get the player data after they rejoin.
Scenario: a player joins a server and collects 5 coins than leaves. Later he decides to join back and get back to his 5 coins. How does the server know that the player controller that just rejoined is the same player as the last one that had collected 5 coins?
As far as I know you tie the data to a specfic player ID and when the playet joins you get his ID and when it matches with the player ID of his data he gets that data. If that is how it works than how do I get a player ID that persists and make sure its secure ( I have tried playfab but it doesn't really work out for me since I cant make the server authenthicate the players session ticket and get his ID in a secure way)
PlayerStates are kept around for 300 seconds by default and are handed back to the player when rejoining
That does require a unique I'd, which online subsystems usually provide. e.g. steam
trough unique net id?
Yee
hmmm I see
so without a online subsystem it returns always random PC name and ID
but with steam it gives out a real id
I think so yeah
I have looked trough some forums to get more details on wht the unique net id with steam prints out and there is some debate on how and what it prints some ppl say to use the player id in game state others with unique net id some say that you cant print it. https://forums.unrealengine.com/t/how-to-get-player-steam-id/21709 idk what to do about it. I guess I will have to test out everything
Weβre making a multiplayer online game with a persistent world. Every player can create multiple characters and play with them, so we need to store players info to know who is who. As weβll be using SteamAPI for authorization and multiplayer servers, we would like to know how we can, from the server, obtain the player Steam ID. We cant find a...
Hey, I'm trying to set up hot-swappable controllers, such that you can use any controller you have connected to your pc to control your player.
I'm having some issues with setting my player controller id. As once I set my player to use a new controller id I can't control my player at all until I unplug and replug my controller. Any ideas what might be causing this?
I can confirm that the inputs from both controllers are being detected.
should i create player properties struct in player state or i should i handle separately by creating the On_Rep events ?
The I'd on the PlayerState, the one you can get in BPs is wrong
Years ago I did the same mistake
The Id itself is not accessible from BPs without exposing it from cpp
You can print it, it has a ToString method
But you also don't really need it. Just for rejoining you should be good with just blueprints
And the OverrideWith function of the PlayerState
(which is a bit confusing, as it calls on the old PlayerState, passing in the new one from the rejoin)
Than what do I use as an ID?
I usually have single properties
You need to utilize an online subsystem
wdym by single property ? struct ?
No each being their own
why not struct and single on_rep ?
More control
So you want one OnRep firing for all of them? Potentially calling lots of code to figure out which param even changed to then react to it? Sounds mad
Unless it's always the same code that should run I would go with multiple props
The only thing I used structs for in the past In regards to player data is customization settings
But that kinda counts as one property anyway.
what if i create type and share only type
which ll be one byte only
for each property
but if I use the steam subsystem how do I get a stable ID for the server to use? unique net ID?
Why does the server need a stable id
yeah actually i create separate and its not looking , same code looks to me thats y I want to get advise on that
The clients all have their id set through the subsystem code
if there is another better way to do it with minimum code
Minimum code is not always the desired way if it limits functionality
What properties are we talking about
And why do they all need OnReps?
yeah you are right that's y i am here may someone can suggest if there is which i am not thinking of
For that we would probably need to know exactly what properties you are talking about
like player shoes , socks , jersey , helmet name etc
That's customization data. That as a bunch i store in a struct
But things like Kills, Score, Assists, Deaths, etc I keep separate
By hand or you just refresh completely
Struct because it's very likely that you move this data around
And then it's easier as a struct
actually its looking good to me because there already a struct buy for sharing i am doing each property saperate
PlayerState to PlayerCharacter. PlayerState to PlayerState etc
than how do I get that ID? and what is it steam64,something else?
okay great
I'm not sure why you need the Id tbh
You get it from the PlayerState through c++
any documentation on that?
one think more if yo have any suggestion how should i get which property is changed ?
Hm not sure maybe by hand comparing them. It can always be that multiple properties changed
On what? Me asking why you need the id?
okay if create a delegate kink of onpropertiy chnage let say
i change each property which is updated ?
it make sense ?
Yeah I guess
I would suggest you make your system work and then worry about this
Cuase you are overoptimizing stuff atm
I would start with refreshing everything even if not changed
its for me ?
well for my project when a player leaves all its data are stored on a pawn that mimics the player "sleeping" and I want an ID so that the server knows when the player joins the server what sleeping pawn he is assigned to so it can get his data.
Right well this is actually a shitty setup to be fair
The data should be on the PlayerState
Including a pointer to the sleeping character
UE4 already has the code to re-give the PlayerState, so you would have all data
And you can reposses the character
ok than so the overridewith function restores the player state no matter what right?
Yeah it gives you the option to move some data. You will need to toy around with that a bit cause epic made it a bit confusing.
When the player rejoins they get a new one and then it finds the old one. And then calls OverrideWith on the old one passing in the new one. But I think it also reassigns the old one so I never understood why I would want to override anything there if it gives the correct state anyway
Maybe mistaken. @chrome bay ranted about this the other day too
Your GameMode should define the inactive PlayerState lifetime.
Not sure if your dedicated server is supposed to have those sleeping characters even after a restart cause that needs saving of all the data outside the server process
SaveGame or Database
Yep. Silly implementation. I went all the way back to 4.0 and its the same there though, so it must have always been like this. Waiting from feedback from epic.
Figured
There's only one reason I can see for it, which is it makes it easier to restore other references to the PS
But the function naming is mental
Either way if you still need/want the id to do things manually, you can store it and compare it as a variable type and I think also as as string
But requires c++ to access it in the first place
Not much c++ but some
FunctionLibrary with one function in it for example
I really hope there is some documentation on the internet about this
Yeah some person somewhere most certainly posted a code snippet about it
But as always, Multiplayer in UE4 more or less requires c++
If you aren't willing to use/learn it you will have a hard or even horrible time
Take a look at the ShooterGame sample. What you usually do is simply play the "effects" for firing locally when sending the RPC, so that it feels instantaneous.
E.g, firing anim, muzzle flash, sound, apply recoil etc.
99.99% of the time, the shot will succeed server-side, so those 0.01% of times when it doesn't the player never notices anyway.
You can predict ammo client-side too, just requires some careful implementation. Generally though stuff like this that requires instant feedback you should try to predict client-side.
GAS makes it easier, worth looking at the GAS Shooter template too as a more modern way of doing it.
Not yet seen that tried at scale though
GAS Shooter template? Is that the RPG project or a new one?
It's a popular sample created by a community member:
https://github.com/tranek/GASShooter
Thanks I'll check it out
i am making a spectating system, i made it so it activates when there is more then 10 players, but i dont know how to connect so it attaches the player bp of the first 10 players and loops thru them if pressing space. I only sofar managed to make it attach to the player itself who was joining and being 11th player.
@twin juniper in the GameState there is an array called PlayerArray
You can use this to find the characters of all players on the client
Hello how can i hide other players when i click the keys? like when i click right mouse button, all actors containing a specific tag will not be seen by my camera
3 parts: 1. google how to do something on key press 2. google how to get all actors with tag 3. google how to hide object
Can I use single keyboard to control two players ?
If player-possessed pawn has multiple AI-controlled satellite pawns what would be simplest way of referencing owning player from satellite pawn?
scenario: satellite pawn kills other player / or other player pawns, need to get actual player for damage processing
what would be simpler and better
- setting owner of satellite pawn to playercontroller on spawn and using Getowner
- setting instigator of satellite pawn to player controller pawn on spawn (but there is a possibility that it may not be present)
- Add a reference to owning player controller to AIController of sattelite pawns
- something else?
You can
What? The satellite pawns need to reference their owner?
yeah, if satellite deals damage i need to provide reference to playercontroller they belong to
for various reasons
now debating between owner/instigator/custom replicated variable to do so
uh when the satellite is spawned by the actor plug in self as owner
then inside of the satellite blueprint you can call get owner node
that is pretty much what i did right now, thinking if it is fine
it will work reliably
i mean i would set the owner as the player controller that owns the actor
and set the instigator as the main pawn.
then run all damage stuff using GetInstigator..
Hi all, This should be an easy one for yas lol. I'm trying to replicate a simple action. When the player presses a key, they will spawn their weapon and switch their animation based off 'Combat State'. I have set the actor which attaches to the players hand to be replicated and it does show up, However the client is not updating their animations locally, but updated on the server. What am I missing? (New to Replication) Thanks
That multicast is redundant
And you are only changing the combat state on the server
You need an OnRep variable that you set there instead ( in your character ) and set the state on the animBP in the OnRep
Ahhh ok thank you
I know that the game mode doesn't replicate, but if I set a variable to repnotify on it, will it fire the OnRep function when it changes?
clients don't have gamemode so there is nothing to replicate them to
onreps called only on clients when value is received on client
My game mode keeps a list of all player controlled pawns, and I want my game state to have that information. When would be the best time to send that information to my game state? Each time a player joins/leaves in the onPostLogin and whatever the leave one is?
game state already has PlayerArray which is a list of PlayerStates of your players. you can get Pawns from it
I guess I would just do extra checking to see if the states have controlled pawns
@thin stratus So I kind of have it working, however when the (top left) client equips a weapon while out of render distance and then goes back to the (top right) client, The top right doesn't see the animation change. Only the weapon attached. Is that just the variable thats being repnotify i'm messing up?
@orchid violet I kinda handle this in a slightly different way. When player equips a weapon i replicate the pointer(reference) to that weapon. The anim blueprint checks to see if a weapon is equipped (in the players hands), and asks the weapon, hey what anim state (Melee, Ranged Rifle, Ranged Rocket Launcher, etc) then does the correct animation.
no need for anything else or setting things manually, anim blueprint should be able to handle that and adjust the animations without any external stuff.
you should never tell the anim bp to change states nor should the anim bp handle the states like that
it should pull what it needs from the player character.
also never spawn the weapon like that
weapon should be spawned SERVER only
and set to replicated
never spawned on the clients manually
flow would be this, Client presses key -> Server Spawn Weapon (Run on Server) -> Server spawns weapon actor (which is replicated) and attaches it -> Store reference to weapon in a variable (set to Replicated) -> AnimInstance checks if weapon is equipped and runs combat state.
instigator is pawn, and i have the case when player pawn may die and be pending kill while satellites still alive (for a period of time) and do damage.
for now rolling out with owner being playercontroller will see how it goes.
Ah ok, Thought I was just using F key for now so I could learn a bit more, Having a hard time with replication.
So this would be incorrect? It is ran though an on server node
Thats kind of what i'm doing though.. I should make the weapon itself repnotify and then use the animation based on that, got ya :
doesnt need to be repnotify
your anim bp should ASK the weapon
your weapon should hold what blend space to run
or w/e
anim instance just checks if weapon is equipped (via the weapon replicated property)
and then goes Weapon->GetBlendspaceRef
that is it
this also means your code is cleaner/easier to maintain
Ok, Appreciate all the help π
if you need more help or clarification you can ask π
I'd probably use an event dispatcher to update to the proper weapon blend space
ctrl + c
Hi all, im going through this multi-edit tutorial. Just wanted to verify, is this the best way to work on multi-editing if your both in a different country / on different internet?
https://cdn2.unrealengine.com/unreal-engine-remote-multi-user-editing-guide-404332864.pdf
Do I need to set a component to replicate if it exists within a blueprint actor that already replicates? I'm attempting to swap a mesh out at runtime and clients aren't seeing it, despite multicasting the mesh swap.
Yes and no
Your own components that have replicated variables and maybe rpcs would need to be set to replicate
Epics components like StaticMeshComponent, could be set to replicate, but that would only have an effect if it would also replicate the static mesh change
Which I think it doesn't
So you can keep it non replicated and instead add an OnRep staticmesh variable to your actor and handle setting the mesh in the OnRep function
It's strange because I basically did the same thing with a skeletal mesh and it replicates properly.
Are you saying here to use a var of type static mesh that I attach on construction of the actor that repnotifies and then update that at runtime? Instead of having the mesh component created in the hierarchy?
Worth noting that StaticMeshComponent already has an OnRep for it's StaticMesh pointer. So if it is set to replicate on a replicated actor and that value on the component is changed on the server, it should also update on clients.
hm ok, thanks
Yeah okay I always have the rep notifies in the actor cause epic is super inconsistent with that stuff
To be fair. I'd personally put it in the actor anyhow. Less networking with a property in the actor, and I'm also still sour that the OnRep for StaticMesh in the StaticMeshComponent is not virtual.
Maybe you can hijack whatever the onRep calls, if it calls anything virtual
I'm streaming in a level and when it finishes, streaming in another level, but I'm setting the second levels transform beforehand. This works for the host and most of the clients, but not all. Does anyone have an idea why it might be failing for one person?
Hi! one question about sessions.
I'm using firebase auth for login and than moving into a "server map"
i'm saving one unique tokenID that i get from Firebase to identify the players, i'm adding it to the GameInstance.
Is there any way to check if the same TokenId is already on any client connected so they can't log in twice?
Is there a built In component for things like this already? (player session)
@fluid summit probably better suited for #online-subsystems , but i'll answer here anyways. If you're authenticating through a non-engine based authentication system, ie one that has a online subsystem implementation like Steam, then you'll need to do some handling yourself. Personally I use a game instance subsystem to manage that stuff. Once I have an auth token from my authentication service, Cognito for me, I just set a bool as true and call a function named IsLoggedIn() which just returns that bool.
You could try moving the logic to a repnotify assuming it's the server telling the clients to load the level
Can anyone help me please? This deducts the health of the player shooting instead of the one being hit
Someone knows the console command to join again the editor server when you disconnected from it?
trying "open 127.0.0.1" but it doesn't work
I was doing it before but not sure its the right command
Try making a HUD widget and using it there
you mean instead of using a console command?
@balmy sable don't cross-post
That makes sense, do you mind sharing the name of the subsystem you are using? or is the one that comes with the AWS suite that cost 250$?
and yeah, i'm using VaRest to make requests to the firebase api, through there i can make a token for the logged user, but i'm not sure on where to save the token in order for it to be in a safe place
also, how to check that's not someone with the same token already logged in as a client (i.e.: the same client logging in twice)
Why update only when rendered causes dedicated server replication issue?
maybe because the server doesn't render anything, but i'm not sure
Yeah, it doesn't render anything - so no updates.
Usually considered wasteful to run animations on a dedicated server
just for testing purposes, i gave a random numbe between 0 and 1000000 to my clients when logging.
both clients got the number 7 the first time
So i'm not sure if what i'm looking for is exactly game sessions.
I'm running my game on a dedicated server and players interact in a mmorpg style (one big persistant world).
I'm trying to get a way to identify the users after they log in, in order to fetch their player data.
Currently i'm using the unique token id i get from my authentication service, i'm saving it on GameInstance for each client (this works ok)
Is there a better way to do it? The "sessions" that i see everyone else use, they are more oriented towards Game Rooms like a particular match in fortnite and it's not what i'm looking.
(currently i'm trying to find a way check if when a new user tries to log in, if there's another player with the same tokenId (the same player logging in twice)
How many players?
You can't have a dedicated server in UE4 with more than 100 or so players, it's not designed for it. Even 100 players is a butt-load of work.
wow really? didn't knew that
i'm looking for something like travian or art of conquest
i can expand with multiple servers horizontally, there's no problem in that i guess
A UE4 dedicated server is a single game "session", with some connected players. That server has it's own instance of the game running and players drop in and out.
Yeah natively you can't get that to work
If you want data persistence, you typically need a global data server that your dedicated servers then interact with, or the clients interact with directly.
Either way, not something you can do out of the box.
Either you replace the servers with something that can do what you need, or you wrap them with something
Both need a special solution
yeah
that makes sense, for data persistence i'm using mysql and for user authentication firebase auth sys.
Yeah that's all fine
what about knowing wich users are connected and identifying them?
Don't use Firestore :D good choice
That's what user accounts are for
And how the session stuff works in UE, at least.
They login, then you have an account ID - in UE that's known as FUniqueNetID
And that's the key to whatever backend online service you're using that identifies that player
i'm not sure this would work in my case.
If my user unique id on my login system is ("ASD123") and he logs in, if he tries to log in again while still logged in, how do i identify that ("ASD123") is already logged in?
the FUniqueNetId should be a diferent ID each time for the same player, right?
maybe i can just store the ids on an array on the server and check against that
and as they log out/log in, remove the ids.
No the ID is the same every time
It's the unique identifying ID
What you are talking about is a session
At least as a concept
why? D:
Cause it's expensive as fuck
oh firestore, yeah jajaj
i went for mysql exactly because of that, the price were madness
That and limitations
i'll probably change the user auth also, the prices don't make any sense. but the free plan is great for testing
so either i find a pluging that handles sessions on a dedicated serve or build the functionality for myself, there's nothing already setup on ue4?
also i need to find a way to "do things on the server side" when a user logs in (even if they just shut down the game) like saving data and things like that.
And you connect to that
UE4 isn't an MMO engine, ultimately
And that Server might have a Session
ANd you might be part of that Session
But that's it
So it's going to be an arse from the get-go
The proper way of doing an MMO with UE4 is to only use it as a 3D engine and to write the whole network part outside and integrate it via a plugin
At least that's my 2 cents
But the thing is
In all honesty
If you can't pull that off
Don't make a fucking mmo
π
Don't be one of the people that think they can pull it off
yeah i know, i'm just trying to build a prototype to learn the engnie and multiplayer functionality
Yeah that's the wrong genre then
i already reduce the scope of what i want to do a few times as i get to know what is posible
Make a 8 vs 8 shooter
Then you can embrace UE4
Make a second Unreal Tournament and you might have half the game already done when opening the Engine
(sad truth)
There is this outside system that makes large worlds with Ue4 possible
But $$$$$$$$$$$$
I can't recall the name
And I don't know if that is still alive
have you seen art of conquest or travian? i think the main functionality can be done without the "mmorpg" aspect and only fetching to the database
SpatialOS was that thing
but i'm not sure if i can do something like that in a secure way without using a dedicated server.
was?
As in, was what I meant 10 seconds ago
oh right
I mean, okay, so something that doesn't actively need LIVE multiplayer
SpatialOS I think is about tying multiple UE dedicated servers together as one big one, and having players in different spaces IIRC
Can be achieved with UE4 and database stuff
Very niche solution to a very niche problem though
The 100 people limitation is 100 people playing live on a server aka Fortnite
Travian looks like you don't actively interact with a live player
yeah, the live multiplayer would be extremelly limited and can be removed if necesary. the general idea is to fake a persistant world through database.
That is something else, but that would also not be done with any ue4 network code
there's some live interaction, but can be completelly removed.
If you want to do that, then do it via some socketed database
Something that can give you live updates on the database with callbacks
okey, i'm gonna check what other functions do i have as a base on UE4 for players when joining/leaving a server and try to build custom functionality on top of that
Maybe instead of Mysql (I'm not good with databases) look into MongoDB
I know that can be sharded and has a socket connection to the currently "playing" user to get updates
If Mysql can do the same, then nvm
that's interesting, i'm gonna look into that
Yeah my fiancΓ©e created a mobile app with MongoDB (previously Firestore) and FirebaseAuth recently and dived a lot into this. That's why I know about the sharding etc., cause I had to listen to the evening "Bug talk" :D
That's also why I say that Firestore is expensive
And limited
jajaja nice
yeah, the main problem right now is how to know a player logged in and how to do stuffs when a player shuts down the game (wih could be solved by constantly updating the database whenever there's new info available, but that sounds extremelly net expensive, maybe mongoDB can come to the rescue there)
Assign players an ID when they register and use that as the unique identifier in game
The MongoDB Socket connection would help here yeah
Save it in database and load it every time a client logs in
Generally you could have a socket connection to the backend to know if they are online or not
Check if a player with that ID is in game every time someone tries to connect to avoid dual accounts
And to send data isntantly
You will need to save state in database, so for example online=true/false
When player logs in successfully, set it to true, and when they leave game set it to false
exactly this is what i'm looking for, if i can send all the data live, i don't have to worry to close the socket manually and i can let the player log out without a problem. The socket can be timmed out and that's it.
i tought about this idea, but the problem i have currently is, how do i let the server know that a player closed the game? if not, they will register the user as logged in, even when they left long ago.
Yeah i would just read a bit into database + socket + session etc.
It's an annoying entry into this shit
Cause it's always done in 20 different ways
There are built in nodes for that
things like internet connection problems or things like that, i would need to account for those things
And Stackoverflow hates new users
it has been fun so far, since the idea is to build the game to learn, i don't have any hurry
do you know their names? i have been looking for something like that i can only find sessions (as per fortnite session)
Let me try to find it, I use them in my game but don't have the code at hand atm
There are several events
There is one in controller, one in gamemode
Hello. I'm trying to access player state in begin play of pawn. But when clients join the game PS is null on server, but its correctly accessed on clients. And this happens only in standalone game, and not in PiE?
i think you are right, there's a "logged in" logout" node on player controller, i'm gonna check more into those
- When the Client receives the Character, it might already have the Replicated Properties set. So it's actually not a give that you get a Character on the Client with a valid PlayerState. You could be lucky here.
- When a Character is spawned, it is not possessed. The PlayerState comes from being possessed by a Controller. BeginPlay is thus too early. If you need the PlayerState, you need to use a function later down the chain.
@blazing cloak
Also check out the one in gamemode, It should be called logout and have controller as a parameter
I can't remember which one I use, but it's one of those two π
@blazing cloak Examples would be:
- PossessedBy (Server only)
- OnRep_PlayerState (Client only, C++ only)
From there you can pull player id and update the database to set online=false
yeah, i'm gonna look into that one and the one with MongoDB, thanks a lot for the help
Np
Hi, does someone know if when i log into an online session my game instance disappear or every client has it's own?
GameInstance is per game process and is not accessible to other processes
So each Client and the Server have their own
No networking and preferably not gameplay code in those
So, can i load player info from game instance instead of reading a save game file?
You could, but both ways would be loading it locally on the process's machine
If that's a Client SaveGame, then you still need to send it via a different, networked class
Can i load the info an send it to the server via RPC?
You can try
I know that in The Ascent we had to send it segmented
Cause too much data for one RPC
Yes
When the Log is telling you that the RPC is too big :D
Oh that's nice
Any reason you're not using event any damage?
you can
I saw this from a tutorial
I remade this and now it works
Hi, it's me again, if i replicate a component that i create in GameState, it replicates its variables?
If the component is replicated and owned by the game state, variables marked for replication will replicate
What is the node for a player leaving a game or disconnecting?
No, I just call the sdk functions directly via code. If you don't know c++ you'll probably need that plugin or w/e
Event triggers when a player logs out so you can run some post-logout logic, while the Logout node logs out a controller that you pass in
Ah understandable. How could one handle someone leaving or disconnecting for instance?
Additionally, I thought that the OnLogout event would output a controller but it doesn't. Is there a way to get the controller?
actually, would this be correct?
Not sure what is the context but there is already player array in the gameState that is filled by the engine
I'm making a duel where a player hosts and waits for an opponent.
If nobody is there, he can play against AI.
If someone else is there, he can play against them.
If the opponent logs out or disconnects, I want the AI to take over.
Good point with the game state
I'm also labeling players to announce the winner
Gamestate is definitely what you want to use. It holds the array of player states. If you need access to the controller, you can just use:
PlayerState->GetOwner();, which would be the controller that owns the player state.
i'm not sure if BP has an equivalent
Then it should be fine as that array is only filled server-side AFAIK and it is exposed to BPs
player state is owned by the controller? I thought it was the game mode.
guess i will move my stuff to player state for MP mode
Player state is owned by AController. The server spawns one from the game mode.
It is replicated so clients also have access to the player array.
rock paper scissors online proves to be more challenging than what i thought π
Anyone managed to use their steam app id in PIE ?
@thin stratus i'm gonna end using mysql with VaRest and read all the userinfo when the clients logsin, and save it all when the players logouts.
If for some reason some other player requieres that player data, i'll check if it's online and update it in that moment.
that way i can save a lot of data transfer and i avoid using a live connection.
The mondoDB approach seems like a overkill for some prototype like this, but it looks quite interesting. i'll look later on how to implement a mondoDB and use KAFKA integrated with UE4 for a live connection and datastream
Sure. Wasn't sure if you have any things that need a live update
Steam does not work in PIE.
E.g. a friend invite being sent which would update a collection of invites, and thus needs to update the UI
Does anyone have a cheat sheet of interview questions to ask someone for a multiplayer engineering role?
that would be a question for #career-chat
void UCustomMovementComponent::OnMovementModeChanged(EMovementMode PreviousMovementMode, uint8 PreviousCustomMode)
{
Super::OnMovementModeChanged(PreviousMovementMode, PreviousCustomMode);
// Landings
if (MovementMode == MOVE_Walking && PreviousMovementMode == MOVE_Falling)
{
if (GetNetMode() == NM_DedicatedServer) // Sometimes gets called when jumping with output saying MovementMode = Waling and PreviousMode is equal to falling. How is that even possible?
{
GEngine->AddOnScreenDebugMessage(50, 1.f, FColor::Red, FString::Printf(TEXT("Previous: %s"), *UEnum::GetValueAsString(PreviousMovementMode)));
GEngine->AddOnScreenDebugMessage(51, 1.f, FColor::Red, FString::Printf(TEXT("Current: %s"), *UEnum::GetValueAsString(MovementMode)));
}
}
}```
Any ideas on the above? This code works 100% of the time on the client but 40% of the time or so the server seems to think that a jump is actually a landing. It makes no sense, how does the if even get triggered on the server.
*(I gotta go to the shop quickly, but I will just leave this here and check back in 10min)*
https://drive.google.com/file/d/1xfHjA-v72hCsCg5NZvg7Qdrgmn66cxTh/view?usp=sharing , https://drive.google.com/file/d/1GRBSSkTG8Dxl-cZMGZ3Kg-jh1vnau57-/view?usp=sharing ' in these videos like showen the equip montage plays in client view and if u go to the view of server client plays again. Please if anybody experienced this before help me I'was trying to find the reason so long I need your help codes are like this;
Anyone who has a pointer about the best way to handle gunshot hit location on the player mesh? I would like to implement a more detailed damage system depending on where the player or AI got hit.
you can use a physmat, and just check against that.
you would just need to set a physmat for each of the body parts you want to display.
Wouldnt that give me the same results as hit bone? Not sure if hit bone returns the location if hit is in the connected mesh to the hit bone
alright so this is a pickle of sorts.
I am playing rock paper scissors and set it up as multiplayer (local) for now.
So I got player A (auth) and player B (rem).
My MP functions work as such:
Widget button choice -> PC X -> GM -> PC Y -> Widget Y updates
And these are the base functions for the replication in the player controller:
and in the game mode, I use this:
In the current setup, ONLY Auth manages to get the data to Rem
But Rem fails completely
if adding print strings, the remote part doesn't fire at all
I'm wondering if i missed something simple
huh... turns out my get game mode and cast fails when assigning my player's choice on remote.
Does remote not see the game mode?
damn it eXi!
Alright i am out of ideas. So the client cannot see the game mode but the game mode can track the other players.
So i need to make the client talk to the server to get that data.
How??
Depends on what you're trying to achieve
hi everybody , i wonder .what is the difference between EOS and online subsystem ?
@rapid bronze i want data to be sent to only opponents not self. I need the player controllers but only server has game mode with that info.
There's PlayerState to share data between players, atleast access it
And it really depends on what type of data
Hm...
You cannot send data from one client directly to another regardless.
Ok so how about this
Log in
Server has access to game mode.
Client logs in.
Server asks game mode to update player profile
Game mode updates all game states
All player controllers access game state data?
Game state and player state are accessible everywhere.
Whatbthe heck is a player state!?
I suggest reading through the common classes section of the network compendium.
Hi, can a TArray of custom structs be replicated? If so, can it also be replicated using RepNotify?
So all I have to do is have UPROPERTY() for all struct properties I want replicated, then have UPROPERTY(ReplicatedUsing = "OnRep_List")? It should know when the array changes?
all members of a struct are implicitly replicated
if they're UPROPERTY
you can specify NotReplicated for stuff you do want to skip replication on but be UPROPERTY'd
I didn't know that. Thanks!
I didn't know either until someone mentioned it here the other week
i've found that FFastArraySerializer is far better at replicating arrays than normal Replicated TArrays
the comment in NetSerialization.h goes over why it's better and how to use it
highly recommended
I don't replicate TArrays anymore once I figured out FastArraySerializer
still, you can't replicate TMaps or TSets without custom netserializers
which i've done before, extremely not recommended tho
there is a reason Epic never wrote that code and you figure out pretty quick when trying to figure out how to replicate a map's keys
and sometimes replicating the key changes it's hash!
Whatβs with the tag
oh i meant it as a response
as roy awesome was talking about them and i just realized that he wasnt actually in the conversation
my bad
Been thinking about a project im working on. I just realized I have no reason to care about cheating (it's a 4 player co-op party game)
lol
Been over-designing everything to try and prevent cheating, but like
who tf cares
this is my first time learning a lot of this so making it more complicated than it needs to be isn't helping the learning process lol
On that note, there are a lot of videos talking about specific classes and nodes and some follow-along tutorials in the pinned messages. But does anyone know of any good sources for learning about the general design of multiplayer features. I'm at that point where I mostly "get" all the constituent parts, and can make simple standalone features replicate over a network, but am yet to make that final step to really "getting it"
may just need a bunch of practice, always of course.
kinda the shit at the whole planning it all out part, even aside from multiplayer.
I copied this lines of code exactly from UT's source code and PostNetReceiveLocationAndRotation() throws stack overflow error which is kinda irrelevant. Anyone implemented UT's method before got the same error too?
if (bMoveFakeToReplicatedPos)
{
AssignedFakeProjectile->GetReplicatedMovement_Mutable().Location = GetActorLocation();
AssignedFakeProjectile->GetReplicatedMovement_Mutable().Rotation = GetActorRotation();
AssignedFakeProjectile->PostNetReceiveLocationAndRotation();
}
Make sure that AssignedFakeProjectile isnt accidentally pointing to this?
Yeah it was pointing to this, interesting π€
Normally if this is equal to fakeprojectile it should never run that code
thanks!
thanks!
Is it possible to use bots (with simulated connections) to stress test a game's networking?
Idk if this is the appropriate channel, but is anyone here familiar with using aws sdk's inside of Unreal?
So what I dont understand about this is, that function (BeginProjectileSynch()) only runs in non-authority, so it should be called on fake projectile
I had some little differences with UT's version since instead of spawning projectiles, I'm using an object-pooled system so at the beginning I thought that stackoverflow issue is my mistake
But now after debugging I'm realizing its very accurate that I'm seeing an stackoverflow issue
Am I missing something or BeginProjectileSynch should be called on server?
On UTProjectile.cpp's beginplay its called if ROLE_Authority is false
Not sure, cant remember, its been a while since ive looked at UTs projectile net sync code lol
The FFastArraySerializer instructions says use MarkItemDirty for changed items and MarkArrayDirty for removed items. What about adding items? Is that automatic? If I call SetNum(3) on the array will it automatically replicate the added elements?
Adding is a change.
So I would have to call MarkArrayDirty or MarkItemDirty?
No, MarkItemDirty
Ok thanks!
/** This must be called if you add or change an item in the array */
void MarkItemDirty(FFastArraySerializerItem & Item)
{
/** This must be called if you just remove something from the array */
void MarkArrayDirty()
{
Always check the source if your not sure about something.
Source is gospel π
Do you know is there any alternative approaches for predicted projectile spawning?
Just asking for curiosity though, UT method is solid
Alternative to UT? Not sure, Id say they will all share similarities.
Predicting everything has major drawbacks which become apparent after you attempt to Predict everything.
Then you usually realize that its easier and more performant to simply trust the client more and do server side verification instead.
For the most part the result is the same.
Yes, I agree with you
less prone to lag issues that way too
Players generally care more about actions being immediately responsive.
Not so much that damage/health was updated/caused a few frames late etc.
I'm only using predicted spawning for my bullet projectiles since my project is very strict with projectile movement components
Kind of a bullet-hell game
there's a good GDC talk on how overwatch does it.
hey it's in the pins #multiplayer message
Hmm, I actually remember that, but I watched that on my very beginner days, I need to watch it again to understand
Thanks for reminding
I heard that OW grenades arent predicted at all, Players dont even notice that the grenade itself is spawned a few frames late because of lag, the only thing that matters is that the action of throwing the grenade is immediate.
So the Player has the feeling of responsiveness.
I dunno man, like i said, i heard.
Like flash bangs or something
like at all
ah ok
I dont play it lol
xD
It is pretty instant
however, a common problem is a no reg
where the server just says, nope you didn't actually do that.
happens with everything in the game
Yeah well thats the downside i guess.
yeah
Its a good choice for matchmaking games, since you can (for the most part) always ensure a player has the best connection to the server.
mmhmm
well, ish
OW complicates matters with SR in comp games
I've seen a lot of people play on 200+ ping
their shots are instant but there's a noticeable delay in confirming a kill.
Obviously you cant always ensure that, given whether you expose the choice for players to change regions etc
But by default your casual audience will be on servers they have a good connection to.
west coast and east coast
EU only has 1 iirc
oh yeah
Blizzard games in general separate out by regions from the get go.
Granted, you could bypass that if you were using flexmatch on gamelift or something
But that leads to some weird occasions too
if your scaling rules aren't set to keep up fast enough
I think "no reg" is better than being hit behind cover like what plagues BattleField games for example.
What is "no reg"?
that happens in almost every game
non registered hit
basically you clicked the head, but the server says you didn't
Yeah but its by far most notable in BF in my experience.
I havent played CoD since BlackOps
But i remember BF went full retard into hyper prediction lol
COD uses listen server model sometimes and you see a lot of errors with the projectile logic
Since connection is not always good
It blows up
latest CODMW was using it
ofc it is
I don't think the BR is though
a listen server couldn't handle all that madness
Ah.. Warzone is quite good about network architecture
I first noticed it in MW 2.
I never encountered the connection issues I've had with the other COD games there
I was clearly around a corner on my screen, wasn't in the kill cam.
They went P2P in MW2 from what i remember.
Could be wrong.
Pretty sure the "Host" was just designated for authority over the GameState.
Probably saved them a boatload of money though.
Yep
π€·
I looked into the costs of those once
running 20 servers per fleet instance on aws gamelift
and their average player count
was something like $30k a month to host on AWS lol
assuming 24/7 uptime of full load
they have their own servers
but yeah
like they have bare metals
which is def preferred
There is risk to both methods, especially for indies.
I really like old school browsers lol
so I have this issue in multiplayer where if a player leaves for the main menu, the server detects the disconnect but when I directly quit the app, it does not and the pawn stays there. Any way to work around this?
The Server should eventually determine that the connection was lost and remove the PlayerController.
Which in turn should remove the pawn.
@mossy kindle These screenshots are way way to small to even read.
Oh wait i'll resend it
Here is the dying logic
This is where dying is checked and called
And here the HUD reference is being set
But when the player respawns, it gives an error about removing the widget crosshair and the HUD
In short, I need a way to remove the HUD
it is not doing that sadly. I have a dedicated server which resets on all users quitting and the pawns stay when I reconnect.
I have a sphere collision that will print the name of the actor that overlaps it
But when the player on the Server touches it, both the Server and Client prints this, which is incorrect
CustomCharacter011 is nowhere near the sphere collision. Only CustomCharacter01 touched it.
Why is this?
maybe cuz the actors are assigned different names on each instance. Player data is stored on player state so maybe try printing data from there?
It's not incorrect. Collision events happen on every game. The Client print is for the Server Character overlapping with the sphere
Okay, here's a test..
I don't know how to differentiate between the two players, so instead I print out the player rotation
On the server, I walk towards the sphere collision from left to right
On the client, the player is facing straight
So it looks like the issue is like what @rough kestrel stated, that:
On Server: player1=CustomCharacter01 and player2=CustomCharacter011
On Server: player1=CustomCharacter011 and player2=CustomCharacter01
That's pretty confusing
Yeah, I noticed that overlaps are called on both server and client
that id why you never use actors name to refer to the player. Grab its player state which is replicated on server and client keeping the player data for the session.
Actors are adsigned random names on spawn. As for not wanting the overlap to work on client, you could do a switch has authority so it only works on server allowing you to do consistent multicasts
the name isn't random, it's procedural. It's basically the number that it was spawned. Until you destroy Actor_1, then the next actor that spawns will become Actor_1
Which variable from player state is best used to differentiate between players?
Can u declare a delegate in structs or only classes?
you could declare custom variables in player state which are assigned by the game mode. Set the variable replication to repnotify.
You can get the reference of player state from any pawn if it has one.
Check out this video to understand the networking classes first.
What I did was assign an int id via game mode on the pawn itself (pretty sure that was a bad approach tho)
Hello guys, in this video I will explain the GameMode Class, GameState Class, PlayerState Class, and Player Controller Class within Unreal Engine 4. I will explain the practical uses of these classes and how you can implement them in your multiplayer game. To move forward, you must understand what role each of these classes play in your multipla...
To identify the player uniquely your only proper way is to use the UniqueNetId which is only accessible via C++
oh? why only that approch tho π€
@rough kestrel The general reason for that is because often players need to be distinguished via their Subsystem account. For instance your EpicGames account in EOS games, or SteamID in SteamGames.
How can i destroy the gun actor?
When player dies it leaves the gun hanging in the air and respawns with a new one
It is being spawned and attached on begin play
when player dies call destroy on the gun actor?
Tried
Didnt work
For the server it destroyed the gun but for clients the gun was still there
is the gun actor replicated? make sure Replicates is checked
I don't see a reason why it shouldn't work if you destroy the actor on death event from the server
show code how you doing it
Ok
Most often the cause of that is because you're spawning the gun on all machines and it just looks like there's only one.