#multiplayer
1 messages · Page 663 of 1
Do you guys set FX related multicast events to reliable? I'm testing with average latency and unreliable RPCs almost never run
Like %5 of the chance clients see visual effects on unreliable RPCs
that depends on how much you clogged your network
ours work fine
setting everything reliable makes network perform worse, not better
I am unable to use Unreal Insights because my Windows is not working very well lately, but I can say I am not using that much bandwith, actually not even close to "much"
bandwith is not the only thing that can choke your network
especially with listen servers
@winged badger you using rider?
CPU can affect bandwith?
oooo that's an interesting idea. let me try that
no, but there is a limit how many reliable RPCs can go per network tick
and how much time server can spend evaluating actors for replication
most network chokepoints are in those 2 categories, not bandwidth
I see, well still I can say I guess I am not close to that point, so probably I should debug more before trying to understand whats going wrong
Thanks Zlo
@winged badger fantastic idea on using vs for debugging. this is great, thank you!!!
agree with this, a few hours did a test with 250.000 actors replicating on owning client, with a timer every 1 sec to change one variable (replicated).
The bandwith use was still quite low, but the server was dying from the quantity of information it had to process
How do you troubleshoot multiplayer replication issue using VS?
How do i prevent local player controller to change a variable in the player state ?
I know i could use a switch has authority but thats not really the point. I am trying to prevent cheaters from changing PlayerState variables
the player state is server-side. even if a cheater were to change the variable on the client, the server would overwrite it
there is a copy of the player state client-side which serves up replicated values
if your game is server-side authoritative, it's unlikely that a cheater changing values locally would affect other players
Can i store the players Health for example in the player state and then request the Health var in the player BP to show in UI ?
I did it and it works but im now curious about cheat protection and i think you just answered that.
The only other thing would be:
Where should the TakeDamage be called to adjust the player health ? -> in the player state ?
I tested by grabbing and printing the player state replicated Health variable.
When i change the health variable from the Player BP, it works. I feel like it shouldnt
yeah for sure the player's health can live in the player state, but modifying the player's health should not happen client-side. the server should be the one modifying the player's health and then that should get replicated to the client
if you run the code client side it'll always change, for sure. but that doesn't mean it's changed on the server
tag your TakeDamage function as UFUNCTION(Server, Reliable) and then implement it
you'll notice that the health doesn't change on the client
that's because you now need to grab the replicated value and show it
OH it works
I see
I printed the health from the player state in the event tick and tried changing it in the Player BP, it printed the new Health variable but instantly overwrote it
is the variable Replicated?
Yes. Actually i have a problem now
don't we all
It prints:
Client 1: 100
Client 1: 100
Server: 100
Server: 100
Client 2: 100
Client 2: 100
Then i change the Health variable in the Player BP to 500 and it Prints:
Client 1: 100
Client 1: 100
Server: 100
Server: 100
Client 2: 100
Client 2: 500
Okay I did it with 1 player and running dedicated server:
Prints:
Client 1: 100
Server: 100
As expected.
I change the variable to 500 in Player BP:
Client1:500
Server:100
This is correct im assuming ?
Becuase any TakeDamage or GetHealth will be called on the Player State and the clients health shouldnt matter at this point ?
Should the Take Damage function be called by casting from the Player BP ?
i'm not sure what this means. you can set it to BlueprintCallable and call it on the BP. it's tagged with Server so you know it's going to be server-side. if you have doubts wrap it with HasAuthority
The player state should hold all information that the player has throughout a session, taking a shooter for example his score, KDA, rewards, etc. Everything unique to controlled pawns, such as stats (health, stamina), accessories (weapons, tools) and pawn specific UI should all be stored in that pawn.
Is this true?
I have been told differently
hello , how can i replicate rotation in c++ in an easy way (by using functions that already exists) . Didn't find it in the doc.
what have u been told differently
Store player stats . etc . in the Player BP itself which sounds like BS.
I am thinking I should store everything in the Player State and then reference those variables from the player BP. Hopefully Lag doesnt cause huge issues here with server response times.
Im not an expert, but afaik your original concept is correct.
The player character BP should be for stuff like pawn specific controls. While The player state is for storing stats and other data you'd like to prevent the client from tampering with
That being said, if you're not worried about cheating for whatever reason, you can honestly just do whatever works lol
Im not familure with all the good practices
Yes. Worried about cheating. I think the PlayerState idea will work
Now I am trying to think of how to store the players inventory in the PlayerState.
Wonder if I could use a DataStruct with Objects and the in the Player State, Have a replicated Empty Array or Struct of some time and then when the player adds to inventory, the server function is called and adds a specific Struct Element to the Inventory
I don't see why not
I have been struggling with the multiplayer inventory concept for about a solid week now
That's not entirely accurate. Sometimes you want to store stuff directly on your character, stuff like health, inventory, etc
in terms of server authority, there's no real difference between character/player state
Wouldn't storing those things directly in the Charactor make them vulnerable to cheating?
no more than storing them in the playerstate
As well then, do whichever works I suppose
But when you try and change Player State stored health variable, it will not work. This seems to be more protected?
if the variable is replicated it doesn't matter
the server will correct any change the client tries to make
I managed to fix my rotation issue , but now if i wwan't some to join me in game (i'm running as listen server) what am i suppose to do ?
I would take a look at #online-subsystems
thanks buddy
Been trying to find an elegant solution for replicating physics smoothly. Didn't expect it to be such a subject.
My current project is a game that resolves around stacking and organizing boxes that are easily knocked over
But it's so damn jittery when testing online, clients with even moderate ping get janky jittery movement
I was looking at the SmoothSync plugin
There are so many physics based multi-player games, which makes me know it's possible lol
But I can't find one definitive solution
I read that it'll be way easier with Chaos
Chaos is a buggy mess still
I haven't messed with it yet, just read that it'll be way more deterministic and thus easier to replicate. Or that's what I understood, still really new to networks
Most of the time you fake the physics replication. Replicating actual physics can be extremely expensive. There is sub stepping for physics, which you can use to make it deterministic, however that means your players will suffer a very degraded experience if they have a poor connection
Where values are stored doesn't particularly matter for cheating in your case - whether it's a Pawn or PlayerState, both can have replicated values from the server that can prevent the player from modifying their values. Preventing players from cheating is largely alleviated by not trusting clients to tell your server what is what. Eg. If you let your client tell your server "I hit this particular actor for 30 damage" - what's to say the client can't manipulate the values to say "I hit this OTHER actor for 300000 damage". Instead, you should just let your client say "Fire gun" and that is sent to the server to then figure out who was hit, and for how much damage, and the server then replicates the results back to all clients.
Storing a health attribute or any values in Pawn is fine if it is related to that pawn, but PlayerState can work ok too. It doesn't make as much sense to store in PlayerState if say, you can control multiple pawns - then you'd have to create multiple health variables in your PlayerState anyway which you may as well have put into the Pawns themselves.
love this. Thank you
Hi! i'm doing some tests for replication.
I'm using a listen server and spawning a bunch of TestActors on server and replicating both the actor and one float variable on each of those actors. Than running a timer to change the value of the float every second.
if i try to read the value of any actor spawned on the server, it reads okey and it changes.
If i try to read it on the client that it's supposed to be replicated, i don't even have the actor in there.
Am i missing something?
Is the actor you've spawned set to replicate?
yeah, it's the one on the first picture "ProxyClass"
Only relevant to owner
Replicated
NetLoadOnClient
also, i just found that if i spawn, let's say 100k of those actors from one client controller (using RPC On server).
When i close that client, the 100k actors stay on the server (i tought that they died with the owner)
Could this be the reason for both things?
i'm calling "On server" from the player controller and passing self.
Would this mean "Self" version of the server for the player controller?
in that case it would make sense to not replicate the actors or the float within the actors to the client
I think you may be running into issues because you're trying to create 10000 actors and replicate them through the array.
I've set up a test actor on my end same as yours, spawning it the same way (but only 1 of them), and using a key press to check the random float, and it works fine.
that makes sense, on the game i'm developing i have a similar setup with the array and i ran on to the same problem
let me check without the array
in the GASDocumentation it says to use LocalPredicted for the execution policy for abilities. however i'm getting issues with montage prediction where the montage basically fails to play. ServerInitiated seems to work way better for me. is there any reason why i shouldn't be using ServerInitiated? it's the only net execution policy that isn't a massive PITA
where doesi t say that?
cause they all have their own uses
he doesnt say to only use local predicted then
Local predicted is when u want to predict the ability
do i risk a super laggy game by just setting all of my abilities to server initiated?
Server initiated is when u want to wait for the server to activate the ability before starting
yes
what can i do to prevent this montage from not playing predictably? i'm failing on this:
the ability is executing fine both on the client and the server but for some reason the montage isn't playing, it's just getting rejected and my gameplay ability is going to On Interrupted
is their a valid prediction key when starting teh montage?
also move over to #gameplay-ability-system
ah i thought this was #gameplay-ability-system sorry
the problem was the array, thanks! i also got around 100/150 less ping at 250k actors
Anyone seen this type of error ?
i haven't seen it before, but it seems that the channel for the actors is not found.
Heres another one for example:
LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor PlayerStateTest_C_1. Function ServerSetDefaultHealth will not be processed.
what are the replication properties of the actor that ownes that health property?
A PlayerState is created for every player on a server (or in a standalone game). PlayerStates are replicated to all clients, and contain network game relevant information about the player, such as playername, score, etc.
https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/GameFramework/APlayerState/
A PlayerState is created for every player on a server (or in a standalone game).
maybe it's trying to update the other player's version of that playerstate, but they have no open channel for that actor?
maybe try a "has authority" before setting the heal
Okay yeah it only throws the error if i play with more than 1 client in the editor
now that i think about it, this is a horrible ideal, they should have that thing updated too.
maybe the replication is sending of the new state to the other clients, i would check if the other player sees your hp correctly if it changes, just in case.
Will test now
So when i do this. It updates on both. Which is right ?
I can see the same result on both screens
is there a clean separation of organization that yall do when replicating? i'm having a hard time piecing together what code i have running on the server and what i have running on the client
You shouldn't need to RPC from Begin Play. Use just the Switch Has Authority.
Well i was needing to call it
Im not understanding
When running multiplayer you have more than 1 computer running the code.
- The server.
- Any clients.
So when something "begins play" it can "begin play" on:
- The server.
- Any clients.
By putting in a "Switch Has Authority" you're telling the execution to only proceed on the computer that has the authority over the actor. In this case, it would be the server.
just in case anyone is interested, replicated arrays can hold around 5k pointers (448kb) if not within a struct
`Static arrays are sent over the network efficiently by only sending the changed values. This rule however is overridden if the static array is within a struct, due to the "all or nothing" rule attached to structs. Thus avoid large static arrays within structs, as then the entire struct is sent even if a single array value is changed.
Replicated static arrays must be less than 448 bytes. Thus some static arrays of structs cannot be sent due to this restriction.
Replicated notification of static arrays only work on the first initial replication update. Subsequent static array replication updates do not call ReplicatedEvent. However, if other replication notified variables call ReplicatedEvent, the static arrays then also call ReplicatedEvent. Static arrays within structs will always called ReplicatedEvent. Thus, if you are finding that static arrays aren't calling ReplicatedEvent at the appropriate times, replicate a boolean at the same time to make sure that ReplicatedEvent is called.`
Okay but how should i be calling -> ServerSetdefaultHealth at runtime
It just doesn't need to be marked as a replicated function.
Eg. This would only run on the server.
Yep
okay, i was confused thinking you were telling me to remove begin play node entirely lol
If you leave it as an RPC event, I believe that opens a means for players to cheat as a client can then spoof an RPC to run that event.
ahhh. okay thank you
wouldn't this mean that any RPC is vulnerable to explotation for players?
Absolutely - this is why you should pass only minimal information from the client to server - only what's absolutely necessary to determine what is going on, and then verifying what is going on while running on server.
Don't trust clients.
Oh i actually understood now what that means.
I tought i was safe as long as i make the call to modify stuff from the client doing a RPC on server.
You can, but the server should be verifying the action - not just doing it because the client asked to do it.
Unless of course, you don't really care.
Question:
I am storing an array of asset data for the inventory. The asset data derives from my cpp files and was just wondering if it would be smart to make totally separate arrays for different types of items in the inventory ?
For example:
I have a data asset for weapons.
It has all the UPROPERTIES i need for all my different variables.
For consumables etc, should I make another seperate data asset with different properties ?
Rather than just have some large generic data asset
@ebon plume https://www.youtube.com/watch?v=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...
this video will tell you everything you need to know
i just watched it, i even learned some new stuff i had no idea about
WOuld this work? https://gyazo.com/bee68871a821c3488010464da41eba58
not really, since the value passed to the onrep there will be the previous value
why do you even need an OnRep function for this?
IsAlive is being passed ot Anim class. Then being used in AnimBP to play dead animation.
that's not my question
It works when I use server and multicast to set IsAlive
you don't manually set the clientside value at all when you use an OnRep
which is why my question was why are you using an OnRep at all?
I'd understand if you were using it to fire a delegate or something
Not sure trying to avoid using server and multicast to set IsAlive variable. I setIsAlive to false when the player health is 0.
so you called it OnRep_ despite the fact it's not that and it's an RPC?
that makes no sense
I was watching this video which did.
link the video please and the timestamp
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...
that is not what that timestamp shows
Ok i'm confused. Let's put that aside for now.
Just to set IsAlive variable is it ok to set it via server and then multicast. Or there's better way.
Forget about on_rep
IsAlive is replicated, the OnRep gets called on the client when the value is changed via replication and the new value differs from the local value
sup. i'm still dealing with this. i've got a bunch of AIs that spawn in and have health bars. i can't seem to figure out the best time to set up the player health bar initially. no matter if i do OnRep_PlayerState, PossessedBy or BeginPlay, there's always some missing information. sometimes it's the user widget, sometimes it's the player state. how do you all solve this?
ok, im done. im just gonna stick this on tick with a boolean flag. i've had enough
where are you storing the health?
it's in the player state, in an attribute set
it worked on tick. i just wait for all of the elements to be ready then i create the health bar and enable a boolean. unfortunate, but i've spent several hours on this
that's not a bad idea at all
wow
hm but wait
what if the player state is done before the widget is created
or vice versa
you're just trying to update the health in your widget?
i'm trying to update health for the first time
just on init
the updating works fine when it replicates
I believe the GAS Shooter example actually has that setup
with multiplayer in mind
can probably look to see how they did it
I don't have anything open in front of me atm
you can also ask in #gameplay-ability-system, probably a better place for this type of question
Hi guys, I'm having a very hard time replicating my weapon pickup system. As the image below shows, I'm picking up an actor on the ground if it implements an interface, going to the blueprint where that interface message is sent, and setting my Pistol variable to that blueprint. Then I attach the Pistol variable to a socket in my hand and update the animation so I have a pistol idle animation. This works fine in single player mode. But I have no idea how to get it to work in multiplayer. I've tried many different RPC tactics but I don't know where to put them in which blueprint or how exactly how to do it. Any help would be greatly appreciated.
Top image is in my character BP event graph, middle image is the parent blueprint event graph of the pistol I pressed T on, and bottom image is a function in my character BP
There is a lot of things wrong for multiplayer
Your key press runs locally so the whole pickup interface does. You need to server RPC the input pressed and then let the RPC run the collision check, loop, interface etc
Then in your pistol parent, you are using a lot of GetPlayerCharacter0. That's gonna be the server then, which is wrong. You already passed the player into your interface, use that.
And then lastly, things like attaching something is a change of state. That should be handled by an OnRep variable. Given your code, after my suggested changes, runs on the server, you just need some variable you can set, e.g. a character reference, that is then rep notify and attach in the OnRep function
+- whatever other state changes you perform.
The weapon type for pistol can be pulled from the current weapon of the player, as long as that current weapon is replicated.
Well actually you attach in the character, so a RepNotify weapon reference instead would do the trick
@fluid edge
Thanks for the reply, I’ll try my best to implement your suggestions tomorrow!
If I run an interface call on server, will all subsequent implementations run on server too even if going through other interfaces?
Interfaces aren't networked
If you run a function on the server it stays on the server
Unless that next function is a Client RPC on a client owned actor or a multicast
So let's say i have 2 interfaces
On one i call sever RPC and then i call the next interface
In the implementation of the last one will still be run on server?
To be really precise: An interface is another class that your class inherits functions from. Cpp usually allows inheriting from multiple classes. UE4 doesn't allow that. The only reason that interface class are allowed is that they need to be abstract, means their functions aren't allowed to have a definition (so code in them unless implemented in the class that inherits from the interface) and they can't have any properties. At least no uproperties.
I see
It's more or less a method of grouping unrelated classes together so you can execute functions on them without knowing what actual class they are
Nothing of this has anything to do with multiplayer in terms of rpcs
So in the end it's just a normal execution chain but themselves can't have properties
Yeah
And the functions in the interface blueprint can't have a default implemetation
You can only define name, inputs and outputs
Implementation is done in the BP class that inherits from/implements the interfaces
Makes sense
Cheers for the explanation, appreciate it ^^
can anyone tell me if i can use my mouse debug and make it so i can use it in the export as well. thanks
anyone?
hello?
i want to init setup for player character like jersey ,shoes, helmet etc
where should i write this code ?
on server or client
at first time
Server I imagine would be reading these values and then replicating them to the client, so if the player's character doesn't exist yet, the server should determine this and then just replicate the default values to the client.
If you are seeing logs such as LogSteamSocketsAPI: Verbose: SteamSockets API: Log Ping measurement completed does this mean Steam Sockets is correctly enabled?
If so it looks like they have fixed their routing issues that were previously causing high latency even in lobbies connecting from the same room
Ok seems I spoke too soon, on 2nd and 3rd attempts, ping is up to 80-100ms for players playing in the same room
I guess the routing is pretty variable and sometimes you may get higher or lower latency
In general would you advise using Steam sockets over the older default socket even if it results in 80-100ms minimum delays for all clients? I like the security features but it's a tough tradeoff
does toggling bAlwaysRelevant has any effect at runtime?
yes
UE will not optimize
this object will always be there
how far away from you does not matter then
Okay I made the RPC change in the first screenshot, then got rid of the Casting in the second, as well as changed the Pistol variable to RepNotify, and moved the UpdatePistolAttachments code into the OnRep function for that. Is that what you were envisioning? @thin stratus
Hi! does anyone have an idea of why this may be happening?
I'm spawning a simple actor from my controller on server side that is set to replicate with "Only relevant to owner"
i check on the client and the server, the actor is there.
if i change the parent class of this actor to "Character", same replication settings, the actor won't spawn on the client, it will only spawn on server.
Yeah
Just make sure the booleans in the OnRep aren't having a raceCondition
Or check if you even need both, given that the function already replicates
Some UE programmer that start with networking don't realize that setting two variables that are replicated doesn't mean they replicate in order
Hello , i have a stupid question. I remember having the option of running my game as dedicated server, actually i'm just having "play as listen server / play standalone or play as client
Play as client acts the same
play as client is just the dedicated server option renamed
ok thanks guys !
Looks like the clients cant see themselves or anybody else holding a pistol still
:P Then it's time to debug why
i will say, going back and making my game replicate properly is really cleaning up a lot of mess!
So on pg 20, Game State it says the Game State is replicated to all clients. Does that mean if I start making vars and custom events and stuff I don't have to make any vars replicate or use server to multicast like I've been doing elsewhere with my blueprints?
No, you'll still need to do that.
ohh okay
Got it. Thank you very much for the pushes in the right direction!
any idea on why this is working on the server but not on the client?
i'm spawning a local pawn (no replicated at all) storing it on a variable (not replicated) and than telling the controller with a rpc (local) to move the pawn
if i'm the server works okey, but not on the clients.
Found the problem, if you want to spawn an actor locally and run it with AIController, you need to disable replication and autoposses on the pawn, than spawn a AIController on client and make it posses the pawn
Really dumb question. Where is the best place to store a character mesh when hosting a lobby. I have tried game instance but then I have to keep track of players joining and leaving, and I have tried saving them into the player controller but when the level changes the variables are then lost. Is there a best practice for where to save variables like this? I want to make sure that clients have access but that they can't set the values themselves.
I think player state is the best place if your info needs to be moved across levels
well I made my own player state as a child of the original player state but when I cast the original to the child it always fails.
If I have to I can always just modify the playerstate in C++
you can't cast the parent to the child, it should be the other way around.
guys
now in client side
the game state takes so much time to be replicated i dont know why
who can i make sure that it got replicated to the client
without keep checking validity of the game state and delay for a bit and check again until its valid
shrug no idea. I just know that it is succeding now for some strange reason but once the level loads the variable has once again been set back to default.
what are you doing to persist the data on player state between levels?
I thought the player state and player controller remained the same from level to level. Is that not the case?
Have you used the debugging tools? There is a way to see what data is being replicated
you need to use seamless travel in order to do so and i think there's a few other things you need to do to get the data, but it's posible with player state
@tight glen how i can do this while i test the game in standalon
I think it is the profiler. There is a way you can run it and it will save to a log file. You then open the log file with the profiler after the fact. I think this is right but haven't done it in a bit.
Ah! Okay well guess something else I will have to look at then. Guess that's why you have to do lobby with seamless travel
but what does this benefit me?
cause iam sure that game state is not replicated fast
some time it works
fast , and some time it takes time
This week we'll be joined by Ryan Gerleve and Dave Ratti to discuss general server optimization in UE4, as well as techniques and solutions to improve your Actors' performance in a networked environment.
NEWS
Unlocking Breach’s combat with Unreal Engine
https://www.unrealengine.com/en-US/tech-blog/unlocking-breach-s-combat-with-unreal-engine
...
This shows how to use it
because you may be updating things that don't need to be updated/used. It will show you what is being updated and what is actually being used. Then you can modify your code or replication settings
ok
if you have questions or issues let me know and maybe I can help. From what I have seen/heard sending tons of un-needed data can cause that issue
Found some info that describes what you said here. I will try this out. I apprecitate the help and advice.
i knew that seamless travel makes th egame state and game mode the same
so if i seamless travel
to another map does the game state changes untill all players join the map
i mean 3 were in lobby
so game state player array has 3 elements
does when we travel to another map
the server join s first then other players , so the game state would not change while traveling from 1-> 2 -> 3
or it will just be 3 cause no one left
https://cedric-neukirchen.net/ if you don't already have it.
That might not be his guide.
3 elements... 0, 1, 2
😄
I wouldn't have a clue, I'd just test it and see, horribly large amount of googling I use if things don't work as anticipated now.
So I checked, yeah that's his guide and will generally tell you where to call things like that. The server arriving first is a necessary evil, so the world being replicated after taking time makes sense.
I iam using a struct for weapon attributes such as fire rate, etc.
Is it okay to set these variables in the weapon BP itself or should these be store on the server side ?
In regards to cheat protection
So you can just check if they're realistic when called from the server
Like maybe even keep track of how many times it was called, if that's over x in x time, then this is cheating.
Set by server and replicated out.
Also, is it bad practice to handle actor spawning and attaching weapons to the player with all the socket details etc all on the server?
The only request from the player is to ask to pickup item basically
Yeah that would be the most realistic way.
Basic rule of thumb is just if it's visual, then client, if it affects gameplay server is my understanding. Anything in the client is enemy hands.
Okay so for testing i am currently setting a variable in the player on begin overlap with an object (weapon for example) and then requesting (from the server) to pick this item up.
How can i validate that the item he wants to pick up is legit ? again, for testing im currently passing that variable (actor) to the server as an input for the actor to spawn. I already know this is bad
Spawn it on the server only would seem legit, actors are automatically replicated down by default to my understanding. If for some reason your actor didn't show up, then I'd address that then.
What if the player manipulated the actor (class) it is trying to add
How would the server know its BS
Server can run validation, but if it's spawned on the server then how are they manipulating it? Basically each client is running a copy, but all the real data is server out, the clients can only request things from the server, then it's in charge of updating everyone. So I'm not sure offhand how the client would ever call that with their own stuff basically.
But either way, you just add the validation before the spawn, check that it's of your class etc, maybe have to check if it's possible on that level or whatever code you need.
Here is where im getting the class variable to tell the server what im trying to add
and then
So the actor would have to already exist for the player to sent it through right? Meaning if the server doesn't know about the actor, then it wouldn't acknowledge it as existing.
So for the actor, do i need to spawn it from the server ? Its a Pickup-able object
Your pickup message looks like
"Hey server version of me, try pick that thing up"
Just do a distance check and call it a day
Yes spawn all replicated actors on server
Yep, server won't care what the client claims happens.
Try this experiment, add a wall to the player on beginplay
then walk through it, the server will allow it, because the wall doesn't exist on the server.
So, the client is wrong.
And the server corrects the client
I meant add it client only.
So i cannot manually place replicated objects in the scene by drag and drop ? When you say spawn, do you mean spawn at runtime on the server ? Sorry if im being dumb.
One caveat would be trying to pickup a faraway object. You could send over a valid but out of reach reference. I'd do a distance check or Is overlapping check.
Spawn on server, actors are automatically replicated.
Yeah he's dead on, relevancy at play there.
Here, I may have some resources to make this more clear.
If placed in editor it exists on both sides and should be replicated.
And this is okay for things like weapon pickups
Why wouldn't it be. You want the pickup to stay in sync right?
I'm trying to find the easier version, but Ryan Laley has one intro set that's good
Okay, im slowly getting what you guys are saying lmao. I need to watch and read more on networking.
And yes
There is a guy named Bryan iirc on youtube that really made it click for me
❗ DISCLAIMER: Re-uploaded due to the original video being somehow magically deleted (I didn't do it..) 😭
👋 Welcome to the Replication Series! This series covers how Unreal Engine handles Replication from the ground up starting with what replication is and how Unreal's Client-Server model works and then moves on into more advanced topics.
📹 ...
Here, this guy really shows it well.
Basically to keep it simple, what happens on the server is what ACTUALLY happened. Everything else is fluff
Exactly
So i think in my case, im technically doing it right. I just need to add some checks and validation
Nobody else mattered, we just do them the courtesy of letting them know what happened. Server rules.
If you're new enough to be asking this question then don't worry about validation right now.
By the King's permission as it were, nothing happens without it.
Whether or not you need to validate really depends.
Not a problem until it's a problem, just work the skills until it's natural.
Okay. I will get into some videos...
Just wanted to make sure i was going in the right direction with the pickup system
In my project I just relay the pickup button press so I don't have to validate anything. But it depends on the pace of your game etc.
Exactly.
I'd let the interact call go through, then let the server deal with it, tell the client what happened.
Thanks guys
Better to never let them do more than ask 😄
Yup. But if my project involved trying to throw back a grenade I might do things a bit more client-side. It'd suck to think you're tossing a live grenade back and you really just closed a door
Yeah, that would, but hey, I'm more evil than you. That's the UI guy's job. I'll handle that when I'm there 😛
It's all a function of interaction density and whether or not things are aimed and speed and urgency and a million other factors.
Yeah that makes sense.
You doing interaction as an interface or component?
Too many things too close could certainly cause issues.
Depends, done both, right now just playing with my own, usually interface is my preferred thus far, but still fairly new to it all myself. Sounds like you might have a bit more depth on it tbh.
Most multi questions here aren't that complicated yet :D.
I think I forced space on spawns when I hit that issue last time I messed with it.
I like the scenecomponent approach as then you can have a location that interaction happens and also it can have state.
Looks like their plan for modular would be more component based.
Hmmmm... not familiar with that in any of the multi I've done.. got resources for education?
I've seen it done through actor components added for inventory calls.
Is there a way to do client -> server replication where the client (or rather their player controller) do not own the actor?
I guess a good example would be have a widget open up a door or toggle a light that isn't owned by anyone
Oh lol, I'm on the wrong discord server, no wonder XD
Route through something the player owns. From the servers point of view the character or PlayerController did the request. It doesn't care about or even know about the widget.
- //DOREPLIFETIME(AWhooshPlayerState, PlayerProfileStruct);
2.
//For Player Profile
// DOREPLIFETIME(AWhooshPlayerState, WhooshPlayerID);
// DOREPLIFETIME(AWhooshPlayerState, CycleID);
// DOREPLIFETIME(AWhooshPlayerState, HelmetID);
// DOREPLIFETIME(AWhooshPlayerState, FrameID);
// DOREPLIFETIME(AWhooshPlayerState, TyreID);
// DOREPLIFETIME(AWhooshPlayerState, FacialHairID);
// DOREPLIFETIME(AWhooshPlayerState, HairID);
// DOREPLIFETIME(AWhooshPlayerState, SkinTuneID);
// DOREPLIFETIME(AWhooshPlayerState, GlassesID);
// DOREPLIFETIME(AWhooshPlayerState, JerseyID);
// DOREPLIFETIME(AWhooshPlayerState, MaskID);
// DOREPLIFETIME(AWhooshPlayerState, SocksID);
// DOREPLIFETIME(AWhooshPlayerState, ShoesID);
// DOREPLIFETIME(AWhooshPlayerState, CountryID);
// DOREPLIFETIME(AWhooshPlayerState, HeightCm);
// DOREPLIFETIME(AWhooshPlayerState, PlayerType);
// DOREPLIFETIME(AWhooshPlayerState, Weight);
// DOREPLIFETIME(AWhooshPlayerState, Gender);
// DOREPLIFETIME(AWhooshPlayerState, SocksLength);
// DOREPLIFETIME(AWhooshPlayerState, FirstName);
// DOREPLIFETIME(AWhooshPlayerState, LastName);
// DOREPLIFETIME(AWhooshPlayerState, TeamID);
// DOREPLIFETIME(AWhooshPlayerState, DisplayName);
which one is better ?
should i replicate each value separate or complete struct ?
I've been told that structs automatically do per property replication so that changing one value won't automatically send the whole struct each time. So I personally would just do a struct. Not to mention the amount of OnReps you'd need to make for that many variables to update potential UI would be a nightmare to keep up with.
yes i know about struct they will send only changed property
i just want to know about code readablity
there is one think when ever a property change character have to check on each property
whick is chnaged
but i do each property separate then only respected delegate will fire
that's the thing is bit bothering me
You could very easily write some functions into the struct itself to compare against a same type struct to check if certain areas are different. For instance you likely want to just update all visual aspects if any of the clothing, gender, weight, cycle, tire whatever stuff is changed. Where as you might have different delegates for names or teamID specifically. It'd be very easy to separate your delegates in the OnRep by passing in the old data in the OnRep function and comparing for differences.
what if i create a single delegate let say OnPropertyChange and then update each property which is updated
like by checking not old one ?
did this make sense ?
Not fully following.
Personally. Those states aren't likely to change often. You don't have anything there that might actually change more than a couple of times a second at the fastest besides initialization time. So a single delegate and single onrep should be entirely fine. If for some reason you actually end up with performance issues related to these things updating, you could optimize it at that point fairly easily.
But as far as the simpler question, for readability, definitely single struct versus dozens of loose properties.
yes i meant that.
with single onrep and delegate
thank you soo much you make my decision easy for me
Any ideas why would a struct not replicate?
a Blueprint JSON Object struct from the BlueprintJSON free plugin to be specific, from server to client
set to Replicated, and after the Set node it has value on the server side but has no value on owning client
Probably the object itself isn't meant to be replicated
@bitter oriole So how does one make an object meant to be replicated? 🙂
By making all relevant data replicated inside the object code
For a struct that would mean make all fields UPROPERTY(Replicated)
And make sure all sub-field structs also do that and are USTRUCT
For Json it might make more sense to simply send the data as text
The plugin imports Dom/JsonObject.h
which looks like an engine out of the box object
can't seem to be able to find it in the Engine's source
anyway, I'll try replicating it as a serialized string, then parse it into the object
@bitter oriole thanks
FJsonObject does not have any replication support
mm, ok
Is the client-server model that unreal engine uses for its multiplayer framework the ultimate solution, or are there any other significant ideas on how to handle multiplayer?
it's the only one provided by UE
It's also the only one that really fits what the engine is meant for
It's generally the best approach... especially if your goal is to support more than four players, without lots of desync, and with some protection against cheating.
One of the other models that has been used in the past is "Lockstep". But it requires deterministic gameplay. With that mode, the simulation doesn't move forward until input is received from all clients. This can be OK for turn based games, or small number of players with low latency. Originally CoD Spec Ops was using this model. Keeping your gameplay deterministic is a huge headache though in a realtime game, which is why CoD doesn't do it this way anymore.
There are some Korean games that use a more peer to peer model as well, each client connects to the other connected clients and I think are generally client authoritative. Easy to cheat in this, and you get desync issues.
Each client basically runs their own simulation
But without the deterministic guarantee of lockstep, and without the input lag that lockstep introduces.
So there are other models, but yeah client-server is really the standard way.
and I don't know how you would do any of the other approachs in Unreal. Would probably require a lot of custom networking solutions
Even some RTS games use client-server method today
Yea thanks for answering. This is exact level of comprehension I wanted, and even more. I was kinda curious what it looks like from perspective of someone who has some experience in creating multiplayer framework, and whether what unreal uses is absolute/universal go-to solution
So this is somewhat similar to listening server (in ue), but without listening server :derp:?
It's like every client running their own listen server... and them all having some way to decide who wins when there is a debate
smells like desync, or trouble
Oh very much so, especially when you have clients with bad networking.
It actually worked surprisingly well most of the time. Felt pretty good when connections weren't poor.
Unreal isn't exactly the universal solution. For shooter games, the absolute best is actually what's in the Quake/Source engine. The networking is more difficult there but the way it works is that it records snapshots so that the server can rewind time and confirm hits properly. This is also how the killcam works.
Unreal doesn't have that extra layer, and so any rewinding it does is more of an approximation. This is why Call of Duty has such good feeling netcode.
Oh thats interesting, is it possible to try to rewire ue4 in that way or at least to some extent?
Yeah, to some extent
Isnt CoD a mix of listen server and client-server model?
Yeah, but listen server is still Client-Server.
It's just the server is run on a client
Yeah, you're right
There's even one thing in CoD that is client authoritative (but don't tell anyone) 🤣
I should've say mix of dedicated servers and listen servers
Probably thats why its easy to hack 😄
As far as I remember, there were 0 dedicated servers. It was all Listen Servers.
At least until you get to the Battle Royale one
What I dont understand is what if every connection has a bad quality of network?
How they manage that?
The experience would be shit 🙂
Haha so they dont care? 😄
The probabilities work out in their favor, and they have host migration setup to detect that situation and switch hosts
The client authoritative piece is that the line traces for visibility tests for the map icons is actually done on the clients and then sent to the server to share with other clients. Otherwise because it's a listen server it would be too expensive.
Everything else is server authoritative
I presume if you are trying to make a multiplayer game with top-notch netcode, you are not going to be successful like the upper mentioned quake/cod level of smoothness without a dedicated person/team who writes whole multiplayer infrastructure from scratch
Having a network engineer is definitely the ideal. But even without that you can still get it to feel really good. It also depends a lot on your design. There are plenty of shooters that run on Unreal and still feel good.
You have UT source code that you can analyze Epic's method of networking
Also GAS is pretty useful
what is GAS?
I just asked about GAS on #cpp, but i got scared off by the premise of complexity. Not that I dont like challange, but i'm pretty new to unreal
Oh yes
IMO, what Unreal lacks in the Quake style of networking, it totally makes up for in the ease of doing everything else.
Have you touched the id tech?
Its not that complex, its just too much information to learn
Its actually pretty abstract
I worked on CoD, which is built up from the Quake engine so yeah 🙂
I think CryEngine & Lumberyard have Quake roots too, but I'm not 100% on that.
I wanted to make a dota 2 like demo, where to control one of the heroes. I like to imagine I'll be able to make it nice a playable for multiplayer, but only to certain extent. Like moving character, throwing spells, killing other player, dealing damage ect. No fancy stuff like creeps, ai, gold, ect. Would you recommend GAS for that? Thought behind this project was I would be able to put that as a thingy in my cv, not sure how much of value it would be tho
Unreal networking from what I've seen would be great for something like that.
That is quite fortifying to hear (pun intended)
When you use GAS, most of the time everything works like "GAS to your own framework", so for anything can be considered as "abilities" GAS is great but.. (its a big but there) some engineers I've met worked with some AAA titles said GAS is pretty much okay but not totally great for anything, so most big studios either create an equivalent one or extend it
Oh, that sounds like, you have to try it to find out. Fair I guess.
If you're planning to get benefits of its prediction system and your framework already works with gameplay tags, for your own project its great. But for getting a career, rather than GAS itself, understanding the 'behind the scenes' part would be useful imo.
very useful, indeed i'm quite busy figuring out how to get a job, so this is very helpful, I'll look into some ue official videos on YT. I think they have one on GAS
^ that, and this: https://youtu.be/_713CSOWkTU
Nice, I'll check this one out myself! 🙂
I was having some issues with my projectile, and server spawned projectiles was quite off... so i created anim notify and printed the socket location where I was spawning the projectile, and guess what they are different locations on server and client?
Any work around ?
Simple anim notify to debug
This is what it prints
locations are different.
and believe me I didn't move my character at all while i was doing right click to do projectile attack.
@rich ridge By default animations or even poses don't play/apply on server, so on server your character might be in default A pose.
set VisibilityBasedAnimTickOption to AlwaysTickPoseAndRefreshBones
or trust the client for the position they are firing from 🙂
Hey! How ServiceRequest UFunction specifier should be used? And the difference of this with NetMulticast, Reliable?
oh yes, I do remember it doing it for one of my other project.
and then the bone position starts sending updates in tick.
i guess i will have it turned on for characters which are doing projectile attacks
thanks brother, you saved my day
Though, to be fair, to the average "I wanna build a game" person, UE is the best with networking for engines. Quake/Source aren't so easily obtained and used for your average noob.
100%.
What I mentioned before--
IMO, what Unreal lacks in the Quake style of networking, it totally makes up for in the ease of doing everything else.
and that's just talking about the networking side. Unreal is way easier to use across the board.
I guess my previous message was unclear too. Unreal networking is way easier for almost all things you want to implement, compared to Quake/Source
Price for God tier big brain stuff I guess. Difficult to use 🤣
Imagine if Valve actually cared about their tooling, what a world
It's also like... you can get by with Unreal networking for the most part, and if you really need to get fancier it's always possible to just write your own networking layer for it.
There was a great video I saw the other day about Rocket League networking. They integrated a custom physics engine and did some fancy stuff on the server with how player movement is processed and sent back
I'm fortunate enough to desire to create the types of games that are right up Epic's alley, so I don't think I'd need to go that deep with it for quite some time
With what I'm working on I'm already needing to write some custom stuff so that I can have clientside-predicted server-authoritative physics objects.
If it's pure server authoritative, it ends up looking awful
so all the clients need to be able to predict but then eventually need to agree on the positions 🙂
Basically just adding dead reckoning to it
They integrated Bullet physics engine pretty sure
What they do for networking is full client side prediction (server authoritative) for the whole scene, this allows them to have reliable collisions between clients since they are moved to your local timeline (predicted) together with the ball, works pretty good in practice even with non deterministic PhysX
Their server isn't waiting for player inputs, it uses last know input, if the input buffer is running low they tell the client to send more/run the simulation slightly quicker
If I remember correctly their talk
Yeah, I think that's pretty close to what I remember. For the input buffer, the server doesn't actually ask the client to send more or less. It handles this by just creating fake moves or I think skipping moves to cause the buffer to be consumed faster or slower on the server which works out to the same thing.
and then yeah, I think I misremembered. The server doesn't rewind the simulation, it's the client that does that based on including frame numbers in the responses.
which is your "moved to your local timeline" note
It's very fancy. 🤣
Do the other player's moves get transmit to the clients for the clientside simulation?
The piece of "move to your local timeline" I think is also where the Bullet physics was important. I'm not sure how you'd do that in PhysX
I mean their talk sounds great and all but if you have played the game your self and get latency issues, be prepared for a rough time 😅
That said it does work pretty well overall though, but does fall apart with latency more and more. (Or packet lost of course)
But that’s basically every multiplayer game in a nutshell.
True, but it's a really hard problem that they picked as their core mechanic 😄
I definitely see mispredicts at least a couple times per game
In the time I played I had usually a 8ms ping, so I had zero to no issues unless their servers were lagging 😛
Most of the time when I see mispredicts, its when other players narrowly miss the ball.
But yes since they use client side prediction obviously it will go wrong at times especially with more latency / packet lost.
yep
Yeah, the local client just uses the last known input for other players pretty sure
It's very fancy. 🤣
😅
For the input buffer, the server doesn't actually ask the client to send more or less. It handles this by just creating fake moves or I think skipping moves to cause the buffer to be consumed faster or slower on the server which works
Can't remember exactly but I know they mentioned upstream and downstream input buffers, can't remember which one they are using but I know they mentioned one in which the server tells the client to run quicker
The piece of "move to your local timeline" I think is also where the Bullet physics was important. I'm not sure how you'd do that in PhysX
I implemented something similar to what they did in RL for our project using a custom solver instead of PhysX and it worked pretty good, can't tell for what it was but it worked pretty good 👀
With PhysX I think it still can be achieved but the rewinding and replaying would have to be done in a separate physics scene or possibly with the PhysX immediate mode
Replicating physics is a complex problem, especially in a server authoritative environment
I’ve seen it said before, but what is it that makes this so difficult? Is it that you can’t easily do the process it self (rewinding) or is it because mismatches in physic time frames because of how UE4 does physics?
It's because you're trying to get three seperate timelines to cooperate and feel good
and can't communicate important things like "he hit the ball" immediately
Should have clarified, I’m referring to rewinding.
So there are just and multiple different ways of doing it and tradeoffs to each of them
Oh
That is a question for Blue Man it sounds like 🙂
For our project we switched to fixed timestep which helped a ton but PhysX is by nature not fully deterministic so there is always gonna be some misprediction which will result in desync, this is why RL switched to Bullet pretty sure.
This gets worse at higher latency since there is more time for errors to happen.
The rewinding part is just setting the object to the state server sent and replaying all the moves in your history buffer.
With PhysX you have to move objects to a separate physics scene to do it so you are not simulating/predicting unrelated objects or possibly the immediate mode which I haven't looked into much.
Not sure about Bullet but for example Chaos allows you to simulate a group of objects you want directly instead of the whole scene and pretty sure they did it for their network prediction plugin Epic is working on.
Syncing networked physics is like having multiple alternative realities with slightly different timelines and outcomes 😅
In other words.. an enormous pain in the butt
So it is possible to rewind things but basically requires engine modifications and more setup?
You can probably get 80% there without any engine mods, only thing you really need to mod the engine for is fixed timestep (with physx at least, chaos has an option I think)
But you'll need to write your own movement replication instead of using the default
RL talk is probably one of the best resources on this topic
Hey, should i do a line trace for interaction input in the player controller? or should this be handled by the character class instead?
What's the best way of hiding an actor based on relevancy? I have IsNetworkRelevant overridden and setup properly. I can see that it's not relevant to certain clients, but it's still visible to them. I just want it to not be if it's not relevant.
Actors would usually be removed if they are no longer relevant to a client...
I am not seeing that happen :/
How do you know they are not relevant?
i put breakpoints on it and checked.
I think you broke something then 😁. Did you write your own relevance logic? It has to be the server deciding no longer relevant. Then the server closes the actor channel, which is received by the client which calls EndPlay on that actor.
We mainly use the basic net distance squared which does exactly that procedure I just outlined.
Although I think now we maybe have more advanced stuff going on too with ownership and rep graph, but the basics still hold.
Hmm. It is running from the server, we have it setup to be non relevant if it doesn't belong to your team. The weird portion is if you're on the team that spawned it and then swap teams, it's still visible. If you're not on the team and it's spawned it behaves as expected.
Hi! which one do you think it's more hack proof for a dedi server?
Considering the first one will only run on the server and the second on whoever has network authority - the first one. (You should expand the Has Authority macro to see what it actually does)
(of course this is with 0 knowledge on how you are doing anything else and who owns what)
I'm just worried because someone mentioned that RPC are vulnerable to hacks
a cheat can arbitrarily call RPCs
really don't like net code in BP but I'm not sure what you think will change with this since the original was a server RPC anyway and will execute on the server
What don't you like about having net code in BP?
feels limiting and produces spaghetti
Alright
Both are bad if you are allowing a client to feed a value to the server that they probably shouldn't be allowed to. The server should hopefully already know what that value is by reading the server's copy of the object that has that value and then apply that value where it needs to be applied.
If this is what I think it is, you're trying to increase the resources of a player, be it through item use, or some other upgrade system.
If you allow the client to tell the server VIA RPC what the value is, then the player could potentially feed in a spoofed value - so say you were expecting them to use an item and it provides 3 Food, a malicious player could spoof that call and provide 3000 Food.
Alternatively, if you only allowed the player to say... "Use item in inventory slot 3", the server can verify if there is anything in slot 3, what it actually is in slot 3, if the player is allowed to use whatever it is in slot 3 currently, and how much of resources is provided by consuming whatever it is in slot 3, then provide the resources of whatever is in that slot to the player VIA replication through your replicated struct.
All that the "Switch Has Authority" check effectively does is verify whether it is a server copy running the code, or if it is a client's copy running the code.
There's also no replication taking place in this image - if the "AddResourcesAuthority" event was called on an execution path that was executing on Client, it will execute whatever comes next only on the client. If it was on the server, it will only execute on the server.
In this case that event "add resource" is triggered only from another actor, with "authority" check before calling the method and the calculation of the amount is based on a property that is replicated.
is there any risk in doing it that way?
Is that event clicked interface being called while on the server?
I'm guessing probably not as you have a GetPlayerController 0 which won't work correctly on server.
oh i didn't tought about that one, i'm still having troubles firing the "clicked" event while on multiplayer.
i'm gonna check on that one too
Any player input events are not replicated to the server by default, and you can't RPC to the server through an actor not owned by the PlayerController.
you can RPC through any actor that you are owning
How I've set up interaction on my end was to take the input event > "Run On Server" event with reference to desired Actor to Interact with > Server checks if actor is valid, decides if I'm within range of the Actor to begin interaction and if I'm allowed to interact > Interact Interface on the specified Actor which can do whatever is needed while still running on the server.
I do have some checks client side as well before starting the RPC, just to prevent spamming or unnecessary RPCs if it would be a legitimate attempt to call.
Is there a list somewhere showing all the events relevant to multiplayer games in terms of client and server connection points? E.g. OnConnectionComplete?
When I play in editor as client and do stat net I see a ping of ~200. My network emulation profile is average so expecting to see values much lower. Are there other places to set latency?
Depends on ur settings if their set to everyone or only client or only server
But there are also console commands for setting ping
I forget them rn
Tho
Had for everyone
You should be using a Map
Key=SpiritStones, value=10 etc
That would be good
Probably did it with a struct as maps don't replicate.
Yeah, Map was the first option, but it doesn't replicate.
I would do an array or structs or something else then. That is gonna get super gross if you ever want to extend the resources
Why can I, from my UI, call a server RPC on my player controller, but not on my gamestate if the gamestate exists on clients too right?
u can call an rpc from ui as long as the rpc isnt within the ui itself
and u also own the other object ur calling the rpc from
Because you don't own the game state. At its lowest level, all you own are the player controller and possessed Pawn
You might own the player state but you really shouldn't be doing much logic in these state actors
got it, thank you guys
I'm using a button to cause a post process to appear on screen and it seems to break when i switch from 2 to 3 players in editor. Does anyone know why this might be a problem?
Seems like it stops working as soon as a second client is on the same machine
hey i wanted to make a local multiplayer game but not split screeen everything is replicated but i dont know how to implement it
Hey guys, i'm having a few issues with multiplayer state changes, basically i have an audio component that changes the music based on the match state, now oddly enough for the client even though the functions fire when i step through the music file isn't changing and i have no idea why, anyone run into this@
can someone help me
Hello guys , i read the "setting up dedicated server" from unreal doc, but i didin't understand where i can find server code. (Accept clients methods , packet managing etc .... )
Not if you don't ask your question.
Are you 100% sure the state change is replicating correctly?
How do you guys predict ammo usage in weapons? There is always desync between client and server on my setup
I've wondered about that. My first thought is to only sync on reload. Some games only replicate on semi-autifire and not on automatic fire
So im trying to set up a system were a player can select a skin and then other players would be able to see the selected skin. Only issue is that so far the only thing it does is apply the skin the player has selected for every other player even if they did not select that skin. So for example; if you were to select skin 1 as player one and skin 0 as player 2 then player one sees player 2 with skin 1 and player 2 sees player 1 with skin 0 and not skin 1. Does anyone know what im doing wrong?
The actual problem in my case is "required ammo on reload" is different between server and client and that causes a problem when I am out of ammo on client-side
And same with weapon-switching on no ammo etc.
You should never replicate state through RPCs, always through replicated variables
Solution would be to make a replicated variable somewhere(in the weapon ideally) that would indicate what kind of skin that weapon have
Then when that variable is replicated to the client you just update it's skin. You can modify it from the client through server rpc
Is it possible to replicate the scale of a component on a replicated actor without replicating a float and manually calling SetWorldScale3D on the component for example? I know there are sometimes functions automatically replicated such as some of the hide or show actor functions
I don't need to replicate movement in this case, just a once off scale init
did you tried to enable replication on that component and just setting the scale on the server? It should potentially work
@empty axle The skin selection is done before the weapon can spawned so it cannot be stored in there I think. Would saving it to the gamestate and applying it when the weapon spawns also work? And then I should just replicate the int that selects the skin from the array right?
Then you should store it in the playerState for example. GameState is just a single actor so you would have the same case as right now and every player have it's own playerState.
I meant game instance sorry, but does the same story still apply then?
ow ok ill see if i can cast to the playerstate then
Thanks that does indeed work. I had thought since the actor itself was replicated, so would the component but yeah it also needs to be replicated
@empty axle So I should replicate the integer that decides the array index in the playerstate right? And then should there be custom events that fire on the server/multicast or just completely remove those?
Yes and you just need one server RPC to change that index. No multicasts required
Anyone have a good recommendation for adding proximity voice chat to a listen server based mp game?
why is this shit not saving.
So I have it set up like this now: The skin selection widget button press activates a custom event which is fired on the server, this custom event casts to the playerstate which sets the replicated integer to a certain value and executes a function in the playerstate that gets a array item based on this integer. Now this array item is then pulled when the 3rd person weapon spawns (The 3rd person weapons casts to the gamestate) But it still doesnt show unique skins, it only shows the skin the player has chosen and displays it for everyone
I think i messed up somewhere with the texture array selection thingy but im unsure where
post the code
ok let me crop it all nicely for you hold on
please note that i did not change the 3rd person weapon code much since i didnt really know what to do there, should i just use beginplay for everything instead of using 2 seperate events?
Hi, does anyone know if i check the "Use seamless travel" in a lobby GM and change to a map where i set the default GM to be a Gameplay GM, does the defults GM, PC & PS change to the default in the Gameplay GM.
It does definitely replicate however it appears that because i change the matchstate quickly i.e. in the handlematchstart() it changes the matchstate to another state, this seems to be causing the problem with the client... a little bit annoying as the gamestate should still react accordingly
@empty axle sorry for the ping but im unsure if you recieved my message 😅
RPCs inside widget will not work, you have to move it to the playerState
Change your replicated variable index to be an onRep variable so you can react on the change of it inside playerState
Inside this onRep you can apply the skin to the weapon locally if the weapon is already created and when you are spawning the weapon also apply the skin based on the variable inside playerState
So I should set the event in the widget to not replicate then right? Then send the int from the widget to the Repnotify int in the playerstate and in the playerstate I can do stuff with it then?
Hi, sorry if this is a stupid question but how important is the Game Instance class? im reading through the Network Compendium and notice it isn't referenced under the 'Common Classes' section, im also going through a VERY old BP Multiplayer series on Epic's YouTube where the guy referenced the Game Instance class and that he'll be doing a lot in there
Game instance is something that is not at all replicated and is unique to each running instance of the game (whether client or server)
It also doesn't get removed upon moving levels and the like, so it's useful for holding data that needs to persist.
What type of things does it handle compared to a GameState for example?
Yes set the event to not replicate and call server RPC event on player state instead inside which you would set that int. Then that int will get replicated to clients and inside RepNotify you will we able to update the skin
Oh okay so would GameState persist moving levels?
So what is the difference in functionality between the two?
Gamestate is replicated, and is not unique - clients and servers share the same gamestate
I'm not really referencing the Gameinstance class, because I tend to never use it for Gameplay
usually not even to store persistent data
I use it for things that have to to with the overall game, which is something you might encounter needing in later stages of your game dev
Got ya, ill carry on with this series as well as the compendium and maybe when it comes to it come back and confirm weather things can be/should be done else where later down the line, thanks everyone!
This one -https://www.youtube.com/watch?v=_XyjMeAb3fw - its old as shit so i know a lot of it is prolly out dated by now but im just starting to dive into the network side of things so looking to get a better understand of wtf im doing lol
Unless you recommend a better up-to-date tut?
I don't know any but that tutorial is utter garbage
They teach so many wrong things
I called them out ages ago, they aren't redoing it or taking it offline
It's such a shame
Lol typical! ill keep looking then haha thanks for the heads up!
On video 6 you would have found this in the comments: https://forums.unrealengine.com/t/blueprint-multiplayer-video-series-is-teaching-a-lot-of-wrong-things/79186
Which is me calling them out
2016...
I don't think they fixed this
Yeah no they didn't
Yeah they haven't by the looks of it lol a lot of the comments on there now are people saying they've done things wrong too
Let's just mark everything replicated
sadlnkgöalskgjklöag
Getting angry seeing this online
;_;
@empty axle So i tried a couple of things but its still not working sadly. So what ive done now in in the Onrep function called the variable for the thirdperson weapon and set the skin there which didnt work, I think because when this variable is set the weapon hasnt been created yet. And when I try to save the variable in the playerstate and call it back in the 3rd person weapon it only works for the client that has selected the skin. The server, and therefore the other client, dont see the change in skin.
this is my function which doesnt work
The list is endless
If you can spent some money, check Udemy for Tom Loomans Online Course, that might be helpful. Otherwise, if you are good with learning from reading exiting and working code, I have a lobby project on the marketplace. Does cost money though. Totally fine to not spend money of course.
Yeah i dont mind ive bought mannnnny udemy courses now lol i actually have already gone through the Tom Looman one but it was ages ago now i think my problem is that i did C++ courses first without learning anything in BP, then decided to learn BP because most youtube tut's and a lot of stack overflow was BP so i haven't touched C++ for ages now, the game im working on is all written in BP so i was trying to get everything done in BP first then kinda 're-learn' C++ by converting it all over to scripts before releasing it
this was before discovering this discord ofc so much more help available here lol
Converting projects from BP to C++ is a good idea
I second Tom Loomans course.
Is your project on the marketplace BP or C++?
BP
Yeah its a good course maybe should go back through it at some point lol
But it's not a tutorial. It's all commented, but def not a tutorial :D
No of course lol where can i find it?
Just search for Multiplayer Lobby Kit
Nice one ill give it a look 😄
Oh yeah, exi - I was able to solve my inventory issue a few days ago. I uhhh....forgot to set the actual TArray to be replicated 😅 - everything else was replicated though, lol
Ok I got it ALMOST working now, I'm really close I think. So the host only sees his weapon but the connected clients do see the proper weapon of the host. Now I need to figure out how to get clients to replicate too and not just the host. Any ideas?
So the OnRep fires for everyone?
It's fine if the weapon is not there yet, you still need to handle that case. The second case to handle would be to get the replicated variable inside Weapon BeginPlay and apply the skin also there.
Important notice here is that you need to apply the skin to proper weapon. So if the skin replicated for some player state you need to update the weapon that belongs to that player.
how to politely explain in simple way (or link to an article) that it is not a simple thing to convert a singleplayer game into coop game
So the only issue remaining is that whenever the client selects the skin the server refuses to update the variable for some reason. The host does affect the variable for the server and all connected clients can see the host's weapon properly but all the clients just use the same skin
Just say that you pretty much have to rethink everything because of network issues. If they don't want to believe you, oh well - carry on.
guys iam using seamless travel , from what i know that the variables in gamemode and game state dont change. But i think mine reset when i use the seamless travel , i dont know why
iam trying to use these variables after i travel and its back to its original form
game mode and game state recreated on travel
player state has copyto methods to copy data
okay
so does the player array in game state also changes
or since its a player state array , this array is copied and not recreated
APlayerState::SeamlessTravelTo(APlayerState* NewPlayerState)
but what if i need the player array in game state to not change
so when i join the map
io check the number of player controllers in map with the number of player states
so how can then check that all players were inside the game are all ready after the travel
cause not all players will be ready at same time
When I start my dedicated server everything is smooth, but after a long period (4-5) hours maybe game lags even more
How can I find the thing doing this problem
any ideas, any tools I can try ?
Yeah, it's probably floating point errors accumulating
Unreal isn't built for long sessions
4-5 hours doesn't seem like a long session. I wouldn't jump straight to float imprecision. Depends on what they are doing in their game.
^ Could be improper memory management
My first thought would be memory leaks/not handling actor lifetime stuff
If we can use Unreal Insights on dedicated servers, that might help to him
iirc there was a use case for it
if it's a blueprint-heavy project though, potentially rip 
Well besides everything he said he runs the instance more than 5 hours
that shouldn't be an issue
Plenty of UE games get ran for more than 5 hours.
with proper memory management & administration
proper loading & unloading of stuff etc etc
No I was trying to say it feels like not a match based game so he might need to end up learn how to solve that floating point accuracy thing too
Besides from memory usage issue if its exist
Yeah, when he reaches 4km in size
we are way above that
Its 25 hours
game has lag more than at start
Adding ping to it
I had around 100-120 ping as Im not in US
and this server is US
what about performance tho?
have you benchmarked performance & timings?
I have not
Foxhole (a game made with Unreal Engine that its matches sometimes takes months to finish) resets its servers daily or each 2 day
please direct me to about how to do so
I am going to look into unreal insight, network insight
Months....? 
How about character movement component tho ?
The patience
Also for a quick info you can look at your server providers website, I assume they should provide info about CPU and memory usage?
It is pain to play with even with low latency
WW1 simulator 😂
^ then you have bad memory management
if performance gets worse as time increases, that cries out leaks
I mean, this is a common thing in general, says nothing about the engine.
What I meant was character movement component
Not our game 😄
What about the CMC?
Is there a tutorial or guide on how to use it properly for a networked game
You're right, I just wanted to add that
Like every tutorial on Youtube uses the CMC
It most likely won't be.
DediServers literally have codelines to suggest restarting after 24hours
So you 100% always want to at least restart once a day
I am trying to understand why a ChildActorComponent never appears on a client connected to a listen server (even when set to replicate and net load on client). The parent is also set to replicate. Is this a known issue?
Is it best practice to have a bunch of variables on a StatsComponent or just a struct? That is to hold the classic RPG type stats.
I hold them inside of structs if I'm not using PushModel system
What do you mwan by push model?
There is a PushModel system in the engine lets you mark properties dirty manually, that way your variables dont run inside of the loop
But if you're using structs, PushModel system sends every property, normal one only sends the ones changed
ah ye i gotcha
One more question on this topic, I like to use RepNotify whenever possible. What's the state of the art regarding RepNotify and Structs? Just run the RepNotify on every update and branch out into different code depending on the variable INSIDE the struct that changed?
Trying to get a client to join my session over blueprints. The Join session Success pin fires, but the two never seem to connect. Any ideas? Important bits:
I have confirmed:
- both client and machine are connecting to steam (on space war)
- The host is adding "listen" as an option (shown above)
- The client completes a search for sessions, finds exactly one, confirms it has a unique key associated with my game on the session, and then calls join session as shown. The "On Success" pin fires and prints the string
Full sequence of events is:
- Host creates session
- Host loads map with option listen
- Client searches for sessions, and finds the host's session
- Client completes Join Session successfully
- Client does not load map to join host. Host doesn't see any activity to suggest client joined, at least on the PostLogin event
Okay I need help. Been struggling with this for quite some time now...
I have a character that is a floating droid - well it appears as floating because it's just positioned around capsule head height.
I am using controller rotation for the spring arm pitch and yaw. The Droid mesh itself is a child of the spring arm. So when I look up/down it rotates everything (as intended)
To get around the capsule itself rotating, I'm simply not using inherit pitch. I am using the YAW so it rotates horizontally. As intended.
Everything works locally.
Problem:
The spring arm rotation is obviously not replicating because I am not allowing the capsule (parent) to rotate on the vertical axis.
To get around this... I replicated the spring arm directly with relative rotation. This works but creates a huge problem with latency when using network emulation.
Any advice would be GREATLY appreciated.
I also looked at ALS system and it seems they are moving things with sockets. Wonder if that could work ?
Also, sorry buttercup_ lol.. we started typing at the same time
It's just like that but there is a skeletal mesh attached to the camera
Not using the inherited one
Wonder if my problem could lie there ? If so, should I go into the character cpp itself (unreals cpp class) and add ones there ?
But still. Don't see how that would replicate the spring arm properly. All the replicated rotation and movement comes from the parent capsule
Attaching anything gameplay related to the spring arm or camera just smells funky to me, that seems ass backwards
What is your DESIRED effect? A mesh that pitches as it moves?
Yes. When I look up / down I'm having the droid (sphere) rotate with it.
Seems funny maybe, but it's the result I need for this particular situation
So basically the same problem as replicating gun pitch in a shooter?
just need the other players to see the droid pitching up and down as you look around?
Yes
Horizontally everything is fine
And I don't want to rotate the capsule pitch obviously lol
I'm assuming this is based on Character right? You have a CMC?
Yeah it's based off the character and using the inherited movement component
I'm assuming CMC you are talking custom ?
Use that to drive the rotation of the drone
Does anyone have an idea of why it may not be working? according to documentation, replication of Struct array should work okey.
"Stats" array of structure type is set to replicate
oh my bad, the problem is that i was getting a "copy" of the array item instead of "a ref".
I'm hoping someone can help me or point me at something to read more: I've worked with Unreal for 7 years but never touched any multiplayer code (yet!). I read somewhere that "Unreal is great at client/server games but for other stuff you have to write it from scratch."
For PC/Console (not mobile) multiplayer games with 2~4 people, would that be client/server still? The person who starts the game is effectively the server?
It could be, or it could have a separate dedicated server.
Depends on the game and requirements.
Yup, if you are a Listen you are the Server too, if not Dedicated is separate
The issue with using a player as the server as the "default" scenario is that it means the experience is going to be highly dependent on someone's network. Also means you probably need NAT punchthrough.
Unreal can work fine in this scenario with no modifications, it's still just client/server
It just has different concerns around networking that aren't specific to unreal.
Oh jeez. But if we're a small company it's not usual that we run our own servers anymore is it?
I know some consoles do that as a platform. But on steam?
Depends
Managed services like gamelift and playfab make that more accessible
but it really does depend on the game itself
You probably have never played a game that didn't use the client/server model
I can't think of any beyond maybe age of empires 2? Or starcraft?
Destiny + Destiny 2
they're hybrid
Main networking is done over P2P, with *multiple low tickrate dedicated servers handling "important" events.
anyway, switching between dedicated and listen isn't particularly hard. If you're writing things that don't assume the server has a player (you shouldn't do this anyway) it's incredibly easy to test both dedicated and listen servers.
So it's not something that absolutely has to be decided on early
I suppose star base is also p2p. Assuming you program it right, you should be able to play your project as standalone, listen server, or dedicated, with no problems.
Holy shit I'm so out of my depth as a UI programmer. I gotta learn a lot!
I'll look up Listen vs Dedicated. Thanks for the pointers!
do ue4 dedicated servers get some kind of unique identifier i can use in my backend api?
or is that something i should generate?
i have this in my "Ready To Start Match" on my gamemode
but once "is game mode ready" becomes true the client gets disconnected
Your problem there almost certainly is not this function. What do you do when this function returns true?
is gamemode ready is set true on begin play
the function is built into AGameMode
and overridden in BP
it starts the match i.e spawns players
in this case ive connected it to a function called CanStartMatch which always returns false
yet the client is still being disconnected
Hello, i read few tutorials on unreal subonline system which i understood decently , but there is something i'm still missing. My goal is to make a multiplayer game based on a dedicated server but from what i know , a dedicated server is composed by many files and classes that manages a lot stuff as packet sharing, accept client connection and lot more. The thing i don't get is how i can use a dedicated by ignoring all this stuff and by just using preset functions in unreal. My guess is that all this stuff is implemented in unreal but i can't find where it is and how i can eddit it. I'm just curious about how things work inside the box. Thank you verry much ❤️
Does anyone know of any good example projects? I see there's a Multiplayer Shootout project but it was last updated for 4.24
This tutorial uses a sample project from Unreal and converts it to multiplayer and explains things good, its getting me started pretty well https://www.youtube.com/watch?v=1hzcLMnZ3eI
Check out my Unreal Engine 4 courses:
➤ Souls-Like Action RPG with Multiplayer: https://devaddict.teachable.com/p/souls-like-action-rpg-game-with-multiplayer
➤ Multiplayer First Person Shooter with Dedicated Servers: https://devaddict.teachable.com/p/multiplayer-fps-inspired-by-cs-go
➤ Multiplayer Top-Down Dung...
He also has a vid on integrating Steam Multiplayer thats good
Thank you!
Hmm I can't see where to download the project for this example
I believe its the hour of code project from unreal, might be in the learn tab on the launcher, ill take a look too. I was just using his knowledge for my own project. Ill have a look around for it
@rancid flame Looks like its in the Marketplace, just search Hour of Code
Looks like the Content Examples project also has some networking stuff in it
https://docs.unrealengine.com/4.27/en-US/Resources/ContentExamples/Networking/
for like a melee weapon trace, is sweeping collision as unreliable as just having constant collision/overlap while moving? i remember people saying collision isnt always so great for moving objects on the server, so a lot of things use line traces etc. anyone know what i mean?
I swapped from overlaps to traces as it was really inconsistent for me, so far traces worked perfectly well and its pretty easy to implement
https://github.com/brynertoma/UE4-Resources (Source: https://youtu.be/TEojA3VBXG8)
https://github.com/EpicGames/UnrealTournament (Source: UT itself)
Also ShooterGame available on Epic Games Launcher
UT is recommended after you learned the basics and wondered how prediction and such advanced things work, ShooterGame is good for understanding basic concepts, and the first one covers everything about entry to replication very well
Both are also extremely old and outdated fwiw
But we only have those provided by Epic 😦
Hey does someone have experience using the plugin "Smooth Sync" on the marketplace?
Hey all 👋
Does anyone have a replicated Pawn class with movement in C++, or a git link with one? Need for study reference.
(ref: KK_UEM) http://gdev.tv/uemgithub. Contribute to UnrealMultiplayer/4_Krazy_Karts development by creating an account on GitHub.
how do you debug to see what information your game state is replicating?
have any of you turned on UseAdaptiveNetUpdateFrequency? If so... how?
They override everything in "ConsoleVariables.ini" engine ini file... and there is no way to do it without changing that one engine file.... have you found another solution?
you can just switch cvar on server and see effects
aight! Thanks
Seen this https://github.com/EpicGames/UnrealEngine/commit/002a1bebb69660c16b4f2f0f8b0f43520e818cd1#diff-7f69b5e66f7365484672aeb4e44691f46a89674b05df4587a02ad49369360ec6 so it might no longer be necessary to do such thing in future engine versions!
you can specify it in your DefaultEngine.ini too
not currently due to the initialisation order
so you need to call it by hand right after ConsoleVariables.ini gets called
I'm having troubles with the Minimap for my multiplayer game. The minimap function is working however, it's only showing the camera for the first player spawned. So the client sees the camera that's tracking the server. How do i have it so it's independent?
i have the screencapturecam2d (idk the name of it) and a spring arm component
does it have something to do with the material?
Hi, did anyone encounter such a weird bug when joining online session? Let's say player A creates a session and player B wants to join. After successful join, player A leaves session and player B is stuck on 'joining' which means, if any player creates a new session he/she will automatically join this new session (ofc despite choosing previously different session to join and even from different player).
Literally I can't do anything to stop player from automatically joining this new session.
void AWhooshPlayerState::OnRep_PlayerPropertiesUpdate()
{
OnPropertyUpdateDelegate.Broadcast();
}
void AWhooshPlayerState::UpdatePlayerProfile(const FPlayerProfileStruct& playerProfile)
{
PlayerProfileStruct = playerProfile;
}
UPROPERTY(ReplicatedUsing = OnRep_PlayerPropertiesUpdate)
FPlayerProfileStruct PlayerProfileStruct;
its not working
What is the correct way to call events replicated in other actors? All the examples I've found events are called by Character or by PlayerController, can I call an event from an attached actor like a weapon class?
i replicated the struct and its not sync with other players
You still have to use the server for changing replicated variables.
So you need an server RPC for this.
Also note, if you want that the OnRep also fires on the server you'd have to call it manually in the server RPC
its mean a property we can not change property from client ?
even its relicated ?
No, if you change it on the client it will only get changed on the clients machine.
Server -> Clients never Client -> Server with Replication.
(Replication != RPC's)
only TArray is replicated
Isn't it kinda a pair though ?
Like you need the server to change it which is why i'm usually having a server RPC in mind to change it
That's what i mean
but a client cant change a replicated property and expect it to update on server
Replication != RPC tho. RPC is remote procedure call, and is not replication
to me those are different systems
I guess in my head it's just a pair cuz that's pretty much the only way to actually replicate changes besides with some other methods like BeginPlay and similar
RPC's don't need to change stuff tho
Tru
@tulip ferry there is FastArraySerializer
but its just a TArray underneath
it has callbacks on client side
when an element changes
and you have to mark array/item dirty, etc
hi, i watched all multiplayer video series from unreal youtube channel and i did same as them in my project. but i have a problem. all input actions and axis work expect mouseX and mouseY, and i should press and hold mouse button to rotate character! anyone knows why is that?
Is the "random" sequence here useable for multiplayer games, or is there the problem that each client gets their own random sequence ?
How do you replicate constructor args in bp? I'm spawning this unit with the "Team" field exposed.
The team field is used in the constructor to change the color of the unit. The teams field is set to replicate, but the client colors everyone as if they were on the default team.
I'd probably just create a Init method which does this kind of setup.
I guess in this method you'd also have to set the values over the server
Each client will draw a different one
Kinda thought so, thanks for clearing it up ^^
I tried creating an init before. It seemed like the host was spawning the unit, then running the function as multicast before the client spawned the unit, and thus the client wasn't running the function when it spawned it on its end
You shouldn't use a multicast for this since if a player is not relevant it wont get the new state
That's likely a case for OnRep's
k
Should be enough to move this to BeginPlay
Team should be replicated at the time of the Actor being repicated and ready for play
There might even be better functions but BeginPlay works
ah that makes sense too
Hey guys, this question is pretty basic, but my understanding is that if I mark a function as Client in the PlayerController and call it from the GameMode (therefore Server) it should only be triggered in the client that owns that controller. Right?
A ClientRPC called on a PlayerController from ServerSide will call on the Client that owns the PlayerController. For one cause the Actor is owned by that Client, and then of course because no one else has that PlayerController on their end.
That's what I thought. Thanks for confirming. I have an odd behaviour where it being called twice and something inside the Gameinstance (which I call inside that player controller function) is not being triggered at all. Probably something in my end, I just wanted to discard that moving piece
it seems that the local player controller's player state isn't ready to cast to my custom player state on the client end during the pawn's begin play
That doesn't sound like something that should happen. Do pawns really run begin play before the player controllers are initialized?
I put in a loop at the front to wait a bit and try again until the player state is replicated but that feels super gross
I finished my widgets for handling server browser and hosting a server. Next I'm trying to get sessions to work. In blueprint there is this node create session. From What I understand creating session in c++ isn't as fast as calling a single method, what is a good place to start working on session in c++?
edit, found it I must have missed the docs on online subsystem before
Who should be setting the ViewTarget of a PC? The server or the Owner?
@wheat grail ViewTargets are local. So Owner. Native PlayerController has an implementation for this already. Your client can set their viewtarget themselves, and there's already also a ClientSetViewTarget Client RPC you can use to have the server tell a client to set their view target to something.
Cool, thanks. Kind of figured out by trying out I was confused because it wasnt working I was doing it OnPostLogin right away just skipping a frame. Where would you recommend to do it?
Depends on the use case. This for some sort of camera in a level set as a default view?
Yup. Its just an actor that acts as transform (with no rep)
Personally I'd find some sort of client local function to call that from. PostLogin is pretty early to be sending RPCs. HUD or PlayerController's Beginplay would likely be perfectly fine for that. HUD negates networking checks. PC requires IsLocalController check.
The idea is to fired it up from the GameMode (because it depends on the actual game mode that you are playing, solo vs multiplayer local vs multiplayer online). So the PC localController is kind of implicit with the meta client
An InitialOnly replication value with an OnRep might work for that as well.
sup. i'm designing a UE server that registers itself with a backend API. i'm wondering where i would put this kind of functionality. i'm thinking it should happen in AGameModeBase::BeginPlay because at this point the world has fully spawned. am i doing this kind of functionality in the right place? is this even the right channel to ask this? or should it be in #online-subsystems
guys
since iam using seamless travel
all the game state and game mode got recreated
and since i need th evariables in game mode and game state to check thing after travel
i need a way to pass these variables or a way to get it or to make the game state and game mode the same
if spawned in code you use deferred spawn, set arguments then call finish to actually spawn
if spawned from blueprint or you can add meta=(ExposeOnSpawn) to property to explose it
Looking for some advice on integrating Vivox. Jumped on a project that has it implemented as a subsystem but i just took a look at their shooter game example which instead extends the game instance.
Wondering if anyone else has opted for a subsystem?
We just switched from a monolithic GameInstance to a few subsystems, including Vivox subsystem.
Makes no difference really but it's a better separation of code.
Does it make any sense to replicate a variable inside the player controller with condition "Owner only"?
The PlayerController is only on owning client and server so that condition is redundant.
Quick question, for a game instance in multiplayer, does each player have their own game instance or is it shared throughout the server? Just starting to implement multiplayer functionality and am a little fuzzy on game state, game instance, player state, and etc.
One game instance exists for each running game. One exists on each client, one exists on the server.
The server does not have multiple game instances. It has only one, regardless of number of players.
Is there a mechanism to extract stats from the character movement component about the size of corrections being made to character transforms/positions/velocities? I'm seeing visual glitches on the client end when changing movement direction (w/ simulated latency enabled) and wanted to see if there was a stat that will confirm what my eyes are telling me
Hello, I'm wondering if I can get a bit of help spawning pawns for listen server and other clients? I have a widget button that spawns a pawn by calling a gamestate run on server event and passing the player controller (which then multicasts for all clients to see the pawn). It works for the server, but doesn't for clients. I'm really not sure what's the best way to handle this (and I'm sure I'm doing this wrong...)
^ You don't need to Multicast for this though... do you?
Pawns just need to replicate and be spawned by the server
unless you're talking about "seeing" as toggling SetVisibility / SetActorHiddenInGame
same principle applies for any actor that you want to have a replicated copy on all machines. Spawn Actor with bReplicates = true from Server and profit
ah okay
the pawns should be replicating, but i'll double check. i'll get rid of the multicast and see if that helps
hmm.. i'm still seeing the same issue. listenserver works, but not a client
could it be something to do with the widget button on client not being able to call a gamestate run on server event or something?
Are you trying to run an RPC from a Widget?
Or does the RPC exist in your PlayerController/State?
Rephrased: In what class is the RPC declared?
Widget calls the event in game state class
Yeah, no
Check the network compendium (Pinned comment in this channel)
Widgets can't send RPCs
The run on server actual event isnt on widget
GameStates can't send RPCs to Server either
you need an actor that has local ownership
From a widget PoV, your most logical choices are PC/PS
I guess it didnt make sense to me to have a player controller have a spawning rpc, which is why I thought gamestate was best. I know game mode only exists on server, so that was a no go. Hmm... okay. I guess I'll move that rpc to player controller
Ohhh.. gotcha
then you can run whatever your Gamestate/gamemode/etc needs to do
Thanks for clearing that up for me. I'll give that a go
That totally did it XD I've read that network compendium, but still getting confused when putting it into practice, heh. I'll go through it again!
I realize this question may have some nuance to it (and depend on settings/gameplay, etc), but roughly what kind of latency tolerance can one realistically expect to get from unreal's character movement component?
:triangular_flag_on_post: abtin#4237 received strike 1. As a result, they were muted for 10 minutes.
hey guys i have a question for you all with replicating instance static meshes...has anyone here used that in their multiplayer game
what's the question
hey thanks..do the instance static meshes have different indexes for the client and server? like the "body index" on the instance static mesh
depends how do you create it. Is it preplaced on the level?
so basically i got a forest..and if you get close enough to the tree you can interact with it..it is replaced by the static mesh instance..and if you leave that area..it goes back to an instanced mesh
im going to do some more messing around
if it is preplaced in the level then yes, otherwise it depends how do you spawn them
ok cool thanks
is there a way to get the instance by its transform instead of index?
so when i replace the instance with an actual actor back to the instance...the index changes..this is gonna be tricky
real quick is there a way to print messages in only the relevant PIE instance? it's confusing when all the clients are printing in every window
Did you tried without instancing? There is some auto-instancing feature right now in the engine from 4.22 IIRC That could make it a lot easier for you
no
ty
can I stream a level for a client but not other clients?
For a game like Borderlands which randomly generates weapon stats when a weapon drops, would the best way to replicate this be to spawn the default weapon and then set a replicated struct on it containing all stats which would replicate down to clients and init the weapon via an OnRep function?
That or you set them upfront when spawning
And they would be replicated on BeginPlay then
@grizzled stirrup
You can just mark them as Replicated and set their condition as InitialOnly and on beginplay if you're auth set their values
Or you can spawn them as deferred and set their values before finishing spawning
or just replicate a seed
and have the client figure it out
instead of replicating a whole bunch of stats
Yeah I was thinking this may make the most sense as long as the rand seed result will always match on client and server which it should if they both call the same func on begin play and don't reuse an old FRandomStream