#multiplayer
1 messages ยท Page 129 of 1
legitamtely the hardest thing i've attempted to make thus far and i feel like im either being retarded or this is actually just that hard
Simple question. When i print a string in my gamemode (which ofc runs only on server). Why do I see the message on both the listenserver and the other connected client (running from editor)
is the print somehow replicated or do they both think they're the server?
I think i figured it out, the print is actually replicated. hence the "Server: ..." so only the server is calling the print
EventOnPosses is called only on server side which added to my confusion
it's not replicated, it's called on server only. You see 2 prints because 2 people logged in, (the listen server, and a client)
If it were replicated, you'd be seeing
Server: Hello
Client: Hello
It'd be a multicasted event if that were the case
Finally, Event OnPostLogin is in the gamemode IIRC, which doesn't replicate at all. It only exists on the server, so it can't really replicate even if you selected the option to.
yeah I agree with all of that, I think you misunderstood
you can clearly see on my client that it also says "Server: Hello", this surprised me as I a corrected assumed that the client never ran the print code
but apperently the text that gets printed from the server, also shows up on the client
thats what I mean with "the print is replicated"
so you weren't asking if prints were replicated, you were asking if they are suppose to show on both screens?
yeah I guess so, maybe i chose my words poorly
if the rpc function is in the playercontroller class then you can just reference itself, else you can get the owning controller of the *pawn
What would be the best way to detect a certain player as a admin
is it possible to change the net cull behavior so that the actors don't disappear from the client? I want the object to still render but right now moving away from relevancy seems to destroy it
I don't want it to be always relevant since I don't want it to continue sending rpc's
I'm a bit confuse... what would be the best approach for Health bar (the one above other players/ennemy), Right now I built a Health/Damage Component that relate the information to the widget but I can't get it to replicate at all
Are you actors "static" such that they aren't getting updates? Then dormancy might be an option and you just increase the relevancy to match the visibility you want. If not, you'll have to make an engine modification to allow for Actors to keep their channels open when not relevant. Warning though there's lots of edge cases to handle when you begin to go down that approach.
Another option is to use the ReplicationPause feature which I don't believe is documented anywhere. You can tell an Actor to pause it's replication for a specific channel. It will still be considered "relevant" but it won't send any updates
You should replicate the health value only, then let the client handle the healthbar themselves
thank you for the reply, I'll look in to ReplicationPause!
I've set the Health value to RepNotify and build the logic inside it to calculate the Percent and send the value to an ROC to update the bar, still not working
You'll want to override IsReplicationPausedForConnection(const FNetViewer&) which gets called on the server before replicating to an Actor
Since the feature is not widely used, there are bugs that you may want to fix if you want it to work perfectly
But should mostly do what you want
ok wait i didnt see the screenshot
Is the problem other people not seeing the correct health? Or is it the owning player?
other people
Because it seems like you're only updating healthbar on owning player
yes I reverted the replicated logic
just wanted to show you the actual base of the logic
Instead of using Run on owning client, set CurrentHP as RepNotify, then update the widget inside that repnotify function.
Health / MaxHealth needs to be replicated properties and should set to Rep W/ Notify. It can be on the character itself. You set the health & max health variables on the server only.
Apply Damage / Any Damage events have to happen on the server. You calculate what their new health value was after Apply Damage and set it in the health variable.
The Heatlh variable when set up as a Rep W/ Notify variable will give you a generated function called OnRep_Health which will trigger on clients when the value replicates. You can use that function to update the widget component with the value.
I did that and now the the bar doesn't update anymore ๐ซ
Make sure the Set Percentage function is set up properly
And also check if the damage is being properly applied
Because it seems like it should work
well it was working for the owning client prior, so its weird that its not anymore, its somehow was just working with the ROC. Like if the server wasn't replicating the information fast enough
Was the owning client also the server?
Put a breakpoint on the Set Percentage node. See if it triggers it when you know the health value should be changed.
You can also put print screen nodes to validate if the health is changing correctly on clients or not. So you can pinpoint if the problem is in the widget or the networking.
just tested, it doesn't pass HealthBar Get Valid
since it's the server its not the one owning it I gues
Where are you creating the healthbar?
Each client should create their own independently
it's on the player as a widget component
Where do you set the reference to the user widget object
Where is the initialize called?
Lastly, where does this initialize gets called? lol
The reference should be getting dropped somewhere
The any damage is inside the character correct?
the reference is working if it's not called by the server
no it's in the component also
is the component set to replicate?
the widget component yes, but I think the other is not facepalm
you don't need to have the widget set to replicate
it should only exist locally on every player
true
that might be the problem
ok so replicating the component fix it but its still not showing to other player
just tried both, its not that
Ok what's the exact problem right now, does the health value update correctly now? is it only the widget the problem?
yes, the health update properly for the owner
the value doesnt update on clients?
or does it update but the widget isnt showing it properly
so I'm running the test with 2 clients, both client can see their own health bar update with the right value but they don't see other client bar updating
Inside the RepNotify, can you put a print screen node to show the health value on screen, so we know if it's the value that's not being updated or if it's the widget not displaying correctly
I just tried with a print string inside the HBWidget and the health is getting updated properly for both client, same inside the repNotify
The problem lies here.
no its working fine otherwise the bar wouldn't be updating right
Begin Play fires on both server and clients.
The cast will only ever succeed on the owning client as controllers do not replicate to all clients.
Controllers still exists on their owner clients
otherwise the clients wouldnt be able to move as the input wouldnt be mapped
oh i misread i think
yeah wait
Right, but the begin play is triggering on clients as this is on the character, but other clients won't have the controller.
So Initialize will only ever be called on the server and the owning client.
If my player is mounted on another character using possess, when my player disconnects, the mount disseappers and the character on top stays. How do I solve this>
there should be a "OnDisconnect" event that you can then check if that player was on the mount or not
In gamemode?
ye
EventLogout
i am not sure of the name
I only have access to controller. How can I get the player?
im 90% sure u can get the player from the controller
So the issue is deeper.
umm, maybe im wrong
So my mount disappears and the character on top stays. I don't want the mount to get removed.
well, then u probably need to unposses whatever it is that is being possesed when ur character logsout
ive never done anything similar tbh
I'm trying to understand the concept. I can then figure out the implementation.
Anyone has done something like this in the forum?
this might be usefull
a lot of terrible suggestions in that thread by just a cursory glance
Is MarkItemDirty() gone in unreal 5?
So I'm doing it in blueprint, so I assume EventEndPlay is the one
Why do we do this and what does it mean?
This is a simple upper body montage playing representing a melee attack
is this so that it doesnt run on my client because i cant see the mesh since its owner no see?
So it saves resources?
I don't think you can override that function via blueprint?
well, if you are doing multiplayer with only blueprints u are in for a bad time...
The issue stems from the Game destroying the PlayerController when they disconnect which then calls this:
void APlayerController::Destroyed()
{
if (GetPawn() != NULL)
{
// Handle players leaving the game
if (Player == NULL && GetLocalRole() == ROLE_Authority)
{
PawnLeavingGame();
}
else
{
UnPossess();
}
}
Which results in the pawn being destroyed:
void APlayerController::PawnLeavingGame()
{
if (GetPawn() != NULL)
{
GetPawn()->Destroy();
SetPawn(NULL);
}
}
To resolve, one would have to override PawnLeavingGame() or Destroyed() to remove this behaviour.
Yeah let me show you what i did
i think hes only working with BP's tho so...
Basically On click leave button I have an event called in my base player controller which calls an interface, that basically ragdolls my character and kills them in game (ran on server), back inside my widget i then carry on and destroy the session caller so it logs my player out of the match and then can just put my player in the menu again
The interface though to ragdoll my player and kill him is binded in my player class
hope binded is the right word
So it can't be done in blueprint?
Destroy session caller event in my game instance
Nope. You can get an event in PlayerController called Destroyed in blueprint, but it doesn't overwrite the existing behavior in C++.
PawnLeavingGame there's no call in blueprint.
Hi guys. I have a multiplayer game and server all done from source build (windows)
What is the easiest way to Pack it for Mac Version.
I have 2 MacPro 1st is on M1 Pro chip 2nd is on Intel i7 when I drop the project to Mac M1Pro I can play the game in Editor and all works, but when I want to Pack it, it says Unknown Error.
Same if I want to connect to the server from Editor, its not going through.
Connecting from Editor to a standalone Server is not really adviced, since the editor does a lot of extra quirky stuff.
So you should focus on packaging. And the easiest way to package for Mac is to have a Mac and package it there.
If you run into errors you will have to figure out what they are. There should be more than Unknown Error to find in the build log
is it a problem If on windows all done on source build 5.1 and on Mac I am using Epic build 5.3 ?
I have a question, i have created a component that can store player data such as collected points to a webserver
however i am not sure where to keep the component on, like what is the best practice
i do not want it be live on clients sides, so i was thinking of creating a gamemode with that component attached. but scores are store you know in player state, so maybe game state ? but as per documentation game state lives on all clients
i do not want to work on security aspect yet ๐
what do you suggest
Hey guys, if I have two Characters and I want them to be able to just move in a scene, I just need to place two player start and set bReplicates = true in the constructor right ?
I have created the elevator system so that when you click the elevator button from any floor it will call the elevator to that floor.
Iโm trying to get an animation of this to happen and I have it so that the elevator floor will always โriseโ up to the correct floor@but for some reason if youโre below the floor that the elevator is currently on and you call it to your floor then the elevator will teleport below the floor and then rise up to the correct floor.
In theory, it works but if someon was to be on the elevator this would cause issues in where players are located and would glitch you below the floor you actually are very quickly and the take you the proper floor
Anyone know of a way to test a steam multiplayer game on the same PC ? or do i have to install on a 2nd pc(which is a bit inconvenient) to test?
You will need either a second PC or you'll need to run a virtual machine on the first PC
I assume a Virtual PC will need it's own Steam account also
usually yeah
Shouldn't be too much hassle installing on a second machine if you have an App and a second account, just push to steam backend and download on each client.
Ah ok thanks, I really didnt want to keep walking back and forward from pc,s located in different rooms of my house when one is downstairs and one is upstairs
well the good news is you only really need to test it to ensure its working
Is there any better solution than using replicated TArray<FKeyValueStruct> variables and then updating TMap variables from this array on the OnRep function to fake TMap replication?
Hi !
So I think I missed something somewhere, or it is not possible like this.
I have a TArray<UCustomSaveGame> that I want to replicate to the client
the replication happens but the values in the TArray are all null
My initial thought is a savegame could be replicated, but it might seem I could need to wrap them in an actor and set it to replicate ?
Any replicated actor can be replicated as a reference
Any non-replicated actor must be stably named (loaded directly from a package)
Any replicated component can be replicated as a reference
Any non-replicated component must be stably named.
All other UObjects (non actors or components) must come directly from loaded packages```
guess that answer my question ... right ?
not even sure wrapping will work actually
Avoid the TMap entirely ๐
Is it possible to pull the player controller (whatever it might be controlling at the time) on the listen server without any more information?
This would be in the context of a pawn that is calling server methods.
Only the local one
The one of other players is better retrieved relative to whatever they are doing
So in my case, I have a customizable bullet that is a pawn to support once it is fired, tracking it's behavior. The player will have orbiting, zoom, and pan functionality in flight to see where it is going. When a player fires a bullet, they hit "T" and snap to that pawn. In the case of subsequent bullets, hitting "T" from bullet view will move the next bullet and so on until they get to all bullets then return to the player. So in my case, where is the ideal function to 'possess next bullet' and from where should the controller reference be pulled?
The T input to call PossessNextBullet should likely be on the PlayerController itself.
Input (On the controller) > Run On Server > Find appropriate bullet > Possess (Self) to the bullet to be possessed.
I...dont..have...any...functions...on....pc
You could technically put the input on your character and on the bullets, but you'd be duplicating the code unless you have it call somewhere else. You should be able to "Get Controller" from a possessed pawn which you should be able to use to possess with and not need any casting.
I would question if you want to do that
The whole possess of a "Pawn"Bullet
If you just want the camera to follow etc., you could simply handle that via the PlayerCameraManager
It becomes increasingly difficult to map a player to their actual Character if you unposses it
@surreal plaza
If it's not like the Redeemer, where you actively street the projectile, I would not make that a Pawn anyway
I would just have a "LastShotBullet" or so an array of those on e.g. the Character
And then in the PlayerCameraManager, get the current ViewTarget, which is the Character
Check if the Character has such LastShotBullet
And then set the Camera accordingly
That way you keep all the ViewTarget benefits of you character
And if the character dies, you still have a valid PlayerController and PlayerState assigned to assign deaths and kills and what not
I have what might be a very basic question, what is the "right" way to have a player control a secondary item in a multiplayer game at the same time as their possessed pawn?
I have vehicles that can have a turret attached. The turret is a spawned actor that is attached to a socket on the vehicle pawn. When not online, it's simple to just directly update the transform of the turret rotation form the pawn BP. But online that doesn't work even if I'm calling for the server to then multicast that to clients.
I'm guessing this is a known thing as it's really just the same as having a weapon pickup that has it's own animations/features. Wondering if anyone has a any pointers or article links for the right way to implement.
Does anybody know more about the Steam online subsystem? #online-subsystems message
I want to run some blueprint code when both my playercontroller and playercharacter are both spawned and connected on both server and clients (my controller spawns the character). sounds simple but driving me a bit crazy.
I tried running the code in playercontroller OnPossess - But only called on server
I tried calling a multicast on playercontroller from playercontroller OnPossess - doesnt get called on client, eventually found it playercontroller is special and replicated unique
I tried calling a multicast on my playercontroller from OnPossess in the playercontroller - Doesn't get called on client because the client seemingly hasn't spawned its version of the playercharacter yet
I tried running it in beginplay with a IsLocalController check followed by a server call to run the code on server as well - works on client but for server the controller isn't assigned to the playercharacter yet (pre-onpossess I guess)
I really wanted to avoid using delays. Is there a proper way?
OnRep_Pawn is probably what you want to override for clients, then OnPossess for server. Have them both call the same function.
@prisma belfry alternately run something from the playerPawn onBeginplay? As that will only start once it's been spawned, and the controller is already in existence. Depending on what you need to trigger and replicate where, you should then be able to have an event run on server copy of the pawn and multicast to the other copies.
I tried that @vivid river but on the server "GetController" returns null ( on client it works)
OnRep_Pawn seems interesting, I'll try it
oh OnRep_Pawn is not exposed to blueprints but I can add some C++ specifically for it, just hope it works then
OnRep isn't called for all clients though, specifically the local. Is there a specific reason though that you're targeting all clients & the server?
its a vain reason maybe, I just want to assign a damn casted version of the player character on the playercontroller, but I refuse to believe it can't be done cleanly so im taking it as a learning opportunity
/** Pawn has been possessed, so changing state to NAME_Playing. Start it walking and begin playing with it. */
virtual void BeginPlayingState() override;
also looks very interesting. Excellent documentation ๐
net profiler on a source build is showing up blank after recording a session. Anyone know why? I even build the sln.
Hello i was wondering how do i get the player ping to the server ? i want to have a widget where the player can see how much ping he has .
I am trying to get my steam to play nice with lobbies(i am using lobbies as parties cause thats what the documentation leads me to belive they are for).
When i join a session it creates another lobby and disbands the previous one, basicly it ruins the previous party.
I did some digging into the subsystem and from what i understood there ate 2 types of sessions, "internet sessions" and "lobby sessions" (correct me if i am wrong).
When "use presence" is true, it creates a "lobby session" but when its false it creates an "internet session", im trying to mess with that to see if i can get the session to create without creating a lobby.
My issue is that i cant create a session without "using presence", does any one know how to do this, is this even possible?
not sure if to put this question in multi or animation or someplace else but
i was wondering whats the best way to make sure all clients know another players yaw / pitch etc
mostly used for head rotation and aiming offset
GetBaseAimRotation can give you the pitch afaik
seems like this fixed the 'pitch' but not the yaw
Yeah it will do pitch only
maybe i could try without the delta, i am pretty bad at rotators and vectors so a lot of the times its guesswork for me lol
AFAIK the entire ControlRotation isn't replicated around, but you might find it somewhere
i remember in some project i just did a multicast inside the pawn or the player controller itself then read the value from there
which will work i know but it feels clunky
from player input to server to multi basically
could crack open lyra again and see how they handle it
yeah it looks like remoteviewpitch is the only automagically replicated view property for Pawns afaik
kinda annoying
I guess it's based on the fact that most of the unreal games use the pawns yaw as the yaw
I'm getting a fatal error with my fast array
LogWindows: Error: appError called: Assertion failed: FixedShadowIndex > Index
Okay, I can replicate it. It occurs after:
- Add an item to the array
- Use the item
- Add another item to the same slot
- Attempt to Use that Item and then Remove that Item
Seems like my health on a client is always 0 when I press play in editor so it's instantly destroyed, if I remove the destroy then client can walk fine but can die again if damage is applied. It always triggers health changed and kills the client like something is dealing damage to it but nothing is
i'm using 'play standalone' with 2 clients and a dedicated server to test multiplayer.
the issue i have is that the derived data cache isn't used, so it always has to compile shaders which makes testing very onerous. is this normal?
Having to compile a few shaders doesn't mean the DDC isn't in use.
It means a few shaders need to be compiled, which can be for a variety of reasons, most of which are at a minimum ignorable.
hmm. these shaders compile every time (i wont change anything, do 2 tests in a row, they still compile).
is there no way around this?
helpful to know that regardless though
Well standalone opens semi standalone instances of the game
If there is no apparent reason for Standalone and you just want to test something, simply play in the Editor
@cloud lake
Hi everybody,
I'm working on a multiplayer project and I have a question about PlayerStart.
Do I have to put them inside the editor or can I spawn them from C++ code?
Ehm, why?
Like, the PlayerStart is meant to be a Transform with some extra fluff for your Character to spawn at
So it kinda should be placed into the level
If you are determining the transforms in C++
Then the PlayerState becomes redundant in that regard
But I mean, you can still spawn them from code if you want
I'm pretty new to Unreal, I was understanding that you need a playerstart to spawn the Character in the level
We want the project to be used by lots of people, so I don't want to put the playerstart by hand
No you don't need them.
By default, if you don't change anything, UE's GameMode spawns the DefaultPawnClass by finding a PlayerStart
All of that can be overridden and changed or completely ignored
For Multiplayer it's usually good to override the given functions
E.g. FindPlayerStart or ChoosePlayerStart
And then doing whatever you want in there
@thin stratus thank you
There is a case in my game where I want to make effectively a knights of the roundtable type of situation. So for any X number of players, they are evenly distributed around the table. Is that a case where code based spawning is advantageous?
Yup โฆ you want custom spawning logic you make custom logic
Hello, does anyone know what's the correct way to forcefully disconnect a client from a server?
Change Level to something else
Do I need to do that client or server side?
Client
uhh, alright, thank you
@mystic estuary You can try destroying their playercontroller on teh server
@thin stratus I am trying to move some functions to my playerController like we discussed yesterday. I am trying to give my custom pc a reference to the gun on begin play using GetController. That way, I can do Input->Run On Server -> (Gun) -> Find appropriate bullet. But GetController only works on the listen server player, not the client side players. GetController returns null. Is that expected or do I potentially have a wiring problem?
BeginPlay is too early to access teh Controller on Clients
That's what OnRep_Controller or OnControlledChanged is for
Nice, thank you. Do you know a good diagram online for these more subtle points?
Well, actually.....So right now the controller method is server. So it is like customController {[Server]DoGunStuff()}. My thought was to wire up those references server side, so then it only needs to know about the gun. Is that not the right way to do that?
If the DoGunStuff is in the Controller then sure
I usually place my RPCs into the Gun
And make sure it's owned by the Client
And then they need the ref on the Clientside too
But it's honestly enough if you keep this all in teh Character
Iirc the stuff we talked about was the projectile follow stuff?
The ViewTarget is the Character anyway at that point
Yes, this is the projectile follow stuff.
I've noticed after switching to 5.3 that RPCs seem to be limited by MinNetUpdateFrequency quite heavily. I always thought that only affected replicated properties, so it has me very confused. I thought RPCs were meant to be sent instantly?
For now, we have a simple throttling mechanism for multicast events: a multicast function will not replicate more than twice in a given Actor's network update period. Long term, we expect to improve on this and have better support for cross channel traffic management and throttling. - https://docs.unrealengine.com/5.3/en-US/rpcs-in-unreal-engine/
That must be it, just super weird I never ran into this issue until recently.
Maybe there were changes to when actors get "throttled", or maybe I'm just losing my shit. I'm positive I never ran into this issue and I am doing things virtually identical to what i've done before over the network.
So ive been watching and getting a semi overview on multiplayer works.
I wanted to start going step by step and this tutorial series seems like exactally what I am looking for, but Im a little worried since its from 7 years ago. Should i be worried about that?
https://www.youtube.com/watch?v=abmzWUWxy1U&list=PLZlv_N0_O1gYqSlbGQVKsRg6fpxWndZqZ
In this video we take a look at the finished project and step through each of the features that will be covered in this series. We show our functional Main Menu and its options, a lobby where players can chat with one another and select their characters for the game, some server options such as changing the map or match time as well as the abili...
or if anyone knows of a better series id love to watch them
I have an odd lifecycle question, what causes a pawn to be spawned for a player controller on remote client connection, then possessed and promptly destroyed, then spawned again and possessed like nothing ever happened? I have HUD functionality that is created OnRep_Player state and sometimes the HUD is claiming the character is null. (mostly during bad simulated latency and packet loss). The HUD is only created from the player so its really not possible for it to be null unless its destoryed. Ive noticed that during this odd behavior, the camera view goes onto the pawn, then down to 0,0, then back to the pawn, presumably the new one the gamemode has created.
Hello, I'm trying to make ActorComponent that binds its function to an input but it works only on server and not the clients
what am I missing?
Begin play is prob too early for client. Your controller is prob null
@spark shadow
hey , need help with this approach , a multiplayer game , players go through a series of levels , in those levels they collect points , and the points travel with players as they go from level to level , how do i achieve this score track system ? like , i want each player to store his own score
not necessarily a step by step guide , i need the approach and i will find my way
There's a persistant data compendium in the pins here.
Off the top of my head you have some options:
- Use PlayerState to store the values and use seamless travel - there is more info in the persistent data compendium on how to copy values between travels using this method.
- Use save games on the server for each player. The server uses the unique net ID of the player for the save game. This can be loaded into the playerstate when you want to be accessing and modifying it. Save before moving, load when a level begins.
- Use save games on the client and send the data to the server on begin play of their controller. This would require you to trust the client to send you the correct points they have which means they could spoof it, so it's not very secure. This does allow your clients to connect to any server and retain their points.
- If the points don't need to be persistent between server launches, you could use the Game Instance of the server and store the points in a Map variable of Unique net ID to Points, and then look up the player points from there on level loads and replicate them on the playerstate and store them back in the game instance before moving levels.
Hi guys I'm working in UE4 using Online Subsystem Steam and the node 'Host Session'. My question is, do I need to specify a map for this? If I create a session, will players who join said session just get teleported to the map I am currently in?
Is the GameMode always loaded? do I ever really need to check if the game mode is loaded if im, for ex: checking something on it - on begin play in another BP ?
Well, game mode doesn't exist on clients but otherwise, it mostly ends up spawning all the other classes like GameState, Controllers, Playerstate and most often the player pawns.
Related: Detailed Actor LifeCycle Diagram
ah i see thanks, that makes alot of sense
Hi!
I am looking for a cheapest way to store player data for read / write on a remote server.
I also want to use Unreal 4.23 for HTML functionality
If anyone has suggestions for what to look for, please let me know
That's not something that is really pertinent to Unreal itself.
Cheapest way to store player data on a remote server also isn't very descriptive of what it is you're actually trying to do. Like, I could suggest that you have a small Raspberry PI or some old computer hardware hooked up to your home network that you then have an API on that you can call to save small bits of JSON and retrieve the data from. Could essentially be free save for your power and internet usage.
I want to have a database of items collected by each player and they currently equipped items
So essentially a Map of player name -> equipped items index array + owned items index array
You'd need to research how you want to store that data first using whatever tools you want to use (Bunch of JSON files, NoSQL, Postgress, MySQL, DynamoDB, EOS, or using a BaaS like Photon, Playfab, Braincloud, Acceleratxr, Accelbyte etc.), and find out how you can have Unreal communicate to those services. Unreal is ultimately flexible and can be set up to communicate with any of these kinds of services and there is no single right answer for what you're trying to do based on what you're describing. The difficulty level and cost of setting up and maintaining such services depends on how you want to approach problems like uptime, scaling, backups, security, authorization, etc. and can even be influenced by if the service you want to use has some form of Unreal SDK you can implement or has a plugin for you to use which can make the Unreal portion of it effortless. Again, cheaply can be a simple JSON file for each player that's hosted on some old computer hardware hooked up to your own home network. If you want more than that, you'll need to do the research and find what is acceptable to you and what price is right.
At the end of the day, all Unreal should have to do with it is sending requests and receiving responses which is most likely the easiest part of the entire process and all that this Discord is really meant to help you with - not saying you can't ask questions about this kind of stuff, but the help you'll likely find is limited :/
I'm really lost here. Can't figure out why the server is allowed to walk on top of geometry collections but the client is prevented/teleported. Any idea? I've tried messing with all of the CMC settings but nothing worked.
Getting any warnings in your output log?
Nope. I just tested it with a pre-placed Geometry Coll. and it worked fine. Maybe it's how I'm spawning the geo...?
but it's weird to me because they are clearly the same geo on each screen not sure why that would matter
I believe it can matter as if there isn't a shared reference to the geometry that is known about on both the server and client, then the server doesn't know what the client is walking on and corrects their position to what they know the client can be walking on.
Oooo
I'm basically triggering it via an interface and then repnotifying a non replicating event to spawn the geo
perhaps if i call the event on the server?
Hmmm nope just spawns on server then haha.
Hmmm seems no matter how I spawn the geo nothing changes.... wtf lol
Errr. nvm, somehow figured it out and not sure what I did haha. Thanks for the words @sinful tree you're great.
You should only spawn something on server side
If the actor is set to replicate it will spawn it on the clients
Yeah I know the problem now is even though everything seems to be replicated, spawning a geometry collection with replication doesn't seem to spawn it on client without a multicast.
I'm also spawning a component, not an actor
Sorry, "adding" a component.
This replication in the geometry collection is what fixed the movement, but now I can't affect the geometry on the client. D:
Might have to change my geometry collection component to spawn a new actor or something lol
Anyone see a problem with making a "ClientState" macro library like this:
You are mixing NetMode with NetRole, they are two different things. A client could have authority over an actor if they explicitly spawned it. Read the pinned tips and tricks article, it explains the two.
Authority doesn't really check whether something is a server or not. Authority is whoever is in control of an actor. An example of where this would fail is if you were to use it on an actor that was spawned only on a client, in which case the client is the authority, but your custom macro would return listen server.
A better check there is if it's not a dedicated server, check "Is Server" and if true, then it is a listen server, if false, it is a client.
Is there a way to make some replicated vars be part of the spawn bunch a client receives when the server spawns an actor?
Tranek said something about using AbilityTasks to replicate, but what if i dont use any AbilityTasks but my code is only like this, how do i replicate?
In blueprints you can mark variables as "Expose on Spawn" and "Instance Editable" which would then give you a place to insert values when calling the Spawn Actor from Class node.
In C++ you can use SpawnActorDeferred() which then allows you to call some functions and set variables before calling FinishSpawning().
In this case you're accessing the Character Movement Component which handles its own replication.
In fact, this ability wouldn't need to be run on the server at all.
I just do this and when i click nothing happen
But it worked on the listen server
Oh maybe it's not a replicate problem
becasue my client isnt even jumping
Jump is already built into the CMC itโs even got client side prediction thereโs need for an extra RPC.
The character movement component already has its own built in mechanisms for replicating movement. There is very little benefit in having to RPC to the server to request to jump which then grants the ability and triggers it - in fact, this'd be kind of bad as you're having to wait the round trip time to actually get the movement response, so if they had 200ms ping, they'd be waiting about 400ms to see that they jumped.
If you want to gate jump behind an ability for ensuring tags are met etc. Just grant the ability the one time at start up. Then trigger the ability from the input press, no RPC needed.
Anything movement related you probably want to have the ability granted from the get go so that you can at least have some client prediction working so it doesn't feel unresponsie.
I think i'll do that later, now my ability isn't even firing
Interesting... and variables set before calling FinishSpawning are guaranteed to make it to the clients as part of the spawn bunch when opening the channel?
I'm not entirely sure, but I am sure that references that don't currently exist on a client wouldn't exist if they were referenced when spawning the actor either.
Your best bet is almost always to use OnRep variables and trigger the logic they require when they have been replicated. Even if it's a one-time thing and you want to ensure several variables are received on the client before doing something, you can build up some local logic (think a bunch of booleans set locally that you check on a function call each time a variable is replicated) that checks to validate all information required is received before continuing.
Alright, yea that was the alternative was just hoping to avoid it if possible. Thanks for the info ๐
Hey guys, i have a bit of an odd request but i guess it still inside of the scope of this channel.
Let's say you are interviewing some one for a junior network position, what questions would you ask?
Feel free to PM me the questions if you dont wanna spam here.
befoer i give myself a bunch of onerous wrok, anyone have this issue:
I have a sysstem that attaches weapons to my main agent mesh. works great in single player, and it also works in multiplayer. As long as i don't use the 'DefaultWeaponPickupScale' variable i have, so i can make adjustments to weapon size.
when i set the weapon mesh scale to say, 1.5, the weapon still spawns but it has a major offset so you see it flying around in the air.
i can fix it by 'baking' the scale of every weapon mesh, but it will suck to maintain and i also have about 20 weapons/agents.
anyone else experience this issue with scaled meshes not replicating properly when attached to sockets?
In PlayerCharacter, i have OnRep_Controller() and OnRep_PlayerState(). But i want an event in which i have both PlayState and PlayerController. Do we have that event?
the only thing i could find is OnRep_Owner(), but it doesn't have both
there is also an event called PreReplication(), but there is no PostReplication() which is quite weird
Canโt you just get the player state on rep of the controller? It seems weird on rep would return multiple variables since itโs activated when one specific one changes? Maybe I am misunderstanding though
Right I just mean, OnRep fires when a variable is changed. How would it handle two variables changing? I would think if u need playerstate in your onrep controller you would just get it using onrep controller -> get controlled pawn -> get player state from pawn?
but my player state didn't exist in that event
Then how would u have an onrep cover both ? Bit confused
What are u trying to do
hope this isn't a dumb comment but you're aware you can create events that have inputs right? so u can easily create an event that takes a player controller and player state as an input.
i had some issues with attaches and placements and it turned out i had a messed up base scale in my BP, it was like 1.1 instead of 1, not sure if that is relevant to ur issue.
Outside of that the only issue i can think of is that its not attaching to the socket in the server and only in the client?
i only run attach on authority and then replicate the weapon actor and mesh. works perfect in single player and multiplayer, just not when its scaled in multiplayer :/
im not sure if that is enough, first i would check if i have all components in the weapon set to "replicate" and if not i would set them all to true
but where do i broadcast that event then, still need an event
i think ive read something about position not being replicated by default in the documentation
but i cant recal
well what are you trying to do? if this is something related to the player spawning, you can put it in 'EventHandleStartingPlayer'
OnRep_PlayerState:
if(isValid(GetOwner()))
CallYourEvent()
OnRep_PlayerController:
if (isValid(PlayerState))
CallYourevent()
right
right but that's some racing so maybe not very right
i guess I'll go redesign my system
yeah it sounds like you're just hoping there's some kind of OnRep that handles 2 variables changing and being valid at the same time, i don't really think it can work like that\
Movement Replication
If an authoritative Actor has Replicate Movement enabled, or bReplicateMovement is set to true in C++, it will automatically replicate its Location, Rotation, and Velocity.
check that variable and see if anything changes
like 'if this one is valid, poll the other one till it changes and check if thats valid, then let you run a function'
triple checked and yeah they have replicate movement on.
i think i've found the best solution for now which is just using the 'import scale' rather than rescaling them in maya. that means i can just modify the scale with 2 clicks by reimporting the mesh after modifying that import scale which seems to be bomb proof / always works in multiplayer :/
but yeah, scale seems to consistently break them (float with a major offset).
could the scale also be scaling the socket relative location to the object?
i dunno man, seems like its gonna be trouble down the road
yeah def has already, i tried to fix this for good a couple months ago, game is pretty playable atm etc.
this runs on authority
then the attach runs
Wait, after i give ability to ASC, can i activate it once or infinite amount of time?
what is ASC?
Infinite
Ability System Component.. you seriously asking?
yeah i was, i just wrote ability system in our game
but started in 4.26 so, prob the default one is better now
oh.. i sometimes forget this channel is actually multiplayer
thought it's the same channel with GAS
my bad
they are all the same undocumented thing really
so I got a question regarding using GameInstance as a way to store persistent variables between open level (hard travel). Right now I have a set-up:
- Players connect to server 1: a Hub-like lobby where players equip gear, abilities, etc
- They can start matchmaking (via Playfab) and once enough players match, they all move (via open level - hard travel) to the new server (server 2)
What I'm trying to do is store the players various data like equipped items/ equipped abilities/etc since the pawn/player controller/playerstate are all going to be destroyed. From my research, the only thing I can find is to store it in the GameInstance. Locally this works when I store variables in the GI and retrieve them on onPossess but unfortunately it doesn't seem to work when I am actually testing between two separate servers
so my question is: Is GameInstance the wrong approach to store this data? as far as I understand, the GameInstance should live throughout the life of the current play session, but in real server -> server travel it doesn't seem to work
i've had this issue before and created a PlayerData struct inside the playercontroller, then when the playercontrollers swap on level travel, i pass the data.
your setup might be a bit dif from mine though so maybe there's an easier way, but yes i have had the issue with PlayerData (when i tried to stash it in the game instance) not persisting when server traveling.
the Event Swap Controllers gives you an opportunity to pass the data as the controller is destroyed and respawned on travel
i guess i'm not really storing it in the game instance at this point though, when you think about it. but the variable does exist there too.
ah yeah I initially had that which I wish I could use because it'd make life so much easier, but the problem is that is only seamlessTravel which means I'd need to have the server travel with the players if I'm not mistaken. The problem is hard travel doesn't call Event Swap Controllers
unless it's possible to seamless travel for clients and not servers? right now i'm calling open {ip}:{port} for my traveling, which I understand is a hard travel -- don't know if there is an alternative!
so you're saying, there's 2 dedicated servers and you're going between them?
like, in my setup, i have:
server: running multiplayer lobby.
client: running 'entrymap'.
EntryMap does the 'hard travel' you're referring to on each client, which loads both players into multiplayer lobby (running on a dedicated server, idling away till players join) using ip:port.
once they're in multiplayer lobby though, everything needs to happen at the server level for me since i want both clients to travel at the same time. if the server was running a dif map to the client, i imagine it would just bioot the client because it assumed it was cheating or something.
if you wanted to have one client then load into another server running say, multiplayerlobby2, i'm not sure how you would get that to persist.
(unless u were doing it with like, a user account or smoething which would definitely work).
maybe its possible though.
yeah essentially two dedicated servers: one being the lobby that everyone can connect to and then the other dedicated server is essentially the โmatchโ when whoever queued goes into the server. So I donโt necessarily want all clients to travel โ just some, Iโm using Playfabs account system so I definitely have playerId and whatnot
so thereโs only every one โhubโ dedicated server but there could be a bunch of ongoing matches
ah so you want a social lobby
with say, 20 players
then 2 go through a portal to play
and join into a new server, but you want to keep their stuff?
but the stuff is only saved per session?
its a weird sort of middle requirement, like, if they have gear thats attached to a user account thats not just for one session, this is no problem
yeah I guess I was somehow trying to avoid api calls to fetch all their gear again on traveling but trying to explain it more now it seems I need to fetch all their stuff again from a db/service that has everything set
well, just to be clear, what stuff are we talking about here
So each player has equipment/inventory per account that is attached to their account. But they donโt necessarily need to take everything into the match itself, only what they have in their inventory/equipped
sure, you can persist it between multiple matches for sure tho.
i do that in my game, where they can rematch and the data will persist.
but if they went to a dif server and i wanted to display wins and losses between sessions, i would have to do the api call
like martin plays leorange a 3 round match, i can have it update the score each match and view it between each, persisting the data in the game instance provided the server does not change, even tho the maps are restarting etc.
, and then we finish our session, that kills the server container. now i come back (joining a dif server ip / dedicated server instance), and i want to see 'total wins' or something, i would have to do an api call there i don't really see another way to do it.
there could be a way though, my knowledge is not exhaustive by any means.
but it seems like trying to join a server with a client that has its own data that is just kinda 'accepted' by the server seems like it would allow cheating
For MMO games, there may be dozens of map levels. Thousands of players are on different maps. The architecture of UE4 is that each map needs to start a dedicated server separately. When players go from map A to map B, they will disconnect from the dedicated server for map A and establish a connection with the dedicated server for map B. Because ...
so yea i think you either need to use something like socketio (we use this to manage the server containers) or varest or aws lambda etc.
maybe playfab hass something, no idea.
Ah gotcha, okay weโll that at least explains the weirdness โ appreciate taking the time to help!! Yeah Iโll probably just fetch via api on joining the new server the players data. Thanks a ton!!
gl. yea what i'm getting is you want to have some api way of accessing data for what you're doing regardless, its not like you're doing the most simple thing possible.
like there's the game multiplayer element, but also the social lobby element, you'll end up needing something like this for sure.
yeah I see why most games don't try going for a social lobby element and just go straight into matchmaking
I didn't really read what you're talking about, just skimmed it.. but you wouldn't use socket.io you'd want to use UE beacons
We used beacons in one of my projects to have some characters/admins replicate across dozens of dedicated servers
Can someone explain to me how a network replication system works
Because I'm going nuts
Something changes in the server. The server says, "who should I tell about this?" and sends it to the people that need it.
The people that need it the update their local values and potentially call an event.
multicast rpcs dont need an owning connection to go throug?
Only server can call multicast rpc
im trying to understand say for example, i want to show a message to every one, that comes from the server
how does that rpc travel, does it go throught the regualr way through the PC?
PC= playercontroller
Client -> server rpc -> multicast rpc
If you are already server
You just multicast rpc the msg
For clients you can only call rpc from things they owe. Typically they only owe the controller and the pawn they controll
let me put it this way, lets use the message example, i can do that in gamemode by fetching with a FOR LOOP all the player controllers and sending a client rpc through that, how would i do that with a multicast?
assuming im calling the RPC from the server
Game mode only exist in the server
exactly
So if u need to send msg, from game mode. Then you can do just that
Loop thru all player pc and do client rpc
Epic made videos for chat system in their official YouTube channel
ye i know that, im not trying to do that im just trying to understand multicasts better
Mostly uses the player controller
It used multicast too to broadcast the msg
You can take a look at it I suppose
Multicast rpc basically server telling all machine to replicate the function/event
Let's say u want to play a montage
If you want to multicast to everyone, run one on the game state.
It is replicated to and relevant to everyone.
A multicast rpc is sent to everyone the actor it is run on is relevant to.
If it's called on the client, it will still work, but only run locally, not be sent to anyone else.
ok but i would still need a connection of sort right?
if i want to communicate with a widget through a player controller
Yes. Rpcs only get sent to people connected to a server...
no i mean an ownership connection
No.
No ownership is required to receive an rpc.
A multicast rpc. From the server.
Or this wouldn't work.
so the owning connection is only for the "client" rpc
Correct
And server rpc.
A client rpc is sent to the owner of an actor. A server rpc requires the client to own the actor it is sent on.
another thing, i still dont quite see how a multicast would look like in the message example code wise
i would still need to do a for loop to fetch all the individual player states no?
maybe its just a bad example
and not the way multicast are intended to be used but from the documentation and description it looks like it would fit
There is no looping involved. The rpc does that for you internally.
And unless you call it on a player state, the player state is entirely uninvolved.
If you call it on a game state, it does not check anything else, it just sends it to everyone via the game state.
What example are you looking at?
im not looking at anything im talking about this example of sending a message
exactly, this is what is confusing a me
so i just do something like GameState->GetPlayerState()?
does GetPlayerState, even exist?
how does that call look like?
so that we can reach the PC
What is the example you are looking at?
i am not looking at anything, i just sugested the simple task of sending a message to everyone with a netmulticast
When you have a replicated actor, there's a "channel" that is opened on it. Multicasting on that actor from the server, regardless of who the owner is, will attempt to send a message on that channel.
If that channel isn't open on a certain client, say because the actor isn't relevant to that client, then they wouldn't receive the multicast.
that i got down, im just trying to understand how a multicast called directly for the server can reach players without doing any sort of loop
say i have an authority switch on my game state that calls a multicast on the server and i want to reach my players UI
theres gonna need to be a path to the PC's with pointers right?
You don't specify which players receive the message. They just all do. If the actor is relevant.
Not necessarily. Example: Create an event dispatcher on your game state. On your multicast, call that event dispatcher. In your UI, bind to the event dispatcher in the gamestate.
oh ok, so event dispatchers are an option
If you're multicasting from an actor that doesn't have a good path to find the local player controller like the gamestate, yeah, it's a bit tough.... I think maybe Get HUD -> Get Owner would maybe be the easiest way to find the local player controller from like gamestate or playerstate, assuming online play only.... But if you're doing HUD stuff, then maybe at that point you should be using the HUD class ๐
Local player subsystem...
i didnt even know that existed
more things to look into
how do u guys manage to fit all this stuff in your heads? its just so much information
10 years of UE experience? It all stays in eventually.
I haven't even done any mp work in 5 years. I just keep up to date in here.
ok so now a proper question, in tests ive found that players with bad fps have choppy movement, is there like a variable that i can turn on to smooth this?
im assuming its choppy because they are sending data irregularly and in less than ideal time intervals
Is my understanding correct?
GameMode only exists in the server so HasAuthority() always returns true in GameMode.
ye
Hi, I'm making a grappling hook using cmc. Phys function uses attach point location. I spawn projectile on the server and process the hit on the client and on the server, where I set the attach point value and set bWantsToGrapple = true. But in this case, there is a delay between when the player input and spawning projectile, and then in the OnProjectileHit function I process the hit on both the server and the client, where the hit point on the server is different from the hit point on the client. If projectile GravityScale = 0 then there will be no corrections, but in another case a large number of corrections appear.
What is the best way to spawn projectile in this case? Is it better to do this on the client? I know this may not be safe, so I would like to ask for advice on how best to do this.
What is in the GetGrapplingHookForwardVector function?
returns the camera's forward vector
So what do you want to do exactly? Do you want the client to predict the grappling and remove the delay? Are the hit points always different on client and server, or only when GravityScale != 0?
only when Gravity Scale != 0. In general, yes, I want to remove the delay so that the client instantly spawns his projectile and does not wait for the server to do it.
You can use UGameplayStatics::PredictProjectilePath on the client and start predicting movement based on that result.
You could spawn the grapple projectile actor on the client just for the visual effect
But then you run into the issue of the server projectile replicating down and you have 2
I know games like UT in the past would take this approach of syncing up the client projectiles and server projectile when it replicated
I don't know the specifics of your game but you could also have a fully clientside grapple actor if it doesn't need to do anything more than move along the predicted path
Ok thanks, I'll try
Sounds like you've fine tuned your compression algo if it manages to all stay in ๐
Hello, what do people usually do to create development cheats that should do something that can be done server-side only, but should be usable client-side?
For instance, what if I want to create some cheats to add health to the character using GAS? Gameplay effects are only applicable on the authority
Does anyone use "advanced sessions" plugin? Can someone explain what exactly does it do? Their documentation is very weird and redirects me to the VR page, on github it says "for unreal engine 4" but apparently also works for ue5?
Advanced sessions just expands the functionality provided for the steam sub system.
I can't remember everything specifically but
It gives things like a server move node to move your lobby and
More lobby/session set up options
Ok, gotcha
Speaking of, there's NO official way to append custom session data like name, game mode etc. Without messing with the source code yourself correct?
Yo guys, im making a game where a few players are survivors and 1 player is the monster and i want to test some stuff. I had the question of how i would randomly choose 1 player that loads in my level to play as the monster and the rest as the player character BP. How do i do this?
Sort of need to know the number of players that will be joining the game first. Based on that you would wait for them all to join, or for some cut off time in case they don't all join, and then choose one of the players from the PlayersArray from the GameState, and do whatever logic you want with that particular player and do whatever other logic with the others, and then start the game.
Guys!!! I know this is like very chaotic and hard to understand probably but i have a problem and lack the knowledge to to something about it. I have a somewhat simple idea and will try to explain it as simple. Players join a level. One player needs to be monster. Other players need to be player. I have made a very messy blueprint of this and its not working at all. I have made a monster spawn point actor and a player spawnpoint actor. its so hard to explain that im gonna provide screenshots. I would appreciate every help
see Datura's earlier reply
i see... So basically i would have to set up the scene to be a black screen with maybe the text waiting for players to join
Once all players join > Loop through players > Check if Monster
Monster > Spawn at monster spawn point
Not Monster > Loop through spawn points until you find an empty one, spawn the character & possess them, break this spawn point loop when found.
Completed Loop > Start Game.
If you want to add variety to where players spawn and not always the same set of spawn points, call a shuffle on the player spawn point array before calling it so players would be randomly distributed.
okay so the method of looping through spawn points and checking if they're empty is correct but just need to add that break and wait for every player to join?
This part is no good as each call of the loop body it'd be pulling another random number. Pull the random number and set it somewhere before looping, then you can check it within the loop.
Otherwise, yes, your set up looks mostly ok.
like this?
ah i see
you think i need c++ for the part where i check if all players joined because i cant seem to find documentation on that from unreal
Yo man i have already implemented the break but there is something weird going on where there is always 1 unpossessed player character just standing there when there is no player controller to possess him and the monster that spawns cant be controlled he just stands there.
and oh yeah the players are getting spawned at the same playerspawnpoint... Im so sorry to be taking up your time but im just tryna learn :p
could this be a problem where the MonsterPC isnt being excluded from the array so it can be the monster PC thats being overwritten
this should fix that right?
Question, I'm starting a new project, it will be a prototype for a game that has some similarities with chess, will have multiplayer, both turn based and realtime, what makes more sense to do, start a new project and then add multiplayer or grab a working multiplayer FPS game from one of those out there and adapt it to a more RTS-ish like game?.
im gonna give up for the day
I am trying to replicate a rock switching colors when you click on it. Currently Server is replicating to client, client sees a color change but does replicate to server. I've spent hours on this, any advice is appreciated. More details below.
The rock is generated at begin play by an object called grid placer which places currently 64 rocks. When the player controller left clicks on a static mesh (I look for a "Tile" static mesh in collisions and I'm certain this is successful) , and event runs on server which multi casts an event in which an interface is called. This interface tells the clicked Tile to update based on color (color is a variable storing an enum in Player). Tile then updates an Enum variable which OnRepNotifies an event in Tile which changes the color.
Whatever this is probably shouldn't be a multicast.
In fact, it absolutely shouldn't be, as it's on the player controller, so it'd only ever run on the server and the owning client since player controllers don't replicate to all clients.
Input > Run On Server > Do things on Server like setting OnRep variables, OnReps then can apply visual changes for all clients.
Okay, thank you. When I remove the multicast I no longer see the visual change on the client but I'm getting the feeling that's actually closer to correct since it shouldn't be done there in the first place.
Check your hit result is actually returning something, I'm not sure Get Hit Result Under Cursor can run on the server (for a client, if it was a listen host's player controller it would work)
Rather, server changes appear in both, client cannot create changes
Okay, I'll look there. Thank you
Looks like it doesn't have a result for the client. What would you recommend doing for the client to click on the object?
You can gather the hit actor on the client when they press the input, verify it is valid, then pass it as an actor variable in the RPC.
The server should likely check that the actor is within range of the player or whatever other checks you want to make sure of so the player isn't attempting to just spoof whatever actor though when running on the server, and after validating, call your interface with the actor passed in through the RPC.
That worked perfectly. Thank you so much, that was countless hours trying to figure out what exactly was wrong with it. The colors are updating perfectly (inverted because cameras are on opposite sides) and I can finally get back to actually making the game. https://prnt.sc/6JONWEqFxy6q
netUpdateFrequency has a default value of 100 but in the documentation it says that a good value for pawns is 10
so which one is correct?
the 100 i assume?
I believe the answer is, it depends
if you have a lot of pawns fewer updates is better, especially if it isn't a game that requires tight replication
if it's a competitive game that requires high precision levels of replication, more is better
im not saying correct as in whats best for the implementation, im saying correct as in the best default value
clearly some one made a mistake somewhere, either in the code or in the docs
its more about curiosity than anything
oh, my bad. I can't speak to that
@limber gyro An appropriate default for that is going to be different depending on your game.
Its likely 100 because you will get a smoother experience, albeit at the expense of server CPU overhead.
Replication frequency is certainly something you need to be actively concious of as a developer and tailor it to your needs.
Looks like with Iris we might be able to schedule replication dependencies? https://github.com/EpicGames/UnrealEngine/commit/8bedaec173b3d77513569271ac9c0a3778c129a4
Sorry, I'm a bit clueless on your problem as I haven't worked with sessions very much myself but what you have shown is exactly how it's supposed to work.
what would be the cause for an actor disappearing when outside of net cull distance? Intended behavior is that it stays visible, just not sending RPC's, but on my actor it's disappearing when I leave net cull (I tested and changing the net cull changes the distance the actor disappears)
note that this is an actor that is spawned at begin play, placing it in the level works, but spawning it with begin play makes the actor disappear when outside of relevancy
That's exactly what culling is - the actor gets destroyed on any client it's no longer relevant for.
If you place it in the level, it's considered a "Map Startup" actor so does not get culled - but it's actor channel will be closed.
Hey, I have an object with collisions made via physics asset animated, but the animation does not happen on the server, so the server collisions stay outdated. What should I do to make it happen on the server, so my client can 'feel' updated collisions? I have VisibilityBasedAnimTickOption set to AlwaysTickPoseAndRefreshBones.
upd: Enabling 'Allow to tick on dedicated server' in Skeletal Mesh solved the issue.
how would I mark spawned actors the same way as "map startup" so they don't get culled but rather it's channel is closed?
or where is this functionality being handled so I can take a look at implementation
You'd need to spawn them procedurally and deterministically on Server/Client.
So they would have to have static names, and manually be marked as map startup actors. The latter part is easy, the former part is much harder. Could start by reading through this:
https://vorixo.github.io/devtricks/procgen/
thank you for that! huge help ๐
Oh my, this looks awesome!!!
https://github.com/EpicGames/UnrealEngine/blob/ue5-main/Samples/Games/Lyra/Source/LyraGame/System/LyraReplicationGraph.cpp void ULyraReplicationGraphNode_PlayerStateFrequencyLimiter::PrepareForReplication() { ReplicationActorLists.Reset(); ForceNetUpdateReplicationActorList.Reset(); ReplicationActorLists.AddDefaulted(); FActorRepListRefVie...
I'm looking for an answer~
I'm sure this question has been asked before, but what's the best way to handle spawning a replicated actor by the player controller? Since the PC only exists client side, I can't have a function that executes only on server on the PC, right? So I have to call a function from the playerstate that executes only on server?
PC -> Server RPC to spawn something. Done.
The Server has all PCs
Client only has their own
hi, I'm making a murder mistery game, where the murders have a red color name and only them can see other murder players with red name color, in multiplayer, event and replication how can I do that?
I created an enumerator with 2 different roles (normal and murder), and I even created an enum var inside the character
I'm trying that in player controller OnPossess
that's inside the player character
the problem is that like that even the innocent players can see the murders
Instead, set the color based on the replicated role and the LOCAL PLAYER's replicated role
compare them
The rule is "Text is red if this character is a murderer AND the local player's character is a murderer"
I'm actually a beginner in multiplayer in general (sorry for my questions in advance), how would I do that in bp?
Not sure if it's the best but this'll work
cast that to your player pawn class and get the Player Role
if it = murderer and self.player role = murderer then text is red
so in my player character I have to make an event, for example, UpdateColor and call it on join in game mode or player controller
in the UpdateColor event: if PlayerRole (got by pawn) = Murder and PlayerRole (own on character) = murder then set the color to red (on character)
Because it has the specifier "NotBlueprintable" on AInfo class, which is the parent class of AGameSession
Hey, i am having some trouble with network replication. Everything works fine while just doing normal listen server. But when I enable network emulation and set it to average, some events donโt run. My theory is the network is getting overloaded and some events that should get replicated just donโt. So when I remove the multicast event that is supposed to just play shooting animations, fx and sound, the line trace function runs fine, no problems, but as soon as I plug the multicast function back in everything brakes, as I said, some events donโt even get registered and are just ignored. So I wonder if anyone has this problem, and what your solution was, also if you havenโt had this issue before, I would love some feedback on how to optimize network replication and how to replicate Amin montages more efficiently. Thank you in advance!
Well for a start, the "average" profile is slightly exaggerated, but do you send any of these gameplay critical multicast RPCs as reliable?
Also replicating an anim montage itself seems fairly inefficient, instead of just having a minimal amount of information to do the same thing
The montage is likely replicated as a path to the asset, but if you had an event with a shorter name, or an enum, then that's going to take a lot less bandwidth
If you have a lot of inefficient reliable events, then the reliable channel can also get saturated
Maybe my brain isn't in the right place right now - but the name of the event has an effect on bandwidth? Am I reading that right?
the actual name of the UFUNCTION probably plays a part, yeah, but if the multicast is passing a UAnimMontage, then that's just going to be a whole-ass string to the (virtual) path of the asset eg. "/Game/Animations/Montages/Thing/AM_Thing.AM_Thing"
Yeah, the 2nd part yeah. But it was the first part that I was like, "wait what?" ๐
You sure about that? It's not a pointer to the asset?
how does that work over the network?
Fair enough
I was thinking along the terms of maybe the asset manager has some means of attributing assets to an ID or something along those lines, so if you did reference it across the network there's some look up magic that happens to find it. If it's sending the path, that does kinda suck :/
the asset manager really isn't as smart as it seems. unless the FName of the asset is in that master list of FNames (forget where it is), then FNames replicate by their string value rather than their numeric index
I do, and it doesnโt seam to change anything. To get you a better understanding, the multicast function is quite big, I designed it to handle whichever animation, sound or fx you put in the field when you call the custom event. What I didnโt think of is that this can be inefficient and slow, which leads to tons of unexpected problems. I see your idea with the enum, but I didnโt quite get it. If you could explain more in detail I would love to try. Lastly I want to mention that I am not using a ton of reliable events, just for the reasons you said, it can block the reliable channel, so the only thing really using reliable events are the crucial spawning and team selection events
And yes, I am sending a UAnimMontage ๐ญ
The average profile simulates packed loss that's actually much worse than what an average player would get. In that case, a lot of unreliable events would get dropped
I didn't know this to be honest. I like to test stuff on the worst case for both server and client ๐
as for an enum, it would be something like Multicast_BroadcastEvent(EMyEvent::EventType); and the client can use their own version of FX data to spawn the same effects
Things like animation, sound, or FX should be data somewhere that the client can read without having to be told by the server
Yes, I understand, but how would you replicate a shooting animation which should be โfiredโ or shown when a player shoots? Right now, as you head, player shoots->multicast play animation(To make sure everybody sees the animation montage)->line trace->
the client should know through data available to it (through a data asset, blueprint value, whatever) which animation it should play when a weapon is fired
do remote clients need to process a line trace? if they do then you could have an RPC replicating the minimal amount of data it needs to perform the trace
Like I mean, the line trace is the bullet of the gun
Also if I have a ton of different characters with different animations, would your approach still work
wouldn't the "characters" in this case have some kind of data asset or BP with the animation data in it?
the client should be able to tell which character/class/whatever a player is using and be able to read that from somewhere
Could work, but seams overly complicated. However I will give it a try. Thank you
how's that more complicated than replicating a whole bunch of asset paths every time an event happens?
whatever you're doing to determine those FX assets, you just do it in the multicast itself since the client likely has a way to determine it anyway
I see, I get your point now
Ok, so after some profiling... There is some magic happening. After the game starts up, the first time an asset is referenced through the RPC, it is a big RPC of about 80 bytes but any subsequent RPCs referencing the same asset from a client to the server or server to a specific client appears to be pointer references as the RPCs are only 4 bytes. Each client appears to have their own "big" RPC when they first send or receive this asset reference to the server for the first time. When attempting to call a different RPC after calling the first referencing the same asset, the second RPC is still small.
So it appears after first referencing the asset over an RPC, the client and server reference it as a pointer after that point. I tried calling an RPC in a separate actor component referencing the same asset after first calling an RPC and it still was only 4 bytes.
well that won't be a "pointer". clients and servers don't share memory, it'll likely be some kind of GUID
The first one is probably a path and a net guid. Then just net guids.
Got it. So when connecting to a server, send an RPC for every possible asset so you can go brrr during gameplay.
The network version of PSO caching ๐ง
I'd find it funny if there is already something built-in to warm the cache
I'm trying to understand the costs associated with multiplayer games on Steam. From what I understand I will need to purchase an app/dev id from Steam, but are there other costs I am not aware of? Let's say the game is Steam peer 2 peer, is that even sustainable for a large open world TPS? Would a dedicated server be required for such a game? I know how they work, but is there something else I am missing?
well how many players in a session?
I was thinking max 32 or 64?
if this is just some p2p co-op thing, then you probably can get away with listen
ah nah, 32-64 is definitely dedicated territory
consumer connections aren't that good
You tryin' to make Battlefield on P2P or something? lol
Just beginning to realize the impossibility of it lol
So, technically, the cost would be the dedicated server host?
well it's complicated. if there's only 1 "session" then sure
there are whole businesses built around game servers
Yeah I know how gaming servers work, I was thinking of paying for one so there are open servers in certain regions then allow players to buy hosting and host their own.
But I am just going off how SA-MP works lol I have no idea what I am doing yet but I know the goal post's location now.
having a baseline of official servers and allowing the community to host certainly could work
SA?
San Andreas
Ah
San Andreas Multiplayer
that old multiplayer mod
hey devs!!I need help with replication, but I haven't been successful.
This is how I setup my project:
Objective: To Show the team in which the client is in as a text on them something like how they do with Counter Strike
Setup:
GameMode spawns the Controller
Controller Spawns the initial Team Choosing widget to allow the player to choose the team
Once they do this, the Controller spawns the player and posses it
Widget is created from a widget blueprint which has a method to update the text values
After the OnPossess() method in the Player controller (which is working on the server side), the gameMode is used to trigger method in it called UpdateOnNewPlayerJoin() which uses an RPC chain:
UpdateOnNewPlayerJoin() -> Server_UpdateOnNewPlayerJoin() -> Multicast_UpdateOnNewPlayerJoin()
which then loops through all the stored Controllers in an array and Triggers the method UpdateOnNewPlayerJoin()
This chain is responsible for updating the Overhead UIs for now
My problem is that only the host is able to see the updated UIs on all the players while its not the other way round... I do understand that newly joined clients doesnt have the update history which is why the server needs to update it for every player... but for some reason, it just dont wanna update... it would be really appreciable if someone could help me with this please!!
Relevant snapshots:
https://drive.google.com/drive/folders/1kTh7dzG2qLA7X7YVLM_U5vUlFNwsWT_N?usp=sharing
Game Mode only exists on the server. You can't use any RPCs on it.
And player controllers only exist on the server and owning clients
Interfaces for the GI implementation seems a bit of a choice when we have S U B S Y S T E M S
oooo I see!!! actually I have the controllers refs stored there... so I thought it was logical to put them there
It's not even important to store references to controllers in the game mode. Your gamestate contains the "PlayerArray" which is the playerstates of all players in the game currently. From the PlayerState, you can get the controller it belongs to.
there's also an array of controllers (server-side) in the gs too
ah nah, nvm, you do have that step
misremembered
actually I was playing with the systems where I came across an issue where I was trying to trigger that GM chain from the pawn class in the OnPossessed() method and when I tried to get the ControlledPawn() ref from the controllers, it returned null unlike when I called that from the Controller... is it because I placed the chain inside the GM
ah UWorld has a player controller list
so is the GameState a good place to use as a root for all these massive chains
like for the purpose I have
I'm not sure how a team select got that complicated
am very new to the multiplayer... its just been 2 weeks of me into this
If a team ID changes on the player state, then an delegate from an OnRep can easily refresh the UI
so moving from single player... things have changed alot
Not particularly. GameState just contains that array, so if you want references to controllers, that's one way to get them without storing them yourself.
like the way things need to be set up and all
yes things are a lot different but at least multiplayer centric stuff usually works in singleplayer just fine
if a game is supporting both
I will give that a shot and see if I can reach somewhere with this... but thanks alot for the tip guys!!!
Actually I started with creating some basic mechanics and then moved onto try and make it a multiplayer... coz if not, I think it would have been difficult for me to find a starting point
I did realize it yesterday while reading through the docs... thankfully it was just some basic ones
I managed to do the stuff on the game state... but couldnt manage to get the replication... the additional changes I tried:
The player state has a stuct member which stores some deta related to the player... Instead of doing it on the client, I have shifted it to the server
Controller:
void AInputController::PawnSetup_Implementation(ETeam Team)
{
Server_PawnSetup(Team);
SpawnPawn();
}
void AInputController::Server_PawnSetup_Implementation(ETeam Team)
{
Client_PawnSetup(Team);
}
void AInputController::Client_PawnSetup_Implementation(ETeam Team)
{
if(UKismetSystemLibrary::DoesImplementInterface(PlayerState, UPlayerStateInterface::StaticClass()))
{
IPlayerStateInterface::Execute_InitialisePlayerState(PlayerState, Team);
}
}
Player State:
void AMP_PlayerState::InitialisePlayerState_Implementation(ETeam Team)
{
FMatchDetails MatchDetails;
UGameInstance* Instance = GetGameInstance();
if(UKismetSystemLibrary::DoesImplementInterface(Instance, UGameInstance::StaticClass()))
{
MatchDetails = IGameInstanceInterface::Execute_GetMatchDetails(Instance);
}
mPlayerDetails.Team = Team;
mPlayerDetails.CurrentMoney = (Team == TERRORIST)? 1000: 2000;
}
the 2nd window is the host
Client's can't call RPCs on the gamestate. Clients can only call RPCs on actors they own (Like Player Controller, PlayerState, their controlled pawn)
You also don't want the actual change to be a multicast. Use an OnRep to trigger anything that needs to happen when it changes, and for anything else, make sure it's reading the variable.
You also cannot reference player controllers of other clients. The PlayerState has a pawn reference too, you don't need to get the controller from it to get the pawn.
What even is the point of this RPC in the player controller?
The client wouldn't be setting values in the player state, the server would be
Funky interface usage too
I was taking the approach something like: Since all the inputs were getting triggered from the controller class... when the controller is done possessing the pawn, it will than call the Server method
Yes, which calls a client method
yeah... somewhat like... I have all the Action methods like Interact, Pickup etc which are calling the Server methods... so instead of directly calling the server methods, am using them
I mean... thats the kind of tree I am using for everything
The server should be doing the team assignment, but all the server RPC does is just ask the client to do it
And it has no authority over that data
Hi guys, I searched but I couldn't find a proper source or test. Is there a test about how many ccu Unreal's own multiplayer infrastructure supports? Of course it depends on the game, but what is the average power consumption and the number of people a single server can support? Can anyone who has tested and researched on this subject inform me? Thanks in advance.
The question isn't specific enough.
For what kind of game? On what hardware? Are we talking about a single server instance or some sort of scalable structure (which isn't actually part of unreal so if that's the case the question doesn't even make sense)?
Fortnite exists, there might be some info out there about what kind of hardware they run their servers on. Valorant also exists, and while individual games are on a much smaller scale they've given extensive details on the performance characteristics they hit on servers (and clients, for that matter).
Given that "power consumption" is mentioned the answer is "it depends" in every single case and for the most part the bit that it depends on isn't even unreal, it's the server hardware.
My question is actually for numbers like instant 1k ccu. But @latent heart answer was enough for me. Thank you very much.
With great power comes great power consumption
Hi, i'm hoping someone could help with a confusion i'm facing related to replication.
Take this example. I spawn a gun actor for all players in the network in the begining. Now on pressing P, every character's gun gets destroyed.
The above sequence works as expected when playing. The gun gets destroyed both on the server and each client instances.
Now the problem I am facing is when I try to make a c++ variant of the above logic.
The c++ header side is this
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Destroy Weapon"))
void Destroy_Weapon(AActor* weapon);
UFUNCTION(BlueprintCallable,Server,Reliable,WithValidation, meta = (DisplayName = "z[Server] Destroy Weapon"))
void Server_Destroy_Weapon(AActor* weapon);
UFUNCTION(NetMulticast,Reliable,WithValidation)
void Multicast_Destroy_Weapon(AActor* weapon);
The cpp implements are this
void UMyPhysicsComponent::Destroy_Weapon(AActor* weapon)
{
if(weapon != nullptr)
weapon->Destroy();
}
void UMyPhysicsComponent::Server_Destroy_Weapon_Implementation(AActor* weapon)
{
Multicast_Destroy_Weapon(weapon);
}
bool UMyPhysicsComponent::Server_Destroy_Weapon_Validate(AActor* weapon)
{
return true;
}
void UMyPhysicsComponent::Multicast_Destroy_Weapon_Implementation(AActor* weapon)
{
Destroy_Weapon(weapon);
}
bool UMyPhysicsComponent::Multicast_Destroy_Weapon_Validate(AActor* weapon)
{
return true;
}
and then I attempt to call the server destroy function in my pawn by pressing P. Now the weapon does get destroyed, but only on the server instance. The weapons on the client instances doesn't get destroyed.
which doesn't make sense to me, as the sequence of operations are the same both in the blueprint screenshots and the c++ variant.
Which is to encaspulate the destroy operation inside a multicast, and then encapsulate the multicast in a server call rpc.
I feel like I missed out on some step for the c++ side, but can't figure out what.
I'm hoping someone here could shed some light on this.
Feels like the multicast is simply not working for some reason in c++
What's the proper way to replicate movement for ACharacter, because AddInputVector isn't replicating to the server (except it replicates in BP???) (asked on #cpp I found a potential solution that I'm trying, replacing the super::getlifetimereplicatedprops with ACharacter::getlifetime...)
ok that did nothing, why isn't character movement replicating client->server?
Does actor have correct owning Actor?
I am fairly certain let me double check (if it isn't then for some reason it got set to a different PC)
hmm I overrode PossessedBy without calling Super::PossessedBy I wonder if that might be the issue (one sec while live coding fails to compile the change while the engine is running)
OMG that was it... @tranquil yoke thanks for uh guiding me in the right direciton
not quite the wrong owner but it was that super::possessedby wasn't called
ohh, well i was trying to help the other person, but something works for you that is great ๐คฃ
in a multiplayer game does each actor automagically have an object ID aka fnetwork guid?
Replicated actors are assigned a NetGUID yes - though those GUIDs are unique to each Server/Client connection pair so are not universal
Ah damn. I'm trying to figure out a way to keep track of player characters and pawns on a team using game state.
Just track them by pointer as you normally would. NetGUID is for low-level communication only
It's what allows the network system to send/receive pointers to objects and have them resolve properly.
So I can just have a map of maps in my gamestate base? Like Team1: &object pointer1 : object1 pointer and this would work?
It's a horrendous data structure but yes, you can just keep refs in there
hahaha. Would you have something better to recommend? Maybe something built into unreal? BTW thanks for the help.
I would just create a team interface (or use the engines one) and store a team on each item tbh
Can someone explain to me why a rotator when parsed to the server suddenly becomes really weird. On client a rotator's pitch goes for example from -20 to 20. When passing this rotator to the server using an RPC, and then reading the value on the server, -20 suddenly become 350 or something. Why is that? I'm trying to wrap my head around why a rotator changes when passed to the server but I can't think of a single explanation.
When I split the rotator and pass the float values along seperately it works just fine
But when passing the rotator as a whole, the pitch, yaw and roll values become different.
This is extremely weird behaviour imo, would love to understand why this happens.
Is this some kind of optimization / quantization happening of some sort?
Above zero the values are the same:
Under zero, they're not
When doing this it works just fine:
I don't get it xD
Wait is it because a rotator that is passed to the server uses 0 to 360 instead of -180 to 180?
Still makes me wonder why
@void nest rotator gets compressed when being send over the network
Thanks, that was kinda it and fixed it. It was a reference issue. I got it solved by saving a reference to the weapon right after it is spawned as a variable within my actor component having the rpc functions, and then destroy the weapon through that variable instead of destroying it based on the input parameters of the server call function.
all this time I thought my multicast rpcs weren't firing at all when in c++ lol
do mean something like that? (that is in the character bp)
and this is OnPossess in player controller (it uses possed pawn), there is a switch on int to decide if player is innocent or murder
What does local authority in control mean? Is it a character controlled on a Listen Server?
bool AController::IsLocalController() const
{
const ENetMode NetMode = GetNetMode();
if (NetMode == NM_Standalone)
{
// Not networked.
return true;
}
if (NetMode == NM_Client && GetLocalRole() == ROLE_AutonomousProxy)
{
// Networked client in control.
return true;
}
if (GetRemoteRole() != ROLE_AutonomousProxy && GetLocalRole() == ROLE_Authority)
{
// Local authority in control.
return true;
}
return false;
}
idk why but that's not working
Hi! So I made an AI in UE5, but when the client alerts the AI, the AI goes to the Server, but I just want the AI following the nearest player, how do I do this?
it is a controller that is controlled by the server, whether listen server or dedicated server. Eg. You could be using an AIController to call this function in which case it is a local controller to the server, but not necessarily controlled by a player.
You can't use "Get Player Character X" in multiplayer. You need to give it the reference to the character that you want it to chase, and in this case, you are provided with in in the On See Pawn event.
Also, there's little point in having RPCs in an AI Controlled Character, especially on Begin Play - in this scenario you want to use a Has Authority node connected to begin play and use the Authority branch to call the logic that the "Get Mannequin Type" event does.
@velvet meadow โ๏ธ
in predicting projectile paths, the sim frequency is in ms?
so if im trying to compensate for ms between client and server, i would do the time sent then run the sim, and if its 50ms out and the sim frequency is 10ms, i'd get the 5th result and start the bullet there?
I think you're misunderstanding what sim frequency is, it has nothing to do with the time you're trying to make up for on the server. It's about how often the path should be broken up to test for collisions (or how often points should be added to the list when not tracing if the goal is to get a list of discreet points rather than an arc).
Traces are always in a single direction, but a projectile is generally going to travel along an arc. So you need to break up that arc into segments that are small enough that being straight doesn't matter much. The sim frequency is what determines how often the arc is broken up.
This is simplifying a bit, but should get the idea across.
If your goal is to only sim the first x seconds on the server then you'd set that as the max sim time. So for 50ms you'd set the max time to 0.05 and check the last result.
ah that makes sense, thanks
how would you guys deal with working out the amount of time it takes for the message to send from client to server, would you send a datetime object to the server event and subtract the current datetime?
i see that ping is stored in gamestate but idk how accurate that would be in this use case
could also send the get server world time and get the difference on arrival?
Assuming you have a well synced clock that can work
What are you trying to do, predictive projectiles?
yeah
I'm not sure what predictive projectiles refers to, but are you trying to do the thing where players who are lagging can still damage other players by having the server check where the victim would have been x milliseconds ago?
basically. im not making anything competitive so i figured i can just shoot the projectile, when the server is notified, get the ping and move the bullet forward for the server to match the client basically
send that to the other clients
then yeah, I'd send the game time in seconds along with the RPC to fire the bullet. Then the server would just need to compare that time with the current game time in seconds to figure out where to spawn the bullet
but if you're not making anything competitive I don't see why you'd be using this method
You'd be better off just letting clients do their own hit checks and then tell the server what they hit right?
wouldn't it end up looking off visually for some projectiles? if someone has 200ms ping or something it might miss entirely on other clients games
I guess it'd make sense if your projectiles are so slow people can see them, but it'd also be weird if a projectile just randomly spawned inbetween you and someone else
I guess you can pick your poison there
yeah ill probably need to figure out some interpolation
goodluck with that ๐ซก
i imagine with anything under 500ms it would be fairly hard to tell if i just interpolated the position from the muzzle to the start of the new projectile path and fired it

yeah you should be fine, but it sounds a little bit more challenging to me
are you planning to hide the server bullet for the client that fired the shot?
spawn the client bullet and then do it for everyone else to match it, shouldnt have to mess with the client bullet
if everyone spawns their own version of the bullet that isn't replicated I don't think you'll be able to make that feel smooth for each individual client
I think you're better off having the client spawn it's own bullet, and then the server fire's a replicated bullet that syncs with the clients bullet.. but the server's bullet should not be visibile to the client that fired the shot lol
because then the client that fired the shot will end up seeing 2 bullets
trying to interpolate and sync all these things together while accounting for ping sounds like an advanced thing to do is all I'm saying
maybe you've got what it takes though it's definitely not impossible
Projectiles chew through net bandwidth. Thatโs why most games with them have a rocket launcher type weapon with a slow fire rate. Bullets should typically be line traces instead of projectiles.
Each projectile has to be spawned and itโs movement replicated during its entire lifetime. Thatโs a lot of data per projectile and if you have a bunch of players all shooting guns with projectiles itโs going to cause problems.
If you look at a net profile most of the data is from character movement because the vectors keep updating. Now if you have a whole bunch of projectiles itโs like a bunch of vectors to keep replicating.
fast moving projectiles do not need continuous replication, it's unlikely they'd survive long enough to make it past more than a handful of net updates
Depends on the level design. Not all FPS games are indoors with close walls.
What if the firefight is outdoors?
even so, mispredictions after a server-confirmed projectile spawns are unlikely unless affected by physics
and the likelihood of a misprediction even on a projectile that does have something like bullet drop is unlikely to affect gameplay in a game with lots of bullets whizzing by
only slow moving projectiles (or ones that cause large effects like explosions) where a player can easily pick out the fact that what they saw doesn't match the server need continuous (or high-net rate) replication
But if you lower the net update frequency then the hit detection wonโt be as good of an experience for the player
well I made an actorless projectile system that didn't require any continuous networking
fast moving projectiles have this problem regardless
even bullet traces have this problem
All Iโm saying is use care with projectiles or else things can get messy real quickly.
yes, use care. But the issues are all solvable without blowing up bandwidth.
The harder part is not blowing perf because you're spawning thousands of projectiles as individual actors.
but that's not a networking issue.
every game, even the super precise competitive ones like CS and Valorant, have a degree of "wonkyness" around their prediction. "Blood shots" exist in all games except those trusting client hit results (to some degree at least) and aren't specific to true projectiles. Hell, they're easier to solve with true projectiles because you can at least have a chance to correct projectile position when the server confirms a shot.
Just donโt give every player a mini gun that uses projectiles. ๐
The valorant dev video where they explain how they designed hit detection is really good.
it is, their whole perf video is great
only problem is just about everything they've done requires pretty heavy engineering work and engine changes
Same with the one for over watch.
though you can do "lite" versions of most of the things they've done, just won't be as performant and it'll have limitations
Client prediction and reconciliation theory for physics based movement.
Hello community!
I'm currently working on a physics-based game using my custom character pawn class, which relies on AddForce for movement instead of UCharacterMovementComponent. Consequently, I lack access to built-in features like client prediction.
To address this, I've opted to implement a simple client prediction, but I'm encountering challenges, particularly in reconciling the client's current predicted state with the last agreed state received from the server.
The approach I've learned involves reverting the client to the last agreed state received from the server and then reapplying every input that has occurred since the client was in that state.
However, my movement operates with AddForces every frame based on players' hand inputs (similar to VR Gorilla Tag movement), making it challenging to re-simulate every AddForce that occurred.
Does anyone have a good approach for handling this?
Is it possible or does any one have advice on how to get the player controller that clicked on the actor from within said actor!? (If that makes sense)
You could probably try summing the forces and applying them once instead?
A physics based approach is going to be fraught with challenges
@hollow nexus Might be of more help.
On Clicked events would only trigger locally so it would be like Get Player Controller 0, there's no good path to get the controller that performed the click in another actor.
An alternative would be to have a mouse click event on the player controller that gets the hit result under the cursor which can give you the actor underneath the cursor when you clicked.
Was thinking along those lines , thank you
It doesn't work like that.
I have a Velocity and a list of { Vector3 force; float DeltaTime;}
In my simulation I need to know what the final position of my Pawn after simulating each add force in the intervals of each deltatime.
The information I need is the final position after that, and the final velocity.
Cant just apply them once.
You can't leave me hanging. I'm actually interested in this if you have any more details
Do you use those instanced meshes or something to get around this problem?
It's just some magic with substepped line traces
Is that like you do a line trace then do smaller line traces between the start and hit point?
I'm using the OnlineSessionSubsystem to create a quickplay game. The ListenServer can see the client but the client can't see the ListenServer. Thoughts on what the issue could be?
What do you mean exactly?
The Client cant see the Listen Servers Pawn?
On Join, the "player" spawns some actors. The ListenServer can see it's actors and the newly joined clients. The newly joined client can only see itself
I'm not sure how that would help
@unborn nimbus Sounds like you are only creating those Actors locally
You likely arent fully grasping the requirements for these Actors to be spawned appropriately such that each network context would see them
Read the network compendium
And research correct procedures for spawning replicated Actors
They work appropriately in DedicatedServer/ListenServer configuration
But when I launch 2 standalone and have them connect, this is when I see the problem
well nevermind I'm lying
someone broke something. Ignore me
If you have lots of the same projectile then yes, that'd be a good solution.
though actor pooling is probably good enough for things that aren't approaching bullet hell
@hollow eagle @plucky prawn We ended up using a Niagara System to visualise the projectiles as individual particles.
ah nice, yeah that's also a good way. I haven't done enough with using niagara for that kind of thing tbh
Hi guys, i'm looking to implement multiplayer into my game, my next step was to implement the combat, though i'm second guessing myself because latency will be extremely important. Should i get the combat working locally first or attempt at net code first as it may influence how i do the combat implementation
re: ggpo
W.e step you do, the true test is when you simulate latency
How do i fix this?
I`m changing maxwalkspeed on PostAttributeChange (AttributeSet)
Is it wrong?
You probably shouldnt be doing it that way.
You should be overriding the CMC to inject the movementspeed attribute value instead
Is there any c++ example?
Probably
Do u know any?
Not off the top of my head.
Its easy to override the CMC.
The function you want to change is GetMaxSpeed
The examples use fixed movespeed and movespeed modes (sprint, walk, run).
My game is a mmorpg and i have slow effects / dynamic movespeed. Is it possible with networking in mind?
Modifying movement speed with effects is tricky. The CMC has its own predictive movement system, meaning that the server listens for where the client is moving and will only correct the position of the player if the location doesn't match where the server thinks they should be, and the movement speed being consistent between them is fundamental to that.
In order for movement speed to be correctly predicted and prevent correction by the server, the change needs to be implemented into the saved move list in the CMC.
If you change the movement speed value on the client first and replicate it to the server (eg. client is requesting to change movement speed), it can work, but under bad ping conditions it will start becoming jittery very quickly with more corrections. To get this working correctly for a "sprint" or "walk" toggle, you have to actually insert a flag in the CMC's move list so the server knows when the client was trying to sprint or walk, so when the server receives the moves, it knows when it should start sprinting or walking based on the client's values and then you'll end up with no corrections.
If you're changing the movement speed value on the server first, the client won't know about the new value until it replicates to the client, but then the server is already going to expect that the client is moving at the new rate, so you're going to have corrections as the client will continue to move at the speed it knows about until the new movement speed is received by the client. One potential way you can handle this situation is by having a grace period when the movement speed is changed where you set the CMC to allow for client authority over movement (like maybe a second at most) giving time for the changed movement speed to replicate then everything should appropriately line up and no longer correct, but even this isn't foolproof and allows for cheaty clients to change their position to basically anywhere in the game in that moment.
How do you use a blueprint map to store player controller as key with bool value for each player? I want to keep a separate bool for each player but I'm struggling to figure out how to use maps properly
You're hoping to have this map replicated?
Adding things to a map is usually as simple as setting up your map so that it takes the appropriate thing as the key, and whatever you want as the value, then calling "Add" on the map giving in a reference to the key you want to use and setting the value you want associated to that key.
Why I ask if you wanted it replicated, is that Maps do not replicate :/
I'm storing it in gamemode, I just want to store whether or not each player has readied up essentially so I can check to end the turn
I'm not used to how UE does it all so storing and checking that data is leaving me puzzled
Well, you don't technically need a map to do something like that as you could just store the bool in the player controller itself, and when someone readies up, get the Player Array from the Gamestate, loop through them, get their controllers, check if each of them have the bool set or not and if so, proceed. If you wanted other players to know if someone was ready or not, you'd probably want the bool stored in the PlayerState.
Are you certain about this? The client will be attempting to move based on the max speed it currently knows about, where the server will be receiving moves and playing them back at the max speed it knows about. Even predictively modifying the max speed on the client will result in the server not having the correct move speeds when it is expecting them through the CMC.
Eg. Let's say I apply an effect from an enemy AI that sets the movement speed attribute to 0, thereby negating all movement.... I will get a correction on the client side when that finally replicates as that effect would have applied on the server first but my client thought they could still be moving forward at their full speed until such a point that they receive the replicated effect.
Hmm, each players ready check is currently in the player state, but that does sound easier, I'll give it a go
What actor does spawn ACharacter?
Any actor can spawn characters. If you mean what spawns the default pawn, that would be game mode.
This is something Iโve been looking into and Iโm curious how I could change this flag thing you mentioned? Assuming this would be in cpp
It is something you'd need to set up in C++, but can be exposed to blueprints to trigger on and off.
https://youtu.be/17D4SzewYZ0 This video seems to give a good explanation of some of the features of the CMC and shows how to create a custom character movement component with a flag set up for sprinting.
Dope. Legit noticed the majority of server lag comes from movement based things and sprinting is one of them (my current sprinting logic is not great tho). Essentially doing what you mentioned about telling server first, then clients
Hey, how does JIP (join in progress) work with FFastArraySerializerItem? Or more specifically, does the FFastArraySerializerItems PostReplicatedAdd get called when a client joins?
It does yes, because you'll receive the initial state which will differ from the local (empty) state
Fantastic, that works perfectly for my use case, is there any chances or scenarios that these functions don't get called? I'm using them for non-cosmetic gameplay stuff so it'd be a bit of an issue if they can get dropped for any reason ๐
No, it's the same premise as all other variable replication
Awesome, thanks for the clarification!
The only case where you wouldn't get the callback, is if the client already had something in their array with the same ReplicationID - but that should never be the case unless you're messing with prediction or w/e
No, not doing anything fancy regarding prediction, just wanted to use the functions as a "client side hook" for copying collision bodies from actors stored in the fast array to client side collision of another actor (addon/mounted parts of a vehicle).
I was using multicasts but they were getting dropped unless I set them as reliable which whilst isn't the worst since they absolutely needed to run, I figured there'd be a nicer way since I needed to store the "parts" in some kind of replicated array anyway.
Yeah never use Multicast for stateful changes
Or any RPC really
There are exceptions to that rule, like if you have a set of transactions with one particular client that are both reliable and only valid for that session, but otherwise, properties always
Yeah, I figured it wasn't the correct way to go about it, I just totally forgot about the FFastArraySerializer, thanks for the heads up, something that's always been on my mind, is there a more efficient way to send Actors/Components via RPC from clients to the server (or the other way around) rather than just the pointer (I've not really looked much into how that works under the hood, but on the surface I figure it's probably a more costly option than simple data like an int?).
For a use case specific to my scenario, a client picking up an addon/mountable part and attaching it to the vehicle, would it be acceptable to send a pointer to the part itself + location to attach it to the vehicle or is there just a nicer way to do it?
Or am I overthinking it and it's just trivial/a non-issue?
Hey, has anyone tried to connect ue to postgres db? Is there any good pipeline without purchased plugins?
A server? Or a client too?
The first RPC with an actor, component or asset reference either sent to or sent from a specific client has an initial larger RPC, which appears to be sending the path of the asset. Afterwards, any subsequent RPCs sent to or sent from that client with reference to that same actor, component or asset are small, likely as it now uses a GUID of some kind to reference that asset across the network.
I did some testing of this yesterday sending a data asset and the initial RPC was about 80 bytes but subsequent RPCs were 4 bytes.
Okay @lost inlet i have Done in this way now, but it is still dropping events after 40 seconds of constant firing.
Thanks for the explanation, that makes a lot of sense, I came from a modding background in ArmA and we used a netid (basically a string/GUID) to reference things over the network and never really put much thought into how it works in UE or other modern engines.
So essentially, it's a non issue/not worth looking into alternatives, just the obvious, be smart about what gets sent.
Yeah, probably not worth looking into alternatives. I think for the majority of use cases a large initial chunk to get the reference association between the client and server to then use a smaller ID is acceptable.
Nice, thanks for the info! ๐
I'm having issues connecting two users through steam. in PIE, everything works as expected, on steam build, both users get put into separate matches
99% sure that steam subsystem doesn't work with PIE. I think running standalone will get it to work though.
Yes, it works
on steam it does not
If I launch two standalone from the editor. Everything works as expected
if myself and another dev launch steam, we do not connect to each other.
@_@
Hello everyone, this is how I run play anim montage. When the client plays the montage, the server sees it as jagged/choppy.
When you use the Smooth Sync plugin, everything becomes very smooth.
trying to think how to identify bullets for purposes of destruction caused by the server. so i'd need an id to match for the bullet across everyone.
i am already sending the time the bullet was created on the client so i guess i could use that in a map 
A struct bro
why would i use a struct over map here?
iirc from yesterday, you're sending an RPC about a bullet being spawned. The struct can contain all necessary information about the bullet. which would include the ID, and the time it was spawned
also maps aren't replicatable, so you'd have to break it down into 2 arrays
im not sending the map data. it'd just be the time then the client/server would spawn the bullet and map it to the owners time i sent. dont worry i got it
is dormancy only set manualy?
server on unreal engine base
I'm going to go insane- so if anyone can help me out quickly.
So I currently have this in my header file
// Server-side function to handle sprint state change UFUNCTION(Server, Reliable, WithValidation) void ServerSetSprinting(bool bNewSprinting);
And then this is my CPP file
// Validation function to prevent cheating bool AJavelinCharacter::ServerSetSprinting_Validate(bool bNewSprinting) { // Basic validation logic return true; // For now, always return true }
But then I get the error: class "AJavelinCharacter" has no member "ServerSetSprinting_Validate"
In the UE 5.3 doc it says that once you add the WithValidation condition, you just have to add the suffix.
Validation will kick the player for cheating, btw, not just stop the action.
(if it returns false)
I don't think it's quite a good idea to use it for a player pressing run...
Using admin commands when not an admin might warrant it.
I know this doesn't solve hte issue, but still ๐
I just copied and pasted your code, changing just the namespace on the ServerSetSprinting_Validate, and including ServerSetPrinting_Implementation, and it compiled fine (5.2.1, but still should be the same on 5.3)
Hot reload maybe?
so i forgot at the time i asked this, but how does this work if i want to send a uobject through an RPC? im guessing the replicated subobjects list wont work for this
Yup
Did you have any specific #include?
Nope, just put it in a random class.
does anyone have any information on how to get voice chat working without using OSS? or do you have to use an OSS for voice? theres a VOIPTalker class which is available out of the box but i also found this https://docs.redpoint.games/eos-online-subsystem/docs/voice_chat_overview/ and after adding VoiceChat to my modules it didnt work and enabling the plugin causes this #plugin-dev message
Anyone know how to specify which ip address the game server should listen on?
if you're talking about the default port, you add this in DefaultEngine.ini
[URL]
Port=7666
I guess I should specify that ultimately I want to scan a specific subnet for lan games through the lan OSS
Nope. I believe unreal uses the ip address that's configured to scan a specific subnet
I just don't know where to configure that
Trying to test the lan multiplayer over VPN with others
if you're not using any service (steam/EOS) I think you'd need to set up your own for server discovery
or just scan all ips in a given subnet range I guess ๐ค
The default OSS is Lan and it has functionality to discover servers using the subnet's Broadcast address
oh I see
The issue is I'd like to test it with a VPN LAN adapter not just the local LAN
never used it
But it only seems to scan the "normal" one
the "VoiceChat" module doesn't do much other than have a voice chat interface (think OSS as being an interface). I implemented Vivox in the past
ehh this thing? https://unity.com/products/vivox-voice-chat
oh thats the unity implementation
yes. "EOSVoiceChat" implements the VoiceChat interfaces for EOS
i thought it was a unity product
it is a unity product, unity bought vivox
oh
i tried adding the eos voice plugin but i dont have an account for eos or anything and i didnt see any blueprint exposed nodes for it so i wasnt sure what the deal was
we used Vivox because of cross-play
you can just make one, but you'll need to be authenticated with EOS in some way to login to voice
so theres no way to do voice without using a OSS?
though EOS voice still has weird limitations from what I remember, mostly with room size
Vivox is pretty good.
define "without using an OSS". you're not using OSS at all in the game?
well right now its basically a fresh project, just trying to plan and figure out how to do it. im not using steam or EOS right now and dont want to tie specific functionality of the game to either one
the point of OSS is you have a common interface regardless of the underlying platform
ah right
and you can actually have multiple OSS instances, just that the INIs define a default one
oh interesting, i thought it was a one at a time deal
a game I worked on had the Steam, Epic, and a custom OSS running on the Steam version of the game
thank Epic's cross-play requirements for that one
ye for sure
so if the voicechat plugin doesnt do anything by itself and the eos plugin is presumably for eos, is there an option for OSSNull? or would i just make one for that?
well EOS supports platform login
but you need to do the title setup and everything for EOS
hm. im checking out ODIN as DevilsD suggested and it has a free tier so i might check this out
i was kind of wondering if it was possible just with unreal though. like how source engine has it built in
Odin does not require a specific OSS to be used
Neither does Vivox
They implement their own transport layer.
You are just simply integrating their stuff into your game.
well Source just uses Steam voice, which is what the Steam OSS uses
Both are relatively easy to integrate.
ah ok nice
It does - the same principles still apply. The engine warns you against using the legacy style method now.
i think im a bit confused. if the uobject doesnt need to be a subobject of the player for example, but i want to send this object to a player through an RPC do i need to do anything beyond adding the replicating stuff to the uobject?
Hey Guys ive got a weird thing here
https://gyazo.com/28530b4f04ce945f4977554903067b98
Ive Got this Dialogue System or whatever but its not displaying the correct textfor the Clients ??? (left one is Server/listen) right on is client
https://blueprintue.com/blueprint/gro2t5v2/
Any Ideas ๐ฎ ?
Unless it's an asset it has to be a subobject of something replicated
hm alright. maybe i can use a manager class or gamestate or something
Or it needs to be deterministically spawned with the same name on all connections, and you force it to be addressable by overriding IsFullNameStableForNetworking
spawned as in an actor? i didnt know you could spawn objects?
I'm assuming he means created with NewObject with a deterministic name for the name parameter
i could probably make that work actually
anyone got any ideas :/ ?
Gonna need a little more info regarding on how're you determining the text to be displayed, where is it gathered from, etc, since if the hosting client (server) is displaying the correct text, this is probably just a case of the remote client not receiving the correct information in order to select the correct line of text, for example a DataTable row name or an array index (depending on how your text is stored in the game)
Based on the information you've provided, if the host/server is displaying the correct text, then there's no issue with the function you've posted on BlueprintUE.
If it correctly displays the characters in the correct order, etc at all times on the host, then the problem lies elsewhere, such as how the value of FullText1 is set, if this is within a widget, the client has its own separate widget instance (these are not replicated), so FullText1 will be different if you're ever changing that to a different block of text on the host.
So basically, since we don't have your project on our computers, we're going to need a little more info to help you find your problem ๐
What are the overheads of setting a skeletal mesh's anim tick option to Always Tick Pose and Refresh Bones so that the bones can update on server too? I'm always finding myself selecting this option for Character mesh in order to let server calculate transform related things based on the current animation/bone/socket positions. Is there a better way (optimization-wise since it's an option under the Optimization category) or is this considered as industry standard or something?
@weak linden that makes sense
i mean im calling the function from the server with a RPC funtion to all players to start "AddLine1" from there its all handeld clientwise
The server definitely needs to "Always tick pose and refresh bones" since it never renders.
The same might not apply for clients, though.
Are clients able to skip ticking the pose if the character is behind a wall?
Selectively set this option at runtime based on if the character is on a server / client.
Secondly, if this adversely affects server performance, consider lowering the update-rate of animations on the server or figure out if characters always need to tick at all times or if there are times when the server doesn't care about the body transform of the character
so im not really changing anything from server after that
and all variables are replicated and "pre-set" with the text
Alright, could you show some more screenshots? Preferably starting from where the host/server sends the initial RPC to start the process?
On a side note, if it's all pre-set text, you theoretically don't need any variables to be replicated.