#multiplayer
1 messages Β· Page 5 of 1
There are multiple ways to tell. If it's a server RPC, you can see that the value is not being changed on other machines(not changed on server and thus not replicated to them). You can also check the NetMode
Just seems so weird...
i'd understand the client not being able to send to the server, but what's really baffling is that the server can't send to the client, either
It's in the wording... "Run on Owning Client"
If the client doesn't own the actor, you can't do a client RPC. All you can do from non-owned actors is replicate values and I believe multicast.
yeah, that's why i said i'd understand that
if that was all, i'd be able to fix it
but i'm really confused cuz the rpc invoked from server ain't working either
You said what is really baffing is that the server can't send to the client.... The reason the server can't is that the actor has no owning client.
okay, i probably misunderstood rpcs then
in that case, it's the opposite of what i was thinking
i've never done networking in games before
If you want a nice video: https://youtu.be/JOJP0CvpB8w
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
thanks
still cant find anything on this but trying to set the array size in the constructor. Setting array size in construct doesnt work, and in post init properties it still sends everything for each index. Where can I set it manually on client before properties are sent to client?
Do you mean if you have an array [0, 0, 0, 0, 0, 0, 0, 0] it should just send 8 * [0]?
yes basically
That's a very basic method of compression, maybe you can turn on some method of compression for certain replicated data but it might have significant performance impacts
Or do you know for a fact that all elements will be the same value?
But how would you even for a specific array? I was trying to solve it by trying the client to set it up before the server but I guess server will send the properties first unless it is set anyway.
which is what I was just trying to solve for now
Can I ask why this array has all the same values and how frequently it has to send this array? At the surface this problem seems like it isnt worth your time trying to solve
Since, as far as I know, the server by default will only replicate data when it sees it has changed value
Just once, it is because im using indexes as points to reference with dynamically sized array. Just want an initial starting point for the client from which object is created, in which server doesnt need to send everything and only the differences.
Hmmmm one solution is to turn off replication entirely and use RPCs
There may be quite a lot of issues with this approach but the main one I can see immediately is having inconsistent data
If there is a way to send an rpc before the server sends the properties to client but I dont think there is?
There is actually a Fast TArray Replication that only sends events to add or remove elements from an array as opposed to sending the entire array however it doesnt guarantee that the order of the lists is consistent between the client and server. Is consistent ordering necessary for you?
yeah I guess I will just find workaround and do it statically. Was trying to have be more dynamic.
TArrays are dynamic :D
I mean how they are populated. Server thinking array starting as empty for client = whole array being sent regardless? If I could use fast T array replicated to send just what is not null and have client fill the unused indexes, and somehow guarantee ordering. isnt a struct also required?
How large are your arrays if I may ask?
And yes a fast TArray requires the elements to be UStructs
~10k
Ah I can see why you dont want to be sending that every single time
@twin juniper I'm sorry but I really need to go to sleep XD. I wish you good luck
okay thanks anyway I will find another way
Can anyone provide me leads on how to setup steam sockets
Is there a special array that replicates more quickly than others? I don't care for array order
I know there is one for Structs, didn't know if there was one for objects
Hey guys, I'm a little confused on how a dedicated server works. I have the following questions: Do I have to make a separate build for the server every time I change something inside my game? Does every member of my team have to have the engine built from source?
- Yes
- Not necessarily, just the one who builds the server instance
If I spawn a replicated actor and then dynamically add replicated components to it Using AActor::AddComponentByClass, all on the server, are the components guaranteed be replicated with the actor's packet, or can there be race conditions?
Greetings!
Not exactly a multiplayer problem but has to do with servers and network.
I'm working on a code plugin for the marketplace that will have it's own GUI, and I'm wondering, what would be the easiest way to keep a single string variable somewhere on the internet storing the latest version number of the plugin.
That way every time you launch the GUI, it checks on the background if there's a new version, and it just displays a pop-up, with maybe a button linking straight to the marketplace page.
Would that be easily doable?
They should all be in the initial packet so long as you do it in the same frame you spawn it.
FFastArraySerializer? It doesn't replicate "quicker" as such, just tries to do some operations more efficiently.
If you use it in the wrong place it can make things worse
For objects you'd just use TArray
If you change a single element of a TArray on the server is only that change replicated? Surely it doesnt send the whole array again
Only the changed element
But if you remove an element, all elements after the removal have to be resent
But either way, TArray has it's own delta replication that works as you'd expect. FFastArraySerializer is really when you have large data sets, don't care about order, and want to optimize for removing elements from anywhere in the array
Note that you can also replicate static arrays, they will just be "unfolded" like a regular property with fixed offsets. E.g. float SomeFloats[10];
Also FFastArraySerializer has to be a member property, it can't be embedded in some struct or array itself
That seems odd...
TArray items are identified by their index. If you remove an element then by definition all the items after that element have "changed"
Unless for some reason, all those following elements are identical
The delta replication works by comparing the full state of the array
And can also do deltas on the properties within
Yeah right but if the server removes one element from their TArray and then tells the client to remove the same index from their TArray the result is the same
Just seems weird
It doesn't work that way, and it can't work that way
The Server doesn't know what state each clients' array is in, and packets may not be received in the order they are sent
Giving the client explicit instructions only works if you can guarantee deterministic ordered behaviour, which you can't with replication
Yeah that's fair enough
I suppose if you remove an element then change one of the elements after that removal the client might end up changing the wrong element then removing
yeah
If you had an array with 10 elements that all pointed to the same thing, then you remove an element from the start, the array would just be like "I am 9 elements now", but since all the elements themselves haven't changed, you'd only receive the arrays size which would be fast
But basically the way it works is imagine you have a copy of that array, you do all the operations, then the replication system looks at both at the end of the frame, finds the differences, and sends those.
Whereas FFastArray identifies each item by a unique index, and marking it dirty garauntees it'll be sent
and there's a much more minimal book-keeping system for it as a result since the server doesn't need to store a full shadow copy of the array too
You can also re-order the elements client-side too if you like without any issues
Surely there has to be a way of ordering array tasks
I guess it just takes up more bandwidth to do so
Would just be really hard to guarantee determinism.
And probably a bunch of edge-cases where it doesn't work that well
I just thought you could provide specs with the packet explain what number operation it is but thats more bandwidth taken up and will most of the time end up using up a lot more total bandwidth than rarely removing an element will
yeah also during packet loss, you'd have to build up a buffer client-side of all changes until you receive the last one. Replication is meant to be lossy/order independent by design for perf
Very good point
fastarray is a pretty good stop-gap though tbh
If order was important, you could even embed an "index" property in the items themselves
im very sure that if we didn't use a subsystem people wouldn't be able to connect in different countries or cities at that
Am I missing something from the video? What exactly is the issue atm?
Check if this is actually CMC related by showing the netcorrections
Then it might be your Anim setup?
Because server and client might use different variables
What are you actually doing there
Strafing?
What is your code for that
what variables are you replicating?
AddControllerYawInput does not work as intended?
I am guessing you are using some aim offset logic -- I don't have much experience with that sorry. Is the yaw variable RepNotify?
That might be the issue. If you're setting yaw on both client and server, client will keep catching up on the server state
try making the yaw RepNotify, set it on server only and only in the OnRep method set it on client or do what you have to do
Actually you don't need to set it again in OnRep since it is set already (for the client as well)
No, set your yaw variable on ~~client ~~SERVER and it will automatically call the OnRep function on the client with the updated value
and from there you can carry on with your logic
anim logic etc
oops sorry! I wrote set your variable on client -- you should set it on server!
Honestly I am not sure. I read that statement in a lot of places but it does on my current project
It worked?
lol
hello, could someone tell me how can i initiate particle effect for all players except the server one? right now clients can see the effect on server pawn too π¦
Are you using a multicast RPC ?
im using a simple listen server, not very familliar with multiplayer stuff
can you post your code?
try creating a multicast rpc event where you spawn the particles and call that event on the server
if you're not familiar with RPCs I suggest you take a look at the documentation: https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/RPCs/
Thanks i'll look in to this.
I think the problem is the clienet version of the server pawn, i don't know how can i avoid it
I haven't worked with Listen Servers a lot but multicasting will probably work as intended
Hmm, not sure. Looking at the last video again.. the strafing seems quite jittery as well
Could it be a collision issue? Do you have any colliding actor components attached?
You need to use custom flags in the CMC to fix it. I had this issue myself.
In C++. I believe itβs Flag_CUSTOM_0.
Setup your net code to use that
A static site pulled from the internet archive
I've been wondering, since I have a setup for changing movement speed networked, how would I make it nice and smooth on the transition to a lower speed
since when your character is moving at 300 and the max speed gets set to 600 it's nice and smooth
but once you wanna go from 600 -> 300 it's not smooth anymore, since it makes you drop 300 speed instantly
I could make some wonky calculations using deceleration speed and disable movement input for a certain amount of time based on said value
You could interpolate the max speed maybe
so you're thinking to have an interpolation every time it asks for the movement speed smoothly down
but I feel like that would be flawed too
making it a bunch of microlags instead of a singular lag
Well if that's your concern theres no fix
Necessarily you will have microlags by the very nature of ticking
unreal does it well out of the box when coming to a stop, so there has to be a way
It is simply interpolation
There is quite literally no other way for a computer to do it
Of course for the smoothest experience what you would really want is to begin your change in max speed interpolation on your server and then not replicate every single tick but you can use client side prediction
I mean I understand what you mean, but I gotta test it first before I continue this discussion
So maybe if the time it takes for your server to slow down is 1 second then you might send max speed updates every 100 ms but the client can be doing its own interpolation and just using those "checkpoints" to stay in sync
I have a feeling UE probably has a nice function that will do all of this for you though
that's exactly what I am looking for
Does the built in steam plugin work for current ue5?
well for now I did exactly that, works somewhat well, still a lil hitch
I am getting the strangest bug (or my brain is has overheated in this weather)
In my DefaultEngine.ini I set MaxInternetClientRate=10000 which should be the default and my client experiences many more movement corrections than when having this line commented out.
Again 10000 should be the default, so nothing should change in theory. Any idea is happening?
making sure I have this right. If i have an event (run on server) any downstream events called from that event will be ran on the server unless I do any of the other replication methods
Correct
Is it common best practice to ensure all those downstream events are run on server too or is it fine leaving them knowing the context above
I realized I had a bad if node to account for listen servers, which in turn basically removed all the client prediction from my code....
Nope it isn't a common best practice but a bad one
ah ok
If I want the server (dedicated or listen) to spawn an instance of an actor at startup (runtime), as a sort of singleton/"one of a kind" actor instance that I need replicated and a "direct pointer" to from all clients, where should I store it?
Should/can I spawn it in MyGameState::HandleBeginPlay and retain a pointer to it there (in GameState), which will be valid for all clients?
Yeah that seems to be the place, though you can't guarantee it has replicated by the time OnRep_ReplicatedHasBegunPlay() fires. That's why you should have an OnRep for your replicated actor and in that OnRep do what's done inside OnRep_ReplicatedHasBegunPlay().
I would probably make a world subsystem instead and tie it with a replicated actor that acts as an info placeholder
Thanks! Can you expand on this?
I'm pretty new to replication in general, so I have a bunch of noob questions. Firstly, I'm not sure what you mean by OnRep_ReplicatedHasBegunPlay (can't find any references to it, so I assume that's something you add yourself for convenience?).
Let's say I want to spawn a building this way. It will exist from game start to game end (though it may be altered). The server spawns it in AMyGameState::HandleBeginPlay, and retains the pointer as such:
UPROPERTY(ReplicatedUsing=OnRep_MyBuilding)
ABuilding* MyBuilding;
(in addition it has GetLifetimeReplicatedProps with DOREPLIFETIME(AMyGameState, MyBuilding))
The server may also spawn additional actors and attach them to MyBuilding (their RootComponent added to MyBuilding's RootComponent).
When a client joins the server, will the building (almost immediately) be spawned for them and the pointer in their GameState point to it? And noob question; will any additionally added components exist (and the components' pre-attachment original owning Actor instances)?
What caveats do I need to know about regarding "replication guarantees"?
I'm not too familiar with subsystems either (been reading a bit about them just now), though I understand the basic use of delegates. Do you mean I should have a world subsystem so I call a delegate function like MySubsystem->DidReceiveMyBuilding(..) from the OnRep_MyBuilding, which I can "override"/implement/bind other places to perform actions?
(Is the point of this that it is equal to executing additional code in the OnRep-function, but instead of having a bunch of ugly references to all the relevant classes that need to know about its replication, they can instead "register" for this "notification" through the subsystem?)
AGameStateBase::OnRep_ReplicatedHasBegunPlay() is part of the GameState. It's called when GameState replicates bReplicatedHasBegunPlay, i.e, the GameState replicated. At that time, BeginPlay is called on all actors client-side. That means that GameState is guaranteed to have replicated by the time any actor calls BeginPlay client side. If you spawn the replicated actor inside AGameStateBase::HandleBeginPlay() you can't guarantee it has replicated by the time bReplicatedHasBegunPlay replicates, that's why you should consider having an OnRep function that fires when the spawned actor has replicated. Any components you attach to that actor at runtime as long as they are spawned in the same frame the actor has spawned, they are guaranteed to replicate in the same initial packet the actor arrives in.
Programming subsystems are Unreal style singletons that's why they flashed to my mind. You would have a somehow similar approach there. You spawn your replicated actor when the subsystem has initialized. Considering it initializes at a very early point in time, the actor should have replicated by the time BeginPlay is called on any actor client-side. I could be wrong, needs some testing
π€¦ββοΈ searching for the entire name with OnRep_ does give results, but only searching for ReplicatedHasBegunPlay yielded nothing.
Based on what you're saying here, if I only have the capability to join a game that is already "in progress" (no lobbies or synchronized start), wouldn't my actor already exist in the server's GameState before any client joins, and thus the actor would be replicated as part of the initial replication of GameState, I.E. guaranteeing that the actor has replicated "by the time" bReplicatedHasBegubPlay replicates? Or am I thinking about the replication cycle wrong, would the actor be replicated through the "UWorld" or something and the pointer in the GameState is just a pointer that points to nothing yet at the initial replication?
What? You are searching the web?
Look in the source code
Yeah, I found it when you pointed it out:) The facepalm is for me.
When an OnRep fires that 100% means the actor (GameState in our example) has replicated. Though you can't guarantee all properties replicate at the same time, unless PostNetInit has been called. So here's the call cycle you're looking for: OnReps, PostNetInit, then BeginPlay
You can have the GameState dispatch the BeginPlay on all actors inside PostNetInit if you want
BPFL are a group of static functions. They don't store any kind of data, at least I've never tried doing that. Doesn't seem quite right to call them singletons.
Maybe #cpp has a better idea
No. They're just static functions. Shouldn't have state. Subsystems are UE's singleton, like what Wizard mentioned.
Blueprints are code and writing them is coding.
Does the built in steam plugin work for current ue5?
How come movement in the editor is fine for the clients, but when its packaged client is laggy af
You might be able to use unreal insights to check whats going on with your networking stuff
Maybe for whatever reason your net replicate frequency has changed
Hey bro another dumb question, looking at logs and I'm getting a LogScript warning over receiving damage, is that a normal thing?
I'm not sure sorry. Hopefully someone else can help ^
How do i pause all actor replication without destroying it? NetDormancy doesnt work in that case
Not just pause, but pause to specific player
It's literally what Dormancy is for. Check why it's not working
DormantPartial is what you need
And implement GetNetDormancy to filter the connections you want
Yeah that's normal, my social life has been receiving damage since I came back to Unreal 
And how do i control it per player connection?
And also if i want to control it on server, and pawn is Autonomous Proxy, will it work?
Like you would control if an actor is relevant to a specific connection (AActor::IsNetRelevantFor). This function AActor::GetNetDormancy exists on every actor and it returns false by default, i.e no actor is dormant to any connection. This function gets called only if DORM_DormantPartial is set, and only called on server (otherwise all of this doesn't make any sense)
It's called for every connection
Any replicated actor's role on server is Role_Authority. I'm not sure what you mean with that
Got it, thanks!
If you played Dota or LoL, i am trying to implement fog of war, so after i calculate visiblity level for cells, i would like to decide what player sees specific actor
I haven't played either. In case of dormancy you still see the actor even if it's dormant to you. That's why you need relevancy in that sense as it destroys the actor for the connection which isn't relevant to it, so he doesn't see it anymore
Most important, i dont want rpc or movement update come from server, if actor is in invisible cuz of fog for player
visual hiding i can implement in many ways
If a connection is not relevant or actor is dormant to it, any RPCs (multicasts in this sense) fired from that actor won't get to that connection
- Fr thats normal, no joke?
- That joke was legit funny and I actually laughed out loud
I don't know how your overall setup works so I can't tell. But you should be able to trace it and figure what's going on
Damb I was kinda hoping it was just an UE quirk
IsNetRelevantFor accepts as arguments two actors, const AActor* RealViewer, const AActor* ViewTarget, who is RealViewer and ViewTarget?
RealViewer is who you would be testing NetRelevancy for, from the location of ViewTarget
So, RealViewer is PlayerController?
Typically
And what if i return false?
Replication will be paused without destroying actor?
Replication of that actor for that specific player?
If its false the Actor wont be Network Relevant to that Player, therefore it will be removed.
Until it becomes relevant again.
Search for its usage in the code base.
Search for IsActorRelevantToConnection
Its used in the NetDriver.
It calls IsNetRelevantFor to determine if it needs to do something with that Actor for that connection.
Will work for me except removing
Try this?
/** Gives the actor a chance to pause replication to a player represented by the passed in actor - only called on server */
virtual bool IsReplicationPausedForConnection(const FNetViewer& ConnectionOwnerNetViewer);
when you play online in PIE your basically playing with 0 ping. there's some tools in the editor settings that allows you to simulate a typical online environment like you can change how much ping the client and the server has and you can even simulate packets loss.
I figured it out haha, I accidently set something to replicate by accident
nice! still do check these tools tho. they're really handy
you right you right
π Another day and a half defeated trying to get this Amazon GameLift setup started. I don't really understand what I'm doing or what is wrong. But I'm getting this error when I try to run; msbuild ALL_BUILD.vcxproj /p:Configuration=Release
I have an idea.
whats the error?
yes it does
I had issues with steamsockets though, could have just been doing it wrong
steam sockets work fine, except they make it more of a pain in the arse to debug game with clients
you can't configure timeouts
so you have only 17 seconds to continue after hitting a breakpoint or you'll time out π¦
Clients cant sub to event dispatcher run on the GameMode right?
I have a multiplayer setup where the server spawns waves of AI enemies. Lets say 3 waves in total. The client need to know when a new wave starts / completes to display UI stuff. So either i run that in the GameMode if possible or GameState. What do you guys think?
GameState is replicated to all clients, so i'd do it there
Gamemode only exists on the server so you do your server side logic there, gamestate is replicated to everyone so you hold gamemode specific things the clients need to know about there, like a round timer for example.
Unless it per player then you use playerstate
yeah that was my thinking too. But is there any benefit to do the actual spawning of enemies in the game mode. its probably more convenient to have the whole "Wave Manager" in one place
hi,i wanna ask im currently trying to make a lobby system similiar to fortnite using epic game services..i want to do when player loads up the game,it will goes through a lobby where similiar to fortnite,you can party up,add people to the party then when all ready you can go into the world
my game is similiar to minecraft when first launch where you can have a singleplayer and multiplayer aspect and this is for the multiplayer aspect of it
anyone have any ideas how can i achieve this because i have no clue where to start exactly
tag me
just realized how my question is phrase the answer to it can be generic multiplayer design to a game so sorry for how open it is
Do you already have a multiplayer/session system?
Then I would look into either Epic's session system or the advanced session plugin to get started https://forums.unrealengine.com/t/advanced-sessions-plugin/30020. There's also a lot of video of how to get started making lobbies and session. It's a good start.
I have an image that i made an animation for that is 5 frames that just snaps the image to a location. I want to be able to tell the animation to go to a specific frame and just stay there without playing. Is this possible?
can i integrate EOS eventually?
my knowledge with EOS right now is practically zero but i have tried to make a session system with steam before and that plugin
Yes you should be able to. As far as I know you should be able to choose which subsystem to use. Just like in my current project, i'm looking for steam.
I'm pretty new myself, but I got steam working for me. Then you should also be able to get EOS to work.
ah okay
can i explain my game workflow from launching the game to getting the world is
Yeah sure
because i think its easier for me to explain that
okay
so when player launching the game,the design for it is based of minecraft where you have singleplayer then multiplayer
the singleplayer aspect i want it so when player click the button,it will prompt then to create a local save game world object to save all the local data of that world..singleplayer stuff basicly similiar to minecraft singleplayer mode.
but the multiplayer part,i want it so players can host dedicated servers like how minecraft have hosting server right and players can join their friends up
one aspect of the dedicated server part,i have another technology i want to utilize for that but for the players can join their friend aspect,i want to utilize EOS for that
similiar how steam online subsystem is
does that make sense?
if you have played Valheim,the game workflow is similiar to that for the players can join their friend aspect
I got it to work!
Remember to celebrate your victories as you go, big or small. You did it. And don't give up!
Now, lets see how far I get before I hit another wall lol
Yeah it makes sense. I think making dedicated servers is a bit different. I'm not so sure about how to get started with that.
yeah the dedicated server aspect is not the goal for now for the multiplayer aspect.
just for the players can join their friend world aspect
i want to utilize the lobby system for that so if they want to join their friend world,their friend can send an invite to the party,similiar in fortnite before starting the battle royale gamemode
then they can join the world
my game is basicly minecraft and the witcher 3 combine
if that make sense?
Yeah. You can use sessions for that. There's options to invite people, and join people. And to find sessions.
thank you
also do we know some tidbids on how fortnite handle their lobby before joining the battle royale world?
would like follow the recommended way
so far im thinking of using advanced session plugin and the online subsysten EOS and use it like how creating and joining a session would work with steam online subsysten
On_Rep only runs on client right?
I'm not sure, but don't you just use repnotify after a multicast?
are you sure? if i log in an onrep it seams like it only logs on the client
Yeah, Blueprint on rep fires when the server changes the variable.
From the doc:
This is called whenever the variable we assigned as RepNotify changes and will be executed on both the server and client machines.
rep notifies work on replicated variables, so that's unrelated to multicasts or RPCs in general
Alright yeah you where right. i was logging the playercontroller class name and it was the same PlayerController_C_0 on both. so i got confused. thanks!
Im guessing instanced objects that are replicated work the same as instanced actors in the world? When they begin replication only deltas are sent even if they vary from the parent class? Object a value 10, instance a value 15, no values sent unless they were changed? Since that is basically the initial state of the object?
Do you still need to do the bOnlyAllowAutonomousTickPose thing in UE5?
I'm having listen server animation jitter, and came across that as a potential solution
For those who have tested matrix awakens demo in UE5, can you tell me if the car crashes are network replicated?
Pretty sure there is zero network support for that demo
I'm pretty sure it would have made the news if you could play it with friends
So maybe it doesn't immediately crash when started in MP, but don't expect anything other than player movement to work
yeah i know that feature isnt there in that, but i just wanna know if the car crashes look the same on all clients
If no one spent the months of work to get it to work in MP, no
the control rig thing
im looking for any infomrmation in regards to creating a session manager for lobbies to generate in a lobby browser. I do not want to use Steam or EOS, this is strictly for testing.
I imagine, that its most likely going to involve Rest API calls into a dynamic database of some type
Look up how some networking plugins work such as unreal socketio (nodejs) libraries, or other web framework plugins. You could also use one of these frameworks * assuming you mean BP
anyone know what DOREPLIFETIME_WITH_PARAMS_FAST_STATIC_ARRAY() or DOREPLIFETIME_ACTIVE_OVERRIDE_FAST_STATIC_ARRAY does?
Thank you,
Is there a reason why BotController doesnt show up in the outliner but when I debug the AI system it shows there's a controller attached
i am playing it as a client in dedicated server
the name is also different but there is only one bot in the game
Because that's the client outliner and AI Controllers don't replicate by default
Really nice podcast
https://www.youtube.com/watch?v=I845O57ZSy4
John Carmack is a legendary programmer, co-founder of id Software, and lead programmer of many revolutionary video games including Wolfenstein 3D, Doom, Quake, and the Commander Keen series. He is also the founder of Armadillo Aerospace, and for many years the CTO of Oculus VR. Please support this podcast by checking out our sponsors:
- InsideTr...
Anyone know how to start a multiplayer match with the camera faded to black? It seems like on clients the camera is rendering a few frames before any BeginPlay is called. Works fine in single player though
small question about Print String, it seems to print message on all clients, even though only one client did something. is there possibility for some sort of print string that prints only in window where action (like button press) actually happened?
Petition to have Tim Sweeney on there.
That's probably only a PIE thing cause they run under one process
hmm will check that
I'm using advanced sessions. How do I stop that session from showing up in the "Find Advanced Sessions" when I move from my lobby map to a game map? It's currently showing up in the list while a game is being played.
How would I check whether a player is the Host aka listenServer? This does not work... ```void USpeedCharacterMovementComponent::SetMaxWalkSpeed(float NewMaxWalkSpeed)
{
if (PawnOwner->IsLocallyControlled() && (PawnOwner->GetNetMode() != ENetMode::NM_ListenServer))
{
MyNewMaxWalkSpeed = NewMaxWalkSpeed;
Server_SetMaxWalkSpeed(NewMaxWalkSpeed);
}
else {
if (PawnOwner->GetNetMode() == ENetMode::NM_ListenServer) {
MaxWalkSpeed = NewMaxWalkSpeed;
}
}
bRequestMaxWalkSpeedChange = true;
}```
@magic furnace HasAuthority is what I use in blueprints. I imagine that's exposed in c++ as well.
I mean, that is obvious to be honest, let me try
I think there's a "is server" function, not sure if it works the same for listen servers.
So I have to just replicate the controller to make it work?
Hiya!
I assume I can't send the reference of an actor of the network, can I?
Not sure what that means, can you give the use cause intended?
Sure!
I want to tell the server "Hey, this pawn has interacted with this door right here. Please open the door."
Both pawn and door are Actors.
Can I just create a BP Execute on Server event and send a ref to the door over to the server?
There's a flag on the "Creation advanced session" node that's called "Should advertise". I'm not sure if you can change that after the session is started.
If the 2 actors are replicated, yes you can. It will fail if you try to pass to the server a reference of a non replicated actor.
so I should just replicate and it will work fine?
Do you mean that there's a way to replicate AIControllers? i tought that they only run on the server unless you make your custom AI controller
breplciates = true lol
You shouldn't be replicating Controllers. What are you trying to accomplish?
Got it, thanks!
You are looking in the wrong place. Look at the server's outliner, there you find your AI controller
got it. More than this I wanted the behavior to replicate which it does now haha
Yeah you can replicate them, though I've never had to
You can use PlayerStates to share data.
yesss.
bUsePlayerState=true iirc it's called in your AI controller constructor and it gets auto spawned
oh you mean the controller will get spawned on client's side?
Hello, is there any documentation or resource where there is an example on how to synchronise and replicate a variable from the server to a client that joins later.
I can't seem to get this use case to replicate the variable on the client with the value on the server.
A PlayerState will get created and replicated if it's set so
Nothing special about it. Any replicated variable set on server should somehow get to the client even if he's a late joiner
I see, thanks for that
Thanks then i Will try again
My guess though is that you are replicating some data type that doesn't support replication
In such case you should be looking to replicate the state and not the variable, and inside OnRep_StateVariable() you do your thing
Here's one you can take a look at: https://vorixo.github.io/devtricks/stateful-events-multiplayer/
Hey guys, do you have any info, docs or talks on how to do server rewind for hit validation in unreal engine?
I understand the general idea, but my question is more on how do you do the rewind, is storing the position/rotation/animation a good idea?
or should I go with box collisions and don't use the physics asset for validating hits?
Kay thanks
If I do my pawn possession in game mode on OnPostLogin, will this information be replicated?
And can I put multicasts in game mode
As long as you are possessing a valid pawn then yes. Note that HandleStartingNewPlayer is the function in charge of spawning pawns and possessing them which called right after OnPostLogin. Also it's called for both seamless and hard travels, making it a better place to handle such functionality, while the former is called only for hard travels.
Nope. Reason is RPCs can be called only from replicated actors, while GameMode isn't one of them
ok
thank you
spawning actors inside gamemode seems to work though (they are replicated actors I spawn), so is it a general rule that a replicated actor doesn't need to be spawned on server?
That's not what I said. Replicated actors must always be spawned from server. Though to call RPCs on an actor, that actor must be replicated
So yeah spawning replicated actors on GameMode is fine
Does any 1 have experience implementing steam sdk server stuff that can give a hand? im trying to implement a ping function from the SDK but it always returns "fail"
I don't know what an RPC is. Is a multicast an example of one?
Though if you are storing a reference to that actor on the GameMode, then you're out of luck as client's won't be able to access the GameMode in the first place
ok, thanks. I need to look over everything
Yeah a multicast is one of them. There are three types
Strongly recommend reading through this. https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/RPCs/
Not too many infos out there, but here are the ones I pinned for myself:
- #multiplayer message
- Searching "server rewind" in this server search tool.
- https://www.gabrielgambetta.com/client-side-prediction-server-reconciliation.html#server-reconciliation
- #multiplayer message (in this channel pinned messages)
- Checking ShooterGame source code
Hi everyone, how can I seamless travel with dedicated server?
same as you would with listen server
ServerTravel MapName?listen?game=GameModeAlias
thanks, what about the ip?
with seamless travel enabled on gamemode
there is no IP on seamless
you don't connect to the server, you just browse a different map on existing connection
(also implying that first connect can't be seamless)
I'm starting to understand...I'm going to try some stuff...thanks for the help
Is there any method that you can think of to make the first connection seamless?
no, by design, seamless travel requires you to already be connected
quite unavoidable
I mean in general, has there ever been an Unreal game that can go from single to multiplayer without a hard cut / loading screen?
it can go from single to multiplayer as long as you're not running standalone
As host right?
as in, people are able to hotjoin
So the clients who connect to you will have a cut
yeah, they do need to load the level
server needs to spawn their pawns
etc
not really following how you planned to go around that
even with seamless travel, you're going to have a cut
and that is assuming you can hack the engine for server to host 2 different maps at the same time
we let them choose a map and some other stuff in lobby
and procedurally generating the thing takes about 10 seconds
having to spawn 50k Actors or so
This is a town/dungeon loop like Diablo, as host/singleplayer there's no load screen from startup to shutdown. The only hard cut is joining another player's game.
i mean you can procedurally populate a streaming level
then add it
host wouldn't notice any loading time
if you don't create entire sublevel sync in one tick
Yeah we got that part handled, I was just curious if anyone's ever covered up the Client joining to be seamless
they can't
like Dark Souls
dark souls is custom engine
and i imagine most of it is just masked
smoke&mirrors is what we do to pay our bills after all
unreal needs to
1 - establish a connection with the server, getting the current map back
Yeah maybe we'll mask it, the town(spaceship) to dungeon(surface) transition is a teleport, so maybe some full screen FX or a fade to white can cover it in all cases. Then the town (local spaceship) to town (serverside spaceship) can be the same. It just needs to LOOK the same, not necessarily be the same.
2 - browse to that map, which is pretty much OpenLevel
3 - wait for the PlayerController and Pawn
then it can start playing
Are there any considerations if it's already the same level? It always is, and that level is tiny. The large area is always out of view when teleporting.
it will be faster as it won't have to load the assets for it
but thats pretty much it
provided you don't let the asset manager release them during world cleanup, that is
Yeah I'll look into that stuff. The hub is ALWAYS around, from startup to shutdown. The only difference you'd see when joining a game is the sun angle being different and interior changes due to game progress. You start and end in the same location on the same map with 99% the same assets around.
@fathom aspen thanks π !
Properties and unreliable multicasts iirc
Uhh
I need unreliable multicasts
But dont need properties
How can i optimise in that case?
I'm not sure I get the question
Has anyone tried multiplayer VR using VR Preview? I'm trying to teleport in one of the clients but the teleport trace doesn't even show up. It works when there's only one client tho. I'm testing in the VR Template project btw.
I can't seem to use Spawn Emitter at Location on the client side.
With my current setup, the emitter spawns only on the server and the client doesn't see anything.
It's being told to spawn on server
You can't RPC from or to an actor that is not owned by the player.
Shoot Gun > RPC to Server to Spawn Projectile > Server Spawns Projectile > Projectile Hits something (as detected by server) > Projectile Multicasts effect
Emitters don't replicate (I guess you can make them so, though you shouldn't)
Literally what @sinful tree said, Multicast instead
Yeah
That's better, but the hit result probably won't be valid.
but I guess this has to be called from within a player character is what I'm understanding? because this by itself doesn't work
Hopefully your actors replicates
oh
Nope. This isn't a server/client RPC
the projectiles (the actor this function is part of) does replicate, yes
Good
how would I make the hit result valid?
You'd have to pass through the data through the RPC and pass it through the function. If you're only using the Impact Point, I'd send that through the RPC and have Make Blood Splatter function take it as an input.
oh, the projectile spawning does work on both ends already
That probably means you're doing the overlap / hit check on both client and server.
This is the current flow:
and this works perfectly fine for apply damage to players on both ends
client shoots server and vice versa
oh....
so in here I could take the hit result and do the emitter call from there?
instead of from within the projectile?
That looks standard for the shooting portion.
On your projectile itself though.... What does your hit check look like?
What creates "hit result"?
There we go.
is this bad?
Ok, so that should be fine. The Has Authority node should make it check on the server, but only on the server.
yeah
that's the case
ohhhh
I see now
okay
ok I see why the emitter isn't spawning on the client
but I don't know what's best to do here
do I move the emitter logic over to the player character? feels odd to me
I'll have different emitter effects later on for different projectiles
No you shouldn't need to. The projectile can replicate using the multicast to cause the emitter to spawn.
The only thing is, if you're feeding in a value for a location for it to spawn, you have to pass it through the multicast.
do you mean with mulitcast a custom event that's set to multicast?
Yes
because all I've got is just spawn on server
I don't think I've got any multicasts right?
You did this.
one sec
Add a vector input on ServerMakeBloodSplatter and MakeBloodSpatter.
In the above, connect the the output from the event to the function.
When calling ServerMakeBloodSpatter, get the hit location from your hit result and pass it into the event call.
Within Make Blood Splatter funciton, connect the input to the spawn location.
it works!
but
Why does it work when I use the Hit Location but not if I use the Hit Result?
Because Hit Result isn't replicated and is only being set on the server.
Does Unreal can send via RPC uint16 and uint32 types?
You are passing the value from the server to the clients in the RPC.
So it's not replicating a variable, you're sending a value.
It's just like how you're sending what gun it is you want to fire to the server.
in other words, the Hit value is not usable if I want it to work on both ends with how I personally have set things up
or is the Hit value by default not replicated
The hit value isn't calculated on the client as you have the HasAuthority check blocking the event from executing on the clients.
ohhhhhhhh
omg
yeah..... I just realized that lmao
omg I was so confused the whole time
jesus
thanks a lot I'm blind sometimes
jeez haha
guess it's a good idea to look at the complete flow instead of assuming things lmao
What does bClientSimulation do in the Character Crouch function? I'm guessing it makes it so it is smooth on the client and starts crouching immediately rather than waiting for updates from the server?
Does anyone remember the command to simulate latency on editor / standalone?
Net pktLag=int thanks!
L for LAG
Yeah that's the Replication Graph
I don't know any info on it but the docs/source code and that video and couple of other places but they are not intros
Quick question, since to replicate UObjects, only actor channels matters, does it matter where that uobject get instantiated or what its outer is?
I have an array of instanced uobjects in an AActor, but for management and organization reasons I want to move it to a data asset
And during beginplay, I'll copy the array to AActor's replicated Uobject array again
like
void AActor::BeginPlay()
{
ReplicatedObjects = DataAsset->ObjectArray;
}
in theory it works, but wondering if there is any negative outcomes on the long run
hey how do I automatically set net.UseAdaptiveNetUpdateFrequency to 1
You prolly want to use the network simulation settings instead tho. It'll have nice presets
Even with only 1% packet loss the movement lag is noticeable and jittery is that normal?
How are you doing movement?
Well I have two base characters. One is using default movement component and other is using a custom one. Both are lagging about the same with packet loss.
hmm actually its not so bad, I think the lag just seems worse when I have a GPU related fps drop
does any 1 know if unreal has built in functionality to convert IP to decimal?
I have an actor with a replicated defaultSceenRoot with an Replicated SkeletalMeshComponent with physics. I spawn the item on the server. what did i miss? it does not show up on the client
I do set the skeletal mesh on begin play
depends on the game, is the hit important enough that i needs to be the same in every machine?
forgot to mention that the actor itselfe is replicated:
are u gonna have a ranked mode?
if so i would do it server side
im not exactly sure how good that would feel response wise since ive never worked with vehicles
do they have like a custom movement component?
if they do i would probably let the movement component handle that stuff
For that, in the Config folder of your project, open DefaultEngine.ini and add the following section:
[SystemSettings]
net.UseAdaptiveNetUpdateFrequency=1
However, in UE4 and UE5 Early Access, this wonβt work. To make it work in those engine versions you have the following alternatives:
a) Remove net.UseAdaptiveNetUpdateFrequency=0 from Engine/Config/ConsoleVariables.ini in the Engineβs directory.
b) Switch the CVAR value in the Server when the game starts (right after ConsoleVariables.ini gets called).
i cant be of much help since ive never done it tbh
go with client side then
it should be easier indeed
I found the problem. im passing in a skeletal mesh to actor that i spawn, and then set the mesh on the replicated component. apparently the mesh itselfe that is getting passed needs to be replicated aswell
but there is something im missing still. Im getting diffirent meshes on the client and server. im using a subsystem to return the item that should be dropped. i though this would only run on the server.???
In this 2018 GDC talk, Psyonix's Jared Cone takes viewers through an inside look at the specific game design decisions and implementation details that made the networked physics of Rocket League so successful.
Enjoy the hellscape that is lag-compensated physics.
Does unreal engine built in sessions work in current version
Hello π
Does anybody have any idea what might be causing this weird pullback on the clients version of the server / host character?
It only seems to happen on the clients screen when the Server characters stops moving, it doesn't happen the other way around.
**note: ** Game is running at 15fps intentionally to highlight the issue. Its less noticable at higher fps but its still happens
I assume you are running some PktLag?
Happens without lag as well.
I'm testing now with a default character just in case its something I've done on my character since i do use Client Auth Movement, but it still happens with the default character π€
It looks like it is predicting the client movement and then correcting
have you tried turning on netcorrections
to take a look
p.netshowcorrections 1
I believe
Sure 1 sec
Although it would be weird if the server is correcting its own movement on clients, since clients shouldn't be predicting the servers movements
No Corrections happening
it would be weird
but that's honestly what it looks like
well, I don't know then, have no other theories
Does anybody know why a Custom Event that's set to Run on Server would be changing a Pawn reference to None once it's been passed in?
So testing with a Default Character BP, it actually looks like the Mesh is racing a tiny bit ahead of the capsule, then gets moved back.
I wonder if this is just "how it is" and its masked by animations or something. I'm gonna check the default Third Person Template
What led you to believe its getting set to None?
It is None once printed in the custom event
which is causing it to fail to get my controller, and then fail the cast.
Where can i pass data from a beacon connection to the game connection ?
My Client's Game Instance references a Pawn, and I'm trying to access that Pawn's AI controller (Which only exists on the server), so that I can manipulate it.
So, I've grabbed that reference from the Game Instance, and called the Custom Event that's set to 'Run on Server' and passed it a reference to the Pawn.
But, it's being set to None.

Assuming that the print you showed in the screenshots is the one saying None, it means the reference you're getting is None
The print for the client's custom event above is showing the Pawn's name
the issue is the 'Run on Server' custom event
that one is providing None, as it's deleting/not accepting the pawn reference
Are you sure its the Pawn Reference? You're immediately casting to a controller which it may not have yet, which would be None.
It's a pawn reference, just printing exactly what is being passed in returns None on the Server.
It might be that you're hosting Data in the Game Instance. The GameInstance is essentially the Window the Game is in. Meaning it only exists on that machine.
So if you're trying to pass an object to the server that way, it might fail because RPC i think expect the object to exist on BOTH the server and client, it just says which one to run the code on.
So if the Pawn is in the GameInstance, it never existed on the server, so the server has no idea what object you're talking about.
Right, but the item in the GameInstance is set to be replicated currently.
Shouldn't the Server be aware of it?
Replication only works Server -> Client not Client -> Server
My recommendation would be to use the Game Mode. The GameMode ONLY exists on the server, so its a good place to put anything that should be Server Authoritive. An AI controlled Pawn fits that description since AI Controller only run on the server as well IIRC
Then you replicate that pawn to the clients if needed, but most likely the server should be the one creating / controlling this.
If you want a client to control the AI, thats when you pass a Server RPC, so the Client can tell the server "HEY DO THIS THING FOR ME". And it should be able to, since the Server is the one who created and owns the object, so it exists.
And further to this, Game Instance doesn't replicate. It only exists on the local machine.
Looks like the same happens with the Provided ThirdPersonTemplate.
Guess its just how it is, and its masked by smooth animations or something since its A LOT less noticable using the actual mesh vs the Cube
The latter point is what I'm trying to accomplish. I'm spawning in an AI possessed pawn, and using the Player Controller's reference to it in order to have the Server perform actions on that pawn's AI.
Then what i'd do is the following:
-
Spawn the AI Possessed Pawn on the server (Can by done via an Server RPC, or a Server Auth Object like the GameMode)
-
Make sure the Pawn is set to Replicate so All clients get a copy of it
-
Use ServerRPC's from the Client to tell the server what to do with the pawn. You don't need to pass in the Pawn, only the intent. For example, if you want the pawn to move to a location that the player clicked, you calculate that position on the client, then pass the Vector Location into the Server RPC. When the Server receieves the RPC, it will have access to the Location you passed and then it can call "AI Move To" or whatever method you're using to move the character. Since the Pawn is Replicated, all clients should see the pawn move on their screen.
Note: Make sure the Pawn has Replicated = True AND ReplicateMovement = True
Thanks, that's pretty close to what I had configured already. I guess my confusion here lies in why the reference to the pawn I want to move doesn't need to be passed to the server.
Does the server also have an exact copy of the player controller, that holds the pawn reference? If it does, and the references are different between the Client and Server, that'd explain it.
I have an issue where simulated physics replication is causing problems. When i drop an item on the ground the item some times goes trough the ground (which is a plane). I have a Z check inplace to put the item back above ground again. But once this happens on the client it keeps repeating the process.
any ideas how to solve that?
doesnt seam like the location is replicated att all...
The PlayerContoller does exist on the Server AND the client, but it DOES NOT exist for other non owning clients.
So in theory it should be an exact copy, but of course depending on how you've got things setup, it might not be since you can easily set Client or Server only information.
Since the Server is the one Creating and Storing the reference to the AI pawn, the Server always knows about it. Most likely you probably want to pass a reference to this pawn or some sort of indentifier to the clients, so when they RPC back to the server, the server knows WHICH pawn it should act on (incase their is multiple).
The most reliable way to pass information like this is using RepNotify, which means it automatically updates the client Value with the Server value when it changes on the server. However, the limitation here is that the object storing the reference needs to exist on the server and client, so using the GameMode for RepNotify won't work. Using the GameState however would.
When you first start a game, and you make no changes to any variables, the server and client have the exact same player controller.
You can have variables that are changed on the server only, or that are replicated to the client.
You can also have variables that are changed on the client only. Variables cannot be directly replicated from the client to the server, you have to RPC to the server to feed the server any client-side values.
Probably under the Job Board category. #instructions for details on how you can make a post.
Is it possible to use beacons in editor ?
widget that should only appear on the player approaching it. But how can I make it not appear on the other player?
Plug your cast returns into "IsLocallyControlled" and branch. If true, do the stuff.
@sinful tree now i added "IsLocallyControlled" but this time it is showing on other player, not the closest one
Can you show the updated code?
@sinful tree
You need to connect IsLocallyControlled to a branch
and you should do it to both the OnOverlap and OnEndOverlap
Client authority over physics has a fundamental problem when 2 client objects interact
They are both "authoritative"
so which one is authoritative?
Yes
Oh, are a) and b) different options, not both requirements?
Hello! I'm looking into a way to get my NetMulticast RPCs to players a little more selectively, and I was wondering what the right way for this was. My initial guess is that the Validate function for the multicast determines if it gets sent? I'm working in C++
Partly it's to not send out data that a player doesn't need to know for performance reasons, but also it's to prevent players from knowing info they shouldnt know.
Thanks in advance!
Validate is only for client to server, isn't it?
Multicast is sent out to all relevant clients. There is no selection.
You can't multicast to specific players. If you want to do that, you need to rpc to individual players.
Server - client machine RPC this to the server
Client - server machine RPC this to the client
Multicast - server machine RPC this to all relevant clients.
I guess by relevant it means that any actor not relevant to a player doesn't get the rpc.
Distance culled etc.
But that's not an rpc-specific thing.
That's right, yeah. I'm just trying to figure out the right way to do this. From what I know, Client RPCs only get sent to Owner, but Multicasts get to everyone. I'm trying to find a way to selectively send out RPCs to particular clients without regard for ownership. I'm not entirely sure what the right process is, so its the reason im asking
My first instinct was that there may be some kind of mask that can be applied to the NetMulticast, maybe some conditional in the form of a lambda similar to how arrays get sorted, but i'm just guessing really
The easy way to send out rpcs to specific people is to send client rpcs on their player states.
Or player controllers, ofc
wouldn't you have to have individual functions for every possible kind of data you're trying to send?
Sounds like a chokepoint that will bloat the PlayerState class hardcore
I mean yes, I'm more talking about the organizational POV
You can use their pawn
Currently my RPCs stay in their relevant class
I guess I'm just surprised that there isn't a way to multicast by profile or something
sounds much tidier
property replication for example has conditionals, I expected a similar thing to exist for RPCs
I'm sure it'd be pretty "easy" to add a FilterMulticast method to multicast rpcs. Just edit the engine.
I've been trying to stay away from editing engine code because its bound to get borked with updates π
Multicast RPCs are for one-off events mostly.
Server RPCs are the only way for a client to talk to the server.
Yeah I'm facing a situation where there's certain events that have to be multicast to everyone but given how hectic my game can get it'd be wonderful to be able to narrow down what everyone means. Everyone with a POV? Everyone within a distance? Etc.
There's a way to do this with GameState, PlayerState, PlayerController, etc. but good lord it's already so fat
navigating it is hell
cuz I have so much shit in there
Here's the thing... If you are Multicasting say an "explosion" sound off of an actor. If the player's character is out of relevancy range of that actor, the multicast won't hit them.
@sinful tree ooh I didn't know about relevancy being a thing. I'm still learning about UE's networking
That's why I kept mentioning "relevant clients"
We did kinda mention it right when you first asked.
miscommunication, I happen to be very dumb so I didn't pick up on it
thanks a lot! I'm gonna look into relevancy for this
Bear in mind, gamestates and playerstates are always relevant to everyone.
I assume there's a way to override relevancy?
like whatever getter exists in an actor to figure out whether it is or not for a particular player?
You set the relevancy for an actor or you can mark an actor as always relevant
I mean, google is a thing. First links in google.
And I'm pretty sure Cedric's compendium talks about this as well
i had no clue what to google before the convo, and i was still in the convo when it came up hence why i asked
Which should be a hard requirement for all new people to networking
Shoulda read it harder then
Read it multiple times.
Go back and double check stuff.
I still refer back to it from time to time.
yessir
Is there a reason ClientTravel() would be working when ran from in the editor and then timing out when ran from outside it as a standalone game?
i'm having a weird issue, I've got a CPP class with a replicated variable, and a BP class that inherits from it, and the variable is simply not replicating
bReplicates and bAlwaysRelevant are set to true on both the CPP class and the BP class, and this is the variable's declaration in the header file:
UPROPERTY(VisibleAnywhere, Replicated, ReplicatedUsing=OnRep_PlayerName, BlueprintReadOnly, Category="Boing Character")
FString PlayerName;
it still doesn't replicate when the ReplicatedUsing=OnRep_PlayerName, bit is missing as well, and everything compiles fine because all other changes to the code work
the variable is also set on the server and shows up on the server perfectly fine
this is what each client thinks the variables are, Connecting... is the default
What is the parent class?
ACharacter
Do you have the GetLifeTimeReplicatedProps function in your new class, and have declared the variable in there with the appropriate macro?
Hi, I have a world divided into chunks. On each chunk, player can place items. Items can also be spawned by world generator, so there can be plenty of them on one chunk. Lets assume, that I want to replicate this chunk, and I have to send an RPC with an array of: Items IDs(String) and Items Locations(Vector3D). How can I optimise it? Whole code is in C++
alternatives
Hey Guys! Quick question: If I want to replicate a property (eg.: an integer) that is stored inside an actor component, do I have to set the component to replicate as well?
Yes
Alright, thanks.
What is the lifecycle of a replicated actor on the client, compared to one that the client spawn themselves? Are all the same functions called (constructor/OnConstruction, BeginPlay etc), or do they behave differently?
Not speaking from experience, but why would it be any different. It's only the functions that were called for both ends will be now called only for client, BeginPlay for example, and only for that client instance that spawned it
exactly same
if I have logic in widgets can clients use it to cheat?
hi
im trying to integrate the Common plugins inside Lyra into my game and i kept getting these errors
i tracked it down to this class inside CommonSessionSubsystem.h and to this line
and also to this line inside commonuser build.cs
if i remove the comment i got this message when regenerate the project
Log file: C:\UnrealEngine-release\Engine\Programs\UnrealBuildTool\Log_GPF.txt
Some Platforms were skipped due to invalid SDK setup: Mac, IOS, Android, Linux, LinuxArm64, TVOS.
See the log file for detailed information
Discovering modules, targets and source code for project...
E:\CreationArt\Plugins\CreationArtTools\CreationArtTools.uplugin: warning: Unknown platform Win32 while parsing allow list for module descriptor CreationArtTools
E:\CreationArt\Plugins\CreationArtTools\Source\CreationArtTools\CreationArtTools.Build.cs(70,7): error CS0103: The name 'bUseOnlineSubsystemV1' does not exist in the current context
E:\CreationArt\Plugins\CreationArtTools\Source\CreationArtTools\CreationArtTools.Build.cs(79,48): error CS0103: The name 'bUseOnlineSubsystemV1' does not exist in the current context
ERROR: Expecting to find a type to be declared in a target rules named 'CreationArtTarget'. This type must derive from the 'TargetRules' type defined by Unreal Build Tool.
any ideas on how can i fix this
could be how i integrate the .h .cpp to my plugins but i structure it like this
i didnt want to multiples plugins inside my Plugins folder so i just copied some build.cs/.uplugin details on each plugins and paste it inside my project plugin and corresponding public/private into their own designated files inside my plugin
been trying to figure it out for the last week and still havent managed to fix this one
Widgets are client only, so I'm not sure what logic you're referring to, and how would they "cheat"?
tag me btw
They can change the data they see in the widget and show their health as 99999999. Would that change anything? No
ok, i'm trying to cast to gamemode and my reference is throwing empty. i've tried switch has authority and is local controller, but i'm still not getting any references for the clients, but the server is working. i just need a hint.
oh yea... thats funny
Well for example if I have a widget for equipping an item, if I have on the widget's event construct setting what type of slot it is, it seems like they could then change it to whatever they want to and equip an item there, and if the widget then sends has an On Drop function that continues onwards without any checking it could then cause problems
Who decides what item you have in hand? Client or Server?
If client then yes that's a problem. If server then no
That slot can be in the widget and you have no issues whatsoever as long as the server dictates what that slot is and replicates that data to you and to everyone else. So even if you change it for your instance, the server knows the legit value, and any other client likewise
Is an RPC -required- to get the job done?
What job?
oh, communicating from the client PC to the GM.
What are you trying to achieve with that?
There should really be no reason for the client to talk to the GM
I see, so should the server make the slots and also the draggable widgets in the inventory, then check when dropping if it's the same as when it created them?
oh just a player respawn
GM isn't replicated so you can't fire RPCs on it
firing rpc from controller to the gm
If the PC is the one firing then yes
Client presses button -> triggers RPC on Client PC -> Triggers event on Server PC -> Asks GM for respawn -> GM validates and potentially respawns player
Server should do authority stuff. Server shouldn't make the widget and it can't as widgets are client only, at least UMG ones. They are visual, they don't have any gameplay effect, so even if the client cheated in that regard they didn't do anything that is potentially destroying the fun for other players
Even if they changed the widget to be RPG widget, for the server they are still rocking the AK47
What that means is, the client doesn't respawn itself. The server does.
Ah yeah, that's right. I had stored a temporary inventory for the client, and it uses that to create the widgets. They would need to change that to do anything meaningful. Thanks I am dumb. On another note about that exact inventory, where should I store it exactly? It's in PlayerState currently but as everyone can see the PlayerState, I'm not sure if it should be there. It doesn't have to persist as I can always create it again from online.
Even if it's on PlayerState you can make it relevant only to the owner. Normally it's part of the pawn, unless you support reconnections it better be on PlayerState
Did it - its a beautiful thing. I appreciate it.
No worries.
Alright thanks, then it's a weight off my shoulders.
A question on that inventory... if your game supports possessing different pawns, you'd want your inv to be on teh player character, correct?
I don't know much about player state, but if you possessed different a different pawn, they'd have different gear. I'm not hijacking that question, I'm just curious about basic inventory location.
wait... does the player state go with the player controller or the player character?
Oh now I get it. Let's say you have heroes/pawns on your game, and each hero has its gear. That gear would be part of a DataAsset that is linked to that pawn. When you possess it, you PlayerState inventory gets populated with that data
PlayerController
Even if you unpossess your pawn you still have the PS valid
PC is what spawns PS and owns it
GameInstance exists on both though it's not replicated
Also what does the arrow mean?
that it creates it, not necessarily owns it (but can)
Oh then yes a lot of the stuff here aren't correct
GameMode is created by GameInstance
GameState by GameMode (that's correct)
PlayerController by GameMode
Pawn by GameMode
PlayerState by PlayerController
HUD by PlayerController
it is a work in progress haha
Where is the best place from all of these to store stuff like logging in and granting items? I guess GameMode should be better for granting items and GameInstance for logging in than for example PlayerState as it's a lot of unnecessary commands for other players to replicate in the blueprint. I just stuffed everything there since I didn't really have a proper idea.
GameMode already has login methods. IIRC PreLogin for example approves the login, and you got Login, and PostLogin
What do you meaning by granting items?
I used playfab for all the item management stuff so I send API calls for granting items from a temporary array made from collected items, so I guess my better question should be what blueprint should I store all my playfab SDK things?
I don't use such services, but I don't think it's such a matter. Collected items seem to me inventory and that usually goes either to Pawn/PlayerState
Unless you meant they are world pickups
Then they are spawned by an actor manager or maybe GameMode
Your choice
This should have a separate game instance on the server too
Should have been more clear eh
wait, the game instance is replicated to all but lives on the server correct?
I clearly say it's not ^
It's not replicated
So has two potentially different copies
One on server, one on client
Yeah on server, and it's replicated to all clients
It's not like the GameState
Alright, if it's fine that they are in PlayerState and it doesn't cause any hickups then it's all good.
GameState is replicated, GameInstance is not
Yeah as I said they are added to your inventory, so pretty much where your inventory is
Aight, thanks.
No
yellow box goes inside the blue border only
and a different one inside the red border only
There are 2, they are entirely unique and not shared.
To be honest I find it hard to understand it using such diagrams. Literally understand it and that's it π
need that blueprint brain to unveil the secrets of diagrams like this
So the Game Mode is server-only, the Game State is sort of the replicated extension of that, and the Game Instance is non-replicated and represents the game process that's running, from the point you open the game to the point that you close it
@stray thunder
Game Instance is for stuff that should be persistent between loading screens and connecting to host, because nearly everything else is destroyed at some point
i have in my notes the game instance:
Only 1 exists for each client, only on clients.
Does NOT replicate
Persistent through maps
Save Game Data goes in here.?
Save data there makes the most sense imo, everything that would need to access it can do so in a couple steps or less
It's a good place that's no argue. But I guess Subsystems make more sense, as that can potentially clutter you GameInstance making it a less optimal class
Epic mentions that too in their docs about subsystems if I'm not mistaken
I've never done anything with subsystems so far, so that may very well be the case
They are a game changer, yeah you need to check them out
I'll look into it sooner or later. Is the official documentation pretty good, or is there something like the net compendium or GASDoc?
OnPresenceArrayUpdated(const FUniqueNetId& UserId,
const TArray<TSharedRef<FOnlineUserPresence, ESPMode::ThreadSafe>>& PresenceArray) const
This signature confuses me and the documentation doesn't help much either. If User Id is the current local player, playing on the game client, then why doesn't the FOnlineUserPresence contain a unique net ID? If it is a friend's presence data, then why is there an array, given that the user can only login and play on one machine?
If UserId == currently signed in local player, then the array makes sense, except that I would see the presence structure to have the friend's unique ID so I could know to whom the presence data belongs. That's where it stops making sense. There isn't a unique net ID anywhere that I can find in either FOnlineUserPresence or FOnlineUserPresenceInfo structure that's available underneath it
The docs are a good starting point from how I remember. benui also has a post on them which is a defo too
Cool, I'll look into it later, thanks. Getting sidetracked too much atm
sorry for spamming but anyone can help me with this?
The error is telling you what is wrong
Does anyone know why when sprinting my code works as intended and it decreases the stamina by 1 every 0.1 sec however stopping sprinting doesn't stop the decreasing of the stamina. Somehow clearing the timer doesn't stop it π€
Please ping me if any answer π
Are you calling "Stamina Handler" with authority? Is it clearing a valid timer?
Print for the handle and see if it's getting anything
The server also has a game instance
nope I'm not using the HasAuthority node as the flow of the code is executed on the server. Where do I print it ? Because I have it in multiple places
I want to have instanced housing for players to each have a room of items they can use for storage. where should i start with that? dedicated server with 1 level orr?
Under the same conditions that you're trying to access it, ideally. Print it on tick through a server rpc or however you have it set up currently
That's kind of a broad question. Should other players see and visit your room? Is it like a private area you can TP to without disconnecting?
Yeah, that's about right. The net compendium does have something like this already
As a starting point for now, i just want players to be able to connect to their own rooms as a starting point. Visitors probably down the line
Run it in single player then
Still the arrows make no sense as I said.
yea, i'm consolidating all of my references and info
players host their own halls?
Here it returns false all the time
I wouldn't do it that way down the road. Think of mmos, where the players are always on the dedicated server(s)
Also, i want to be able to save/load starting area contents, from server, to prevent cheating
You would definitely run it on authority for that reason
i'm interested in your input
^
Would I do something like.... 100% non replicating content
so everyones technically on top of each other, but no one can see each other
There's probably some inconsistency in how you're setting the timer handle vs accessing it
But I don't see it π¦
I don't see why imo, but maybe it would depend on if you have a player limit/designated room slots
ok got it. if the game instance is the maker - then it should point to the PC as well ? and PC should not come from game mode?
Try printing on tick to see if it's ever valid
Run that on the server if you're setting it from the server, of course
If the GameMode is the one creating the PC why the GameInsatnce has to point to the PC?
No, the game mode definitely creates the controllers iirc
yea that makes sense
the game instance persists through levels, so I guess it just comes with the controller its attached to.
it's really weird it prints always false however when sprinting the printing of false is kinda weird like if it's fighting to be true at the same time https://i.gyazo.com/2a6024a713e7fc3463d3cf92ee575ade.mp4
Yeah both versions are kept upon reconnection. Server one is for sure, local one is kept for that client instance only
Where are you setting the timer handle at?
Here
Where is the value for that variable being set? All I see is you're creating a timer without using the return value
Aka you're creating the timer and then trying to turn it off via a handle variable that isn't being set
Oh good catch π
i see
It fixed it ! Thank you so much π
I keep leaning towards the only way to do instanced player housing being not replicating anything except to the owning player
bOnlyRelevantToOwner if you haven't figured it out yet
Is there a way I could expand on that to allow visitors, or a guild hall kind of thing?
define some relevance identifier?
awesome! thank you
I'm going to need a dedicated server for a game instance, and one for 'player housing' level right? When I setup settings -> maps, i define the server starting map. how would i do that for each? Package multiple times with the diff settings?
You can use command line input for the level name to load.
Thanks!
has anyone here worked with the Oculus Subsystem?
I haven't been able to get it to work
With a Packet Loss of about 1% should I expect some jitter in movement due to NetCorrections?
I feel like I've seen networking models where this can be solved with redundancy but I'm not sure how Unreal does it
You can simulate packet loss using the PktLoss console command and see how it looks.
I enabled it in Network Emulation, but I was expecting small amounts of packet loss to be smoothed over automatically. Even when not using any movement speed modifiers I get some jitter when making sharp turns etc.
I'm not sure what can be done about smoothing out packet loss jitters. I do however know that using client side prediction can help reduce the feeling of input delay when there's a high ping.
Yeah those aspects are set up to work correctly, I've even managed to sort out prediction for melee swings and hits with GAS.
I just sort of assumed the CharacterMovementComponent could handle dropping some positions and just resending what was lost
It does, that's why you see jitter
otherwise the client would be out of sync
The server notices a packet loss and issues an immediate correction
I mean, as long as the player did not move illegally, the player can revert itself to a correction, and then play through every update that is unconfirmed by the server to get back to where they were, and just keep resending data that wasn't confirmed by the server
That's how I learned to do it when I wrote my own networking stuff π
It would already have to do that in order to not correct itself back to a previous position every time the server acknowledges an update that was in the past.
If not you'd constantly be corrected running in a straight line
whats a good system to have a reference to a specific client's pawn without sending a hard reference over the network?
Nothing wrong with sending the reference.
isnt that kinda expensive?
No.
You're not sending over all the details about the reference. You're sending over a pointer.
tested on the profiler... Sent an actor reference... The RPC was 4 bytes.
You're not sending a pointer, but the FGuid assigned by the server for that actor
I stand corrected π
Any time the server sends a UObject to a client that it does not know about, it'll also send an FGuid that identifies the UObject
That way any time you reference it over the network, it just sends the id
Before you get a GUID is the costly part since you send the full path to the object (when possible)
so it's only 'expensive' the first time it's loaded?
technically yes
until the client acknowledges that it received a GUID iirc
Curious as to why the Guid was only 4 bytes though
fixed the errors...instead of putting the .h and .cpp files directly into the plugin,i just copy paste individual plugins and put in inside my plugin folder
felt like an idiot wasted a week because of that errors
the OSS one
could be a plugin thing now that i think about it
ughhhh
So how would i go about checking wether a character reference is controlled by the local client, or a remote client?
IsLocallyControlled
thanks π
Hey, I'm trying to use the online subsystem to connect to a game I'm hosting, the session creation works fine, its when I'm trying to join through the internet where it goes wrong, LogNet: Browse: 79.112.93.79/Game/Maps/L_WorldSplashMap LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr: 79.112.93.79:7777, Name: IpConnection_8, Driver: PendingNetDriver IpNetDriver_9, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID, Channels: 2, Time: 2022.08.07-22.52.57 LogNet: UChannel::Close: Sending CloseBunch. ChIndex == 0. Name: [UChannel] ChIndex: 0, Closing: 0 [UNetConnection] RemoteAddr: 79.112.93.79:7777, Name: IpConnection_8, Driver: PendingNetDriver IpNetDriver_9, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID LogNet: DestroyNamedNetDriver IpNetDriver_9 [PendingNetDriver] LogExit: PendingNetDriver IpNetDriver_9 shut down LogInit: WinSock: Socket queue. Rx: 32768 (config 32768) Tx: 32768 (config 32768) this is what I receive when trying to connect to 79.112.93.79 with Execute COnsole Command node
this is how I try and join the session
this is how I initiate the session
What's the best way to get the reference to the local controller's currently posessed character?
In Player Controller: GetControlledPawn
In PlayerState: PawnPrivate
thank you π youre super helpful. i did just realize i have no clue how to get the local controller.
would this work?
It can, but it's not great to use in multiplayer - and under certain circumstances you shouldn't use it in multiplayer.
In what blueprint are you attempting to get the local player controller?
a seperate actor. an interactable that the players can interact with
Ok, and in what way is the player controller being used?
And sorry, I totally read this wrong originally, just realized it now.
the controller itself is just used to get the controlled pawn reference
ultimately im trying to check that pawn's ASC for a matching gameplay tag
Is it something that is triggering with the interaction event?
i dont understand the question π
you mean if it checks the gameplaytag when the interaction event starts?
if so, yes
what i want to acomplish is, when you interact with the interactable, your pawn gets set to state B, and become invisible to everyone in State A and visible to everyone in state B.
State A can see other pawns in state A but not pawns in state B and vice versa
so my idea was to send a multicast RPC to check if you have the State B tag or not and then set the interacting actor's visibility accordingly
Ok, so when beginning that interaction, is it being triggered on your player controller or character? Like you're pressing a key then calling an interface on the actor?
ive got an ability on the character, that when activated with an input sends an interface to the interactable
the ability system component is on the playerstate though, if that helps
Ok update your interface to include an AbilitySystemComponent reference which you should be able to pass in through your ability (Get the reference from the ability using GetAbilitySystemComponentFromActorInfo). As you've passed in this value through the interface, the actor now has the reference to the ASC that made the interaction request.
oh it already does that, getting a reference to the interacting actor i mean. for the multicast i just need all other clients to set the visibility of the interacting actor to either visible or hidden depending on their gameplay tags
im sorry if this question is super confusing, im having a hard time putting it in words π
Does it make sense to want my weapon, held by the ROLE_AutonomousProxy local player, to also have a ROLE_AutonomousProxy net role? Is it possible to achieve, if the weapon is spawned serverside and is in fact, not a pawn?
Maybe a better way of asking is to just directly get at what im trying to do;
How can i set an actor's visiblity on a client to client basis?
so Pawn A is visible on Client A but not on Client B
With visible you probably mean relevant.
Anything owned by the autonomous proxy is probably an autonomous too. Though why you care about that?
So i'm having an issue where firing a client rpc in beginplay doesn't get registered, seems like the client isn't technically the owner of the pawn yet but the server runs the function anyway. Is there a function that is called early like beginplay but guarantees the owner has been set?
Seems like OnRep_Owner could work, and just check if you are the local pawn owner before doing anything. It would be nice to have something that isn't run on every client though.
You could try using the Possessed event if it's the player's pawn and is being possessed. This only triggers on the server.
Yeah I was just looking at that now
Is that what you normally do?
If you want to do something whenever a player possesses that pawn.
hmm
that is either not the correct IP or the session was not created correctly, personally I use advanced sessions so I can't tell
After further research I found out about nat punching, I currently do not forward any ports related to unreal engine and wouldn't want my users to do either. I simply want them to connect through the internet and play together on a very small scale. Does advanced sessions provide nat punchthrough?
Good question, I use the steam online subsystem, but I think it works out of the box with the unreal networking too. So my guess would be yes.
and that works without user authentication and all that?
does it have any limitations?
Not any that I know of. And if I remember correctly before I used the steam online subsystem it required absolutely nothing. Granted I am no expert in this matter so you will have to research a bit on your own.
In order to use it with something that is published, you need to pay $100 for an AppID.
Otherwise, use AppID 480 for testing π
well he is talking about not using steam
I don't plan on using steam at all, I simply need a nat punchthrough to connect to my listen servers
and I don't want dedicated either
Does advanced sessions support nat punchthrough?
.
I don't know for sure, since I never had an issue with it, so yeah.
Aslong as you tried to connect over the internet and don't remember any manual port forwarding I guess it works
That's what I mean
I didn't have to do anything and it worked.
I did 1 test without Steam about 8 months ago and it worked, that's all I remember. Since then I use Steam.
Thanks! I don't really care for it, it's just that my mental model suggested that's how it should work, and I was surprised at some point to realize it was a simulated proxy.
Yeah that's the other option. I mean I don't really care for the roles. At the end of the day you probably wanna route server/client RPCs through your weapon and as long as it's owned by your pawn and your pawn is possessed you're good
@fathom aspen if we fire a multicast delegate from OnRepNotify(), this should fire the callbacks to all the actors who are registered to the multicast right/
Yeah if they are on the same end.
A function listening to that delegate on the server won't get called
why????
Unless you call the OnRep explicitly for the server
Because the only way to talk to server from client is through a server RPC
I am calling the delegate like this
OnRepNotify happens on all clients right?
@fathom aspen
Yeah considering that's GameState. It's always relevant
yeah, but somehow the functions connected to the delegate don't get called and I am trying to figure out what's wrong exactly
Again this is the issue usually. Consider the use of RPCs in that case
Or call the OnRep on the server
@fathom aspen okay, so the issue is that the functions won't get called because it's not fired from the server
just to be sure how do I call OnRep from server? Make that OnRep function a server RPC?
Nope
Where you change the replicated value tied with the OnRep, you call the OnRep right after, as that's the server
@fathom aspen I see, thanks
Does anyone know how to prevent two clients joining at the same time? There's only two connections open, but they can join at the same- if they search at the same time. Breaking the game. So it makes it 3 out of 2 players joined. Really weird.
You can either use beacons to "reserve" space in a server before triggering the lengthy join process, or you just kick the second player if they exceed the player count once they've joined.
First method is obviously better for UX, but requires C++ and knowledge of how beacons work
I tried looking at the current player amount- but that changed nothing really weird.
If they stop being relevant mid-game they wont dissapear though, will they?
Player counts from the advertised session data (in steam etc.) take time to propagate and are not immediate, you can only really check properly server-side. Using a beacon to reserve a slot before joining is an extra layer
They would disappear for owner, i.e. get destroyed. And will be recreated and visible again when relevant again
If owner is controller that's possessing the pawn, and camera is following etc. then there is no way they will be not relevant
Though what if I want it to be OnlyRelevantToOwner but bAlwaysRelevant to it. Can I set them both to true and that will automagically be the case?
Ah okay. Time to learn beacons
okay, thats basically what i need. what i want to create is a sort of mirror world, and any character inside of it is invisible to those outside of it and vice versa
That's not the case. bAlwaysRelevant is literally always relevant to every connection. bOnlyRelevantToOwner with a valid owner should be enough to say it's always valid for that owner
how can i set it to be relevant to some clients and not others?
APawn::IsNetRelevantFor()
Override it to your liking
It's called on server for every connection
is it exposed to blueprint?
100% no
No idea actually, and I won't bother looking for workarounds. Most multiplayer functionality is in cpp
Only about 10% is in BP
For reference: #multiplayer message
6 is your case
Here's your starter pack: https://www.learncpp.com/
I was so high on sugar and other stuff yesterday that it took me 4 hours to do this "bounce" effect when the cells spawn