#multiplayer
1 messages Β· Page 626 of 1
is your packaged game a shipping build, if it is you need to add the AppId.txt to the binary folder. the steam subsystem is working if the steam overlay shows up in game with the name showing as βspace warsβ
π₯ 
thanks for the help
is there any way to get initial replication before construction of components ? I was thinking about extra optimization to not construct redundant components ?
currently I CreateDefaultSubObject which is in constructor and I guess not possible
π€
for instance I have an actor for a small house and it has 10 static mesh component for glasses of the windows.
when they are broken I don't need them anymore
I wouldn't worry about that personally. If you do want to do something like this, would be better to swap for a different actor when damaged.
Does anybody know a good online service for multiplayer?
Define service
Thank you
π€
I guess he didn't understand what you were really asking Stranger
Heyo!
The HUD(UUserWidget) of the listen server is destroyed when clients join. (At least i think that's what happens, it is visible until any client loads in PIE at least)
Currently i have an actorcomponent that handles HUD, and i initialize it in PossessedBy and OnRep_PlayerState with IsLocallyControlled(). If i delay it till after clients have spawned, it works fine.
Any ideas why?
Edit, Workaround:
Add every connected playerController to a TSet in GameModeBase's PostLogin, loop over all connected players and recreate HUD whenever someone connects
Still no clue why it happens though
@ruby rock you can always attach debugger to a running server/client and then debug your code. Make sure to include debug symbols if you want to debug packaged build through packaging settings
C++ though yeah ( debug symbols etc )?
Yeah you can't debug blueprint code like that
Hi!
Does anyone know if it is possible to connect via internet with the default online subsystem?
Hello everyone, I hope you're doing well. I'm trying to understand something concerning multiplayer and line trace. I don't get it. I'm using the hit result from a line trace to pass the reference of the hit actor to the server and then do a multicast so that everyone knows about the actor that the initial player hit. However, when I do this on the clients, the passed reference becomes null. (I print the name of the hit actor locally on the client and it's here but once I passed it to server and multicast, only the server gets the reference) :
I thought I understood the process but I don't get why if the instance of the client hit actor exist locally, I get a null when passing it to multicast. For info, both server and multicast events are set to reliable, and the hit actor is not set as replicated
Thanks in advance for helping ! π
@weak canopy are you positive the hit actor itself exists on the server?
Considering it's not set to be replicated, I wonder if there's even a direct link between the two. If you spawned them separately on client and server, they'd be two different actors (or if you spawned only on the client, that would never work).
What kind of actor is it that you hit, how did it enter the world?
I'd set it to replicate, then spawn on server.
The actor needs to replicate if it is dynamically spawned actor. That reference can also be valid for non-replicated actors, but the actor needs to be placed in the level
@potent cradle I indeed spawn the item on both the client side and server side, so that must be the reason
But I thought that it would work if the item existed on the client and passing trough but I guess it's not the case ! π
@empty axle thank you, this must be the reason
thank you guys, I think I understand
that is somewhat true
you can go around it, but not with blueprints
I did this because when replicating it, the "exposed on spawn" variable were not transferred to the client, I guess I have to check if the client have the spawned actor before applying the variables ?
all replicated exposed on spawn variables of a replicated actor will be available on client before that actor calls beginplay on client
that doesn't necessarily include references to other dynamically spawned replicated actors, as those actors need to replicate on their own for the NetGUID to resolve
(the client would have a valid NetGUID at BeginPlay, but no way to resolve it until referenced Actor replicated)
any Actor that is spawned with a same name on client/server and has IsNameStableForNetworking and IsFullNAmeStableForNetworking returning true is net addressable
even if it wasn't loaded from package or replicated
thank you a lot Zlo for the explanation
okay, I was calling so "set variable" in the construction script of my actor
I guess it explains the problem !
anything you set synchronously right after spawning the Actor on server and is replicated will also make its way to the client
as NetDriver has its own timing, it doesn't start replicating the Actor as soon as its spawn node is done its job
ok ! I see
construction script is the 2nd part of deferred spawn on server
but can you use deferred spawn in Blueprints ?
so you could technically spawn the actor, wait a few frames, call finish spawning, and then construction script set variables might not make it in initial bunch with instructions to spawn the actor
i'm not sure
you can't do that in blueprints though
alright !
it is a lite version of deferred spawn
expose on spawn variables
as it will spawn actor deferred, set the variables and immediately call finish spawning under the hood
still a good practice, as it allows you to run same code on BeingPlay on client and server
(on server any variable set right after SpawnActor would come after its BeginPlay, and on clients it would be the other way around)
I'm noting everthing you say cause I'm learning a lot ! π
There is a node called "finish spawning" ?
from what I understood ?
I know what I did not replicate the initial actor, it's because it's a foliage component
i remember now
I need to know which instance of the foliage component I'm hitting with my axe (for chopping trees)
but I cannot set the foliage component to replicate
There should be no need for foliage components to replicate, assuming they are in level
@bitter oriole I tried to use the hit instance of the foliage to pass it to other player with multicast but it did not work
(the "hit item" node from a line trace hit result list)
if i have a replicated rotation movement component on an actor, a suppose there is a chance that on low bandwidth there will be some jittering
is there a way to tell the client to do the rotation its own and correcting only at start/stop or a lower rate?
nothing serious, some people apparently following some devs on twitch and discord. rumours
@weak canopy multicast wouldn't work terribly well there
its not really good for keeping states
@amber hamlet earlier you said companies trying out UE5 and and found out nanite doesn't work.. may be because nanite needs high speed premium SSD and those required SSD can be found in new gen consoles.. so that rumor may be true.
maybe, I hope they may inform people how it's going, it's something quite huge that needs some anticipation in order to take benefit from it for a dev
we'll see
The curious case is to see how nanite performs on existing premium SSD like samsung evo 970 or 980.. or nanite is only for new set of SSD
No they won't inform , as I believe they must have signed NDA
I was talking about Epic
I don't think epic will present any demerits of nanite as nanite was the highlight of the UE5's first trailer.
And they boasted it like the invention of the millennia
yeah true. it has been almost one year now
where should I keep game-global variables (for instance the "min duration between two actions", which is displayed on screen)? I understand that the GameMode isn't available from clients
if it's for the entire game, the game state. per-player and other players need to know it? player state or pawn
I hope nanite won't go the way of svogi π
is it possible to just spawn an actor, as the server, only on the server.
I have this coordinator and as the game goes the coordinators job is to just let a player know when its their turn.
I want to spawn this coordinator and just have it send an event to the player whos turn it is.
From what I've tried each player seems to be spawning their own coordinator.
I just want the one.
is it possible to just spawn an actor, as the server, only on the server.
Yes, just don't replicate it.
Though what you are describing is the GameMode class
Just use that
@bitter oriole that's what I was thinking.
i was wondering if i could add a function on the game mode and tick that.
Every time i read up on the game mode class it sounded like what I wanted.
But wasn't seeing any references or examples that mentioned if game modes having tick functions was possible.
So I wasn't sure if it was proper to put processing on it
Game mode is an actor so it ticks
Sorry, I must have clicked on something else, to make that assumption.
Thanks @bitter oriole ! Yeah for sure game mode will be it.
@bitter oriole for actors you place in the level you can edit the default values on the actor.
is there a similar option for a game mode used on a level?
i know we have the 'Selected GameMode' defaults.
But something like a default actor to be tracked from the level.
I didn't want to do a 'level find from all actors' type of approach if i know the exact one I want to hand to the game mode.
consider deriving world settings
but you can always cache your actor or list of actors in something like ::BeginPlay for the game mode
if the actor is spawned, you just cache the reference when it is
if its loaded from package, the level actor's PreSave override can cache everything you need
whenever you press save button on the level
no need to go searching runtime
yeah thats what I was thinking @lost inlet just having an actor that's caches like my 'this levels starting info' and cache grabbing that on the game mode starting.
for gamemode configuration, definitely custom world settings
you can go even further if you support multiple game modes is even a data asset, that's what we ended up with
soft object references are pretty versatile for that
cool cool i'll look into deriving from world settings.
i was also considering a data asset.
But since I needed a specific object on the level I didn't think I had access to storing a specific level object on the data asset.
no, data asset can't hold references to object instances
but you can derive a custom ALevelScriptActor that caches them at editor time
and just access it with GetWorld()->LevelActor, casted to your custom type
override its PreSave to iterate over the level and cache whatever you need
i find it... not ideal to count on level designers to remember to set the references
wrong
TSoftObjectPtr<AActor> can reference actors on the level
it's the entire basis of our scenario system
and how do you save them?
click the save button?
well yeah, but soft ones work and allow you to pick actors from the currently loaded level
that is convenient
it shows an orange exclamation mark if the object can't be resolved, ie. the level isn't loaded
so there isn't any risk of things being cleared by opening the asset
good to know
Hey guys, working on a topdown game. One of my characters has some "Rocket Boots". basically I'm disabling "wasd" input, and for the short duration they're activated, i'm adjusting the players velocity every tick to be it's forward vector * a number. Basically they can steer with their mouse. It works great. However it's not the smoothest in multiplayer. Little bit a jitter as it seems like the server and client are just a tiny bit off with each other. It may be a difference in client frames vs server frames, but I was just curious if there was a better way to accomplish what i'm trying to do. Thanks!
I've made a lobby system that requires players to "ready up" then the host launches the game, the host opens the new level, but the players do not follow, does anyone know how I get the players to "reconnect" to the host?
Hi everybody! I'm looking for a BaaS that is both solid and highly customizable. I mean something that in the future I could easily extend without being forced to redo a whole backend from scratch. I may want to add custom data structures and APIs within the BaaS environment while still using its authentication system for example. Is it science fiction?
@unkempt wind Nakama.
If you make a brand new multiplayer project and then play as listen server with 2 players. If you turn the client slowly it looks smooth for the server. But when you turn the server, it looks stuttery for the client watching. How can this be fixed?
@rich ridge Thanks! It seems really a professional service. The managed solution is very expensive though. Do you know any other option?
I've looked in other mainstream BaaS like Playfab, but I think they aren't very customizable
@unkempt wind When you need high customization, then you have 2 options, either make your own backend or ask your vendor do changes every sprint.
since your vendor won't be making changes for you every sprint, so you need your own backend
Nakama gives you your own backend to manage and host.
I have been hosting nakama for myself on AWS and had setup LoadBalancer.
Gamesparks used to be highly customizable via its Cloud Code, but Amazon ruined GameSparks
Have you tried Epic Online Services, setting it up is a lot of headache
Suggest me Voice Chat Service for Multiplayer Game
Epic Voice in in development.
Yeah that's definitely true, there's no silver bullet. In fact Nakama maybe is exactly what I was looking for. I see that there are a lot of BaaS out there and some provide cloud scripting (like Playfab, or Braincloud), but I haven't tried them yet. EOS doesn't seem to provide any customization or scripting, does it?
EOS will get features what fortnite wants not other games.
Ehehe indeed. It's not an option for me, but it's a great option for games with standard requirements
to tell you I m using Nakama+EOS
Nakama devs are very quick to fix bugs, infact I had issues with client SDK and I raised issue on their github and their devs fixed the bug and released new SDK very next day.
I m using Nakama for auth, friends and presence (I will have to maintain very little db and pay less)
for rest for the services like leaderboard, achievements, etc which can grow very huge in db I m using EOS
and one more things is I wanted customization in auth, friends and presence, for others I was ok with EOS features
Nakama supports push notifications for mobile games, EOS doesn't, that was also the reason why i choose Nakama
That's really interesting, I never thought of integrating different BaaS together, I thought was difficult to handle multiple authentication, but definitely I will deepen the matter! Thank you very much for the hints
Actually EOS supports openID connect, using that you can connect Nakama with EOS
Ah ok, I didn't know OpenID, I will look into that π
That looks insanely expensive, no?
opposite, very cheap
I m doing self hosting
AWS and load balancer.
for now using 1 year free tier for development, when I go production I will use DO, which is way more cheap
yes it do have a console for admin, like EOS console
When giving an ability is the SourceObject replicated to the clients ability?
I thought it was, but I have an odd case where it seems to not replicate
whoops meant to send this in GAS channel
Today I have started learning multiplayer and read documentations. when I tried make a sample by own scenario I have problem. I create trigger blueprint (top left image) and when player overlaped I call function on server and after that broadcast input text and in broadcast function I try change TextRenderer Text but It's not changed but all log message is work correctly. what thing I miss.
@high lance What is the intended effect? That the text above all characters on all clients changes when one overlaps, or?
Yes, I try change text on all clients. It's sample. I try show white cube front of all character too, but again it's not worked
Seems to be working per instance. If you want all characters to have this happen when one overlaps the box, you need to make it happen on all instances.
By broadcast function I try signal all character but the component properties not changed.
Logs show that all character get event and text but only overlaped character text (and cube) properties changed.
Your logs show that only one instance of the character got the event. It played that event on three different machines, but it was all for the same character.
For instance, you seem to be testing with three machines. Server/Client1/Client2. This means there will be three players. In a typical Listenserver setup... That means five controllers. Three on the server, and one for each client on the clients. That also means nine total characters. One character for each client on each machine. Right now your logic is making three characters change the text render and spawn the cube thing, six will be left unaffected.
If you wanted every single player character in the game to be affected when one walks over the trigger, you would need to do something like getting the GameState, get the Players array, iterate over those. Since these are playerstates you'll get PawnPrivate from them, cast that to your character type and then call the multicast event to affect all of them. As right now the multicast will only work on the version of the character that hit the trigger.
Thanks for your response but I confused. I have 2 character on the map and 3 machine (server, client 1 and 2), each machine have 2 character so I should have 6 character why I have 9 character? and why I have 3 controller in server when I have 2 characte?
Ah. You're running dedicated then. So in your case, yeah. 6 characters, and 4 controllers.
and base on this log my change text function call at client 2 by ThirdPersonCharacter_C_0 when ThirdPersonCharacter_C_1 hit trigger so I thinked it means other character get signal. why not take it?
and other interesting thing for me is Other Actor on begin overlap, why when I log it (without Switch Has Authority) It call for both character C_0 and C_1 ?
You can't assume names like that across network, usually. Each machine keeps it's own state and I don't believe those are kept the same on each machine.
But try this. That picture you just linked. Before the Multicast. Put this.
Oh, I think it's critical tip that should add in documentation.
Thanks for your response
Will i run into any problems if i'm only extending the CMC ?
Like that i'm only doing this kind of stuff
class UMyCharacterMovement : public UCharacterMovementComponent
, but not stuff like
class FSavedMove_MyMovement : public FSavedMove_Character
(From this tutorial https://nerivec.github.io/old-ue4-wiki/pages/authoritative-networked-character-movement.html#Conclusion)
Hello , I have a question about Gamemode and Replication. If i'm right, Game mode only runs on the host (i use steam p2p) and I'm trying to change the color of a player (from the Game mode BP). That works but only host can see that change. What I don't understand is why it doesn't "replicate" to client like movement. I had try to enable the replication of sprite for my Character.
I also tried to loop on all of my players character and call a event to them (to change the color locally on everyone) but i don't thing is a good way to achieve that
Hello ladies and gentlemen.
I wonder, why my character's rotation isn't replicated (location is replicated properly).
I set "Use Controller Desired Rotation".
I've tried setting control rotation on server, but it hasn't helped.
How reliable are animation notify for networked games? Is it better to use timers on the side instead?
I use timers for reloading or such things but notifies for footsteps etc.
From what I heard from an engineer anim notifies are not totally reliable but never experienced anything wrong yet, so take it with grain of salt
Ok so basically when you need to something to be reliable (gameplay impact) you usually use timer instead.
Hello! I have a q. regarding Reliable vs. UnReliable
I was told Unreliable was only about being "delayable", so UE does not pause the gameplay to wait for them, is this true?
When i set my RPC to unreliable (so that the gameplay does not stop while waiting for it to complete) some just never make it to destination as if UE just skipped them
Is there a way to have an an RPC that wouldnt pause the main thread like Unreliable does, but while ensuring that all the call still make it to destination?
Reliable RPCs do not pause the main thread.
Reliable/Unreliable is about RPC ordering and whether the engine needs to resend an RPC if it wasn't received by a client.
nothing to do with pausing the game - no RPC will do that.
"Ensuring the packet makes it" is Reliable, basically
Okay I see thanks for the clarification
Would this have to go in DefaultGame.ini or can it go with the other network settings in DefaultEngine.ini?
[/Script/Engine.GameNetworkManager]
TotalNetBandwidth=1000000
MaxDynamicBandwidth=100000
MinDynamicBandwidth=4000
ClientAuthorativePosition=true
I don't see why it wouldn't work in DefaultEngine.ini seeing as [/Script/Engine.Player] works fine there
But since there were posts on the forums saying it doesn't work in Engine.ini and only in Game.ini I wanted to check in with the experts here!
it's easy enough to check GameNetworkManager for it
and in my 10 seconds of using Everything, it is indeed Game.ini
Ah that defines which .ini is used, thank you very much, .ini's demystified!
I had falsely thought it was fine in either since they both start with [/Script/Engine.
Good to know it's easy to check where they belong in the future (config=Game or config=Engine etc.)
anyone know how i would hide weapons from the local player. like owner no see. i attached a weapon to my first person char mesh but i need it not to be visible to the owner.
trying to do something generic with movement abilities in my game. I am not using GAS. I followed a custom movement component tutorial on extending the CMC to accommodate custom flags, but the tutorial i watched was sending any additional parameters (in this case, a requested new max walk speed) with a separate RPC call. is there not a way to bundle extra parameters into the move that is sent to the server itself?
Add it to the strict that gets serialized
If u look at my plugins source code
I show how to do that
Smooth networked movement plugin
Itβs free btw
so the FSavedMove is not the struct that is sent to the server then? is it just for the client to keep track of what it had already done?
Itβs kinda hard to explain
Look at the CMC docs for 4.26
At the bottom at the page
it says look at feature docs for more information, where can i find that
ah so were you talking about this section on extending FCharacterNetworkMoveData and FCharacterNetworkMoveDataContainer
okay so i checked out your plugin and i think i get whats going on. would it be possible, instead of sending all of the various things you want to change (max walk speed, gravity, etc.), to instead send a TSubclassOf variable, and have some kind of GenericMovementFunction object to inherit from, then instead of sending the walk speed variable, just send the ModifyWalkSpeed class, and then the server can just instantiate that object and call like "Execute Movement Function," that way you only ever need a flag to activate a custom move and an object class to represent the move you want to execute? this seems like it would prevent cheating and also prevent you from having to define every new movement type in code
hopefully what i said makes sense
I think that The addMovementInput calls the default cahractermovement (which is replicated by default) but your set control rotation does not. So you will need to create a RPC call with a repnotify which turns the character on all the clients. Take all of this with a grain of salt since i'm pretty new with UE as well π
Does anybody know how to get cheat manager in multiplayer game. I always get null reference, but it works ok in single player
I'm having issue with Unreal's networks RPCs. I'm sending quite high amount of data and a lot of FPS drop ensue on lower end hardware (on my desktop it's fine to lose 20 from 100 to 80 but on a laptop...)
I was wondering if there was anything I could do to not have this issue ?
Are you sure it is because of unreals networking and not the code that is executed after the data is replicated in the OnRep function?
The only thing I'm executing on reception is spawning the same actor as if the server generated the same data
The code is practically identical, but the result is a 20 FPS difference
I tried to track perf on the VS Studio profiler to be sure and nothing seemed out of place
Comment the code out and see if then there is any drop. I am pretty sure it is because of your code.
The second thing is never spawn an actor using c++ new. Always use GetWorld()->SpawnActor method
I know it's confusing but the code is under heavy refactor and AChunkActor is actually not a UObject anymore π Sorry forgot to point it out
I need to rename that guy
there is probably a lot of copying happening in this function that might be the reason of your performance drop
I will try, but the constructor does not do any copying just a few init, and the same function is called when you play solo at a similar rate (actually way faster tbh)
But let me try to comment it out
Thanks
I'm still seeing the FPS drops
I even have occasional micro-freeze
@brazen sluice you used a new operator to spawn an Actor? π¦
i would expect a lot of things to break
so what class is it?
What is the average size of this chunk data array and how often it is called?
single digit kilobyte, usually 2-3kb
but there are a couple of them per frame in current implementation so should consume around 40-50kb/s
and whats the server setup?
listen, dedicated?
Ah listen
and the number of clients?
supposed to work with more?
yup
you might need to rethink the structure then
send clients a seed for random
and let them handle everything themselves
Already what I am doing but the terrain is editable, i'm only sending the edit
But I believe the edits should be pretty small right?
how many considered actors?
Well in this case the edits are the folliage, trees and structure, it's a good benchmark to whatever edit a complex map could need, and that need to work
if you have to send "large" chunks of data you might be better off using a custom socket on a separate thread instead of the ue4's replication system
In the future I'm planning to build a more complex system to make random structure predictables but it's not the case yet, and it will serve as a scale test
it would be easier to just replicate an action causing the change
I thought so, I was looking at this : https://www.unrealengine.com/marketplace/en-US/product/objectdeliverer
I am not using replication btw, I tried and switched to RPC, multiplied by 2 the speed of transmission
then the entire serialized chunk
but you might get the chunk after the action happened a long time ago
yes, thats what fastarrays are for
able to keep state
and do per item client side callbacks
Let say I have 50 edits, then my array is 50 position+material pair, my fastarray would contain the same no ?
what do you plan to do when you have 12 clients and 4 of them walk into relevancy range
and your host is using ADSL?
Well he shouldnt host to 12 people lol
popup a loading screen with a steaming cup of coffee and hope they take a hint? π
Im actually planning a soft 6 people limit, with some hidden config
changes are done by the players, yes?
Yes
whats the chunk count, total?
let say view distance is 12 (will be default) then 12 * 12 * 5 = 720
if you count 1kb average (populated are bigger but if you count total mass, then most are empty)
THat's under a mb
6 client is let say 5mb
Meaning that worst case scenario (every client connect at the same time and needs everything downloaded)
you need ~ 7-8 seconds since default UE cap is 100kb/s per client
TBF right now it works fine, if it wasnt for the FPS drop, the speed of download is correct
I didnt see if it was on the server too
The thing is my laptop is not powerful enough to stress my server
UE seems to lower the bandwith limit client side when FPS drops
which is as soon as I receive data
@brazen sluice try putting some SCOPE_COUNTERs in the client code
will let you profile properly
Should updating player health only be done in player state?
for example i created sever build from source unreal engine version
and then i created the normal game build from binaries version, does it works?
with server?
Any1 tried to replicate savefile? For me it just dont want to replicate :/
Hi, im pretty new to this multiplayer stuff, so i implement the unreal engine Ability System and it works. i made a punch ability that works to and now i try to implement blocking and it works on server, but client 1 cant block if server not blocking, im not sure why but the client get the bool from server and not from this own for the block ability. have someone a tip for a newby like me were i can learn how to fix it ?
the second pic is were i set the bool and activate the ability in my basecharacter and the first one is the gameplayability
nevermind got it π
i need to made 2 custom function (one run on server and one multicast) for pressed an realesed and now ist works
You should have marked the is blocking bool as replicated. Should have achieved the same effect.
this is what i tried first but it doesnt have the effect but i try it again one moment
It showed that it is replicating? The two little white circles at the top corner?
Alright. I just mean that encapsulating the logic in a gameplay Ability should eliminate the need for more RPCs in certain cases.
Basically, you're using RPCs to send changes to the bool value right? From the server to the client.
yeah maybe i find another way when i implement more of the blocking ability functionaly, but for now i leave it with the rpc's because it works and thank you very much for the input π
No problem. One suggestion I'll give is that. If you're using AbilityInputID you can use the pressed released events directly inside the the gameplay Ability.
its look like this actually thats work
No offense, and take my word with a grain of salt. But I think that one of the functions of GAS is to eliminate setups like this
oh thats true i watched a tutorial and set the abilityinputID up in c++, but i have to little expierience with all this stuff at moment, so i thank you for your wise words and look for another option at time i learn more how to use ist correctly π
Yeah. That's a great plan. Good luck.
thanks!
I created this to be able to turn the turret of a tank and replicate this to other clients as well. Now I've got 2 questions about this. 1. It seems as if the setrelativerotation in the input call could be removed if I set the repnotify condition from skop owner to none? This would simplify the BP a bit. 2. The rotation seems to stter a bit, this should be fixable with rinterpto I guess, but I can;t seem to get that to work (or at least it doesn't make a difference to my eyes ;))
What is the best way to know whether a player state is related to the locally controlled player?
I can't compare it to get player character -> player state on begin play as on clients this reference might still be none as character is not necessarily there yet
You can get the "Owner" of the player state, and cast it to a controller
(Player State owner is always a controller)
Hi everyone! I'm working on a dedicated server project,and I want to create new "game sessions" if its needed. But I round into a problem. I've found that for each dedicated server you can only create one game session/map loaded? What is the best solution then for games that creates new sessions if needed? Having multiple dedicated servers is the solution? Does platforms like steam "solve" this type of problems? Thanks!
I'm currently using this method here to print some debug information on screen, but this method becomes a problem when it comes to multiplayer games since if client 1 will use this it will be also shown on client 2.
Is there any similar way to print it only on the client which calls it ?
static void DEBUG_MESSAGE(const FString& Message, const float TimeToDisplay = 5.f, const FColor& MessageColor = FColor::Yellow)
{
if(GEngine)
GEngine->AddOnScreenDebugMessage(-1, TimeToDisplay, MessageColor, Message);
}
no
Damn
if you wrap it in maybe IsLocallyControlled somehow
in PIE it will show for all
in non PIE it wont
as GEngine exists just once for ALL players in PIE
That's unlucky since i'm mainly using PIE
This is a neat trick. Thank you.
I've extended my CMC a bit and i hope someone could review it since i'm a bloody beginner when it comes to UE's multiplayer >_<
Header: https://pastebin.com/gvhm8Pcf
Source: https://pastebin.com/YAauVkBg
Everything seems to work just fine (As offline, server or client player), but i don't think that i'm doing everything correctly, so i'll take all critics with love since it will really help me to improve β€οΈ
You're not using saved moves and compressed flags? Not mandatory but seems to work really well. Also helps in laggy situations.
I rarely use RPCs in the CMC. And I wrote a function that handles any type of speed change into one compressed flag. Nothing impressive but helps a lot since I have only four compressed flags available and potentially more than four movement modes.
Actually not.
I've tried to follow this tutorial here https://nerivec.github.io/old-ue4-wiki/pages/authoritative-networked-character-movement.html
But it ended up with me not being able to sprint due to the boolean sprint variable
I was able to track the issue down to this method here
void UMyCharacterMovement::UpdateFromCompressedFlags(uint8 Flags)
{
Super::UpdateFromCompressedFlags(Flags);
//The Flags parameter contains the compressed input flags that are stored in the saved move.
//UpdateFromCompressed flags simply copies the flags from the saved move into the movement component.
//It basically just resets the movement component to the state when the move was made so it can simulate from there.
bWantsToSprint = (Flags&FSavedMove_Character::FLAG_Custom_0) != 0;
}
But i didn't know what was wrong >_>
π€π€. Can't exactly say what is wrong. The code looks fine.
In case that i'm going to try it again, could you show your method with the flags ?
Same exact thing. Just different variable name
Alright
But if your original method works for you, it's good.
Ye, i'm just afraid that i'm doing some stuff which i shouldn't π
Like that i shouldn't replicate the timer handle or similar
I haven't used timers in c++ yet. I distrust them. So I can't really say. But one thing is this, if the value doesn't change from an initial set value, I found out that there's no need to replicate it.
That's a thing i could follow π
distrust timers? wtf?
Sorry π just the way I am. They've given me some weird behaviors especially when I used them in tick.
you don't use timers in tick tho π
Yep. Since then I avoid using them as much as possible. Definitely not in cpp.
Timers are awesome
our game wouldn't work without them
we would have to use Tick in every actor
Wow. That's a lot of timers.
does anyone know why unlit white is being dispay grey? π
I find it sad that AIPerceptionComponent only perceives Actors on the Server. Yeah it is for AI, but for Players it seems nice too and when using it, it's a shame that the client needs to wait for the server to replicate the perceived actors to the client. Targeting can also be a good client only thing, where the Server only get's the info on who the client is targeting.
Did someone knows about a Client side implementation of the AIPerceptionComponent? Or something similiar?
I think Pawnsense or whatever it's called can do that. Though it's incredibly simple. You'd be better off probably creating your own component for it.
Iβll have a look. Thx Authaer
You want to use timers, they are awesome.
They are not
Uhhhh... question. I am using an existing server array of actors that exists on all actors of that array type. I thought I could use the server to loop through this list and set it slightly differently on each individual actor in that array, but get`No value will be returned by reference. Parameter "PartyMembers."'
Is this because I am running the "Set Array Elem" from one actor on the server that technically does not have ownership over others on the server? I feel like that's why it doesn't work
I created a tempArray for this and still get the error, so my assessment was probably wrong
It's a bugggggg:
When I created my variable on the event, it defaulted to what my variable shoulda been. Resetting that variable to the same variable type fixed it
I have had the last 2 lines in for years to prevent some bug at the time I believe. It seems to work fine on Steam without those lines anymore so is it safe to remove them or do they serve a purpose that I didn't encounter yet?
[OnlineSubsystem]
DefaultPlatformService=Steam
bUseBuildIdOverride=true
BuildIdOverride=1234
On 4.26, sometimes I get a a 0.3 second stutter every 2 seconds while in any project - blank template or myproject.
Unchecking UDP Messaging > Enable Transport fixes it.
I need to test multiplayer though. Resetting my PC sometimes fixes the issue (even with Enable Transport on).
This seems to happen after I -
- connect to a VPN and launch myproject
- shutdown my project, and disconnect from the VPN
- launch my project
Anyone know of a way to fix that stuttering w/o unchecking Enable Transport, and w/o resetting the PC?
Edit: Ah, I think I got it. So, basically, if I don't want to restart the PC, I can just uncheck Auto-repair, and keep Enable Transport checked and the stuttering stops!
@worn hill Do you have send usage data enabled in editor preferences?
That tends to try and send data frequently and if you lose connection it prints in the logs and causes hitches
I always turn it off to avoid this
@grizzled stirrup Excellent! That indeed fixes it too. And it's the best fix in my case. Really appreciate the help!!
@worn hill usualluy for me that means that you turned on undreal with a vpn off and then turned it off
I had to restart to fix it
@eternal canyon interesting. In my case, I
- booted up my PC this morning and connected to my work's VPN.
- during lunch, I launched UE4/myproject, did some mucking (saw no stuttering, left it on in the background and went back to work)
- Shutdown UE4/myproject after a couple hours, finished work and disconnected from the VPN.
- w/o restarting my PC, I launched UE4/myproject and instantly noticed the stuttering
I'm hitting a wall here, hopefully someone can point me in the right direction.
I've got a replicated actor, which contains a replicated actor component. The actor component sets the array variable on server, however the OnRep does not get replicated on clients:
If I do the same thing with a repnotify boolean, everything works as expected.
The pin in 0 is valid, and points to a replicated character.
If I use some print strings:
This is what I get:
-> as you can see, no client REP
What can I look for?
If after this I do:
then everything work as expected:
but not with my array.
so... if I encapsulate my array in a struct then everything works. WTH
I have the same thing, usually due to VPN. Disable the UDP plugin in that project and it goes away.
That's a scary issue...
Makes me fear for the safety of my own arrays
well, there's something deeper than this because I'm trying to replicate it on a newly created project and I can't. Though, the settings are exactly the same.
the only difference that I see with the fresh project is that I've upgraded my project from 4.25.4 to 4.26.1
Could it be that the client already has the value you are setting?
No, because the only thing that runs on all clients before this is:
so basically it's an empty array everywhere (server & clients)
this is literally what I have to do to solve this:
then, it works as expected.
π€
all of the other code is the same
And I just grab the users from the struct after replication:
like this, it works. All the other code is the same. I've basically wrapped my array into a struct...
@potent cradle have you ever seen this?
This problem? No have not sadly. Especially considering you're setting the whole array as a value. I know it doesn't repnotify if you add something to it, but you've set the whole variable to a value, so it feels odd as heck it doesn't actually work.
yeah that's why I'm setting the whole array, I'Γ¬m well aware that setting elements does not trigger the notify
Ok I've tried other combinations, including recreating the variable, recompiling everything, to no avail.
@ember needle you need to remove the client setting the size
why?
I'm changing the inner elements anyway
let me try it though
@meager spade nope, no change.
BTW same code works in 4.25.4
Ok so it doesn't have to be a struct, but it does have to be another variable. So like this it works as well (complete code):
I have a few questions I've been struggling with.
One is a persistent crash that seems to happen with what I think is the Steam Subsystem and lingering sessions causing fatal errors on startup of the program. I have a friend testing too, and the same fatal error on startup kept happening.
EDIT : Seems to be directly related; when i am hosting a game, my friend fatal errors on startup. When i am not, they can play fine.
Are animation notifies replicateable ?
Nope at least I'm not aware of that
UAnimInstance itself is not
Alright π
Can conditional property replication flags be combined?
I want COND_InitialOnly and COND_OwnerOnly
This image from the Network Compendium:
This all makes sense, but why are the Player Controllers on the line and not in each Client-Server intersection?
Are there 2 Player Controllers for each client?
One on the server, and one on the client?
Yep
PC exists on both
I am trying to recreate a few movement abilities from some games I enjoy as an exercise in learning the different ways to do networked movement. The things i'm aiming to recreate are Dash and Springstep from the game Spellbreak, Genji's Dash and Wrecking Ball's Grapple from Overwatch. I am not currently using GAS as most of the game besides the movement shouldn't need it (no stats/attributes or dynamic abilities, leveling up, etc.), but I know GAS has abilitytasks that do some of what I want.
How do I use FRootMotionSource outside of AbilityTasks? I can't find any useful docs on it.
Is Root Motion the answer for most of these?
How do I validate on the server that these abilities should be usable (for instance, on the client I check the cooldown, if its fine, then I predict the move in the CMC, but then on the server I'd also need to check the cooldown before performing that move)?
for reference, https://www.youtube.com/watch?v=4ykAw0GCZyM Springstep is demonstrated 2 seconds into this video, Spellbreak's dash is steerable and affected by gravity, genji's dash is not steerable (and you can't turn the camera during it), and wrecking ball's grapple attaches you to a point on the map that you can rotate around at high speeds until you choose to disconnect
The Springstep Rune Guide for Spellbreak #shorts
WATCH me live on TWITCH: https://www.twitch.tv/bastionlmao
FOLLOW me on TWITTER: https://twitter.com/Bastionlmao
FOLLOW me on INSTA: https://www.instagram.com/bastionlmao
#Spellbreak
#Chapter1
Is there any chance that GetOwnerRole() will not return ROLE_Authority if you are inside of a server method ?
Also, I'm facing here a problem with animation notifiers.
As it seems it will fire multiple times due to the fact that this animation will be played on multiple clients.
Any idea how i could avoid it ? π
It's kinda problematic in my case since the notifier will consume some stamina from the player. And it really shouldn't take like 4x the stamina for 1 dodge animation
Actually, i just had to wrap the method which consumes the stamina with if(HasAuthority())
what could be causing this? the client is in first person view even thought its variable is telling him to be in third person
this is the code that initializes the PC and what happens on value change
hello! do anyone have any guide for making multiplayer fps? Im trying to get my multiplayer fps to work on both client and server side, but i have sync issues. Im working on blueprints
Any good tricks to find out the origin of a read mismatch in net serializers? The kind that would prompt this error: ReceivedRPC: ReceivePropertiesForRPC - Mismatch read. Function: ServerReceivePredictedMessage
I'm attaching a server-side mesh to a server-owned actor, but the mesh isn't being replicated
I don't know why you'd expect that to work
for a component that's cosmetic
ideally, you'd just replicate enough information for the client to spawn their own component
You should take a look at ShooterGame
Is there a "best way" to handle Characters moving on top of other moving actors/pawns? (E.g., moving platforms, ships, etc.)
Seems like I always end up very visible jitter
in the CMC, when the client resimulates moves after a server correction, is there somewhere I can access what timestamp the client is "replaying"?
why does the memory streamer still disconnect the client from the match ?
Hi, new here. Anyone achieved World Origin Shifting in multiplayer sessions? Im using world composition. It should be a game like forza, only difference that main aspect are offroad cars...
WOS in multiplayer is problematic because the server still needs to pick one origin - so computations for players far from that origin will be wrong
There's a marketplace plugin that claims to do it IIRC
No idea if it's good
even if it is just client side? I do not plan to run vehicle simulations on server, the client would probably have absolute authority over the movement.
Client-side only wouldn't work since your characters, for example, would have different locations on server and client
Guys, can a FString be sent via a RPC?
Sure
Then why is it crashing for me? I receive the following error:
Assertion failed: Writer.GetNumBits() - BitsWrittenPrePacketInfo <= MAX_PACKET_INFO_HEADER_BITS WriteDummyPacketInfo exceeded the max allowed bits. Wrote -515960895. Max 20
The RPC in question is a 'Server' call, which passes an FString. Currently nothing happens "on the other side", meaning that the called function does nothing. Yet, calling the server RPC from the client produces this crash
What kind of string are we talking here ?
A simple one, let's say it's compsoed by 5 chars
FString works perfectly fine anyway, I have server RPC calls with FString in my own code
Something else is going on
I know, I don't understand what's going on. Other RPCs in the same class work fine with other parameters
Are you sure the string is correctly formatted - is it fine when printed before the RPC ?
If I run it in debug from my IDE it stops where the crash occurs... but if I "go on" then it works and it always work from that moment on. Without the debugger though, it just crashes in that point
Yeah, I also tried manually inserting a string right now just to test it, but it still crashes
is the overhead of calling a server RPC from the server worth thinking about?
I just tried right now to create another RPC with a string parameter
The RPC does literally nothing
Yet, when I call it from the client the crash always occurs
No idea what's going on. UE is 4.26.1 by the way...
Wrote -515960895. Max 20 lol
yeah, at first I thought it could be that the string wasn't null terminated or something, so it just tried to pass infinite... but even if I hardcode pass it a "test" string, it keeps doing it
Update: I actually discovered that the issue is not the string. It crashes with 'Server' RPC made in that sequence! It basically looks like this:
An that event if fired from C++ like this:
This is the definition of the event:
Now the funny part: if I add a 'Delay' node with a 0.1s delay right after the event is fired in the BP, then all RPCs onward work!
Does anyone have any idea what might be going on?
I mean, I can use the 'delay' workaround, but it sucks... I'd rather understand if I'm doing something wrong...
Hello everyone,
I was just wondering, if a variable let's say Ammo is replicated and only modified by the server, is it considered safe for the client to be the one to process the ammo check, do the shooting trace and tell the server to process the hit? Or should I call a server RPC from the start to check ammo and process the shooting trace?
you should definitely let the server do the ammo check lol
What I'm wondering is when it is replicated if that is necessary or not
as its value is set by the server
so it made me curious
it should be replicated to the owner
Should do both
When you factor in latency, there's no garauntee the clients' current ammo value is correct when they ask the server to fire a shot
It's quite common to predictively manipulate ammo client-side to avoid that happening often.
But you want to make sure it can never go out of sync
True, let the client shoot and validate from server right
Both client and server should check essentially. Having the client check avoids redundant RPC calls that you know will fail, and having the server check prevents cheating.
If you don't check ammo server-side, that's an instant cheat/exploit right there
I see thanks for the insight
although, checking on client side, wouldn't that cause firing/not firing in case of latency? Maybe it's visually better to just let the server handle it and if it's out of sync or latency is super high the shot itself it delayed
That's what I'm saying about ammo, so a common approach is to manipulate the ammo on the owning client as well
Then when you ask the server to fire a shot, force the current ammo value to replicate somehow by marking it dirty so that the client doesn't end up totally out of sync
TL;DR, it's complicated π
like everything in multiplayer
I want to spawn my players only when my game reaches a certain number of players, how would i go about doing that?
As far as i know you are are able to call functions with CheatEngine.
Does that mean a hacker could just call e.g. the server method to give the player health ?
@nocturne iron this after seamless or hard travel?
@vague fractal if you think you can make a game that can't be hacked, think again
Not really thinking that, but i was hoping that the LocalRole will be None or smth like that if a user tries it with cheat engine
There should be no clear client->server path to give the player health that isn't checked/validated by the server
its balancing the how difficult it is to hack, what you gain by hacking it with consequences if you get caught
that makes them go hack something else instead
in our game, only thing that can give player heath via client action are abilities
and the server is perfectly aware if ability is on cooldown, unavailable, or you don't have energy to activate it
its only the server RPCs _Implementation that directly ties into HealthComponents
I see
I havent thought out the system yet, i whant to create a lobby based matching system. Where the game starts after X player has joined.
So i suppose it's after a hard travel
if you have a lobby first
then its after seamless
your AGameMode::PostSeamlessTravel can't call HandleStartingNewPlayer
nor can ServerNotifyLoadedWorld_Implementation
The lobby is a widget on top of the main level
you need to keep count of players that finished loading (it would be NumTravellingPlayers == 0) in case of seamless
and then manually trigger the logic from inside the controller iterator from PostSeamlessTravel
ReadyToStartMatch would also have to return false before the players are spawned
generally better to run a lobby level
Right
then just seamless to play level
after everyone is logged in/ready
makes for much cleaner logic, and generally better experience
I'll give it a shot! thx!
the lobby complexity tends to grow as you delvelop
and your game PC/PS/GM/GS/HUD are unlikely to be able to handle it forever
organic growth is awful
Hello! i want every player (With the right ID) to be able to move the axis, but now only the host can, Anyone know what i missed? π
(This is in the Player controller)
not sure, but maybe the client returns player controller ID 0, since he does not know about the other players. and the server which naturally also has controller ID 0 is the only one who actually equals to that?
hmmm
I tought it automaticly assigned diffrent playercontrollers? i might be wrong af tho
No i do actully have both client and server on 0
are u using game mode -> event post login?
u can built an array with all joined players and i think it will return the actual player controller ID
Hi, I am developing multiplayer game where player has local customization map where its Pawn can be customized, after that Player join the Multiplayer map. I want to take this customization info the the multiplayer map and spawn character according to customization info for each player. Where should i store this customization info ? I tried storing it in PlayerState but then player joins multiplayer map it gets reset.
PlayerState is where it should be stored - have the PlayerController load the data on the client and RPC the server to write it on PlayerState
thanks, will try this.
Alternatively store it on the pawn directly
Well dont know tbh, its a Marketplace project so with full MP support
@bitter oriole do u maybe know how to get a reference to the playercontroller who called an RPC?
Yeah, pass it as a parameter
tried to pass the playercontroller, but its -1
How can I handle sending RPCs on a very frequent timer (calls the RPC on each 0.15-0.2 secs)? I could make it unreliable but I am spawning projectiles that is crucial for gameplay
Show the code
It has to be unreliable. It's probably not as crucial as you think it is
And if the frequency is important (like firing a weapon) you need a start fire + stop fire RPC instead
I see, I'll try the second one, thanks Stranger
I don't see an RPC here with a playercontroller parameter
If you're staying within the same class, the controller is just this actor
No need for any copy
On the client, the only player controller that exists is themselves. you should either have every player controller send input to the server and have the server filter by ID.
But for testing, just have every client player controller send the input to the server, and check if it works where everybody can move the actor
aha well i most likly have it built backwards then
How are you planning on determining who can move the actor and who can't?
With the player ID
Then you should probably handle this in either game state or game mode.
I want sort of big turrets on the map that all players can access/Give input to by only having the right ID
@bitter oriole forgot to hook up the get player controller..
the general setup looks like this. but the RPC always receives "0" since (i think) the client player controller is always 0
I would do it like this.
Client side PC sends input to server side.
Server side PC calls event on GameState or GameMode with parameters PC and Input
GameState or GameMode checks PC ID vs allowed PC, and processes input.
Although I would probably use the Player IS instead of Player Controller. Should be an array of them in GameState by default. And each client should know their own.
Thank you
oh never mind, i think something wasn't hooked up correctly in the other BPs so it was always zero. now it seems to work π
There are optimizations you can do like having the client check first if they're allowed to send input or using a hashmap to hash player IDs to turrets if a player can only send input to 0 or 1 turret at a time.
Depends on how you're setting it up really
Hmm yeah valuable info, gonna try this out tomorrow
I'm working on a spectator mode for my multiplayer game, trying to think of the best way to handle it. Currently I have a camera that updates location and rotation to match the selected player's camera on tick. This results in crazy rubber-banding and the rotation isn't quite right. Anybody got a better idea?
There are not many tutorials/videos on spectator related mechanics
If I wanna synchronise a rotation between server and client every minute, would Multicast be the way to go?
I know there is RepNotify, but I also rotate on tick, which I wouldn't want/need to replicate
^ unreliable server rpc
RPC being Multicast then?
. (i disabled the @ hope no notification arrives)
In a typical server to client implementation you'd repnotify the rotation, measure the average replication rate on client (varies based on network conditions) and use that to smoothly interpolate with quad interpolation
Wouldn't RepNotify trigger on every tick then? But that may not be so bad if it's unreliable I guess
Not on every tick by far, but often, yeah
Tick is fine
The interpolation would need to be there
Movement in general needs to be on tick if you want the animation to be smooth
Ah, neat. I think I might jus try that. The rotation is so small, and constant in time, so I imagine the measurement of replication rate would be overkill?
Depends what you need. For constant rate you can also simply get the shared world time in game state and derive rotation from that with no networking at all.
I feel like I'm doing something like that, though it's a timer on gamestate. It triggers the "syncing" event every minute, but still I feel like the rotation is a bit off. Could be my judgement, though
I do mind the server world time specifically, that one is shared for everyone (to some extet, it's not perfect)
why is my character ref returning none only on clients? edit: also, i added a breakpoint to the cast failed exec pin and it does not trigger, meaning that the cast has to be successful. how is the ref null?
You mean from GetServerWorldTimeSeconds()? I would have thought timers on gamestate would call the event in sync on client and server, but it seems not haha. I'll try make it a function of the server time, and see how it goes πͺ
@faint pawn controllers only exist for the same client and server, never other clients
so client A can never see Client B controller
Hi, what's the best way to have persistent data ? Like username or skin styles
i am telling client A to create a character A ref. i am not trying to make them communicate with each other. this is called on begin play of the PC
and all characters with SimulatedProxy role will have that ref as nullptr
well, they won't even have the PlayerControllers
for other players to start with
also
unless you are doing deferred spawning or delayed BeginPlay
i have a small delay of 1 second set on begin play actually
Controllers won't have a Pawn at their BeginPlay
on server
on clients... its a funnier situation
as the Character Actor needs to replicate on its own
and until it does, there is no way to resolve the Controller's Pawn NetGUID
but if it does arrive at the same time or before the controller
then client's controller will have a character at BeginPlay (unlike the server)
solution:
use OnRep_Pawn/Controller overrides and SetPawn override
from c++
another question. why does the server print 2 times, each with a different version of a game character reference? also the client with seemingly no character reference can print it just fine?
oh wait, the server prints one for the client and one for itself? i think thats how it worked right?
i am trying to let the server read a variable which each client can individually modify on his end - right now stored on the player controller..
currently using a player controller reference, but i cant read the actual variable from the client. is this even possible...? am i storing storing it in the wrong place? also tried pawn and player state...
server can't read stuff from other machines
other machines can ServerRPC the information, using an owned actor channel
to the server
thx @winged badger, didn't know that
avoid connecting GetPlayerCharacter[0] to the business end of a Server RPC
as its evaluated on server
hm
and GetPlayerCharacter[0] on server is not the same as on client that sent it
so what should i do?
add input to the RPC of your character type
and send a reference to the attacking character through the RPC that way
the only reference i get is on animation blueprint
i dont have any events calling from there
thats on my character bp
what are you trying to do ?
Every time i press left click to attack it performs the attack on every client
which shouldnt happen
i have done it before
and it worket
thats a completely new project
do you call attack from the player bp ?
yeah
and also is it like an anim bp montage ?
so your changing the is Attacking bool then the anim bp plays the attack anim ?
can i see where you got the bool from in the anim bp ?
lemme fire up the engine
your supposed to use a different node
use this
then cast the pawn to your character
Respect
or you can use this
its no worries
you're welcome
also it wasnt working earlier because on each client this node gets the local player controller
and on the server it gets the host/server controller
this is not possible. i really need someone to help me figure out what the problem is or i'll lose my mind today. why are the client and the server not behaving in the same way?
i just cant wrap my head around it
so i read the network compendium again and i think a light bulb lit up in my brain. in my player controller, i have logic that lets players switch from 1st person to third, but my problem was that the client(blue) was not properly showing weather the other players were in fist or third. thats because there is only 1 player controller on the client. the second problem was the IsThirdView bool's value on server was the opposite on clients. thats because on begin play, in the initialize i was setting the bool to opposite(not) which triggered the OnRepNotify. problem was, both server and each client would run the logic, so after server is done running the code, the client would end up with the opposite value of the original
so i fixed it by manually setting it by default to false, and on initialise i simply set it to true. someone correct me, but i think even simply setting it true without bothering to change the default is enough to trigger the OnRepNotify, correct?
@faint pawn Out of curiosity, why do other clients need to know another client's view perspective?
i kind of worded it badly. i meant that the client did not have the proper bool value
I was just curious about the necessity for it in the first place. Most situations like that the server and other clients won't care about a particular client's view type.
There's a function to force replication. I'm not sure if it's available in blueprint though, but look and see if it is.
And if you want a variable to be in sync everywhere, you need to set it on the server, and have it be replicated. That should be all it takes. and if you're doing a rap notify, have the rep notify depend on the state of what your replicating. so if you're going to do something when the bool is true or false, have it used the bool to determine what to do.
And also, a variable on the player controller is only visible to the local client and the server. If the variable needs to be visible to other clients, either put it in the pawn or put it in the player state
ForceNetUpdate, but that just pushes it ontop of the replication queue
and it is available in blueprints
won't help any when talking empty template level
as there is not enough stuff on it replicating to put any load on the network
Can root motions be replicated without CMC?
montages should be able to do it
RootMotion movement requires CMC if you want to move
the CMC extracts the anim root motion and processess it
otherwise it will snap back
I see, I was both scared and confused when I see root motion flags on CMC, I thought I cant even play montages on pawns
UE support int8?
UE does, blueprints likely don't
so, if i need int, it must be int32 only?
If you need it for Blueprint, yes.
int8 size 1 byte too, like uint8 ?
i wont make like this
UPROPERTY(ReplicatedUsing = OnRep_ItemQuality )
int8 ItemQuality = -1;
//For BP
UFUNCTION(BlueprintPure)
int32 GetItemQuality()
{
return ItemQuality;
}
Would return int32(ItemQuality) work? π€
i think yes. In this page i find example https://doc.embedded-wizard.de/integer-conversion?v=9.30
var int16 a1 = -1251; // hex 0xFB1D
var int32 b1 = (int32)a1;
so, who can say, how use it true?
int8 ItemQuality;
int32 ItemQualityTest1 = (int32)ItemQuality;
//or
int32 ItemQualityTest2 = int32(ItemQuality);
one is C style, one is functional cast
in C++ you should use the ugly C++ casts (static_cast, dynamic_cast, etc)
C cast can be dangerous
as it goes through a list (in defined order) to find a suitable cast
also hard to find (even harder to find functional casts)
const_cast
static_cast
static_cast followed by const_cast
reinterpret_cast
reinterpret_castfollowed by const_cast```
reinterpret_castfollowed by const_cast that's beautiful
Hey! I have another question regarding Steam and packaged build having trouble with sessions.
We can host a session fine; however a persistent problem is happening. Even when we set the session settings for NumPublicConnections to a number greater than 2, the lobby closes after a player connects to the lobby. Also, even though I explicitly set the bjoininprogress to false, players can still join a game in progress
(Fix for last comment, if anyone cares) After some troubleshooting, I learned the netID was causing fatal errors to anyone attempting to launch the game while a session was available.
Do I need to use static casts? or it will work?
UPROPERTY(ReplicatedUsing = OnRep_ItemQuality)
int8 ItemQuality;
UFUNCTION()
void OnRep_ItemQuality();
UFUNCTION(BlueprintPure)
int32 GetItemQuality()
{
return (int32)ItemQuality;
}
UFUNCTION(BlueprintCallable)
int32 SetItemQuality(int32 InItemQuality)
{
ItemQuality = FMath::Clamp(InItemQuality, -128, 127);
return (int32)ItemQuality;
}
it will work
maybe here it must be like this?
UFUNCTION(BlueprintCallable)
int32 SetItemQuality(int32 InItemQuality)
{
ItemQuality = (int8)FMath::Clamp(InItemQuality, -128, 127);
return (int32)ItemQuality;
}
oh, okay
I am trying to wrap my head around joining in progress games. Is there a formal system in the UE4 code base that supports this? Or is it pretty seamless and if everything is set up properly, it just works? I am additionally looking at the replay system and wonder if/how they are related. I play a lot of Deep Rock Galactic and am impressed how between the procedural geometry and bugs and huge amounts of time (hours?) can catch your local machine up with all of that.
If the games' networking is all setup properly it should just work
Replay system isn't related
Do you think it might leverage the same data behind the scenes?
It does
Great. That makes sense.
Replay system is essentially just a dummy network driver, and you feed the saved game states into it
But what you save as part of the game state is up to you really
I also heard of the very cool Stadia feature that lets you play screenshots of a game. That would also seem to tie into that kind of functionality.
Possibly, the replay thing has limited scope IMO. It's fine if you want to watch full replays of games, which is what Epic built it for for Paragon.
Also takes a massive effort to support, but ultimately it's irrelevant at runtime
Joining a game in-progress is easy so long as the state of your game is properly replicated and setup
ultimately replay/join in progress are totally unrelated though
Right. In the case of DRG, they have to be using something like marching cubes to build geometry, but I CANNOT imagine they are replicating that. Which means that from a cheating perspective, you could locally instantiate geometry that doesn't exist to the authority, but ultimately it doesn't matter.
Most likely the level is generated from a seed, then they have "deltas" which are replicated
Right.
Or something similar. Whether they use built-in engine replication for that I don't know
Most likely not I would guess, since the engines replication is designed for "small and often" packets rather than "large and everything"
One thing I don't know exactly is how they replicate but guarantee order for all of those actors. It would matter which order those are received and commited to the geometry. I believe.
As long as something is persistently the same with a seed a client could safely generate all that stuff on it's own right?
With deltas you mean changes I assume?
yeah
So, for example, you get a bulk detonator blow a huge hole in the floor, then someone adds a platform on top of it. That doesn't work in reverse.
Those deltas will likely be very small, the server will keep a huge history of them since the level opened up, then apply them.
Well mostly like the level state is generated first
Then everything else's current state will be the same.
Just basing this on how I would go about it anyway
They won't keep a record of everything that was ever done on the Server, you wouldn't need it.
All you really need is the initial seed, then the changes made to the level from that seed.
What about the order? If everything is synced, but then the 2 events I described occur. If we aren't guaranteed order, are they keeping an ordered queue or something and only executing once its continuous?
After that, you can just spawn stuff as normal
Yeah that's what I mean, you wouldn't do that. When you join a session in progress you only receive the current state of things, not the full history of the server.
That part does make sense. It is the order of subsequent deltas that has me thrown off between my UE understanding and what it is doing.
I don't think it matters that much
You aren't receiving "remove this stuff then this stuff"
You're just receiving "this stuff exists, this doesn't exist"
etc.
The delta's themselves are stateful
Rather than "do this, then this, then this" etc.
@surreal plaza Are you referring to the terrain or?
Yes, the terrain.
I think I understand your question, as in how do they sync up the terrain but also have player changes be affected to it like the scout who shot a platform right?
Right. But the terrain changes completely, you blow holes, you dig tunnels, it is fully malleable. Now I assume that underneath it all is just a huge 3d array of cubes.
It is minecraft basically.
What my guess would be is that they indeed have cubes / chunks. They probably generate the terrain client side through a seed like we just talked about and just sync up the most relevant cubes / chunks first to the client that just joined. So with that I mean syncing up the changes like "this piece was removed".
Because syncing everything up directly would be a mess.
Presumably it's just a voxel octree
So clients generate the initial state
then they receive a bunch of data which is "this voxel is actually xyz" etc
Maybe that is the way to think about it. It is Lets simplify and say that you have list of 10 cubes, that is the whole world. Your world looks like this.
RREEEEEERR (R=rock, E = empty) Someone could come along and add rocks to the middle. Or they could come along and blow away all of the rocks at once.
So you don't need the full history, you just need "difference from generated state"
That's the key
That's what I meant yeah, just have the differences be synced from the initial terrain. But they probably also split it up in chunks / cubes to not have to sync literally the entire map at start up.
Aside: they wouldn't actually make actors for every unit right?
I am getting there. Like Jambax said, this could just be a 3d enum array even, 10,000 to a side. And they generate that once and subsequent changes just target indices and update it.
So they have enums like (Rock_Bottom, Rock_Stalagmite, Platform, Lava_Pool, Empty, ICE) etc.
From there, they have all of the nice binary space partitioning algorithms at their disposal for update chunks, redrawing optimizations and whatnot.
Hi, so im right that Tick in GameMode only runs on Server?
How can i run some tick code specific for client only?
The gamemode only exists on the server https://gyazo.com/3856de37bf7f9d751f02730ef77ada81
Gamemode doesn't exist on the client, so they can't do anything with it
So there wont even be a way to e.g. replicate from server to clients via gamemode ?
Seems ill have to make use a actor then
Do out-of-the-box ACharacter clients not replicate their rotation? o.O
it does
Hmm, I must have mangled something then
Only my server is updating its rotation
(When mouse looking specifically)
Hmm, does anyone know why rotation (mouse look) would be replicated only from the server, and never from the client?
It also fails to update their rotation when I force it through some debug on tick
Replication is only ever one-way (server->clients)
Which rotation are you talking about? There is no rotation called mouse look
Character rotation is sent to the server based on the controllers' control rotation
That's how it works internally
Make sure you are "rotating" the character by adding/setting control rotation, not by just rotating it manually yourself
On the topic, what's the difference between the control rotation and base aim rotation?
Nothing by default
GetBaseAimRotation() you can use on non-controlling clietns as well, as that includes the replicated packed pitch and yaw offsets
Here is what I am doing at the moment
You don't need to do that
You're setting the control rotation of the controller to what it already is
So that makes little sense
I am adding 1 to the Yaw
Why on tick?
Has the controller actually possessed the character?
I think so, I may not fully understand what "possession" means, but they are controlling the characters client-side at the very least
I'm guessing the control rotation is locally predicted or at least locally updated while base aim rotation is replicated everywhere?
It just seems weird that they would have two rotations that sort of do the same thing
Control rotation is entirely local yeah, base aim rotation returns the control rotation if the controller is available
or the actors rotation + the replicated offset rotation for non-controller
In the case of characters, they can only ever yaw
So pitch is replicated separately as "RemoteViewPitch"
Or whatever it's called
So if you wanted to have one rotation that is the global source of truth for the direction that you were aiming on a arbitrary pawn, you would probably have to just make it yourself?
I tell a lie CMC sends the actors' rotation not control rotation
But by default characters are set to follow control rotation
@dark edge If you can aim on the "yaw" axis independently then yeah
Pawn.cpp only handles pitch by default
Just to clear it up for me, when i replicate this variable inside of my component
UPROPERTY(EditAnywhere, Replicated)
FHands M_Hands;
Is all that also replicated, or will i run into some problems when i change stuff in there from the replicated variable ?
USTRUCT(BlueprintType) struct FHandData
{
GENERATED_BODY()
UPROPERTY(EditAnywhere)
EHumanHand M_Hand;
UPROPERTY(EditAnywhere)
EHandAnimationStyle M_AnimationStyle;
};
USTRUCT(BlueprintType) struct FHands
{
GENERATED_BODY()
UPROPERTY(EditAnywhere)
TArray<FHandData> M_Hands{ {EHumanHand::Left, EHandAnimationStyle::None}, {EHumanHand::Right, EHandAnimationStyle::None} };
};
Everytime i look at the pawn/character classes I leave annoyed by how unneccesarily bloated they are -.-
Yeah yeah it seems like there's some goofy design
AHA, I found it
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = false;
GetCharacterMovement()->bUseControllerDesiredRotation = true;
I only did this when setting up player input
Because there was a weird twitchy bug with animations on creatures
I can probably just check if the actor is possessed in the constructor
I actually just moved it to the possessed by function, ezpz
hey guys i was just wondering what it takes to connect to a dedicated server on my project i have everything specifically replicated for a dedicated server setup that is why i cant test peer to peer using steam any help would be appericiated as i would like to host the server on my local PC for online play but i cant seem to even connect to it locally using open 127.0.0.1 let alone connect to it through advanced sessions does anyone know if im missing a step i need this server up and running for testing purposes so any help would be appericiated
@sick creek For testing purposes, you can test in editor by going to the play settings, unchecking "use single process", set the multiplayer mode to "standalone with client", uncheck "automatically connect to server", and set the number of players to something like 3. Then when you go to run the game, make sure you have "run dedicated server" checked, and then choose to play as standalone.
This will start the dedicated server in a separate window, and the clients will run their own copies of the game, and you can then connect to the dedictaed server by opening the console and typing "open <ip>:17777" where <ip> is your machines local IP (not 127.0.0.1)
This is how I test things like, for example, players joining mid-game
I have a quick question. I want to implement a system where if the server detects that some players are still loading it, it won't start the match without them. Players get a menu pop up to select a team and loadout etc, so what I want to do is give them 30 seconds from the time their menu pops up to make their chocies, and then the game will begin without them if they're still deciding
Is PostLogin within the game mode called on map changes as well, or is it only for players who have joined the server for the first time?
I want to know when the server should set the 30 second timer before marking the player as "fully joined"
The 30 second timer is cancelled when the player has chosen a team or opted to go spectator, so now I just need to start that timer at the correct point
This is to prevent players trolling by joining the server and sitting at the menu forever to prevent the game from starting
Can anyone give me idea
How much Server Capacity required to host 1000 concurrent Players. Game category like Battle Royale.
I'm just curious about how much it costs.
How PUBG like Game able Provide Seamless Server Support for Long Period of Time. Because user pays only ones.
@compact mesa Dedicated servers run single-threaded, so you would need insane single-core performance, and you would need to write an extremely lightweight, custom character movement component, because when player counts go over 100 that becomes the biggest drag on CPU performance
i just found out you need a steam dev app ID in order to use dedicated servers
so ill have to wait till april
Yes. And also there is Big thing called - VoiceChat
@compact mesa Yes that too, but from a pure gameplay perspective, UE4 just isn't built for that kind of player count by default, so likely you would need to write a whole new collision detection and movement component. Even if all your players were nothing more than moving spheres, when you have 1000 of them moving around the map it really starts to choke the CPU
basically steam prevents you from joining the session without the app ID at least in my case since i can find the session but cant join it could be another thing causing it but not sure
How does gameinstance work with multiplayer and dedicated servers? Do I have only one gameinstance per dedicated server? Can I store data on the dedicated server gameinstance without problems? 
and voice doesn't need to run through unreal, or through the same server
@frank birch Each instance of UE4 running has a GameInstance, so the dedicated server will have one, each client will have their own ones. The game instance persists from the moment the game boots up to when it shuts down. Game instances can never communicate directly, so you can't replicate
This is probably a silly question but even in dedicated servers and super big projects, one dedicated server can run only one "game", right? so even if there are multiple servers running they won't mix the data... right? π
Yes, each dedicated server is one copy of the game
Dedicated servers run single threaded (that's hard-coded into the engine) so if you have a physical machine with 4 cores then in principle you could run 3 copies of the dedicated server, and each would be its own separate process
We do that on our game, we have a physical machine we rent in New York and we run 3 copies of the dedicated server on it, and players in the server browser see "US East Coast 1", "US East Coast 2", "Us East Coast 3". They're all separate servers with their own players, maps, game modes etc. But they all run on the same physical server in NY
My fear was that maybe only one instance could be running multiple games so the gameinstance data would get mixed up π
Nah, one game instance per running copy of the game π
game instance is per application instance, not per machine
Great, I was looking for a way to store my "match settings" from the lobby to the actual game map without having to send them in the servertravel command. Storing them in the server gameinstance seems like a good solution π€
its not
its just avoiding leveraging the seamless travel
as you can just as easily have an Actor that persist through seamless travel that can also replicate whatever needs to replicate to clients
which game instance absolutely can't do
I need an struct to be sent through server travel... how? 
I know how to persist data from the playerstates and playercontroller
Its not an actor, is an struct
with all its data
all its structs
everything
and whatever you think you'll need now, trust me you'll need much more later on
the struct is from the gamemode (say, time limit and amount of frags to win)
I know, that's why sending parameters in servertravel?param=mythingy is a bad idea for me π
so make an actor
I have seamless travel on, how do I specify an struct to be sent via servertravel? π€
make departing and travel gamemode add it to GetSeamlessTravelActorList overrides
add whatever data you need to that Actor
and it will just be there
unreal engine says:
By default, these actors will persist automatically:
The GameMode actor (server only)
Where do I find the "persisted" gamemode? 
GameMode, GameState, NetworkManager, all PlayerControllers and all PlayerStates
persist by default
in addition to that, whatever you add to GetSeamlessTravelActorList in GameMode and PlayerControllers
i have no clue what the docs say, i never read them π
ok, I need to pluck a variable from the "previous" gamemode and we agree that it should be persisted...
where do I find that previous persisted gamemode? π€£
as i said i would use an Actor and have GameMode persist it
wdym find?
getPersistedActor is not a thing π€£
how do I find that actor that I persisted?
GameMode spawns it, GameMode persists it, GameMode has a pointer to it
that pointer survives unless GameMode changes class
GameMode has a pointer to it
where?
if it does, you just run a quick TActorRange to find it
you add it
to your custom GM
oh, if both gamemodes share the same variables they just magically appear?
i run a base GameMode with shared stuff between Combat and Campaign modes
i do change GM class during seamless, so i run a TActorRange to find my persistent Actor on the other side
but that Actor is there before the new GM is instantiated
so you can find it way before BeginPlay, before you even instantiate GameState
so all the data is there before the GameFramework classes even begin to do their work
Gamemode always change in a servertravel, even with seamless on. That's why I am having problems finding what the previous gamemode sent
Dm issue ?
Hello people! I'm working with blueprints and build a multiplayer game that relies a lot on VFX. Where is the best "place" to execute VFX stuff on? For example an attack lands on the floor and should cause an explosion. Right now my level blueprint executes that, but that is not very "variable" in terms of levels of course.
@foggy wave can you dm the issue ?
the client
unless its a listen server model
you dont want the dedicated server doing anything except logic
like hit validation
lets say you have a multicast
just add a check after is so the vfx doesent play if its on the dedicated server
But I'm determining hit events for the ground in the level blueprint, where i also execute the niagara VFX stuff
Ah okay that's important aswell I should consider that!
why ?
Because I didn't know how to determine hit events somewhere else xD
can i see what you mean my 'determining hit events' ?
Let me send the BP
this is the short version
I mean it works but it will only work for this level
so your checking if an actor hit the ground ?
exactly
why not make the ground an actor
But I guess I could do that in the actor itself
then check the hit events from there
Oh.
Argh why am I stupid
i didnt consider that
happens to me all the time
you're welcome
Hey i have 2 littles questions, (i'm new with ue4) 1: The best way to "save" data when you use ServerTravel is send the data to the game instance ? And anyone have a idea why my sound attenuation don't have any effect with voip talker ? Maybe is a wrong project setting or something like that
Hi everyone, I want to experiment with SeamlessTravel (I'm using ServerTravel atm but clients sometimes drop out in the process), but I get a server crash when using it:
`Unhandled Exception: SIGSEGV: invalid attempt to write memory at address 0x0000000000000003
[2021.03.25-20.27.57:605][ 41]LogCore: Assertion failed: Outer != nullptr [File:E:/Epic Games/Unreal Source/Source-UnrealEngine-4.24/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectHash.cpp] [Line: 754]
Getting objects with a null outer is no longer supported. If you want to get all packages you might consider using GetObjectsOfClass instead.`
Looking at the stack trace, the culprit seems to be this:
0x000000000555f07d WaTServer-Linux-DebugGame!UWorld::FindWorldInPackage(UPackage*) [E:/Epic Games/Unreal Source/Source-UnrealEngine-4.24/Engine/Source/Runtime/Engine/Private/World.cpp:6649]
Is this something to do with not having a transition map set correctly or something? I thought UE4 generated an empty one if that was the case
Does anyone here have experience with steam and UE4 compatibility? I have no issue hosting a new lobby, but once 2 players join anyone else who joins the session fatal errors and the game disappears from the server list. The hosting is peer to peer. 2 players, no issues and it runs fine over steam. 3 people, one fatal errors.
Ok I fixed the crash issue. It didn't occur to me to confirm that the designated transition map hadn't been deleted by some misguided soul (probably me...). However I have a new problem: the server loads the new map successfully but the clients get left behind in the old map. They do not travel with the server. I have set bUseSeamlessTravel = true in my game mode's constructor. According to the documentation that is all that is needed. What am I missing here? This is being tested in editor using standalone (not using single process)
I thought the editor didn't support seamless travel mode
At least it didn't as of ue 4.24.3. I haven't tried with ue 4.25.x or 4.26.x
@hybrid zodiac are you using the engine source build or one of the epic launcher builds?
@crystal crag Ah maybe that's the issue then. I'm on 4.24.3. I'm using a source build
Yeah, I'm surprised that you didn't get an error message about it. Oh, also, are you using the travel_relative flag or whatever it is? If memory serves me well (which it might not be), you are supposed to use travel_relative for seemless travel
Where is that flag? Never heard of it
It isn't mentioned in the docs
@crystal crag It's a little disconcerting that I can't test seamless travel and make sure it works as expected unless I do a full patch and test on a live server
Oh well, that's what test servers are for, right? π I'll give it a try and see what happens
Hmmmm, do skeletal mesh components not replicate their mesh?
Ah, it seems that it isn't. I need to hack a custom field into my character
You can change the mesh inside of an OnRep function to replicate it to everyone
Right, I am implementing a new equipped item field in my inventory
And I am just going to bind a function to a new delegate that will equip the item
Ok, I think I am making a pretty severe error
void UInventoryComponent::SetSecondaryWeapon(UItem* Item)
{
SecondaryWeapon = Item;
OnRep_SecondaryWeapon();
}
I need to call this from the server in order to replicate the property, yeah?
Hmm, seems I also made a mistake in replication on the way here, only the server has valid item entries
Any idea why my cubes arn't spawning in multiplayer?
https://gyazo.com/e0c1881fd69bad26657c1c7c4b7f6de3
Probably because they arent set to Replicate?
Also why are you using a Multicast to Spawn them?
The Server should be spawning Replicated Actors
Not individual Clients
So I call RemoveDebris which then call spawn in server. https://gyazo.com/db3939384491c0793669d95f42f0a6b4
Is that look ok
So If I spawn cubes in BP on server it works but not in CPP
@hybrid zodiac well I re-read the documentation and it doesn't say that you have to use relative. But also it appears it is a boolean on the UWorld::ServerTravel method itself (bAbsolute)
Sad times everyone. I spilled pop on my keyboard and now it is dead. I won't be able to program again until Saturday.
You can use virtual keyboard and use mouse to click on the letters, good luck
do any of you have experience writing replicated character movement using c++. is it better to do it in the character cpp file or making a custom movement component?
replicated character movement is a nightmare. the best way (so far that ive seen) is to extend the character movement component with custom movement modes and extra parameters in saved moves/network move data. there are a couple okay videos on youtube about it, and with 4.26 you no longer need to send move parameters in a separate RPC like you'll see in those videos, but can actually inherit from FCharacterNetworkMoveData and send the parameters along with your moves to the server.
but to be honest movement is just about the most frustrating thing to deal with in ue4 multiplayer
yeah i kinda figured but the game i'm working on completely relies on it.
same lol
evil
generic network prediction plugin when
its kind of bizarre to me that basically every 3d action game has some kind of dash/blink/dodge/wallrun/grapple mechanic and somehow there isn't an abundance of tutorials for doing each of those things properly like there is for every other aspect of that kind of game
i want a character to be able to wall slide, wall grab, rocket jump teleport and swing around.
It's because it's a fairly complex topic and there's no one-size-fits-all solution
network prediction is hard
i know that but there isn't even like a start.
and that's because there's basically no documentation from epic π
yeah they just say make a custom movement component. no tutorial or information.
network prediction is what i've spent like 90% of my time on for this project, and it feels like even though there isn't a generic solution for it, there could still be more than there is
its something that you need for every multiplayer game for the most part, and there's not really that much good info about implementing it in ue4
they do have a new generic network prediction plugin in the source tree but it is still under development last time I checked, and hasn't been touched in the past few months π¦
yeah i've been looking at that every few months to see if its any closer to being out of "beta" or whatever
mostly because i'm not experienced enough with c++ to really dig into it without any docs or tutorial videos on it
It looks like it's at least partially based on the design for GAS's network prediction, which is the other thing to look at for prediction.