#multiplayer
1 messages · Page 723 of 1
How likely is it you server is running at more than 100Hz anyway?
Isn't the default 100 for everything?
Rather than increase net update frequency, keep it where it is and just call ForceNetUpdate() when you change replicated properties
Increasing the base frequency is generally quite wasteful
that's a really great advice, btw James, I wanted to ask you, because maybe you've dug into this
an Actor with a netupdatefrequency of 0 doesn't send properties when become relevant to it
do you agree with the current behaviour?
@chrome bay
Yeah sadly NetFreq of zero just seems to break all networking
Has to be at least 1
Everything other than pawns/vehicles in HLL is at 1.0 though
Since it's about as close as we can get to a true push model
that's what I feared, but I was thinking that maybe this could be changed
as the only gotcha that seems to be concerning is connections becoming relevant
I think still the case in UE5 latest sadly
Hi everyone, I have a small issue with owner only replication. I spawn an actor on the server and set the owner to the player controller on the server. However, attributes marked "COND_OwnerOnly" aren't replicated to the client (confirmed by switching it to unconditional replication and it works). Am I not setting the owner correctly? Does it need to be the player state perhaps?
it is
actually when a new connection joins the game
actors send properties
even those with a net update of 0
so a later joiner will indeed force properties of actors to be sent to connections relevant between themselves
even if the incoming connection to the game is not relevant to said actor
Yeah, likely an annoying bug in the engine somewhere
that's the word I wanted to hear, bug.
But, it's been around since at least UE4.0 - so a fix, I would not expect 😄
been thinking about this for a while now, but i haven't calified it as a bug
thanks for the chit chat 😄
you still obsessing over it @pallid mesa ?
xD I want to fix it
if you find yourself wanting to fix every unreal landmine that can just be navigated around
you'll never get anything actually done
Should my controller be replicated?
no
😩
i know how it goes usually
I agree but I'm not sure how to do it in the GAS plug-in.
Thanks I'll take a look!
The default for the player state is 1
Ah good, makes sense
I would like to increase it to 30 I don't know
Is there a way to include local players in the Session Result -> Get Current Players? For example 2 clients in the game, but one of them has an additional local player (so there is 3 total, but get current players still shows 2)
I tested it and it works. I doubt though that it has to do something with the Owner taking time to replicate. Try adding a delay after setting owner and before setting the property
Hey, I ended up replicating the value in a different (and better, actually) way, but there wasn't an issue with delay, it just never replicated the value for some reason even a few minutes into gameplay. The idea was that players control a unit, and can set a target for that unit. I had an AActor* replicated value for the target, but despite setting the value on the server, it was always null on the client. Strange
I just replicate the value in the player controller now, so no more problems
Hey peeps,
Quick question (possibly a dumb one but lets see) in regards to multiplayer, do all players share the same game instance or does each player need its own game instance?
Game instance is created when the game starts, destroyed when the game exits, isn't replicated
It persists across levels and games
I'm referring to the GameInstance BP class by the way. Should have specified.
GameInstance exists on both server and clients though it's not synced. They share info through the server
OK. Is it possible for 1 player to send data through a BP class to another player? Say player 1 was running around the map but player 2 only had a HUD on their screen which they could transmit commands / instructions through? I know UMG doesn't allow network replication but could that data not be sent to say a BP Class of some kind which is then responsible for sending that data to player 1?
Players cannot talk together, but they can RPC their data through the server with the player controller as proxy
GameInstance does not have any net support, to be clear
Neither do/should widgets
Correct HUD is client only and relevant to the owning client. You could listen for changes from other players through PlayerState for example as it's AlwaysRelevant
By default PlayerController/PlayerState is the main spot where players can actually send data
Pawns too, when they're possessed, but impractical for non-pawn-related stuff.
So long story short, which class would be best for the 2nd player with the HUD to send data to that player 1 can see?
Depends where the data reside
A PlayerController Server RPC with a PlayerState parameter that does a Client call to that PlayerState's PlayerController on the server
Or a purely PlayerState RPC - yours-, calling the other on the server
But usually player specific data exist in PlayerState
Cool. Thank you for the help. I appreciate it 🙂
How can I make it so one button either creates a server if there's no players online, or joins any server with players in it?
With server you mean session and session questions should go to #online-subsystems . Check last pinned message there to get a better idea on how you create and find sessions
is there any way to switch to single precision floats in ue5?
In regards to dropped packets. How do people usually deal with the rarer cases? I have two cases now.
One is a UObject being replicated, and a GameplayTag never getting replicated.
Another is a full actor never reaching the client. This happens rarely.
I can repro it locally in PIE with some seriously bad packetloss and lag. About 600 latency on server and client and +35% packet loss. And even then it takes me ~20-60 restarts to catch the same state.
I'm wondering if this is Unreal just giving up eventually after multiple dropped packets? If yes, are there settings somewhere related to making this code more persistent? Some actors seem immune to this. Literally updating after up to two minutes. Some just seem to give up entirely.
I'm confused by the naming of this variable: bAllowJoinViaPresence
If I want to make session invite only and do not let players join from friend list, do I need to make this false?
I have been working on building an ability to host a server, which the widget gets created, i am unable to get the joining player to see the LAN server and join or even direct connect.
I am looking for anyone willing to sit out and chat with me about it... maybe see what i am missing
Hi
Anyone know what to do about multiplayer character collisions
Lets say there is half a second of latency, and I run into someone on my client machine, it does some weird jittering because I am actually running into someone server client side but not server side
Then there is the issue of running in front of someone, and actually running into someone but locally I am not so it does corrections
I haven't noticed these issues in games I played
Like Overwatch for example
@winged badger You're famous! 😅 https://vorixo.github.io/devtricks/network-managers/
😳 did you just ping THE Zlo?
Does anyone know how to "refresh" replicated data? When one client updates a replicated variable, it goes to the server, and then server sends out a multicast event to make sure all clients update their widgets. The problem is that if I don't add an attribrary delay to the multicast events, then other clients get the event call, but their variable has not been updated yet by the replication (so they run the event using the old data)
Even at delay of 0.2 clients sometimes have old data still. I'd like to force the client to update it's replicated data when it receives the event call....is it possible?
The simple answer is that you should never do this, but instead simply update the widget when the data actually replicates
Delays should never be used in multiplayer
You can either have a design where the widget pulls data on tick to constantly update, or use replication events
Both kinda best done in C++
I'd like to be able to do use RepNotify, but how I can get RepNotify to work for another clients PlayerState? (so when any client changes a certain replicated variable in their PlayerState all clients will do some function)
can't
For example clients all have Name variable in their PlayerState, and then all clients have a widget showing the name of all the players. Each client will loop the Player Array in the GameState, then pull the "Name" from the PlayerState for each client. When any player updates their name variable, how can I update all clients, but only after they have received the new data?
Well you can but it needs some kind of broadcast - when it changes, any player state should notify all widgets
The simplest design is simply to always update, on tick - preferably in C++
Won't looping all PlayerStates on tick be very poor performance wise?
Do OnReps not work in PlayerState? I know playerstate is weird in some respects.
It does, but for only for each players own PlayerState; so a client gets the RepNotify if it's own replicated variables gets updated
But not if some other clients PlayerState variable gets updated
i have changed animation asset in my character, which is replicated to other players, who are in game.
but if someone is joining that game later, this change of animation is not set and original.
how would i do that ?
Show how you're doing what you're doing
Whatever is driving the choice of animation should be a replicated variable. Whether it's some state var, or a direct montage reference.
i made a component, that should switch between a sit mode animation for sitting and standing
Show your actual code that shows what variable is actually replicated
since here, i don't know what to replicate...
that component just switches:
void UCharacterAnimationComponent::SetAnimationMode(EAnimationMode::Type AnimationMode, USkeletalMeshComponent* MeshComponent)
{
LOG(LogCharacterAnimation, "Set AnimNode Start")
if (MeshComponent != nullptr)
{
MeshComponent->SetAnimationMode(AnimationMode);
switch (AnimationMode)
{
case EAnimationMode::AnimationBlueprint:
if (AnimInstance != nullptr)
{
LOG(LogCharacterAnimation, "Set Anim Blueprint")
MeshComponent->AnimClass = AnimInstance;
MeshComponent->SetRelativeLocation(AnimInstanceLocation);
}
else
{
LOG(LogCharacterAnimation, "AnimInstance was null")
}
break;
case EAnimationMode::AnimationSingleNode:
if (SitAnimation != nullptr)
{
LOG(LogCharacterAnimation, "Set Sit Animation")
GetOwner()->SetActorRelativeLocation(FVector(0.f, 0.f, 92.f));
MeshComponent->SetAnimation(SitAnimation);
MeshComponent->SetRelativeLocation(SitLocation);
}
else
{
LOG(LogCharacterAnimation, "Sit Animation was null")
}
break;
case EAnimationMode::AnimationCustomMode:
break;
default:
break;
}
}
else
{
LOG(LogCharacterAnimation, "MeshComponent was null")
}
}
so they sit
Are you replicating the chosen asset as a replicated variable or by a broadcast RPC?
NetMulticast
yeah that's your problem
the late joiner wasn't around for the multicast
don't do that
set a replicated variable
If it's STATE, use a replicated variable.
If it's TRANSIENT, multicast
okay, i understand that, also the problem.
so i would set a variable in my component, which is replicated, like a bool bIsSitting, and then ?
don't get it bound to the animation - also in my head
ahh.
i try ! 😉
To create the equivalent to the blueprint variable replication RepNotify in cpp declare the variable with this metadata specifier (In this example the called function is OnRep_PlayerMaterialUpdated): UPROPERTY(ReplicatedUsing = OnRep_PlayerMaterialUpdated) class UMaterial* PlayerMaterial; The function called must have UFUNCTION() specifier: UFU...
Just knowing they're sitting isn't enough.
The state might be AChairActor* ChairImSittingIn
null = not sitting
thank you. i try to change it.
I think I found my problem the Net Update Frequence on the PlayerState is really low by default (1 per second)
On a normal actor it's like 100 times per second. So i will increase this on levels that i need to have clients aware of other clients PlayerState
Is it even worth it to try to implement Dedicated and P2P together, each being used for their respective game modes? IE. Ranked played on Dedicated, Unranked/Casual using P2P. For clarification, our project uses the Gameplay Ability System.
Noob Q: Can I write my own multiplayer server to work with a UE game front end?
IE, can I do arbitrary networking in UE? What if it's a REST back end? What if it's a custom UDP protocol (I know that one has to be in a faq somewhere…)
You could, but the engine isn't going to help you much.
You have the ability to use literally any C++ code you want so you can implement networking however you want - there are some utilities for making HTTP calls or using raw sockets too but again, the engine isn't really going to provide much beyond that.
If I use an external networking lib, does it get blueprints bindings?
why and how should they ?
obviously you could make your own access classes
Nothing is obvious to me. I am at the stage of deciding what game engine to go with.
I want to write a game in, hypothetically, UE5 and blueprints, and separately develop one or more libraries in kotlin/native or C#. I've spent the last decade on java/kotlin and the jvm, so I imagine I could handle C# but I'm uncertain how I might shoot myself in the foot with C++
Well something should be obvious! Use UE5! 🙂
Is writing libs in C# something that people do? without undue anguish?
I believe there's a clr plugin somewhere. How good it is is another question...
@dark edge thx, that worked out
What are those libraries doing? Anything fancy?
Nope. Prob just some rest calls.
prob would block on synchronous tcp i/o (so they'd need to be off of the graphics thread)
gpu accelerated packet switching confirmed
hey i am dying to know what the answer is for this i am making my project multiplayer and i spent 1 whole day figuring out why the client was micro stuttering and i tried everything but i noticed when my friend hosted she had 200fps and my game was lagging like mad i couldn't move but when i hosted it was fine i had 90fps but i tested it out and if i host and cap the host fps near to what the client gets it is very smooth
profile it with insights
not sure how to use it but someone must know off the bat why it does it it can't just be me that has this
How the fuck would we know that? You have given us nothing. We know nothing about what your code looks like, but I'd start by at least showing us how your setup works. It smells like you're either getting bandwidth saturation at high tickrates or some of your mechanics break down at that framerate.
watch your fucking mouth and you have no need to look at how i set everything up it's a standard setup nothing more the code isn't the issue just because i set it up like everyone else does i replicated just the movement
we still can't see what's actually happening
we can't ever just take your word for it with stuff like this, we need real information
Is it characters, vehicles, Tetris blocks, what? We know nothing about what's moving and how.
development and for testing it in UE5 it's net mode is as client and set to standalone so i can connect using UI
well, that's good because you can insights trace that
you could just stat uobject or something to quickly see a rough overview but real profiling is generally nicer
this right?
hold on, you need to set some extra command args first
but yeah, run that
so, you probably want something like this for starters
ok i started the trace
-statnamedevents -trace=cpu,object,net,frame,bookmark,timing,counters,animation,physics,stats,counters
fastest way to get there is through here
thanks man
woops, object not objects
fixed
I also may be a little off because this is latest ue5-main
but those are mostly unchanged...
if you want a complete list of what's on try calling
Trace.status in the console
ok command is set
now try running in standalone and check the trace afterwards
keep in mind this trace file could get huge!
remember to launch Insights before running the standalone game
yeah i did try change it's location but for some reason there is not button in the open file dialog to set the file
yeah, afaik it's a commandline argument for the insights exe?
I think it's in the insights docs
shouldn't it of made a file?
Greetings, I hear that we must code Multiplayer first. But from what I've read so far of the Unreal Docs it seems like we are coding Multiplayer as we actually add gameplay features. How far am I supposed to go with Multiplayer when I haven't coded any of the game yet?
If I have no actors yet, why would I begin replicating?
We want to start with terrain generation btw, in our game.
But I was told to do multiplayer first, so I would make sure that the terrain is multiplayer compatible right? Coding multiplayer as I go, not before any features have even been added.
Thank you for reading.
the file will be listed in the insights window
That's a big enough problem to get handled in a multiplayer context. Get all machines to agree on what the terrain is.
it's good you are thinking about this now rather than later
Ok so I don't have to 'code multiplayer' if I have no game yet. I add a feature, make it multiplayer compatible then add another and so forth?
It's more about thinking about what should be on the server, what should be on THIS client etc
and trying to overhaul a singleplayer game to suddenly deliniate between those things out of the blue is hard
so yeah, you can add stuff as you go
Yeah, that is what the docs mentioned. The hard part would be making a whole singleplayer game and then combing back over.
But I can only picture this as 'Make a feature --> make sure it is multiplayer compatible ---> repeat for next feature"
Rather than some ambiguous premptive 'make the non-game multiplayer'
So I will make the terrain generation, then try to make that work in multiplayer with some actors controlled by players.
then rinse and repeat for next feature.
If that sounds good, then I thank you for the responses. It clarified much. If my approach is wrong then please I implore that you let me know.
yeah, kind of hard to draw the line between what is multiplayer exclusive and what is the feature itself
your method should work out fine?
try to test with multiple clients early and often to make sure nothing gets left behind
but if it makes life easier there's no shame in keeping it server only for a bit (just to make the logic simple to hash out I guess?)
that's my rough view on it
Make the game with multiplayer in mind and test in multiplayer from day 1
I think he's on the right path there
Don't wait until it's 80% done then go "Hmm let's start networking this thing"
Yeah, I understand that. But I can finish a small portion , like terrain gen and then make sure that piece is multiplayer. Then repeat for the next feature. Is what I am gathering from what you're both saying.
Just don't want to mess up.
I would like to add you should think about the scale of the game player-wise day 1 too
if you want 20 players running around, test with 20 instances when you can
I think I'll do that after we get terrain gen working. Thank you for all of the responses.
Terrain generation in multiplayer is going to be enough of a problem to keep you busy for a while.
It’s not an infinite world. Finite voxel world. But I’m sure it’ll still keep my busy.
Hey! I'm currently profiling using Unreal Insights our netcode since we have some issues: when a new round begins we recreate all actors (might not be the most optimal way, we can recycle them), on insights it show a peak of 4800 bits which IMO sounds okay for that, but ingame we have reports of players having replication issues (like theirs weapons appearing seconds later, because it is not replicated) and well I don't know if it justs come from this respawn or not..
Several seconds later? Do you know the max time length?
hi guys , which is the best tutorial for learning multilpayer via coding in unreal ?
Generally I would advise avoiding tutorials. eXi's compendium and the docs will get you pretty far. Source code, trial and error and general experimenting will get you pretty much anywhere else.
hello i have a quick question about replication in ue4, as i understand it Uobjects dont replicate. so i wanted to follow a tutorial on how you can get replication to work for Uobjects but i couldn't get it to work so as a work around i wanted to replicate structures with the variables that need to be replicated but structures BP also dont seem to replicate, anyone a idea of what i do wrong?
Here I set the structures variables on the server side
but on the client side the structure is empty. is this because only structures made with c++ that have the UPROPERTY() replicate?
the inventory component is set to replicate as wel as the player and playerController
2 to 5 seconds
we don't understand what's going on really haha, the only way i've redone it locally is with 500 replicated actors replicating a dumb float each tick ^^
we also rechecked 3x our ini settings, nothing worked out...
I meant to sent this
Structs absolutely do replicate
replicated structs in c++ replicate all UPROPERTY() members that don't have NotReplicated specifier
for replicating UObjects that are not Actors or ActorComponents you do need a bit of c++
you need to override and tell the ReplicateSubobjects() function in their Outer to actually replicate them
and the objects themselves need to return true from IsSupportedForNetworking()
you also need to setup something that will keep those UObjects alive, simplest most bare bones version being a UPROPERTY(Replicated) TArray<UMyObject*> MyReplicatedObjects;
as those objects will otherwise get destroyed on client because nothing is referencing them
bool ASolsticeGameState::ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags)
{
bool bWroteSomething = false;
for (UBotStatus* BotStatus : TeamBots)
{
if (BotStatus)
{
bWroteSomething |= Channel->ReplicateSubobject(BotStatus, *Bunch, *RepFlags);
}
}
for (UBotStatus* BotStatus : OtherBots)
{
if (BotStatus)
{
bWroteSomething |= Channel->ReplicateSubobject(BotStatus, *Bunch, *RepFlags);
}
}
bWroteSomething |= Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
return bWroteSomething;
}```
this is an example of a ReplicateSubobjects override i recommend you use, with Super at the end
because that makes the subobjects (in this case from 2 arrays of UBotStatus) replicate before the arrays that hold the pointers to them
which means when OnRep_TeamBots fires, all the pointers in it are already pointing to objects that have already replicated
Thanks for the help when I get home ik take a look at it, do you also have a good place to learn about these sub objects.
i think @chrome bay made a blog about them?
And one more thing as I understand it struts are also Uobjects?
they are not
the memory for structs is allocated inside the owning class, not separately on the heap
A oke
and you generally don't declare pointers to structs as members
while all UObject members are pointers
So in this case the struct is a part of the invertory component witch is a actor component so it is setup for replication
if you Actor is replicated, your ActorComponent is replicated and the struct is replicated
it will replicate
miss any one of those 3, and it won't
And to replicate the struct you need to tell it in c++
Or just set the the struct variable to replicated?
that will make it replicate, yes
but its... awkward
A thanks for al the help
Then I just need to figure out why it’s not replicating
Because I definitely checked al the replication boxes
if you try to replicate a pointer to a non replicated object
that won't work
no matter your setup
I think that is the issue that one of the variables in the struct is net setup for replication
Anyone know or can recommend a lag time for simulated lag? i am using Net PktLag=100 but i have seen people use from 75 - 500, what is a realistic number ?
Hi
Anyone know what to do about multiplayer character collisions
Lets say there is half a second of latency, and I run into someone on my client machine, it does some weird jittering because I am actually running into someone server client side but not server side
Then there is the issue of running in front of someone, and actually running into someone but locally I am not so it does corrections
I haven't noticed these issues in games I played
Like Overwatch for example
I use a higher value for testing bad cases
500 should be good for those bad cases
alright, and around 75 - 100 at default testing ? Does anything work at 500 for you ? or is it see what breaks
what is a easy way to implement voice chat?
i was following a tutorial and it doesnt work
Things do work for me
Everything works at 500
Its just delayed messages
I use client side prediction for everything
PktLag 100 means 500 ping
x2 so 200
(100 + 100) * 2
100 + 100 = 200
200 * 2 = 400
Why do you add 100
In any case, measure your actual ping to confirm since you also add the server frame time
So it depends on framerate, etc
yea i guess, impressive yours works at 2000 ping
When set, will cause calls to FlushNet to delay packets. Value is treated as millisecond lag.
This is Packet lag
Thanks
@bitter oriole where did you find the info that it * 4?
yea a source would be valued ;D
Set PktLag to 100, measure ping
See what you get
If it's 220 or so, guess I was wrong
I can't check now. Ill check later
ill try to check aswell, but ill have to figure out how first ;D
You can do a server rpc sending the time seconds up to the server then on that function do a client rpc sending it back
Then on the client rpc you can take the time seconds and minus the one sent back to you
And print that
That will be in seconds
Thanks i will try
Then you can times it by 1000 to get miliseconds iirc
Or you can just get the ping from player state
PktLag=100 results in a ping at around 50 - 55 for me. at 0 i get 1-3 ping. Maybe i did something wrong. I am using default listen server setup
Yeah, you did it wrong. Make sure to connect two Unreal instances, don't use PIE, and correctly measure ping (the one in playerstate needs a multiplication, IIRC)
pie lag simulation only applies on one side
need to enter it in both server and client console to have a proper 2 way lag simulation
"Need to enter it in both server and client console". Enter what ? i have edited the default.engine.ini file with PktLag=100 do i need it somewhere else ?
think that only applies to the server
but you can change it in runtime with console commands
Just put it ind efaultengine.ini and it'll work
ah, so i need a real dedicated setup to be able to test the 2 ways. ?
no
hello, where would you recommend to publish a mutiplayer game (don't want to own my own server)?
are the main options epic online services and steam?
Alright, at PktLag=100 i now get 200 - 230 ping. I have run PktLag=100 command at clients aswell. but the ping is still 200- 230. Should the result be 400 or do i just x2 to represent 2 way comminucation.
If you get 230 ping that means PktLag only applies to ongoing packets, while I thought it was applied twice
You should always trust the ping since it's a real measure
230 is already worse than 99% of clients will experience normally so you can work with that for a baseline
Setting PktLag=100 in defaultEngine.ini and in a player character with console command both result in 200 ping + they dont seem to add if used together. If PktLag=100 is called from a widget the ping is 100. So i think it gets applied twice. My reason is A character exist on both server and client, where a widget only exist on the client and the command is only applied once. Anyways thanks again for helping me. ;D
Measuring is always good
its the only way to know, for sure ;D
The actor spawned likely isn't replicated
Steam and EOS don't provide servers, they handle the friends lists and sessions etc
That’s not true, there’s a function called replicatesubobjects that you can override that’s like doreplifetime and it lets you replicate pointers
it doesn't let you replicate pointers, it lets you replicate objects
and my statement still stands
as i never said you can't replicate objects
Doreplifetime, subobjects/pointers are replicated through that function
Replicatesubobjects checks if the object the pointer is referencing has changed and if it did it updates it
ReplicateSubObjects doesn't replicate pointers, but it might be used to replicate the thing those pointers are referencing. There's a difference between replicating the object itself, vs replicated a pointer to it.
ReplicateSubObjects does the former
Can anyone help me understand replication? I'm looking at the pdf and all that
I have a function in the gamemode that if the playerstate has authority (is the server) then his own pawn mesh material gets changed to another color
And it does work (I see the material change from the listen server perspective) but on the client side the material didn't change
Like, all I want is to address the pawn owned by the server and ONLY that pawn, I don't want anything else
If another client/player is sharing the code but is not the server I want it to completely ignore it
but switch (has authority) just executes that code on all clients
Ok let's correct some concepts here. First things first, pawn isn't owned by the server as it's owned by the controller which is owned by the NetConnection i.e, the client.
What you should say, the pawn on the server, or the server-side pawn, as the pawn exists on both server and client.
Now moving on to SwitchHasAuthority, this macro doesn't always mean do this if server, do that if client. A client only actor will always has authority over the things he spawns for example.
What is likely happening in your case the way you described it, is that you are changing the color property (that what you ought to be doing, idk what you're doing exactly) on server but you're not replicating the property, so it's not reflected on clients.
thanks for answering, I feel like I'm still stuck behind one fundamental question
My setup is as follows - 2 players, one as listen server, one as client
is there ANY way to distinguish between the two? I want to run some code if and ONLY if the pawn's client is the server
because if you use listenserver the server itself gets a playerstate/playercontroller and all that jazz
but instead every single time I tried multiple things everything I do get executed four times, sometimes even twice for every client I have
like if I just do a switch has authority on the gamemode and if it has authority print "Hello" I get the server saying Hello twice and the client saying hello twice, even though there's only two clients
Yes. If you want to execute something on server side pawn inside the pawn class specifically, you do that using a SwitchHasAuthoirty i.e using ActorRoles(there's another way using NetModes).
You shouldn't need to do one there, as the GameMode exists only on server, so you don't get client prints
I do get client prints though, two of them for some reason
Want me to make a quick video?
Yes I don't mind
Nevermind I think I figured out what I wanted to show you
But still, I'm assuming that ListenServer is used for p2p multiplayer applications right?
You prolly meant something else, but what you described to me just doesn't exist. A print string of "Hello" should be seen twice, one time for each connection, as the GameMode exists only on server and each connection has a GameMode server-side.
Answering your second question, p2p doesn't exist in unreal but yes I get what you mean. It's for games that need to ability to host a session.
If I do a switch has authority on the gamemode bp and ask it to print "Hello" only if it has authority I get the expected result (Server:Hello) both on client and server view
Yes that's what you should be getting. "Client view" is a player/connection and he has the GameMode on his machine server-side
Also try to remove the SwitchHasAuthority and you still get the same result
Because as I said, the GameMode exists only on server, so why you need to switch 
Were I to do this on the pawn class instead (the pawn that both the server and client are using, an instance of it obviously) what should be the expected result?
Server:Hello and Client:Hello or just Server:Hello?
Without a SwitchHasAuthority you get both, Server: and Client:, With, you get only Server:
But why do I get it twice?
Because you have two machines/connections running
Ok we're getting to the issue
if I used Switch Has Authority why does the server run it twice? I'm expecting it to fire once since only one of them is the server
In other words, how do I make it so that it fires only once?
Don't get misled by the names here. One of them is listen server and other is client right, but that doesn't mean that the client player(player 2) doesn't have a server side pawn
Otherwise how can he talk to the server?
You mean the replicated pawn of the server?
So the two prints are one from the server itself and one from that pawn?
I changed the condition from "authority" to "remote" and now the client is printing it... twice?
Yes kind of. The server is the one who spawned the pawn, so he has knowledge of the pawn
You have two prints on each machine as there are two pawns on each machine
What's so hard about that?
And pawn exists on both server and client
What's hard is figuring out why they both seem to have authority
Like, let's reverse the question
Now GameMode prints once on each machine, because there is one GameMode on each machine
How would you go about having this string print ONCE, in this scenario?
I would check if the NetMode is ListenServer
It is
I'm not sure if that's viable in BP
There's a BP node called IsServer, but I'm not sure what that checks
I know, I was saying what I do to make that work the way you want
It's baffling how convoluted this is for such a simple task
And no, I assure you that for a beginner this is convoluted af
I work as a senior engineer in an ISP and deal with complex network on a daily basis, but this stuff is worse than that
It is, I know. Just take the time and reread my messages with a cup of coffee and you'll see how all this make sense
thank you for the reply. does it means that if I deploy a multiplayer game I need my own dedicated server?
@fathom aspen I think I'm slowly getting it, the "two pawns" thing
Although one question remains, from the server perspective since he is the one checking collisions etc. how would you go about having it so that only his own controlled pawn is allowed to collide with something else for example?
So if you add another client, does it print three times?
Either listen server, community dedicated servers, or your own. If you have to ask the question, only listen server or MAYBE a community hosted server is realistic for you. You're not going to be making a GAAS
If he has to ask perhaps he doesn't know yet?
I'm not sure I get what you mean. By server perspective you mean first player(listen server player)? Or you mean the server-side pawn no matter what player that is? because you seem to mix between the two.
You prolly wanted to ask how can I disable collisions on specific player, and for that you have SetCollisionEnabled function
That's at runtime ofc, you can do that in Class Defaults too(though that will do it for all)
Nah I found a "simpler" way, and finally what I was looking for
On the server side (has authority set to true) I check if the player colliding with that box has the same player state name as the server player state name (which I obtain from the gamestate class)
If it is true it means it is actually the server colliding with the box and therefore it runs the rpc and replicates the variables I need, if it's any other pawn/actor/whatever it doesn't do anything
Cool. Why do you run an RPC though if you're already on server?
rpc is probably not the right name
the variable "server name" is actually stored in the game state class (a custom one), in the actual box that checks the collision I cast the game state class and I retrieve that variable
I assume I don't need to replicate it because the gamestate exists both on client and server?
I'm not sure why you need that layer of GameState to have a ServerName. The PS Name is enough.
GameState exists on both right, but that doesn't make the variables replicated to clients by default. You need to do so if you need the clients to be aware of them, but in your case you're doing that server side, so it doesn't matter
At first I was getting the server display name, but now I just compare the playerstate names like you said
Yes I'm doing it in the server because it is the server that ultimately does all collisions and then replicates the result, why would I do it client side?
If I get that correctly, the server just receives the input from the client and does it's own checks and replicates the result
Where did I say you need to do it client side?
I didn't say you said it, I was wondering why would you even think about doing it client side
Since everything happens on the server anyways
I can't think of anything other than optimization
optmization?
Yep. Doing everything server side isn't something you would want to do always
Why most games do client side prediction?
I assume it depends on the scale of the game, and also the number of events happening, and what they are
Otherwise your server would drain out
On that note, is there any security risks in doing this sort of "who's the server check" by getting the server player state from the game state class?
Good luck with single player games 😛
Handling everything on server can be really stressful for the server even for a low amount of players
That's why the CMC already does that for you
Just by looking at how big it's you'll understand
what's cmc?
CharacterMovementComponent
also I have one last question - going back to the listen server thing, right now my configuration is similar to an old call of duty game for example, where one of the players in the server was also the host, correct?
And something else, like fortnite, actually has a "headless" dedicated server that only does calculations and doesn't actually render a world or playerstate for itself, right?
I don't think so, but as I said it shouldn't be done that way
(random game examples btw)
@fathom aspen how would you do it then? you got to have a reference to itself (the server)
Correct
You want that thing to execute only if you're the listen server player(the host) or any player really, but only the on the server?
Cuz I think you want the latter and you think that's done by the former
The collision checks are (by default) done on the server, so in order for me to have it so that only the pawn controlled by the listen server client gets the privilege of triggering that collision I just check on the collision event if the other actor is in fact the server's pawn
How do I check that? I get the server's player state from the game state class and I compare it to whatever pawn's player state has collided with my actor
If they match - server was the one colliding - execute code
if not, ignore it and move on
So long story short you want the only the host player(player 1) to trigger that collision and do things consequently?
yep
the server / listen server player / host / authority guy
the big boss 😛
and above I explained how I did it
Yes, you want some sort of info when the player hosts the game to tell that this dude(the host player) is really the host. You can have a bool property in the PlayerState though(GameState doesn't need to be involved at all) that tells that this is the host player.
In cpp it can be done using the NetMode, but that's not exposed to BP I guess
Gamestate holds a replicated array of all playerstates anyways, so what's the difference?
That's correct, it has info about all players(or more specifically the state of the game as the name suggests), not specific ones
PlayerState holds info about specific players
I swear I have seen once an event that is called whenever a player logs in
I can't find it anymore
It was in blueprints, something like event OnPostLogin or something
Oh it's the player controller nvm
That's in the GameMode
hmmm, I could do some tomfoolery with that
Correct, it takes the PC though!
That what fooled me there hmmm
onpostlogin, check if playerstate has authority - if so save it as the server name 😛
It gives you a PC.
but gamemode is server side only so it makes no sense
Yea right, I meant to say it's a param xD
Correct, that's why I meant you need a way like pressing a button to host to determine if that player is a host
I can't think of workarounds for BP at the top off my head
I'm trying to set that variable from the gamestate
Reason being I have a feeling that if it is the gamestate telling everyone who the server name is it might be less exploitable
Than the individual pawn / player state calculating it itself
Ok cool. How do you set the server name though for the host?
OnPostLogin? Same reasoning as before
What do you mean?
I mean how would you specify what player you assign the sever name to?
You have the server name defined in GameState
not in the game state
But how you assign the host's PlayerState the server name?
the playerstate casts the gamestate and gets the variable
Well in reality it's actually the pawn that casts the gamestate
and retrieves the server name variable
You meant to say get(and not cast) the GameState
But anyways I still don't understand how you specify the server name for the host
If you have a custom gamestate (child of GameState or GameStateBase) you need to cast it as your own type otherwise you wouldn't find the variable
Correct. That's casting. You cast things of the same type, i.e have inheritance relation
You can't cast a PS to GS. I know that 's not what you meant, but that can be understood that way
Technically they're all uobjects though 😛
Also nope, since the gamemode is only ran on the server if I use onpostlogin it returns true for both pawns
(has authority)
since it's the pawn instances on the server client
Correct
Ok what you can do actually to differentiate the host player from the other player, is OnPostLogin, check PlayerArray.Num if equals to 1, if yes, then that's the host, and through the PC you get the PS and specify through a property that it's the host.
Though that won't work in PIE, as they load at the same time
I guess
no they don't
Well it can work, I'm not sure
there's a delay
I know that the first index in the playerarray is always the server/host since he connects first but I can't help but feel that just doing that is
I'm not sure about that honestly...
yeah, smells unreliable from a mile away
Yep yep

@fathom aspen some c++ nerd gave me the answer lol
In the gamemode since it's server-side only use OnPostLogin and find the local player controller, which has to be the server pc
Works like a charm
Now good luck impersonating the server bozo
IsServer, IsLocallyControlled.
well there's multiple ways
long story short is that you want the local pc and code has to execute on the server
That doesn't say you're the host player though
It says you're the server side controller
it is a reference to the server though, and that's all I need for my checks
isn't host player == server in LIstenServer?
Here
Nope. That what I was trying to explain for you for the last two hours
Yes it is...?
A local player controller on the server by definition is the player hosting the game, splitscreen stuff notwithstanding.
semantic argument time
Yeah, this is just semantics.
I mean if you're in the game mode class and you have something that returns true on local pc, it has to be the server client
Read this so you understand what we're talking about
you can't check for authority on gamemode because every pawn would return true
Exactly
I was asking what player he wants to check collision for and he said the host player
I've been telling you for two hours that I'm using a listenserver configuration
which is always going to be a locally controlled pawn on the (listen) server
That's totally different than saying no matter what player that is, I want to do that on server
That's not new info to me
Also player 2 (not the host) can be included by checking this way
That doesn't matter...
It will get whatever players are locally controlled
which is what they asked for
It does, if what he's asking for is ONLY the host
Which player is "hosting" a game in a splitscreen configuration is up to the game to decide, there is no inherent host player in that config.
You could say they both are.
all I wanted to know is which playerstate/pc is actually the server's in a listen server configuration, from the gamemode
If this isn't a splitscreen config then by definition the only local player on a listen server is the host.
so that I can pass along that information downstream without clients calculating it themselves and risking exploits
unnecessary? yes. but whatever
Right, so IsLocallyControlled gives you that.
Exactly. We're not talking split screen right?
Even if we are, whether it matters or not depends on the game.
There is no inherent host player in splitscreen - it could be every local player, it could be a specific one as decided by the game itself. "Host" doesn't mean anything by itself.
Is it wrong to assume that the very first pawn that the gamemode spawns has to belong to the listenserver client?
It should but I've always disliked that assumption.
I can see why
honestly the player 0 thing is such a weird aspect of the gameplay API
people get fooled by it all the time
I don't think it's an intentional part of the API at all - it's just how things work out because of how the underlying system works.
But it's never been guaranteed to be the case.
Which is why I don't like relying on it.
I would argue it should at least strongly indicate it means local client players and not the like, players in the server
Would you say that declaring a variable with the server client info on the gamemode and passing it along downstream to the gamestate/playerstate etc. is safer than having each client retrieve it locally by themselves siliex?
I'm not sure I understand the context enough to give an answer.
In broader terms, I'm passing along some info to the clients from the server directly rather than have them retrieve it by their own means
The idea is that the clients cannot inject it or they'd have a harder time if the info is validated and comes from the authority (server)
IsLocallyControlled returns true if this is a client side pawn. That still doesn't differentiate the host from other players...
Doing the check ON the server tells you if it is the host or not.
This is being called from the gamemode. Which is guaranteed to be on the server. IsLocallyControlled, called on the server, will only return true for players being controlled on the server instance of the game.
What about dedicated servers?
I'm assuming that a dedicated server can only be coded in c++, right?
If you don't own an actor or pc you can't address it directly, without working inside the gamemode/gamestate
Okayy..so it doesn't really true only for client side pawns. Wow all this time I thought it was something to figure out it's something else 😁
I'm not sure what you mean.
Dedicated servers operate no differently from listen servers, they just don't have a local player (and have rendering + possibly other features disabled)
right but does that mean that the server assigns one client authority?
The server is the authority
or rather, from bp only I can only talk to the server (if dedicated) via gamemode and all other server/client shared classes right?
The server will be the only thing that has the gamemode
I can't do custom logic on a pawn if it is controlled by a server or not because there's no controller right?
yes I know
That makes no sense.
if it's not a listen server then the server has no rendering and no pc of its own, correct?
if so, I can't go inside a pawn class and specify some logic if that pawn is being controlled by the server client because a dedicated server has no player controller of its own and no rendering / whatever so it just acts as a headless server doesn't it?
You can. Because a server will still have AI controllers.
The server always has authority. It has nothing to do with whether it has local controllers or not.
But a dedicated server can't just have a player state and player controller and possess some pawn can't it?
because it's headless I assume
But why would that matter
How do you think other instances of the game work? It's no different between listen and dedicated servers from the perspective of remote clients.
Clients can do literally whatever they want with anything in the game. But the server decides whether to accept what the client wants to do, and whether to broadcast that information to everyone else.
Nothing about this depends on the server having a player controller.
That's just another player that happens to already be on the server and doesn't need to send an RPC to communicate with it.
so the difference between listenserver and dedicated server is that the latter doesn't have visual rendering?
because a listenserver even though it is a server and has authority is technically still a client it seems
it's not a client
it's a server
this is why you have authority checks and RPC "things you want to do" to the server when you're not authority.
a server that you can play with? on paper it sounds a lot client-like
it does remind me of like cod4/mw2 host player, but I'm not sure if that is correct
void DoThing()
{
if (!HasAuthority())
{
ServerDoThing();
}
// do something
}
void ServerDoThing()
{
DoThing();
}
conceptually
writing code like this means you shouldn't care whether something is a listen server or a dedicated server
if you're a client you'll send an RPC so the server does the same thing you're about to do
if you're already on the server then you just do the thing and don't have to worry about sending it anywhere
this whole thing is executed from where?
could be any pawn?
Anywhere
if the client player wants to do something on an actor it owns (such as a pawn), it calls DoThing()
if that player is a client, then it also tells the server that it wants to do something
if that player is on a listen server then it's already on the server and it just does that thing.
I've seen some c++ examples, you have to use macros though to tell that DoThing() is a server function right?
in this case only ServerDoThing() would be a server RPC
it doesn't matter if the player is a client or on a listen server, it would call DoThing(). Which calls ServerDoThing() if necessary.
Or it does for dedicated servers but not for listen servers
. Dedicated servers dude here 🙋🏻♂️
ok thanks siliex so bottom line listenserver is technically peer to peer and dedicated servers is a separate entity from the actual players right?
it's not peer to peer
peer to peer would be every client communicating with every other client
listen servers and dedicated servers are the same thing - single host, everyone connects to it. The only difference from a networking perspective is that someone is actively playing on the server instance itself with a listen server.
ok that makes sense
from a non-networking perspective: dedicated servers also disable a number of engine features but that's simply to lower the requirements necessary to run a server (and to improve performance). It's not relevant to how you write the game, except insofar as you want to turn some stuff off on the server because it doesn't affect gameplay.
dedicated server feels infinitely less confusing than listenserver though
because a listenserver is also a player in itself, feels like a weird hybrid
they should be exactly as confusing as each other
writing code in the way I posted above already handles both cases
thank you for all the help
I have on last question
how do you actually "fire up" a dedicated server outside of the editor? Like on a local server or something
Ideally you have a separate dedicated server build, but that requires a source build.
I know in the editor I can set it to netmode "Client" and it runs one in the background, but how do I actually host it somewhere maybe aws or my own hosting or something
You can use a normal build of the game as a dedicated server though
-server on the command line
would that break if you have macros for dedicated server only stuff?
Yeah, but it's incredibly rare to use those
most of the time you'd want to use the with_server_code macro or w/e its called
because that covers everything that can possibly run a server
listen, dedicated, game-running-as-dedicated
You can do it like this
That's how we test, got a laptop synced up through our version control and just get latest -> run bat file -> off to the races
You can do it on a linux server too but since you don't have the launcher version of the engine it's a bit more involved. But you can just fire it up just like launching the game, and don't have to do any building or cooking for quick testing.
If you're serious about doing a dedicated server project you'd want to have a dedicated linux box you can use for testing.
interesting, thanks
I have a big question though now - I just created a random actor with a sphere mesh that I just expand its size with a timer every 0.1 seconds - works flawlessly and both clients see and react to it
but... if I check the actor properties it is not replicated? the only thing enables is "net load on client"
so why does it work?
Begin play happens around the same time on both machines
You've got 2 actors on 2 machines both in sync because they began play at about the same time.
so they're not synced but they seem like it because they're running the same code?
Yup same code starting at about the same time. They're not in sync, but close enough
holy F***
Try make the timer delay random and see what happens
you're right
I just did
I need some coffee
okay I've tweaked stuff around and it syncs now @dark edge
one last question: I've set the actor to replicate but not its components, it still works though is that normal?
like the component I'm increasing in size syncs and also the text syncs using a repnotify but those component are not set to replicate, the actor that owns them does
and it works?
does anyone know how i would pass player data to a widget in the world clientside? ive been pretty stuck for days lol
player controller/proxy:
game logic:
where the player proxy event is being called in the widget
If the repnotify is what's driving the size then it'll be fine
You would need to replicate the actual components if you wanted their properties to be replicated, but you're driving their properties (the scale) by a replicated variable instead.
So the component is not getting replicated, but the variable the actor owns is and repnotify does all the magic? @dark edge
So if I change something about those components and the repnotify is not aware of it then it won't replicate I assume?
My game is progressing well but there is a big problem with players having high ping (cross region).
I want to make my game feel better for people with high ping, and currently it is borderline unplayable.
What is it called when you do stuff to make your game feel less bad for people with high ping? I assume there are some guides for this but I am not sure what to look for
Depends. Where is your game on the scale from Chess <-> Unreal Tournament?
How responsive does it have to be?
And how high of a ping are we talking?
Not sure what games you are aware of but like the level of Fall Guys, Crab Game, Gangbeasts etc. Funny party games basically.
and primarily UK to NA ping so between 120-160
So complicated movement and probably fairly responsive. It's gonna be hard.
The movement isn't too bad, but its stuff like moving platforms. I figure I could make moving platforms purely client side so it will feel perfect to play on, although there will be some desync (players floating on others screens etc)
Latency compensation with movement is an entire subject unto itself, hard as hell.
Am I wrong to assume that if you set the inital position of the platforms server side and then have clients move them independently you get a smoother experience?
Kinda like fake replication, what happened to me before with my non-replicated component lol
How long can you rely on them to perfectly line up?
If you have them start at the same time and their pattern is predictable then.. forever? Clueless
I assume you can do some fancy math to compensate for ping and start time
Sure, but ping varies over time, and you need to figure out what plays nice with your movement system.
Yeah that's fair. I am just using default UE movement component which is good enough for ping. Isn't perfect but its suitable for my use case.
I am mostly talking about stuff like traps/moving platforms. Like I have a pillar that spins to knock players over and I am unsure the proper way to make this feel good. I guess I would make it fully client side, including hitbox, and just have it start spinning at the same time on all clients
but there are times where it needs to be somewhat synced up. I cannot let it be purely client side because it would mess up gameplay
That's a big complicated question. It needs to be synced in some way.
Also I can't think of a single game that has decent intercontinental ping (say us to europe or us to asia)
Not even overwatch or lol
Civilization
I see, so what keywords should I look up for trying to find examples of this?
You probably want to study the CMC in and out.
@dark edge that's not the same as a fps/tps tho
Well yeah, exactly my point. Unless you're ok with ping-delay to see your inputs happen, then the server and clients will not agree 100% on what's going on. How to cover up that prediction/lag is an art form.
From the POV of the server, everyone is in the future on their own machine.
handling that is HARD, probably the hardest thing in multiplayer games.
Or have super lenient tolerances before the server corrects things. Which is what, for example, fall guys does.
Or you can do custom netcode like overwatch that has multiple tick rollbacks and predictions / time stretching tomfoolery
Yeah, hard.
Yeah, lag compensation is a topic I want to really get in depth with and learn in great detail. Personally I find it the most important aspect of a game - but that's partially biased because my friend group consists of people from all around the world.
I found a few resources by searching "lag compensation" so I will probably start with that and look at the CMC in depth. Thanks
Try my C++ Survival Game Course:
http://bit.ly/unrealsurvival
Discord:
https://discord.gg/meFRZfm
Business Email: contact@reubs.io
@dark edge can you check out my answer above?
this
Slightly off topic but if I wanted to make my own movement system for a multiplayer game would you recommend learning C++ first for it or is that something that can be done with BP?
BP feels limiting at times
Does anyone have experience handling multiple (up to 300) AI in a multiplayer setting? I need to think of ways to optimise, profiler says that pathfinding is very expensive as well as skeletal mesh component.
Struggling again with something simple
How do I send to the other clients that I have changed the material of a component?
I tried a multicast event and replicating the components but it doesn't work, changes only on the server
@twin juniper want to be a bit more specific?
Read last pinned message in this channel
I have a sphere that I want to set a different material and have it replicate to the clients (the change)
I first do a switch has authority and if it has authority change the material, the component is set to replicate and so is the actor
but I only see the change in the listen server client
fair, looks like its time to start learning basic C++
so... you only change said component on the authority
Yeah really. learncpp.com would be my pick
I can get it to work with an onrepnotify
but I have to save a variable every time and do the onrep thing
Is there no other way?
You should do it with a rep notify
why?
Did you read this?
If the player party is all on the client-side and the dedicated server knows nothing of it, then how do these bigger games keep track of player parties? Do they store something that gets sent to the server that then links their players together based off of shared client info?
That doesn't sound right. That sounds like it would be easily victim to hacking
I would never in a million years want to try do a multiplayer movement system in BP with prediction.
CMC is like 50k lines dude
you could make some naive approach WITHOUT prediction but it'd be pretty rough
Fair, the CMC is extremely bulky though with lots of options. My end game movement component would be just basic movement with jumping. I would still want to do it in C++ though I am guessing - especially if I want to do prediction and lag compensation
You will end up spending hundreds of hours on it and probably end up with some subset of what the CMC gives you. Just use the CMC unless you are doing something super out-there with your movement.
there was a marketplace thing for predicted cmc + blueprints wasnt there?
I think mmmm made it
What would you class as super out-there? Right next to multiplayer and networking my next biggest fascination with games is movement, and I really think that (personally) a game can be made or ruined by the movement alone.
I ideally want something that resembles old source or quake movement. I tried somewhat replicating it with the default CMC but I struggled. I then looked up what others have done and found people really struggled with it.
I figured to get something like this I would need to build my own CMC from scratch in C++, something I am not anywhere near skilled enough to tackle just yet - hence why I went with the default CMC for the time being.
I'm in a very similar situation as yourself. Don't really know c++ but I'm pretty solid with blueprints. My multiplayer game is using a custom movement component. This one to be exact but I've also customized it a further ---> https://github.com/ProjectBorealis/PBCharacterMovement
You might be interested in using it as a starter or at the very least as a reference. Also its worth mentioning that it isn't replicating well by default. I had to alter how the braking friction works and implement a custom movement mode and send via saved moves to reduce server error corrections. Still working on making it smoother though.
It was built for ue 4.25 so there were some other upgrades I had to do as well, just so it would run on 5.
Yeah I saw that when I was looking up source movement. Couldn't get it to work.
I tried using it when I was completely new to UE though, perhaps now I have a better understanding I will be able to get it working
want to see it in action?
Sure
come to Artist Alley voice chat and I'll stream my screen
on the server or the client?
^
at the very least I think there's "get pawn private" to go PS -> Pawn and then you can get the controller. Don't know if there's one for just the controller
idk tbh
if all else fails, dummy pawn that's invisible
that's a joke
I think there's a simpler way than this, but I know the Controller can reference the PlayerState on begin Play, and save itself onto the PlayerState as a variable
I believe that the playerstate exists before the controller, so you shouldn't have to worry about a race condition there
this worked for me on the PlayerState
I did a MP thing a while back and ran into every combination of "x exists before y so null" possible, it seems like
GetOwner no matter where u are
looks like it's returning an actor.
will that be the controller?
controllers are actors
Yes
Works. Wizard once again coming in clutch.
Hey guys, does PostLogin get called before, or after the PlayerController gets assigned a new default pawn?
before
you should probably be using HandleStartingNewPlayer in GameMode @
its called after PostLogin, and after HandleSeamlessTravelPlayer, covering both scenarios
its a BlueprintNativeEvent, and the _Implementation (or parent call from BP) is what spawns the default pawn
Thank you! For some reason i was told by others on the team that the HUD doesn't appear after connection to the server, and it doesn't make sense to me but I thought it wouldn't hurt to have a fallback to make sure it does.
the server sends a reliable RPC ClientSetHUD early on
as the GameMode defines the subclass of the HUD, client can't just read it on its own
Does BeginPlay get called in the client hud?
So I've read, yeah. Trying to understand why it might be the case
it does, its an Actor
note that when i say HUD i mean subclass of AHUD
aight so in my HUD, on BeginPlay theres a widget getting added to viewport. It appears on screen in standalone, but does not do so in the Client simulation. Any clue what that may be caused by? It's a bare level, so there's very few moving parts
Not asking you to diagnose my project blind, it just seems that if there's so few bits there, it may hopefully be a common issue
and what does the breakpoint say?
there are a couple of ways to break BeginPlay being called on clients at all, mostly with making errors overriding GameState functions
i do an oopsie
most common being missing Super in GetLifetimeReplicatedProps
yeah I just saw it. I implemented PlayFab GSDK using sample code from Microsoft and they missed the supers
@winged badger Massive thanks
saved me from tons of headache
or at least you would have if this was actually the problem
oh nooooo
lol I was so sure this was it, too
does anything else call BeginPlay on client?
there are several candidates
but ultimately it comes to OnRep_ReplicatedHasBegunPlay
in GameState
to Dispatch BeginPlay
but there are dozens of ways to break that
mismatch of GameMode and GameStateBase or vice versa
missing Supers or incorrect overrides in either GameMode or GameState
to completely silly ones, like turning GameState replication off
Well, I've yet to override any base functions in either GameMode or GameState, and now it seems its not running even in Standalone
this is so wild lol
by not running I mean BeginPlay not firing
Alright I'll figure it out and maybe ask more once I get specifics, consideirng how many things could've broken I doubt you can figure it out remotely
Thanks regardless, I really appreciate the details
How I can get know if Actor is off screen on server side ?
you can take a rough guess, as client does update its camera position on server regularly
GetPlayerViewPoint in the PlayerController returns the results
that point is also the center from which the player's relevancy calculations are done
I've messed with Unreal for 8 years and this is the first I've even heard of this property.
its a function
I'm guessing it just reaches into playercameramanager and gets info from there?
updated via ServerUpdateCamera
not sure, never had an interest to fully dig into it
General question for you smart folks: How do you generally handle player spawning in multiplayer? I'm currently using OnPostLogin in my GameMode bp to spawn their selected player character and then I manually call an INIT function to make sure all the initialization occurs even if the BeginPlay of the PlayerCharacter first too early etc. But it's not reliable. I get crashes that seem to be related to initialization.
use HandleStartingNewPlayer in GameMode
its _Implementation / Parent call in BP spawns the Pawn
either spawn it manually and init it, or call Super/Parent and then Init
@winged badger I've seen you mention a few times the order of the methods that get called. Can you tell me where the top of the stack is so I can traverse it myself? Not because I don't believe you, but because I want to build out a diagram for myself.
Thanks man. I'll start working on this. I totally forgot about HandleStartingNewPlayer. And thank you for dissecting the function call stack for me. That's super helpful.
you have Either Login->PostLogin in case of hard travel, then going to GenericPlayerInitialization, and then to HandleStartingNewPlayer
in case of seamless travel its client side ServerNotifyLoadedWorld into HandleSeamlessTravelPlayer (PC swap here), then GenericPlayerInitialization, then HandleStartingNewPlayer
the HandleStartingNewPlayer_Implementation calls RestartPlayer() which spawns the DefaultPawnForController by default
Oh, I meant like from the actual top. As in first loading into a map and then GameState replicating this.
this has nothing to do with BeginPlay
first easily usable hook is AGameMode::InitGameState()
but when players actually join the game, that is outside that flow
i hate naming of that graph
as that (UWorld) BeginPlay is not actually calling BeginPlay on the Actors
Yeah, seems like the GameState does
Depends on whether you're on a Client or Server.
GameStateBase handles both cases. But the flow is different.
There is also no StartMatch function in AGameModeBase it seems.
AGameModeBase::StartPlay() calls HandleBeginPlay on GameStateBase on Server.
The OnRep of the GameState's bReplicatedHasBegunPlay handles calling Beginplay in a Client.
Both do pretty much the same thing. Tell WorldSettings to call Beginplay on all actors currently existing. Then sets WorldSettings State to HasBegunPlay, which then just runs beginplay on all actors spawned in the world after that directly.
Er. I think the state exists in World, not WorldSettings. WorldSettings just sets it. But same idea.
only if ReadyToStartMatch() returns true
Oh. Yeah. Virtual StartPlay in GameMode.
So does anyone know the exact reason a server will start to tank when too many players are close to each other, but do fine when they are quite spread out? Never understood this.
The clearest example I could give is fortnite, the servers feel relatively fine when the game first starts as players are spread across the map. But if you've ever played in a scrim match where practically the entire lobby is in one spot at the end of the game. It feels like a glitchy laggy mess. I undnerstand the FPS lag comes from so many things needing to be drawn on screen
however it feels like the server is lagging hard when everyone is close
Most likely due to the update requirements of connections. A player near more static, lighter connections requires less server time. Each player next to each other, with player characters and other such that require more server updates cause more networking to all parties in range.
It's like the difference between a player standing next to a once replicated chest with an inventory component. Once replicated once, it's mostly done sans the very light replication checks. Player characters on the other hand require pitch replication at the least and it's sent every frame. Plus every other required visual and state replication. Much heavier than rarely changed actors, and those replications multiply with each person.
makes perfect sense, thank you
so I will need to find ways to make as much as possible replicate less
when too many players are closer
One example of scaling using just the pitch replication.
1 player = no replicated pitch as it's locally defined and not sent to non owning connections.
2 players = 2 server replications per tick.
5 players = 20 server replications per tick. (1 replication to each non owning client per character.)
wow that get's complicated fast
Guessing the best way to slow it down would be limiting the ticking rate of players further away from you after a certain limit is rendered on the screen?
and maybe players you don't see won't tick at all?
Replication Graph sort of helps with this. Server considers actors in front of a player more important for example. Might skip a couple of replications on an actor behind them. Epic had a small doc about it if I recall.
Sort of tiers important stuff by view. Players directly in what the server considers a players view get more updates than a person behind, or a person several thousand units away. So if every player gets in range and groups together to stare at each other, performance would still drop. But chances of that are much less.
so then the best thing we can do is try and reduce the tick rate of every actor, and all player animations when the server starts to throttle
🤔
Maybe. Animations shouldn't have much effect on a server unless it's a Listenserver. Even then it shouldn't be terrible. Dedicated have them disabled by default for instance.
right but it doesn't seem like there's a whole lot you can do to avoid this issue without players directly noticing the effects right?
so I am thinking the next best thing would be to try and make it feel less clunky
because FPS does become an issue aswell
remosloot — vandaag om 18:59
hello i am trying to make a UObject to replicate following this blog https://jambax.co.uk/replicating-uobjects/. but i get an unexpected output and cant find why its happening.
"`1>baseBaseItem.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void cdecl AbaseBaseItem::GetLifetimeReplicatedProps(class TArray<class FLifetimeProperty,class TSizedDefaultAllocator<32> > &)const " (?GetLifetimeReplicatedProps@AbaseBaseItem@@UEBAXAEAV?$TArray@VFLifetimeProperty@@V?$TSizedDefaultAllocator@$0CA@@@@@@Z)
1>baseBaseItem.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void cdecl AbaseBaseItem::GetLifetimeReplicatedProps(class TArray<class FLifetimeProperty,class TSizedDefaultAllocator<32> > &)const " (?GetLifetimeReplicatedProps@AbaseBaseItem@@UEBAXAEAV?$TArray@VFLifetimeProperty@@V?$TSizedDefaultAllocator@$0CA@@@@@@Z)
1>D:\GameDev\Unreal Projects\projects\MyFirstProject newtest\Binaries\Win64\UE4Editor-MyFirstProject-Win64-DebugGame.dll :
fatal error LNK1120: 1 unresolved externals
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(45,5): error MSB3073: The command "D:\Programs\UE_4.26\Engine\Build\BatchFiles\Build.bat MyFirstProjectEditor Win64 DebugGame -Project="D:\GameDev\Unreal Projects\projects\MyFirstProject newtest\MyFirstProjectnewTest.uproject" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "MyFirstProjectnewTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========`"
and i get this error if i try to put the "UPROPERTY(Replicated) UreplicatedUObject* testObject;" end it goes away after i comment out the UPROPERTY(Replicated).
i probelbly forgot somthing but i dont know what
You forgot to add GetLifetimeReplicatedProps() in AbaseBaseItem.cpp
dumb question incoming
when i play as a client, the player controller is spawned at the world origin and then it take some time before the pawn is spawned and possessed by the controller so i get this thing where the player is at world origin and then snap to the pawn when the process complete
So I have my server hosting a game with EOS and it shows up in the dev portal. My client is connecting to the server and finds the session, connects, and does clienttravel to the URL we get back. The EOS dev portal shows that 2 players are now connected but the client never loads into the map the server is on. What should I look at to try to figure out what's happening?
I thought the clienttravel was not working but I stepped through it and don't see anything being wrong
The map is a basic map that both client and server have already
output logs, from both server and client
There aren't any errors, it just never loads into the map
I'm just not sure where to start dissecting this issue. Things seem to be ok
I'm overriding OnRep_PlayerState on my custom Player Controller class. Any idea why it isn't printing any of the logs inside?
you do know what normal connection log looks like
server opens a map with ?listen, tells you its listaning on port, tells you what net driver its using...
client does a browse (url), tells you when it loaded the map
at this point you should have a handshake between the two
if there are no errors, find the bit thats missing, then figure out why
you might had broken the replication on the PC, by not calling super on GetLifetimeReplicatedProps
you obviously need a client to test this, c++ OnReps don't happen server side
I actually don't know what a typical connection looks like, but thanks
Hah, I had forgotten about this - But what about a listen server?
listen server player is on listen server - no onreps
Hey yall, looking for some help with pausing in multiplayer games - having trouble getting pause to happen on clients - I am sending a multicast pause event but it does not seem to be working
any tips would be appreciated
When building dedicated servers, is there something special you need to do to get plugins with third party libraries to work?
From what I've read on the forums, this is because pausing the game on the server prevents the RPCs from going out correctly.
Your options are:
- Use SetGlobalTimeDilation 0.00001 instead, effectively pausing the game but not preventing the RPCs from going out. If you left a game with time dialation like this for 1000 seconds (~16 minutes) only 10ms of game time would pass.
- Use a means of confirming all clients have paused on their end before pausing the server. This involves RPCing to each client individually and them responding back before setting their own game to paused.
- Potentially, just use a delay on the Multicast that checks if it's the server and if so, delay pausing for a few hundred ms so the RPCs go out before setting the pause.
thank you much I will give it a go
Hey guys, I've got a multiplayer setup in unreal using Steam advanced sessions, and when using seamless travel and it appears that the Event Handle Starting New Player isn't being called consistently.
As far as I can tell, when I'm testing using my laptop and pc logged into 2 separate accounts, and either of those are the host, Handle Starting New Player is called properly every time for both players. But when a friend is a host and 3 of us connect it doesn't seem to be being called in his logs (unless one of my systems is the host). I've checked that he's on the same build as me, and added a print string as the first thing called by the event... Does anyone know how that event is triggered or have any ideas about what might be causing this issue?
Is there a simple way to use PawnSensing on connected clients? It appears that it only works on the server. I could use RPCs but it might get expensive since I am calling it frequently. Has anyone dealt with this before?
is there a way to send a lot of network data asynchronously from client to server?
im making a multiplayer game where the client sends its save data to the server
idk if i should just use a client -> server RPC or something else
There is no other way to send data from client to server but to use RPCs
and the old http thang
kk thanks!
What's that? 
If you're on UE5, you could implement Lorash's coroutine plugin - https://github.com/landelare/ue5coro - and do it that way lol
Make a subsystem to for it and use Aquanox's subsystem browser plugin - https://github.com/aquanox/SubsystemBrowserPlugin - for, browsing reasons i guess?
upload your 1GB + stuff to an external http host, rpc your server to tell it hey I uploaded some shit externally, then the server knows to grab the payload or "user data" if the user isn't a dbag) @fathom aspen
doing it that way at least you don't bomb your server while its transmitting (not that you should be taking arbitrary data from a user anyway. That's like taking candy from a stranger)
Sorry to bother yall I am seeking help with a multiplayer skin selector in the FPS template. It works in a testing map and game mode but when I launch from the main lobby the client copies the same color the server selected. I am not the greatest at multiplayer replication and could use the help. I think the issue might be in the gamemode but I am unsure where to even start lol
Just have some data on your external host to act as a flag for when data's been uploaded and have the server just constantly query that data
no rpc here
Haha that's a nasty workaround
Where's this color data stored? Stored in the game mode, game state, controllers, etc?
its in a enum
that doesn't tell me where you're storing it
That doesn't answer in what class that enum resides though, and still if we knew in what class we need more info, as no one here can tell how your setup looks
If it's in the game mode, game mode is server only. Doesn't exist on clients.
Sorry its stored in the game instance
The code is in a bp actor called Assault Class A which was in the template
are you storing replicated variables inside of game instance?
GameInstance isn't replicated, so your setup isn't behaving the way you think
Such property should be stored in PlayerState
Oh ok interesting
Also don't replicate materials when you can replicate boolean variables that trigger that action
That's a smart way to save yourself some bandwith
One issue with that tho is FPS template does not have a player state and it semi worked in the test map with a gamemode with just the pawn but wont work with the actual gamemode like conquest or whatever like I am completely stumped and I lack the know how to really follow along so I apologize lol
If one doesn't exist then create one and configure your GameMode to use it. Don't rush things because they work!
My advice would be to take the time and read the compendium as it goes over much of what I said here(you can find it in this channel pinned messages)
Storing such variable in GameInstance is discouraged before it even works or not
{sockets intensifies}
is there a function for when a pawn is unpossessed on the client?
(un)possession happens on server, and so does the functions that get called in response. You would need so form of RPC/replicated properties to tell the client of the action
Well you already have OnRep_Owner, so you can have some way to check if an unpossesion really happened(OldController wasn't null)
So I fixed some things with my BP_BaseWeapon Actor, I got it actually replicated (I was kind of surprised to see that I had to do the Code in the PlayerCharacter and not the PlayerController)
Anyway, I have a struct which I replicate for Meshes and Animations. Now, is that too much bandwidth I send? I have a Data table where I store everything and there I have a dictionary where each name correlates to the animation/mesh.
The DT basically dictates the weapons looks, stats, etc.
Is there a more efficient way?
Also another question, where would I store the players current setup? (Like weapon loadouts) Would I use an external Server or could I use another Data table?
"Unpossess" is called client-side, but only on the client that was previously in possession.
what type of system does games like lets say Battlefield make the player able to change classes in the game like Recon, Engineer, Assault and Support. i know i can make something similar using GAS but not sure if thats the best way
well you can have a hud in which the player chooses the class in every spawn, which then gets propagated to the gamemode to spawn the appropriate pawn class
that's the TLDR essentially
these classes
if your classes are hardcoded and don't require any kind of customisation you just send a RPC with an integer or byte to the server
and employ it in the spawning
these classes are different player_bp?
for example, yes
you can use inheritance for that
that's the most straight forward way to do it
so based on the resolution of your enum/integer
you spawn A,B, C or D
can i message you privatly
In vr multi-player, I am not able to trigger on release/on click. Is there any solution for this?
For 3d widgets
guys do someone work with the
advanced session plugins ??
i have a problem and i don t know where it s came from
i fix it thanks
Can you elaborate on what you're trying to do?
Want the players to join and wait for host to start the game. Works in non vr, but in quest the button click is not triggering.
Do inputs work at all for VR? Is it just that specific widget that doesn't work or does nothing work? If that does work have you tried printing some messages to see where the execution stops (or ran it through a debugger)?
Hey all, was wondering if anyone had any experience with steam multiplayer that may be able to help me out?? Basically, after following tutorials and installing plugins, I’m able to get the steam overlay on a standalone game and I’m signed in to steam. However, when I attempt to Host a session, it fails. I can host a session when I attempt this on a PIE simulation, it successfully goes through and loads the lobby level
Unless I’m in the wrong place, lol just realizing the online subsystems channel may be a better fit.
I've been doing some more testing on this and it seems from looking at the logs that when my friend is the host HandleSeamlessTravelPlayer isn't being called for clients, while it is whenever either of my machines are host. Does anyone have any ideas why this might be?
HI everyone, when I am reading "stat net" at the console, does the in/out rate in bytes refer to bytes per network tick, or bytes per second?
Obviously one is a lot more significant than the other 😛
My game has a weird bug where if I have two client windows running with the same character class and I hold ctrl to crouch then look around with the mouse, they both look around. This doesn't happen while not holding crouch.
Its as if holding crouch changes ownership but for the rotation only. Jumping and other abilities while crouching only works with the currently possessed pawn. This bug even happens with two different character classes using separate movement components (one custom, one default) too wtf?!?!
Does it do it if you map crouch to another button?
Ah ha! No it doesn't. Im using Input Action (crouch) for both, but when I changed one to use Keyboard B it doesn't happen anymore.
So what would be the cause then?
IDK maybe some helper that routes mouse to both screens if ctrl is down, or any of a million other things. Dunno if it's an Unreal thing or Windows or some utility you got or whatever.
Try changing crouch from using CTRL to using B. Changing nothing on your BPs, just the input setup
Trying to sort out if it's the control button doing it or the crouching state.
Oh weird, when I change input action crouch to use B, it works normally, but oddly enough pressing CTRL still has the same issue. It's as if there's something binding CTRL to crouch by default hidden within the character's movement component or something. As far as I know I'm not using any Input Keyboard CTRL anywhere within my blueprints.
does CTRL still crouch? Are you sure CTRL doesn't just route mouse to both screens?
CTRL does not crouch for either client, but it does sync the mouse rotation.
Yeah so check your PIE settings, might be something in there.
Also test if it does it with launched clients
Looked through all of PIE and Game settings, found nothing. Trying launched clients next
any uses of GetPlayerCharacter/Pawn/Controller[0] ?
any static members holding rotation?
How do you all keep track of who is in a party on the dedicated server side since dedicated servers don't use parties at all
Is it just an honor system and the clients just send RPCs, telling the server which other users are part of their party?
I'm not looking for code, just a high level concept solution would be fine
Game-specific party or Online Subsystem party?
If it's game specific, then a user NOT in a party can create one by inviting another user and them accepting.
I'm not sure what you mean by game specific. Do you mean by that a party that impacts game logic?
I mean is the party in the game only or some sort of outside thing like XBOX or Steam
I'm basically wanting to be able to invite my friends to my game and then they will be on the same team, which will drive a lot of game logic such as what quests are available and shared progress / etc.
I originally thought I'd be doing that with the online party subsystem, then I found out that the dedicated servers don't know anything of it. I'll be using EOS
Session Invites and Handling them is on OSS level
which I could in turn use on steam, but right now I just care about EOS only
Ah, there is such a thing as a session invite
Ok I'll have to look into that
I know there is session searching and you can search for sessions and pick one to connect to
is that different from what you are talking about?
Is it normal for all shaders to have to recompile whenever I launch in standalone mode?
Ah, IOnlineSession:FindFriendSession()
and IOnlineSession:SendSessionInviteToFriend()
I can't begin to debug because my machine basically freezes up with two standalone windows trying to compile all shaders again.
our ingame invite is pretty much a button to activate steam overlay/friends
then you can invite from there
Think I've narrowed down my inconsistent HandleStartingNewPlayer calls a bit further - it seems like the client is consistently sending the ServerNotifyLoadedWorld RPC, which I'm assuming that triggers the 'HandleSeamlessTravelPlayer' call - but that isn't being consistently triggered...
Does your game let people send invites at anytime? I'm not using lobbies. The dedicated server is hosting a long running world
Ok cool
