for example, my basic UseAbility() function in the child class (PlayerAbilityHandler) checks right off the bat if I am the server. If so, it just calls Super::UseAbility() and that's it, sending the result back to the owning client in an RPC. If not, I check for AutonomousProxy, and if that's true then I do all of the client prediction and end up sending a Server RPC to call UseAbility() on the server.
#multiplayer
1 messages · Page 620 of 1
@vivid seal In GAS there is only one class(AbilitySystemComponent), client-predict call and server call are different functions
@vivid seal compose
make 2 UObjects with those functions, and instantiate one depending on authority or not
of course dude! 😄 Would be too much otherwise I agree, so setting up dedicated servers seems to be the best choice?
Hi all, I have a problem which is driving me crazy. In my game mode, the match state is somehow being set to InProgress without me calling SetMatchState and I cannot figure out which part of the code is calling it (I did a ctrl-shift-F and searched the entire project for instances of SetMatchState and there are none I don't know about)
I noticed in SetMatchState within AGameMode there is a log to LogGameMode every time it's changed, how do I view the output from LogGameMode?
Try put breakpoint in the SetMatchState method and check call stack, it works for me most of the time.
@finite kettle Ah good shout, thanks, I'll remember that next time! I actually found the cause of the issue, which makes it all the more baffling that the problem only just popped up now, years after development started. It's in HandleNewPlayerStarting
Just had to override it to do nothing since I'm handling player joining logic
But to answer your question, AGameMode is starting game when one bot/player is logged in game by default. If you want to start later, you must set bDelayedStart to true
@finite kettle Ah that might explain why the problem only just occurred now then, I might have removed the bDelayedStart flag by accident or on purpose without realising what it did
Thank you for the help 🙂
Hey guys, I got a weird problem for my character movement in multiplayer.
Server looking at client character is having a smooth movement, while Client looking at server character moves with jitters (shown as the videos).
I put the AddMovementInput node in EventTick as the image shown. I had the character replicated and movement replicated.
Does anyone got an idea how to fix this?😫
Hmm, is it right that pressing F8 to detach from PC during PIE with 2 clients (play as client), would be the server view? Or am I mistaken and is it still client side? I saw some behaviour that led me to think this, but I might be totally off base.
(pawn seems to disappear totally for some fun reason 😄 )
hi, so i wanted to implement multiplayer feature for my mobile game, i wanted to make it with unreal engine online subsystem itself but i dont have much multiplayer knowledge so i wanted it to be like someone hosts the match and the client dont have to put the ip but like he clicks on join and then he automatically joins a randomly hosted match so is this possible and how without a dedicated server or any other solution? please help
@winged badger Thank you for the answer, I had seen a few post on Answerhub mentioning that OnPostLogin was safe for that logic, but I see the intended way is as your stating. I will be looking into this today and hit you up with results. Thanks a lot.
Hello people! Does someone know how to correctly interpolate positions for clients via blueprints? I am doing the stuff in the picture for clients and it seems to work, but I am too much of a noob to know and it may get imprecise later. Thank you!
Hey, I'm currently working on a 1v1 online game using listen-server architecture that will be released on steam (therefore, using Online subsystem steam).
I was wondering if there is a way for me to have a queue-like matchmaking system ?
I know how to create a session, find other players sessions, display them and join one of them but i would like something easier to use as a player. Just click on a search button and wait.
I could just look for sessions and if nothing is found after a few seconds make the player create his own but that seems a little simplistic.
Is there a function that i missed that would help me achieve that ? Or is it not possible to do it cleanly using a listen-server ?
Thanks in advance !
@candid escarp that will choke your network for no benefit
you just need to replicate a single Vector in this case, DesiredLocation
and you let the client interpolate it itself on Tick
ah okay that means the tick thingy should be executed on the client only?
if everyone has an Actor on same location
and that Actor is travelling with same speed to another location
everything is synced
server just shares the initial state
and each client does the same thing on TIck - interpolate to target
logic you used above wouldn't work for single player, btw
I want to make players see same ball positions
it's an online-only game so that's okay
if you have a vector speed then FinalLocation += Speed * DeltaTime
there is no interpolation required in that scenario
oh okay
i will try that, does that mean, that I have to create a custom event that runs on clients only and is called by event tick?
@bitter stirrup its pretty much if game not found, host a game scenario
You could also have everyone host while searching, then quit hosting when they join a hosted game.
That way you don't have 10 people looking for a game with none of them hosting at that moment.
Is replicating the object itself enough or do I have to spawn another instance of the object on the client side?
I am not replicating movement btw.
@winged badger So there's no way to handle it using steam to match 2 players and tell one of them to create the server ?
without a custom server doing matchmaking, not sure there is
Hello!
I would like to ask a question about component replication. I need to have one persistent instance of component over multiple actor's respawns (destroy and spawn again).
Is it possible to detach component and attach it to the another instance of the actor? Would the net channels pair?
Thanks for any advice 🙂
It is AbilitySystemComponent
Yea, but i need multiple ASC's
@bitter stirrup Since it's 1v1, either player will need to host the game, so you can build your own matchmaking with average framerate for example as a parameter and have the highest performing player host once two players are matchmade together
Player has multiple pawns
but you would just need to redirect the GetASC function
Is there any way how to pair them? Or it is a suicide mission?
via playerstate, sure
copying a replicated component onto another actor... that won't work so well
its technically possible, but... yikes
That's a problem I wanted to take care of later, for now it requires one person hosting a game, which works fine
oh, I see 😄 So for me suicide.. Thank you! 🙂
however many pawns you have
you still have the same PlayerState
and i have done a lot of stuff getting the engine to network the way its not meant to
i would not go down that particular rabbithole
@bitter oriole Yeah that's exactly what i want ! My problem is matching the players together. Currently my only way to do it is for a player to create a session and for the other one too look for it using find sessions but at that point one of them is already the server
i am pretty sure the NetGUIDs will break
if you move it to another actor
which means you need to assign a new one.. .somehow
Why not just, like, not destroy the actor
which in turn means altering the engine
Make being dead a state, not the destruction of the actor.
i figured he already considered that before diving into crazy 😄
I'm guessing this is something like an RTS with characters that can have persistent stat changes or upgrades to abilities?
I admit I didn't try to have more AbilitySystemComponents on single PlayerState instance, does it work?
i am still very unsure why transfer the ASC if you have multiple ones
Something like that, it's MOBA. I can avoid destroying the actor, but it will bring a lot of work for the scripters.
So I promised them I will try to find another solution 😄
then make a struct that your ASC can initialize from
and just copy that over
its like 1 struct and 2 functions at bare minimum
Is this for like the main characters in the moba or subcharacters like summons or minions?
Main characters
Destroying those seems icky but if you must do it, then you can figure out some way to save their stats etc to a struct and then reinitialize on creation
You are going to want that struck anyway for things like rejoining from disconnections or saving a game or whatever
Ye, thats what Zlo is saying, but I need to let ASC's logic continue (calculating GE's...).
😦
Yeah, 100%, should not be destroying the characters. Being dead should be a tag
And resurrection/respawning can just be a gameplay effect then
And buffs can persist
Unfortunately this will probably be the best solution.
thank you very much for the advice @dark edge @winged badger
One last thing I wanted to ask: does all that mean, that I have to do all force and impulse calculations myself or can I still use Add Force etc.? I don't know how to get the velocity and rotation other than using get component velocity for the velocity and get world rotation for the rotation
physics is not deterministic, so good luck keeping that in sync
As an example I would take a game like rocket league, the position and rotation of the ball for example. I don't know how much the network will get DDoSed if I update the positions for the clients at each tick
Not at all.. that's like what, 8 bytes, 60 times a second? I'm sure your network can handle 3.8kbps per player.
Okay that sounds alright. Thanks to all, I am still learning about multiplayer syncing and this channel helps a lot
problem is
you sending an update each tick
doesnt mean they will arrive each tick
or in order they are sent
Yeah you need some way of smoothing the fire hose of data on the other end no matter what. Whatever you do, don't try to out engineer the built-in replication stuff unless you really know what you're doing.
or that you have same tickrate
Okay I guess I have to read stuff about that, I haven't tried stuff like package losses etc.
If I do the same calculations on every clients side I should get the exact same results for each client right? But isn't there still a problem, if a client gets disconnected, the positions on the server and on that client would be different
Anybody know why my clients cannot see any other client or the server pawn's movement until about 10 seconds, at which point everyone snaps to their actual (server) location and from then on its good?
There's just about a 10 second period after each startup where the client can't see any replicated movement
Ignoring per second rates and whatnot for middle of gameplay. What kind of download size is generally acceptable for a decent game size as far as initial download when connecting to a server? All of the state variables and whatnot. Possibly considering something the size of ARK in scope, but with much lower player count per server. Are there any statistics on what kind of average connection a player might have for coop style games?
I'm mostly concerned with the ten minute load screen that games like that tend to have. I'm not close to that yet, but I really don't want to just deal with it when I get there, so I'm just looking for some general figure. More or less wondering if there is like a percentage of people who don't at least have like a 5megabit connection.
"I'm mostly concerned with the ten minute load screen"
To load what exactly? I'm not sure how that would be impacted by the connection speed. If there's a lot to load, that feels like loading from disk into memory, no? Something not really impacted by your connection speed.
EDIT: Missed your line about state variables. Strikes me as odd if that would really take up so much though 🤔
Anyone got experience with Steam sessions? I am having a bit of a problem with getting a Steam dedicated server working. I can create a session and join via LAN across my network, but it doesn't work online. I don't have "Use LAN" checked. When I search for my online sessions in-game I find 3-4 sessions, none of which is my session (according to Steam ID). I can find my server in the Steam server browser in both "Internet" and "LAN" tab. Any ideas?
Hey lads, back to dedicated server question. How do I prevent dedicated server from launching when I PIE as a client? I have it running standalone with specific map, so I don't need to run with PIE
play in standalone in editor, then open IP to the standalone instance you have running
Not certain you can join other standalone instances outside of the editor when using PIE though
standalone does not provide info whether its server or not(its actually counts as server)
Not sure what you mean. Standalone instance needs to open a map with ?listen if it wants to act as a server
Standalone is it's own NetMode
To run PIE as a client, it needs a server to connect too
Right, but macros like/#if WITH_SERVER_CODE always returns true on standalone
They will always return true anyway unless you do an actual Server build. They're eval'd at compile time not runtime
Arent running UE from VS actually compiles code?
Sure, but WITH_SERVER_CODE is going to be true unless you did a Client build
Which you aren't doing if you're launching the editor
Alright, but GetNetMode() should return correct values, right?
Ok, looks like its the way I needed. While its not connected to server - it stays as Authority, once I connected to remote dedicated server - all works as I expect
Hi guys, is there any deep guides/tutorials about multiplayer in UE4? I need something advanced for lets say something like AAA quality project. How to properly build multiplayer architecture and make perfect synchronization between players (not FPS genre tho).
can some one give me a hand on how to craft a https request with unreal?
any one that has done that before?
use #if UE_SERVER for an actual dedicated server build
@grave notch Not really sure that a guide or tutorial like that really exists. If it does, someone should probably give it to quite a few AAA game companies. You don't usually get quality without a decent amount of iteration. You don't usually get experience without it either. It's worth noting that AAA doesn't necessarily mean quality either, just a bigger budget. On a side note, any guide promising perfect synchronization between all clients probably should be avoided. PTT means that something will be out of sync for someone or someone will see things before someone else, etc.
Well by "perfect" i meant optimized realization. For lockstep and predictive types.
Sooo I'm trying to use ClientTravel to join a server that I hosted on my local ipv4 address... But can't seem to and I get this error
void UOneGun_GameInstance::Host() {
UEngine* Engine = GetEngine();
if (!ensure(Engine != nullptr)) return;
UWorld* World = GetWorld();
if (!ensure(World != nullptr)) return;
World->ServerTravel("/Game/CPP_BR/TestMap?listen");
Engine->AddOnScreenDebugMessage(0, 5, FColor::Purple, "Hosted xD!!");
}
void UOneGun_GameInstance::Join(const FString& Address) {
UEngine* Engine = GetEngine();
if (!ensure(Engine != nullptr)) return;
Engine->AddOnScreenDebugMessage(0, 2, FColor::Green, FString::Printf(TEXT("Joining!! %s"),*Address));
APlayerController* PlayerController = GetFirstLocalPlayerController();
if (!ensure(PlayerController != nullptr)) return;
PlayerController->ClientTravel(Address, ETravelType::TRAVEL_Absolute);
}
These are Exec functions
I open these as standalone games using powershell btw
Is it possible to stream Level , when we join to server, I want to reduce my Level loading time to as minimum i can have, if possible seamless.
Right now it take 6 to 7 seconds.
On Android though.
if you know what level are you loading into in advance
and you have an asset with weak pointers to the major assets in your levels
you can start preloading assets
before you call open level
we do that from our lobby, as soon as the map is selected, the game starts preloading the level's prefabs off thread
and it shaved a couple of seconds from PC loading times
you mean weak pointer to an Object and that Object will have all the Hard References to the Level Items.
and do AsyncLoad for that Object Class / or something.
Does soft Reference works the same , if i keep asycn Load that asset.
SoftObjectPtrs
Hello, Im wondering if anyone can help me convert an actor so it replicated (Actor is a vehicle), I have the physics and i have it replicating but its laggy and does do what i want it to do. Please PM as i dont usually come here and i probably wont see it here
anyone please 😭
No, the skeletal mesh is not set to replicate 😦
GAS Shooter has first-person/3rd person switch, you can just disable the switch, and always keep in third person... It's not a tutorial per se, but it's primed and ready for multiplayer following Epic standards 🙂
can you link?
@pine bobcat You could try changing the minimum frequency of updates on the actor
IsLocallyControlled() returns always false in my pawn in BeginPlay() or PostInitializeComponents() after calling ServerRestartPlayer() from the pawn's controller, what do I have to do?
Both of those will be way too early
You can look at the possess functions, or the controllers 'SetPawn' function
I suppose that GetWorldTimerManager().SetTimerForNextTick(...) requires tick to be enabled right?
With that function I got it working...
Doesn't need to have tick enabled, but in multiplayer that's asking for trouble still
no garauntee the possession will be received by the next tick
usually will in this case, but delays/timers to get around network issues is asking for hard-to-find bugs later
hello someone is good at making local multiplayer inputs ? im trying to make a fighting game where you can control second player with controller but when i open my level blueprint and create player node , the second character doesnt move when i use controller..
how do you guys sync attack animations between the client and server? do you use a rpc and play a montage? or change a value to transition to a different state?
RPC a montage here
or a state that starts a montage
depending on the use case really
ok I'll try that. getting timing issues with players spamming attacks meaning the state is stuck on attack
and if I set the animation to loop it will start looping as its transitioning out which looks weird
I'll try playing montages instead
you can arrange all the attacks in a montage sequence
then just change which sequence the montage is playing
and RPC that
less payload if you can make it work
1 byte is sufficient
@winged badger do you know if theres a simple way to only play a section of a montage?
I've set the attacks with their own sections like this. but playing a montage and skipping to a section always plays the entire montage from that point
maybe I should just have separate montages for each attack
Hi everyone, I have a challenge I can't quite figure the answer to. I have an admin panel that server admins can use to modify the map cycle for the server. The map cycle is held in in a TArray of a custom struct called FMapCycleEntry within the Game Instance, so I need to somehow send the map cycle to a client, but only if they open up the admin panel and want to look at the map cycle. I don't want to replicate it to everyone as it's quite a bit of information and likely a waste of bandwidth since only 1 or 2 players will have admin privileges
I thought about having a client function which passes in the TArray, like Client_SendMapCycleData_Implementation(TArray<FMapCycleEntry> MapCycle); but it doesn't like that
@twin sable we have synced network clocks and all our networked montages come with a timestamp
so we adjust the start time or the play rate, depending
@pine kernel Make sure the player controller owns the second character. You cannot execute server commands like movement input unless you own the character (you'll get a warning in the log saying something about "no owning connection for actor"
Is there a good tutorial about HUD in multiplayer games? I'm getting crazy trying to add widgets to my HUD at Character spawn, I'm not even sure abouth what should I do, adding widgets from actors BeginPlay or PostInitializeComponents doesn't always work, so I'm assuming that I have to tick my HUD and get from my character if the HUD can display a certain widget or should Hide/change it with a different one, but I'm not sure, I'm getting very confused about them, any hint?
Use the built-in HUD class
it will work exactly as needed in multiplayer
Add widgets in beginplay and you're done
My issue is that trying to add specific widgets for each player from BeginPlay() is that IsLocallyControlled () doesn't always work as intended from there, so I can't know to who I'm exactly adding the widget, yeah by checking the role or HasAuthority I can know who is the server but nothing more
Hud is client only.
So trying to acess it in begin play will return nullptr for non owners? Ty a lot
Beginplay will only fire on the owning client since it only exists there
What about replicated actors? I Am having it fired both on server and clients, so am I doing something wrong?
Hud class does not exist on sever
Are you sure you are using that class for BeginPlay
Yeah, understood that and know I've done what I needed to
If I spawn replicated actors in server RPCs and I put an AddOnScreenDebugMessage in BeginPlay() I get several prints on screen for each spawned one
This are spawned by GameMode
Look
You asked about HUD widgets
You should be using the BeginPlay event of your HUD class - as in, inheriting AHUD in the engine
Spawn your widgets there and you're just done, no RPC or replication needed
I'm not sure what you're asking about replicated actors
Maybe I got a bit confused by that, everything works fine and as I need now, I'm asking nothing about replicated actors, thank you a lot for your help
Alright so
I'm getting crazy trying to add widgets to my HUD at Character spawn, I'm not even sure abouth what should I do
My answer is to use BeginPlay of your AHUD-derived HUD class
If you need character-specific widgets based on whether the character is there, you'll indeed need to tick and decide what to display
how can i get the playernames from a session
is it possible?
after doing a Find Session
it's not no
You can only get the information that the session is "advertising" - which is usually as little as possible
Though, you can get the player name from Steamworks based on the player ID in the session info, right ?
I think it depends on the OSS... I wonder if steam let's you retrieve all user id's for a given session id
ok gotca
it's android platform based
so basically googleplay will come in play
Not familiar with that, but you can try looking into the OSS code
Sorry but OSS?
Oh online subsystem
But how can one look at the google play subsystem code
Not that, but the UE4 OSS implementation for Android, see if you can find stuff
Though I guess the first step is to check how you can get the information in the Android SDK
Second step would be to expose it in OSS
Is it possible to replicate dynamic textures somehow? I'm trying to download avatar image of players to server and set a replicated Texture variable but although the server successfully downloads and sets the variable client value is always null
You can definitely replicate textures but you'll need to handle it yourself
Compressing the raw pixels to PNG or JPG and replicating that in a custom NetSerialize method
Thats smart, but I gotta run it client side asap for that crispy game feel 🙂
figuring out how to balance client side prediction and server authority is a bit difficult though
Reading Tim Sweeney's UT2004 article about replication, are these values still usable in UE4 too?
its out of date a little
when server picks actors to replicate, if will replicate them in order of net priority, it has nothing to do with bandwidth
actors that get skipped for replication panic, increasing their net priority over time
until they get replicated
I see, thanks Zlo
also its 3 for pawns/controllers, 1 for actors nowdays
What do you use for Characters?
lol why are we replicating fish
Right, okay, thanks 👌
we left that on a default pretty much
but we incrased shot lived actors like grenades to 2,3 i think
@jolly siren to create the worlds first accurate network fish simulator?
we are doing another network optimization pass soon 😄
@upbeat basin if your network infrastructure allows for it, would be simpler to have a public server store and redistribute those
hey lads, so I have dedicated server running standalone, however #if UE_SERVER returns false. What am I doing wrong?
I'm running it like Engine/Binaries/Win64/UE4Editor.exe MyProject.uproject ?GameMode -Port=myPort -server -log -nosteam
no, manually
won't return true for editor binaries
well I dont want to start it right with PIE client, because it automatically connects to server. I need to start it unconnected do some auth stuff and when it succeeded - connect to my dedicated server
by the time you finish compiling
I didnt find solution to skip initial connection to dedicated server
the code was compiled... or not based on what that check returned at compile time
with editor binaries, it just won't work
it doesn't check that code at runtime
you can try, if you want a runtime check
if (GetWorld()->GetNetMode() != ENetMode::DedicatedServer)
(actors have GetNetMode of their own and don't need to call GetWorld)
Hm, thats good idea, thx, I'll try
but is it better to replace it with #IF UE_SERVER when shipping game or I can keep this runtime check?
whatever is inside #if UE_SERVER
won't even exist
if the build target is not server
code won't be compiled for the binaries, as if it was never there
it's a great idea to keep as much stuff wrapped in #if UE_SERVER as possible
are uobjects replicated by default or do I have to set a variable
So I have shooting in a montage
When the play click shoots it calls this multicast event so other clients can see the animation
In the timeline there is a trigger which calls an event called shoot
In the shoot event there is a hitscan function that draws a line trace
Works fine for the server
But for a client 2 line traces are produced
But only 1 ammo is used
Any ideas why>?
I am trying to make a fireball explode upon impact replicate correctly. I have the server determine when the collision happens and its effects, but also sends to the clients where it exploded so they can spawn the visual effect in the correct location, to compensate for potential physics mismatch of the fireball projectile. according to my tests the code is being run on the client but there is no explosion. the visuals are working fine for the host player.
@celest sleet show code on client, and how do you know it's getting hit? Sounds more like a visual spawn problem if you know the client code is actually hit, not so much a multiplayer problem
guys i am using eos core is there a way to change the server name?
@celest sleet you destroying that fireball actor in the same tick you MC the explosion maybe?
as the actor destroyed tends to beat the multicast then, and when MC lands, there is no longer an actor to execute the code
is there a way to name the server with eos core in blueprints?
if it works anything like other services
the session can hold data
and you can choose to interpret one of those data fields as a name when you display it
nvm found it
Don't destroy the fireball actor right away, just set it to some sort of state where it's not interactive and said it's lifetime
I found the problem, turns out the explosion size was not being replicated so it was exploding but with a size of zero.
There is no FRotator equivalent to an FVector_NetQuantize is there?
Yeah I figured I'd attempt for the lazy-man route. I'll just do it that way.
@odd sundial It's worth noting that FRotators are compressed by default. At least I'm fairly sure you get the same thing in C++, can't see why it would be different. At least in blueprint, simply creating an FRotator property that is replicated and netprofiling it, shows it not sending a full 12 bytes. Which is consistent with the fact that it gets unwound and arrives on client with 0 to 360 rather than -180 to 180.
Thanks @kindred widget! Appreciate the really informative response.
That's awesome
Most rotators should only send with 4-6 bytes rather than 12. They all get compressed to shorts or bytes. I suppose they figured that 0.005 precision per angle was always more than enough for a simple direction.
But Quats doesnt, right?
I can already replicate textures that are present in my content. Is it because replicated thing is the path rather than the actual texture itself to reduce transferred bytes? So what you mean is that I need to replicate the data I receive from my downloaded image myself instead of trying to replicate it directly as a texture?
if the texture is packaged, then you just need to replicate the asset pointer
nothing else
Well not exactly but I guess we're doing something similar by storing player avatar URLs on our database (since there are players from multiple platforms that have different APIs for profile data). Currently it's the URL that is replicated and each player downloads every other ones images upon connecting the server. I wanted to download the image once on server to reduce our webservice usage and replicate the texture itself, so each image will be downloaded once on server (from our webservice) and will be distributed to the other players
It's dynamic textures that I download from web, so they're not packaged I suppose
replicating URL and letting players download the texture from the webserver is way simpler then getting unreal to replicate the texture imported at runtime
add a sensible cap to the size of the texture they can upload, and it should all run smoothly
I see, thanks for the headsup
Can the GameMode in an online multiplayer call an event on PlayerControllers through an event dispatcher ?
yes, sure take a look at Broadcast implementation https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/AGameMode/Broadcast/index.html
Broadcast a string to all players.
Thanks !
How to handle ping if you want to make actions feels like it was done without ping? For example i click to move to specific position, i send that action to server with 50ms ping, and also i instantly start to do it locally (so you cant feel ping), so now server start to move me 50ms later and i have desync. I want server to understand that i had 50ms ping when i did that action so my position in server should be reached faster. Is it possible to do?
It's complicated
Character Movement has a whole prediction/reconcile system as part of it's movement
In a game where you are moving a character by clicking different position, you will likely just have to live with the latency
I presume you're moving it with AI, which means only the Server can really move it properly anyway
Well actually its more simple, no pathfinding systems, just move to where mouse position was when you clicked (or holding, its probably harder that way). Actions come directly from player. Basically i want to move character forward by exactly player ping so it should be similar position on server and client (small difference in position can be handled automatically by character movement sync if i understand correctly). So main idea just to sync huge difference in position when you start moving. Not sure about what gonna happen if player starts to change moving very often.
Are you possessing the character?
If so, just use AddMovementInput to handle movement (client only) - and this will be handled automatically
ye its your own character
Movement prediction is a lot more complicated than that
If you can leverage the existing system UE has, just try to use that
you mean i need to move my character client only and server will do everything automatically?
If you move the character client-side only via the AddMovementInput functions, then yes it will be handled automatically
Assumes you have "possessed" the character pawn
And that will come with all the prediction logic the character already has
Terms and Conditions apply
interesting, okay i will try
Hey, so, I have an issue that Im unsure how to solve regarding movement jitter. While testing the game as standalone game with clients and server on same PC it all works fine, but when testing over Steam there is jitter most of the time, but not always. It all leads me to believe that its network's fault. Is there a way to see if its network problem, seeing how the ms is in the low 40s?
I have 2 functions.
UFUNCTION(Server, Reliable)
void SetPlayerTeam(int _team);
UFUNCTION(BlueprintCallable)
int GetPlayerTeam();
If i will call SetPlayerTeam(), and then i would want to know team i specified from other client, will GetPlayerTeam() return team i specified?
Same PC is 0 ping, when you start adding real world latency problems appear. Try testing in editor with simulated latency and packet loss and if you notice the same jitter then it's not the network and it's just your code / how the CMC corrects movement
So it could be bad replication even though on same PC its okay? Ill have to recheck that part if thats the case
It's just that you haven't tested what you've made with latency yet
So the flaws will be showing through now
For MP you want to get into a habit of packaging up and testing stuff outside the editor in a "real" environment, but also testing in-editor with simulated lag and such
Thank you, Ill give it a go. Probably a lot of stuff added up too that I havent considered
The editor has some built in stuff for it (look at Network Emulation Settings under Advanced Play Options) - can recommend using Clumsy.io too, that's a handy app
This is good advice, we tend to always run/dev with bad network latency emulation on, then when we play online for real it's a joy to play 😄
Hi everyone, i'm having an error every time a server travel occurs, i guess the error comes from the highlighted line but don't really know how to deal with it.
Maybe it is because i moved the map and it's past location is still linked somehow but how can i fix it?
Question about C++ OnRep. Since it doesn't get called on the server. How do people normally handle that when you're looping over an array? So for instance you change five values. You wouldn't want to call the onrep five times locally. But calling it regardless of whether you changed the array or not also feels kind of dumb.
Do I just need to implement some bool checks and toggle them if I change the array and then if statement that before calling the OnRep or something?
whats a good, easy way of doing a constantly degrading hunger meter with network prediction?
@kindred widget typically server would do its stuff while setting elements on the array
client would ideally reuse that (per element) function during its OnReps
I was thinking like maybe using a replicated timeline or roll my own implementation that just replicates network timestamps + hunger rate + hunger level or something
But idunno
@leaden atlas sync network clocks, timestamp the state when you update it, and let each machine simulate the... degradation
only update from server if something forces an update outside the ticker
Nah. I literally just need to call a dispatch when the array changes at all to update some UI. I just don't want to call it five times in one function, or bother calling it if nothing changed.
this leads to introducing a 2nd variable - lets call it SimulatedDelte
that you tick up/down w/e
and your GetHunger returns the (Hunger + SimulatedDelta)
that way everyone can tick their stuff without affecting the replicated variable
kk
when server chooses to update, client uses OnRep to set its value to server's and zeroes its SimulatedDelta
in its most basic form, that is the cheapest accurate way
I'd think of using an RPC to sync the time instead of a replicated variable, since you never really know when this is getting replicated, but for RPCs you know they are sent
🤔
the playerState constructor should runbefore a post login right?
i dont think so but also i cant confirm
Does anyone know how to set up multi user with hamachi cause I heard its possible but when I tried it but failed for me to create the server due to this error LogUdpMessaging: Error: StartTransport failed to create unicast socket on (btw I dont know where to put this question like in what room so I am gonna place it here since it has some correlation with it I guess)
How to get other client's Player Character?
From where?
From one character to other
What if there are three clients? How do you know which one you want
Anyway call me you should be able to go into game state, get the players array, then for each player, get their possessed Pawn
Right question, im doing it for debug purpose, as im only learning multiplayer
Oh, i got it, thanks!
Hello guys
I've created a blueprint for handle websocket connections
This blueprint is an actor and create connection to backend server (node.JS) by adding this component into "PlayerController".
Now, I would push an event from UE to Node.JS server when player press a button inside a widget. But I can't access into Socket Blueprint ...
So I basically can use runtime checks for development, but use #if UE_SERVER for build, to remove server code from client part, right?
Editor builds and such include the server, and you can also decide at any time to enable server code in your client binaries.
in other words yes UE_SERVER works as you would expect
Cool thanks
Another question - I want to persist player's location every few second to remote server. And since I want to prevent any kind of location hacking, it should be persisting from dedicated server. I've implemented this using FRunnanble, but I'm not sure how will it impact server performance, since if I get ~250ppl running on same server, and every player will generate GRPC request every few seconds - thats probably literally bury my dedicated server
What approach are ppl using to persist player's location to remote server?
Sorry for repeating the question asked in #cpp but I realized this might be a better forum for it:
As far as you know, is UE4 capable of correctly replicating circular object references? I'm working through a bug caused by references replicated to nullptr to clients and the only unusual way about these references is that they are circular (Object A references object B and vice versa). The reference from A->B is valid but not the other way around.
I don't think it would know or care about circular references, as long as both objects are replicated, both pointers are replicated, and the pointers are assigned by the server, I imagine it would just work
I guess I should set up a minimal project and try it out. It's one way of ruling this out.
This is a great practice when trying to reproduce possible glitches like that.
anyone happen to know off the top of their head if actors which are marked as owned by a player are automatically destroyed when that player disconnects? Or do I need to do that myself?
Hi all, I have placed an actor into the map that acts sorta like a controller to remove placeholder actors in the world and adds them to a instanced static mesh component. The issue im having is i want to get all the transforms of these actors and do the work on the server then send all the transforms to the client to sync the server and client up my issue is that my transform array isn't getting sent to the client via RPC event only gets sent to the server.
Im running a dedicated server setup and reading online they say to set the owner to the player pawn or player controller but what if there is no player online? should i set this to another actor and what should that actor be?
hiya everyone. what's the difference between "Play Offline" "Play As Listen Server" and "Play As Client" ? play as client seems obvious - the editor spawns a client and a server and connects them. play as listen server seems like it just spawns one process that is both client and server? but then what's play offline?
maybe it's that with listenserver it opens network sockets so multiple players can play but is otherwise the same as offline?
Play as client implies no listen server, so basically a dedicated server where everyone is a client. Listen server means one of the clients is also the server. Play offline I believe just means there is no net driver.
Optimization question: If you have a replicated struct full of boolean values to toggle things on or off, and OnRep you want to perform an action based on if one of those booleans changed, what is the best way to optimize this? Is it more effective to replicate an array of booleans that have been set to true and compare previous to new state and take action based on if it is missing or added to the array? Or is it more effective to replicate the struct itself and somehow do a comparison to see which booleans have changed? I feel like if the struct had a ton of booleans, then iterating through them all would be less effective.
Have a sneaking suspicion I'm going to be told to finally have to use FFastArray
Do you guys ever find that AGameMode::ServerTravel doesn't work in the packaged distributable? The command is disabled in PIE, but when trying it out with friends with the packaged Shipping build it doesn't seem to actually do anything, which is strange. Looking at the source implementations in the method, it's pretty clear that it should move it and all clients to the new map... but I don't see it happening in reality. I'm sure I'm not the first person to encounter this.
@steel vault depends how many you have, but you could just use a bitmask instead for up to 64 discrete values
Smart. My brain is a fried egg so didn't even consider that. So basically replicate a uint8, 16, 32, or 64 and then diff it somehow?
Would love to know if anyone has a solid bit diffing algorithm
Can just use a simple for loop
Ok, was just going to manually do it that way, but wasn't sure if there was any slick way to get away with not iterating each bit knowing if one hadn't changed.
I guess since it's only on rep and I can set it up so it's not running too often that it won't be much of a performance hit regardless.
Cost will be negligible next to everthing else tbh
Can you call an OnRep function on the client as a regular function?
I think so, but you should separate the action to its own function which is simply called from OnRep. That way you aren’t conflating things.
Yeah I have been doing this but for listen server it can make things inconsistent as when an OnRep property is set I usually call it on the server right after rather than making a separate function that is called both here and via the OnRep
Just one less function call and less error prone in cases where you change what is called in the OnRep but forget to update the function called after one of the instances where the property is set on the server
Would be a no brainer on dedicated servers though
I would argue it’s less error prone to be explicit with function names rather than calling a random OnRep function name. That means nothing until you see what is happening inside whereas an explicit function name makes sense.
Does anyone known of an up to date user login tutorial for unreal? The ones I find are out of date enough where they don't work anymore. I have one which works great on the website portal but no longer seems to function inside of UE4 itself.
I agree but it's just more to keep track of like "oh I'm meant to call X function on the server after Y property replicates" vs "the property replicates, both client and server will call the same exact thing guaranteed"
So if whatever is being called in the OnRep changes, it automatically updates for the server too
Without having to track down where you set the OnRep and manually change serverside function calls which can lead to errors
I know some senior devs in here who would encourage you not to do this, but I will let them chime in if they want. If anything is supposed to change a server side variable then you have an explicit function that does that and you call that where needed. I know it seems like an additional step, but imo it’s best practice.
Yep it is best practice and especially makes sense on dedicated servers
I just have had trouble updating things and it is a bit less clear when I'm looking at code to see what is being run where
Well it is your code base in the end so do whatever works for you 🙂
But yes you can call it
One other check for listen servers that I'm unsure of: is calling a ServerRPC as the host also fine to call like a normal function?
Take this example
// If the host this will call an OnRep function on clients
TimesFired++;
// If a client, tell the host to increment this int for other clients to see
if (Role < ROLE_Authority)
{
ServerIncrementTimesFired();
}
Could I replace this with
ServerIncrementTimesFired();
And get the same result?
Since if host it'll call the RPC function "for free" and replicate the int and if client it'll do a server RPC which will replicate
Im not at my computer so I don’t have the link but I believe that if it is calling from where it is already supposed to be it falls through and just executes without making a network call so that should be fine, but again, there is nothing wrong with being explicit.
Make things operate how they should without fudging things just because they work.
So you'd go with the first option in this case?
I personally make a separate function and call it from within the server ufunction. Logic goes in functions and the server function is obviously reserved for executing logic on the server.
But I believe you can still just call the server function even if you are the server
So it'd be like:
// If the host this will call an OnRep function on clients
if (GetLocalRole() == ROLE_Authority)
{
IncrementTimesFired();
}
else
{
// Calls IncrementTimesFired() on the Server
ServerIncrementTimesFired();
}
Yes 👍🏻
Thanks!
If you want an argument in favor of that method it would be because if the client functionality varies slightly and something server specific happens in the server function that doesnt effect the core increment functionality then they are separate. Compartmentalizing functionality future proofs things better.
Also I think there is a better check for the server. GetNetMode == ENetMode::ListenServer etc.
Can the server set a client's control rotation via a reference to the controller? or does the client have to update that themselves?
Reposting from earlier:
Do you guys ever find that
AGameMode::ServerTraveldoesn't work in the packaged distributable? The command is disabled in PIE, but when trying it out with friends with the packaged Shipping build it doesn't seem to actually do anything, which is strange. Looking at the source implementations in the method, it's pretty clear that it should move it and all clients to the new map... but I don't see it happening in reality. I'm sure I'm not the first person to encounter this.
The documentation says that we should just call ServerTravel and it will "work", though that's not reality for me. I even have Level Streaming disabled, so that it doesn't get short circuited in the implementation.
hey there, Im using advanced steam sessions. Ive successfully hosted a dedi server
I try to connect to the server using the command open 127.0.0.1 and this is the result. Will not connect
also, find advanced sessions gives me nothing
For character respawning do people typically destroy and create actors or just try to reset and reposition a player's actor?
Depends on setup, generally you can destroy the pawn and you keep things specific to the player but not the player character elsewhere, eg in the player state.
Destroying pawn is a bit less messy if theres loads of variables you need to reset as if you create a new one they will automatically return to default.
Just be sure when you destroy it you have nothing running that depends on on it being alive or you will get 'pending kill' error.
Gotta repost guys i'm hard stuck, and i really don't know why: anytime i try a server travel (with seamless travel unabled in gamemode) on standalone or via launch game, the game crashes rightaway
@rustic adder steam API limitation: you won't be able to see a server hosted from a same machine you're searching from
@languid ruin i'd expect a callstack attached to that problem
most likely scenario, your UI should had been cleaned up prior to travel, but wasn't
and if you're expecting a fine control of seamless travel from blueprints, you're out of luck really
rudimentary use of c++ can help tons
you mean i have to remove any widgets from viewport before doing so? also is it possible to quickly provide my blueprint with a c++ server travel equivalent?
not all
some can survive travel and be visible on the other side
but ones that depend on say LobbyController or LobbyHUD being there
when your game switches to PlayController or PlayHUD
those will crash
depends on the widget really
UE crash reporter told you exactly where the problem is
(provided you have debugging symbols installed)
no i'll donwload it in a few hours
try reposting when you do, because 1000 different things could had crashed
and without that callstack, everything else is just guessing
UI not cleaned is just the most common scenario, far from only one
i see, thank you really for the help, i just have one more question: do PControllers persist after a server travel?
they do if you're setup correctly for it
its best to have the travel map run the same GameMode as the departing map
Okay, first I'll try to get the Server Travel working on Bluerprint and then maybe i'll try C++ if I have the time
yes i figured that out
problem with blueprints is you don't have hooks like
void APlayerController::PreClientTravel( const FString& PendingURL, ETravelType TravelType, bool bIsSeamlessTravel )
{
UGameInstance* GameInstance = GetGameInstance();
if (GameInstance)
{
GameInstance->NotifyPreClientTravel(PendingURL, TravelType, bIsSeamlessTravel);
}
}
which is typically used to clean up everything that shouldn't come along for the ride
UI is the most common offender because it is not tied into World
but into Viewport, which is tied to LocalPlayer, which is tied to GameInstance
so it usually doesn't get autodestroyed with the departing world
Alright, thank you again for all the intel, I'll get some sleep before trying this
good luck
My steam dedicated server is not listed in the client server browser. Though if i add it manually it is shown as active, with ping and player count. Using python-valve i get it's address from the steam master server. Is it not listed by default because the game is not released yet? Or did i miss anything else?
Hey there... I'm not sure what I do wrong but I'm trying to have every connected player inside a Box... but it just won't work out... not sure how to do it
@forest sage same machine running the dedi and client?
@winged badger Nope, dedicated is running on a dedicated machine in the Internet.
How does UE handle replication when components are attached? Does it just replicate all child object transforms separately?
yeah. the component itself has the be replicated though.
See USceneComponent::GetLifetimeReplicatedProps
Hi! 🙂
I'm making a multiplayer game and I have problem with replicating movement with GetCharacterMovement()->AddForce(). When I use AddMovementInput() replication is working properly.
When I set my function like this - UFUNCTION(Server, Reliable), when server player moves, all client players are moving with him. When I play for client, everything works fine.
When I set my function like this - UFUNCTION(Client, Reliable), server player is still moving with all players but clients players can't moving themselfes anymore.
After few days of googling and trying to solve it I found only one solution (you can see it in screenshot), but I don't think this is the best practice. Guys, can you please help me out?
Jambox, how does this change for attached actors? If I have 2 replicated actors and attach one to the other. If I move the parent, does the local machine handle the translation of the child object or is done directly?
Let me give you better context. I am working on a battlebot type game, where characters, on the fly, can design new robots, each of which could contain up to say 50 individual components. And these are made on the fly, so characters can have multiple in play at the same time. I am trying to minimize the bandwidth damage from that. If you think of most of the child components of a given bot, they are just following the parent around until they activate in some form (fire, flip over, etc).
Would child actors be a better option here? Or would the cost of the replication be essentially the same?
@potent furnace you want a IsLocallyControlled check in combination with a server function
also, never ignore the log warnings of "no owning player for connection..." that you have tons of right now
Is OnRep exceptionally buggy in 4.26 or is it multiplayer in PIE that is? I have one component that is incredible messy in certain actors in terms of not firing OnRep, and I haven't changed any logic related to the component.
I heard from Zlo yesterday that there's a bug regarding OnRep. That if you only have one replicated variable, it won't fire OnRep.
c++ only
Yes, this is in c++
and i doubt they extra broke OnReps in 4.26
even if i have heard 4.26 described as "critical bug package"
@surreal plaza On an actor, if you replicate movement then that is handled separately via AttachmentReplication
Unless you are changing the component's attachments from their defaults then you shouldn't need to replicate anything else
child actors for components are just going to have even more overhead tbh, because that's a totally separate channel then
I believe I would be changing the attachments from defaults. So imagine you are in front of a workbench with a robot torso. This would be in game. You throw 2 tank treads on it, then a cannon, and a flip mechanism and immediately throw it into the ring.
Those configurations are always ad hoc and not an instantiated blueprint of any kind.
Ultimately if you want to attach components to other components then yeah you need to replicate their individual attachements
the "easy" way is just mark the component itself as replicated and the default properties will handle it
But tbh, you could probably build something more bespoke that handles your case better
And each component has it's own mesh, blueprint for behavior, sounds, and animation.
well only properties you mark as replicated will be replicated
Let me clarify. Each robot part has all of those things. I am overusing 'component'
That is where I am headed. Likely actors. They are robust in their own right. So if I add a 'gun' piece, it might have a unique UI for parameters for that particular robot. Like, caliber or something.
Right
So if you want the easy way, just check "bReplicateMovement"
and whatever you attach the actor too server-side will replicate and be handled by the client
Ok, could you maybe say a little more about a solution, I'm sorry, but I'm still new to multiplayer in UE4. So I would define my movement function like this?
UFUNCTION(Server, Reliable) PlayerMovement(float value);
When I set PlayerMovement like server function and when I add if condition to PlayerMovement (you can see it in screesnot) server player is moving all players, clients are moving themselfes and only server player is "true" for my if (IsLocallyControlled()) condition.
always paste the function header
cant say where that is
i suspect you're doing something unspeakable, along the lines of checking on Tick from each Character if Controller[0] has a key pressed and applying force
@surreal plaza each actor will replicate it's attach parent individually, if that's what you're asking
Then assuming it's relative transform doesn't change, it won't replicate anything else - but the properties will still be checked server side.
So, I have TorsoActor (brep = true) and GunActor(brep=true) and attach GunActor to TorsoActor. Is that right? That sounds like it works, but maybe the most expensive bandwidth wise. The other direction I was considering was that
TorsoActor(brep = true)
GunActor (brep = false) <--- but still instantiate this on all clients
Attach GunActor to TorsoActor.
But! Now GunActor isn't replicated! But maybe I don't care if it is just a visual indicator but the ultimate actions (flipping, firing, etc) are still spawned and managed server side. Does that make sense?
that's just asking for trouble tbh
because you won't be able to do anything involving GunActor and the network then, you won't even be able to reference it
I think you just answered my question. If the relative transform doesn't change, most of the time only the parent transformation data will cross the wire and I won't have 50+ actor content replicating.
The easy way to answer it is just look at AActor::GatherMovement and see what it does
if it's attached to something, it uses AttachmentReplication
if it's not, it uses ReplicatedMovement
Right on. I will do that. I am digging into the network profiler too.
AttachmentReplication is presumed to be relative
Great. It is almost like smart guys put this all together.
So if after attaching the relative location/rotation etc. doesn't change, then no other data will be sent - just the root actor's transform will be the thing replicating
At the same time though, the Server is still going to be testing those actors' properties each network frame
So if you wanted to claw some of that back, you could make your own attachment hierarchy that only replicates once at startup for example stored on the base actor
Lots of ways of doing it I guess
Right. That is where I was prematurely optimizing. I was working on encoding/serializing the robot description into a string and then synchronizing that, but like you mentioned before, that leaves me with disconnected actors. I am not sure that I am following where in our discussed scenarios that 'my own attachment hierarchy' would fall. Wouldn't rolling my own hierarchy just not take advantage of attachment replication ignoring relative stillness?
I am working if this is possible with a chain of objects.
A brep=true
B brep=true
C brep=true
C attaches to B, B attaches to A. If I move A will C replicate?
Nothing will replicate if it's attached, it's attached so it will just move with it's parent
It looks like this works. I wasn't trying to describe circular, just multiple levels deep.
So just so I understand this fully. Even though child transform might be stationary and not sent on the frame, if the parent moves the world coordinate change is handled on the local machine and that all works out.
And this is all done via AActor::AttachToActor.
You're overthinking it. No transform is replicating on the child if you move the base
The base transform change is the only thing that replicates any data
Things that are attached to it just naturally updated like any regular attachment would
That is what I meant to say by 'not sent on the frame.' If I did move the child on a given frame, it would get a replicated transform for just that frame. Otherwise, the parent just carries it locally. Right?
Thanks a bunch, btw. This has answered a great deal of questions and confusion I had.
Yeah that's it
is it useful?
not for my use case
tho from what i can see
it looked as if in the examples that it would smooth the movement on otehr clients (interp) and showed off replicating pawn flying movement component
and replicated physics
that were smooth
tho I could be wrong about some stuff
okay, ty
There's certain times when I want to make sure that a multicast hits every single connected instance of an actor, in which case I set to always relevant before the MC, and then turn it back off after.
Should I wait for a duration in between? Or is Unreal smart enough to notice that the MC happened in the span when it was set to always relevant?
(Granted, maybe I should rethink this entire strategy, but would like to understand how it behaves with the above steps)
I doubt that would work, the Actor won't even exist for some clients when you call the RPC. It takes time for the Actor to replicate to all clients.
That's a good point 🤔
I think I'll go with a repnotify instead, rethink the flow a bit
always vars for state
Has anyone done volume based game session merging?
Wanting to create a single/multi player hybrid based on that
@winged badger I found the issue for the OnRep function.
Apparently I had set the resize of the inventory array outside a HasAuthority check on BeginPlay. Still don't understand why the OnRep would fire on some actors and some not though, that is outside of my knowledge of how networking is being handled
Is there another way to go about replicating whole skill lines like this or do I have to essentially just have the skill twice with the replicated components? Just want to make sure I am doing it the most efficient way.
hey guys, does anyone know what's a good way of handling characters on top of replicated pawns?
I have some very visible jitter
Is attaching OnLanded the way to go in these situations?
Is there a way for the Game Mode to call an event on all the player controllers simultaneously ?
If I use for each loop, it creates a delay, that I'd like to avoid
(the project is blueprint only)
Here's the callstack, I still don't get where the error comes from tho
is there a way to do replication outside of AActor?
i want to do a simple chat system that's outside of the game logic classes
and i was wondering if its possible to put it into like a game instance subsystem or something. some sorta global
This usually means you are calling -> on a null pointer.
hmmm i see stuff with UChannel
I guess there is no way to find out in which blueprint the error comes from?
Has anyone used Unreal Insights and, more specifically, Network Insights successfully? Is it reliable enough to replace the Network Profiler tool?
Talking about this: https://docs.unrealengine.com/en-US/TestingAndOptimization/PerformanceAndProfiling/UnrealInsights/NetworkingInsights/index.html
I've just found out about it but it is still experimental. Is this live-coding type of experimental (e.g. already better than Network Profiler but not finished yet)?
Overview of Networking Insights, the network performance profiling tool
Can it cause any sort of corruption in my project if I use it?
it works, its better than network profiler, and why would it cause corruptions?
If everything in the Anim BP is inherently replicated why not put all the animations in the anim BP that you can and then call them from the character BP/PC?
I don't know. I've been bitten too many times by corruption to the point I fear it at every other step I make 😅
I finally got it to work, I'll ask any questions if I need so. Thanks @meager spade
emitter is not spawning and showing in client side, what cause the issue?
i already doing RPC, but why this happens?
Why are both the Emitter and Template replicated if you already multicast?
And where is that code located in? Is it even client owned? Otherwise it won't execute the ServerRPC
it working now without doing anything, i think making these functions reliable fixed the issue
It might make it work but that's a very bad design. Reliable rpcs for a particle effect is a surefire way to clog up your pipe.
^
then again i always send a reliable client rpc back on sucessful hits, like what this is for, but its never multicasted reliable, them sort of things are unreliable. but the important stuff back to the client is always via a reliable rpc, unless it was a failed hit, that comes back via a unreliable rpc, cause not bothered if client does not get that.
If i set up a game with basic multiplayer where the client is also the server, then want to build out a dedicated server, will all the stuff the server client uses get automatically disabled or do i have to check for dedicated server everywhere i deal with UI and player movement and such to bypass it myself?
@dawn glen If you do your programming correctly, there won't really be a difference between a ListenServer or Dedicated Server. I've been working under the pretense of Listenserver uses, but kept in mind that I may one day change to a dedicated setup. You can very easily separate your server logic from the hosting client's client logic so that when you do change to dedicated, nothing should change except that one client will no longer also be host.
is it possible to predict uobject or aactor creation?
like do it on the client before it happens on the server
It is, but you gonna have "good" times with net pairing client side's actor and server side's actor (to get replication working)
no
you can't predict what the server is going to do, prediction can only happen if the client tells the server its going to do X
I'd say he means exactly the case you're describing, at least that's how I understood it
yeah cause the client could never know what the server was intending without the server telling it, and that is not really prediction 😄
@kindred widget I thought it would cause errors and such if you launched a Dedicated when it was designed as a client server when it would try and run the Widget stuff or cast to player controllers. So i know you can kinda easily put in branch checks for dedicated server and bypass all of that but i guess my question was do i have to?
yeah thats what i mean
im doing an inventory system using uobjects
and i want to predict item pickup/creation or whatever
oh that is one thing i never predict in a multiplayer game
nor have i seen many games do that
even big games like Fortnite don't predict pickups
nothing is going to be more frustrating than thinking you have an item, and server nabs it away from you
imagine like the best item in the game on the floor, 3 people interact with it as soon as they see it, only 1 person is going to get it but all 3 people think they have it
till server rejects 2 of them, that would be bad for those players
good point
i always have in my mind, predict as little as possible to make the game feel responsive
you can play the pickup animation/act like your picking it up locally
(which is what big games do)
Thats one thing i havent thought about yet is "duping" If an item is on the ground and you dont handle it right, the 3 people will pick it up at the same time and all 3 get it.
And how should one best handle that? I suppose i would hit the pickup button and then send my look vector to the server to do the trace to the object?
I think you should just let the client tell you what it hit
And then just perform checks to make sure it's not too far away or behind a wall or w/e
Is it possible to connect to my teammates on a simulated project with steam appid 480? Or do I need to purchase our application before we can really start integrating steam functionality like connecting VIA steam friendslist?
Hello everyone... I have a problem with creating a simple multiplayer game for mobile devices. Like Multiplayer Shootout project sample i made a menu for hosting and joining game. Hosting section works good and session created successfully with Use LAN enabled and level opened with listen option and everything is good. but problem is here when other device wants to find session, i made a menu for that and i know Find Sessions node run On Success but there is not any sessions found !!
Why ue4 doesnt have sql/any db support by default, isnt it common thing? Im not sure should i use rest api through https to work with db, or make db access in ur4 server side (for dedicated server)?
We use a rest service / swapping to a stomp client to do requests to our backend, actually that's really cool, since you can swap your backend as you wish
@plain torrent i'd advise buying the steam ID, its 100$
I was suspecting that would be the answer! Thank you 🙂
it just provides too many conveniences to screw around with appid 480
you can add the teammates as devs
I don't suppose there's any alternatives to the 100$ license?
then they can upload and deploy builds themselves
Such as education etc?
If this is just an early working title, can I buy a single appid and re-use it if this project get scrapped?
but just being able to deploy a packaged version via steam is already significantly improving the workflow
i don't see why not
and you do get that money back if you sell few hundred bucks worth of game
Oh interesting, i wasn't aware of that
I'll definitely have to get that application going I suppose. How long does it take to get an app id?
few days i think
And the prime reason we want this is to be able to start debugging steam p2p. Is this the best solution for that, or is there something else you may be able to suggest? I really appreciate your help!
with your own app Id you can deploy multiple builds, packaged DebugGame configuration is pretty good for debugging
as you get to use the cheat manager, set console variables, slow down the game, use GameplayDebugger, "eject" into a debug camera.... etc
I'll add that to the budget request! thanks for your help 🙂
Does anyone know if TSet supports replication in 4.23?
Only TArray
Alright, thanks for the quick answer
@winged badger May be me being really silly, but I can't find the page to begin the application for our App ID? 😆
Hi everyone! I'm developing a strategy game and I'm looking for a strategic advice. Currently I'm leveraging Linux cross-compilation to build the dedicated server, then I dockerize and deploy it on Google Cloud. It works like a charm, anything that works on Windows works on Linux as well. So much that I didn't even have to set up a dev environment on Linux.
But I know that at some point I might get into trouble. So I'd like to know what is the common practice in the industry and the most traveled path. Are dedicated server most commonly built on Windows or Linux?
I have little experience with UE and I don't know the behind-the-scene and the quality of Linux support. What do you suggest?
If you are serious about it, I would at least whip up a little Linux box for testing. But if it works it works.
Hey everyone sorry to bother again.. We use Digital Ocean to host our Perforce, has anyone used Digital Ocean to host a UE Dedicated Server, and if so, how hard was it to get that setup?
Yeah, I know that mine might seem an odd question. But I've realized that some plugins don't support Linux, so I'm wondering how common the practice of building a Linux dedicated server is. For me that was a natural choice, but honestly if the wind blows in opposite direction and 90% of studios are using Windows, then I won't choose the hard path
For example, it might be helpful to know which OS Epic chose for its own games
I'm not sure but I would bet million bucks that they are running their dedicated servers on Linux.
Easy. There's nothing special about your choice of hosting provider for a test server. It might come in to play for an automated deployment though.
I host my perforce, ue4 test server, and valheim server all on the same machine cuz YOLO
Ahh I see, so I just go through the steps of compiling the source code and uploading it to a linux server?
For testing I just have a compiled engine on the Linux box and it just fires up the project as a headless server, so no building anything every time the project changes.
I'm saving up old parts to build a Frankenstein server system, not long now
Do I need to pull the full release build from git if we're working on 4.26.1?
I don't know if 4.26.1 is currently released but if it is, that should work. Just make sure you're on the same version. I'm not sure if there's any problems between devving on the launcher version and running the Linux side on the built version
thanks, I'm downloading 4.26 now. fingers crossed all goes well
In what blueprint should I handle win conditions for an online multiplayer game?
Should I create a custom game state (child of AGameStateBase) and use that, so it's exposed to BP?
reading about it looks like game mode better for that
Win condition is in GameMode
GameMode should control the game flow (its server only and secure)
Thanks, but why use game state at all then?
I'm looking at documentation, it says to use Game State for stuff relevant to all players because it's replicated I guess, so maybe if player A scores a point, it gets updated in the game mode, then a variable is also updated in game state mirroring the game mode variable (but not determining win/loss), then the player HUD accesses game state or something for score display? I guess that would also stop players cheating by setting their own scores but couldn't they also 'cheat' by adjusting their displayed score, confusing other players, even if it doesn't help them win?
GameState is for things that all players should know about the state of the current game
GameMode should update the GameState when conditions are met
Well I want players to know the scores of every other player. I guess I should have two copies of the scores of each player: one in the game mode and one in the game state. They are the same except the game mode one ends the game when certain conditions on the score are met.
@twin juniper That's a lot of upkeep, and prone to bugs if you forget to update one or the other. Just make your GameMode get variables from the server's GameState.
guys I have screen space widget that acts as nameplate for my character
but in multiplayer
clients sometimes don't see it
well actually most of the time
but when I switch it from screen space to world space it does not disappear
why is that?
and how can I fix it?
Is 'playerID' different from 'controllerID'?
I am getting started with network profiling in UE. Is the network profiler still relevant or has everything moved to Insights?
My client can't see replicated movement until about 10 seconds after starting my standalone game, for the first 10 seconds he can only see client events, then all replicated movement of other players snaps to where it should be after that 10 seconds. Anyone know how i can fix this?
I'm opening my unreal project twice on my PC to represent each client, can that be causing the issue?
@dense ocean How large is the project? How much is being replicated at the start of game?
It's very small, been happening since I just started it
You know you can open two clients from single instance of editor.
I don't believe I can open two standalone games though, I'm using Servertravel to go from a lobby to a game map, and I was told that you can't use servertravel in PIE
If there is a way to do this from one instance of the editor it would be a life changer for me lol
Hmm. not sure then. Might not fix your issue, but I had a similar problem when I started replicating foliage stuff. Even if it doesn't fix it, you might want to make it a habit to drop this into your Project's DefaultEngine.ini when starting a new multiplayer project if you don't already.
ConfiguredInternetSpeed=1000000
ConfiguredLanSpeed=1000000
[/Script/OnlineSubsystemUtils.IpNetDriver]
MaxClientRate=1000000
MaxInternetClientRate=1000000```
can you point me to that message, which says PIE can't to server travel?
It was a long time ago, i never looked deeper into it after that @rich ridge but I am very open and ready to do some testing as I believe it's probably just a setting i need to change regarding seamless travel, or maybe something in my config. I doubt unreal would ever require you to open multiple editors to test multiplayer
Thank you very much, I'll give it a go. I should also add, after that time period the client stays where they were, even if the server used SetActorLocation. Only after the 10 seconds, when the client JUMPS they are moved to where the server previously tried to move them to
Thank you @rich ridge Ill give it a shot soon
and also one more point to remeber, when testing multiplayer in editor for multiple clients.. always uncheck this option
@dense ocean By default all clients will run under one process and will share memory and most of the RPC and replication logic will work fine, when you actually try to test stand alone things wont work
using 4.24
i think 4.24 is pretty same to 4.26 in terms of multiple clients within editor
Hmmm im unsure why I can't run standalone with multiple clients
I set my num players to 2 as you can see, but when i launch Standalone only one standalone window opens
Instead of 2
it should open two
Then i guess there is my problem
try to do in fresh Third person project
Okay i will now
It works, in 4.25
I'll try in 4.24
I'm having trouble launching ue4 in 4.24, it seems i just need to update
I'm going to run to the store while i install 4.26, ill let you both know if my issues resolve after, thank you for your help
how do I end match properly in multiplayer? My print string is firing at the end of the round (when a player wins the multiplayer vs game) when I want but apparently the 'end match' node (I know its not connected lol) just puts 'MatchState' into 'Waiting::PostMatch', how do I proceed, do I need C++?
What is the reason behind having game mode not replicated? Is it a design only decision to keep rules and data separate or is there some more serious underlying technical reason?
it's a design choice, there shouldn't be any technical reason
it also works a lot with players through refs to their player controllers which arent replicated to other clients
If I want to net-quantize my float (to make sure it matches the net-serialized version, precision wise) can I do something like this?
It seems like this should work, albeit a hack, wondering if there's a better way to net quantize floats?
Why though?
Fellas, who will take owner of that object by destroying an object on the map from the server authority? Is it to an entire separate client or a single client?
If it's replicated won't destroying it on the server destroy it everywhere?
no isnt replicated(as replicated its expected but this non-replicated)
just have on the map, so server and clients will load it, when i put the begin play in to authority test, the servers has authority and clients are remote. So when destroying on server, then who will take the authority?
That's a good question. You could test it by interacting with it after being destroyed on the server.
i tried, but still the "switch has authority" says clients are remote. no one authority. like it falls in to space
im atm:
lol
I guess it's technically correct as the thing wasn't created by the clients. When deleting it you would probably want to run it as a multicast event so clients delete it locally too.
well the grasses only no needed on the server, so i dont wanna delete on the clients as they can see grass
i was just avoididng cpu usage on grass BP on server
more weirdly, those client functions work as like authority even they are remote
Are you trying to set the server up as a dedicated server?
Is there a logical reason why a RepNotify within the PlayerState would not be run on the client?
It runs fine on the server, though. But I don't see it trigger on the client
EDIT: Probably because there was no actual change in the variable's value. Cleared it properly first, fixed 🙂
How to set up and package a dedicated server for your project.
You should be able to set up your dedicated server to run with no actual graphic output.
i know, i mean the grass blueprint will load as far as stay in the map. it doesnt matter graphic output
It's my understanding that a dedicated server can also help with performance because any number of calculations that need to be done are on the server, and the result is only replicated to clients
So if I understand correctly you want to delete certain actors on just the server for small performance gains? Nobody is actually playing the game as the server?
No, server just sending acks, variable changes or movements only, so why should keep grass on server tho? also memory reduction affect too.
Sounds like it could work if you don't need the actors for anything. Might be a headache to manage depending on the type of game you're making. You could have clients load the actors locally and never load them on the server in the first place.
Easiest way would probably be level streaming, but there are probably others I'm not thinking of.
Well, i've already changed my mind way to go. So now i have no trouble about this for now.
Can I change the net update frequency of actors on a per player basis
depending on how close they are to something
In some cases I don't want to turn it off completely..it still needs to be replicated from afar, but I don't want to send nearly as many updates
Anyone analyzed UT source code before? I am trying to solve why they are created a new FRepUTMovement and doubled the OnRep. In the comments it says its more effective but I couldnt understand why it would be
Also same for every UT copy of usual engine functions
GatherUTMovement (calls GatherCurrentMovement() inside) etc
From what I understand from this I should not mess with default engine functions for movement replication
Can anyone recommend a cheap VPS host for a dedicated server that's got an intuitive setup with UE?
For a cheap (but good) VPS host I can recommend Namecheap, I don't think it has integrated setup with UE though
Thanks! Do you know if the 2cpu cores and 2gb ram would be enough for a headless server, hosting 4 people max concurrent for play testing?
there's also playfab and gamelift. They provide trials right ?
My teams testing on appid 480, we're finding eachothers sessions when launching VIA steam, it's pulling his server name and when we try to join, we're getting through on success on our Join Session node, but it then doesn't connect to the server. Everything works fine on LAN. Does anyone know what could be causing this? Our default subsystems are set to steam etc
I'm under the presumption that all of these do the same thing. At least I understand that the actor component version of GetNetMode more or less gets it's actor and calls it's GetNetMode. But what is the difference with AActor and UWorld's GetNetMode? Why doesn't AActor's InternalGetNetMode function just call GetNetMode on World? It already gets world before doing the net driver thing anyhow?
Just mostly wondering if there's a reason for this to behave differently somewhere or if they'll act identical.
im not convinced they behave differencly @kindred widget
Actor can get the NetMode via World or via its ActorChannel
i think
but different implementation might just be epic being sloppy
plenty of that going around in GameFramework
Kay. I'll just treat them the same way. Just wanted a sanity check. I'm a lazy person. I'd have just made AActor call UWorld's GetNetMode and been done with it. 🤷♂️
Hey guys, is it possible to replicate UPROPERTYs on interfaces on the interface itself? Or would I have to add it to the DoRepLifeTimes of the child actors?
I don't think you're supposed to do networking with interfaces. They're just a way for actors to communicate without casting per machine.
Yeah true, traditionally interfaces are not meant to have properties on them, just checking that maybe since they are artificial interfaces they had support for that
Out of my area there. Haven't used them past the basics.
Shouldn't UHT complain if you add UPROPERTYs to an Interface?
It will, can't have 'em
Please let me know if/when you figure this out. I haven't been able to properly server travel a steam client to the steam listen server for a long time and I have gotten exactly to the point you have. It succeeds the join after finding the host session in a search using app id 480, but doesn't server travel when doing the join. I saw examples that prove you can just run the join session and it travels automatically, but this hasn't been working for me. It just stays in the lobby until it times out.
From what I understand it's best practice to handle respawn stuff in a gamemode bp. How exactly do you communicate to it that it's time to respawn a client? Am I able to create an event dispatcher for that?
run a timer (on server) and loop it and in every loop spawn actors on server and it will reflect on clients too.
Eh? Why not just call RestartPlayer?
Called on GameMode, takes a PlayerController object input. You can call that when you're ready to spawn the player's pawn for respawning.
@chrome pagoda You are just trying to basically be able to kill off the player's character, and then respawn it as if when you open a new game?
That sounds like what I'm looking for. Will need to test when I'm working on it next.
Hi guys, what would be the correct approach to replicate a variable only to specific clients? None of the lifetime conditions seems good for my case and I'm trying to avoid multicast
You can't do selective replication of variables
The only solution for a variable would be a different actor which is only relevant to those clients.
you can replicate actor only to some clients though @oak hill @chrome bay
yeah, sorry, you kinda said that 😄
How do you do that, by the way? I know PlayerController does it. Never got intrigued enough to look into it.
player controller is only relevant to owner
basically, override IsNetRelevantFor
or put it into some buckets in replication graph only
Ah. Neat. I assume that a good way to handle this is like.. returning a bool based on the controllers the actor should be relevant for? I might mess around with that sometime.
Sounds interesting... any place where can I find more info on the replication graph?
I think I need some more control than the IsNetRelevantFor function
i have no idea, there are probably some sparse docs, some semi-useful youtube videos and a blog or two about it
Basically I need a specific actor to be replicated the normaly way, but only some variable need to be replicated to specific clients
we went to custom push model before repgraph came in
so never went around implementing the thing
no
entire actor or no actor
repgraph or not
are you talking about unreal push model?
you can't pick and choose what variables inside 1 actor go to which client
you can just pick which actors in their entirety go to which clients
oh, so I cannot do that with replication graph either
only way you can do it is by rewriting 80% of the low level networking in the engine
do not recommend that
definitely not XD
literally, idea goes against the core structure of the unreal networking
so I think the only way is to rewrite my logic in another way
Only semi manageable way I could see handling that is a terrible reroute through controllers. Set the value on the server, and in the set function, use the desired client's controller to RPC that change to the client. I feel dirty even mentioning that idea though.
you can spawn another actor
to carry that data
and make it relevant only to some
its less messy
Why do you need only one client to have said info, but for the actor to exist on all?
you mean by overriding IsNetRelevantFor?
btw, @oak hill good part of pvp team setups
will have a single team actor per team
that replicates only to their team
it will override IsNetRElevantFor
to cast rel viewer to controller, pull the team ID from the controller and return false if the controllers team ID does not match its own
im guessing you want something like that
not really
basically I need a generic actor that is visible to anyone, but only some players can use and receive its data
but players aren't part of any team
maybe a solution could be to store an array of these players in the actor itself and use client RPC, but I was asking to know if there was some method that works in this situation by using replicated variables
nope, unreal replication will send the entire replicated actor to all relevant clients at the same time
ok, thank you for the clarifications
Pretty sure ue4 replication sees what has changed since last replication, serializes it into a package and and sends it to all relevant players
So it would be pretty much impossible with the current system to do partial replication for specific players, maybe with custom net serializers you could have the client discard the data when it receives if it's not the correct one but that's a workaround and not sure how useful would be for your use case since the server is still sending it to the client but the client discards it
When you are building the DevelopmentClient, are you forced to automatically connect to a server?
I only ask because in my client entry map, the map loads and my UI gets created and put on the screen, then after about 30 seconds, its like the client resets.
Everytime this happens, I see this error pop into the log:
[2021.03.01-01.47.57:896][460]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionTimeout, ErrorString = UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 20.01, Real: 20.01, Good: 20.01, DriverTime: 20.04, Threshold: 20.00, [UNetConnection] RemoteAddr: 127.0.0.1:7777, Name: IpConnection_2147482037, Driver: PendingNetDriver IpNetDriver_2147482038, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID, Driver = PendingNetDriver IpNetDriver_2147482038
[2021.03.01-01.47.57:897][460]LogNet: Warning: Network Failure: PendingNetDriver[ConnectionTimeout]: UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 20.01, Real: 20.01, Good: 20.01, DriverTime: 20.04, Threshold: 20.00, [UNetConnection] RemoteAddr: 127.0.0.1:7777, Name: IpConnection_2147482037, Driver: PendingNetDriver IpNetDriver_2147482038, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID
@oak hill what's the gameplay feature you're trying to implement with this?
Does anyone know of a reason why a delegate would hang? Sometimes Oculus CreateSession will call success delegate, other times it will not succeed or fail, just hang on a middle step.
Particularly using the Oculus OSS it calls:
OculusSubsystem.AddRequestDelegate( ovr_Matchmaking_CreateAndEnqueueRoom2(TCHAR_TO_ANSI(*Pool), MatchmakingOptions), FOculusMessageOnCompleteDelegate::CreateRaw(this, &FOnlineSessionOculus::OnCreateRoomComplete, Session.SessionName));
but doesn't end up calling the OnCreateRoomComplete delegate. I've run this several times and it has only succeeded once so far as I can see, in the third or fourth try
Hi nice people, a quick question about the replicate variables. Say I have a class derived from UObject (Let's say it's called UClass1), and I make it as a variable reference in my HUD widget. When I try to call from my HUD to my player controller's "Run on Server" function which requires a UClass1 argument, would it be successful?
I know that if the parameter is not of type UObject, but of a value type (say int, boolean), it works
seems that passing a reference as parameters on server RPC will cause missing object?
if that is the case, does that mean we'd better keep the data in our player controller owned actors and left HUD focus on communicating with those actors?
Unfortunately, RestartPlayer doesn't seem to work in my case.
I'd like to notify GameState or GameMode of a player's death and do something depending on what GameMode is loaded. Preferably without relying on DestroyActor to call the event.
So you can pass array of value type variables from client to server using RPC, but you can't pass a set/dictionary, right?
by "pass ... using RPC" I mean pass that as an argument
Hi everyone. I'm very new to creating multiplayer functionality but I'm interested in learning how to incorporate this into my games. Very limited coding background. I want players to be able to connect across the internet (hosting lobbies, finding matches, etc). I know two possible options are Steam Online Subsystem and Epic Online Services--are there any others that would work here? Which would be the easiest to implement with my background?
I’m not 100% on this but I think that only applies to TMap and TSet properties, I think you can as arguments.
If not, you can just convert to TArray before calling RPC anyway
Hello, people. So I need to confirm something. You can only call RPCs from actors, right?
So, if I mark a function as multicast, server or client in a component class, and I call the same function within the Component class it doesn't treat it as a RPC unless I call the function in an actor class. From a function defined in the actor class.
Please I need clarity on this.
You can call RPCs outside of the actors too, even in the UObjects: https://www.thegames.dev/?p=45 (KaosSpectrum's blog)
Thanks. I was of the impression only Actors could call RPCs
I have a variable that's RepNotify set to "owner only"; the server set's til variable and the owning client (of the actor) calls the RepNotify, but on the listening server the RepNotify is also called - why would it be running the RepNotify, if set to "Owner Only" - should the remote client (i.e. actor owner) not be the only place it's executed?
Just read the blog now. Seems I have to add some extra code. Do I have to do the same for actor components also? Not just UObjects
In components you dont need that, that blog post is only for UObjects
👌 No problem
Mostly because BPs don't actually use OnReps. They check if the variable changed. In cpp you dont have servers calling OnReps at all.
Does this mean bp spams the tick function to do this?
I need an actor that could be a container, a pickup, or something with which every player can interact, but I want it to replicate its content only to the relevant players. So I need two different replication conditions, one for the visual aspect and the other one only for the interacting players. In the end I created an actor component in this actor and wrote a check in ReplicateSubobjects to replicate the data of this component only to the interacting players. @winged badger @signal lance
ReplicateSubobjects doens't have parameters to distinguish who its replicating to
ActorChannel is the channel of its Actor Owner
I'm not sure, through ActorChannel from what I've seen I can reach the controller of the players
In fact I'm doing a check based on PlayerController/StoredPlayerControllers inside this actor
you can reach it with a static function, does't really matter how you get the PC
the check will at best, make it so that the ActorComponent doesn't replicate unless there is at least one player it should replicate to around
then it will replicate to everyone
it doesn't run that function per NetConnection
But I've seen that ReplicateSubobject gets called once per player if I'm right
Like IsNetRelevantFor
it doesn't
it gets called when the ActorReplicates
once
and server will map the Actor for replication once, then replicate it to everyone to whom that actor is relevant for
2 approaches here - send the data to everyone and discard it client side if they are not supposed to know it
or - use another ActorChannel just for that data
note that if there is a repeating pattern on who should receive the data
you can run network manager actors that does that extra replication for dozens of other actors
instead of each actor spawning an extra of its own
But I'm pretty sure it was working... I can see that if I play with two or more clients, the ReplicateSubobject function gets called for every player controller
And I use this to do the relevancy check
I'm willing to bet that if the relevancy changes on the players' side, it won't replicate the destruction of the subobject though.
Be an interesting test to try though
What I mean is essentially once it has already replicated to a given connection, it will probably always do that - even if it just gets left with redundant data, since nothing is going to destroy it or clean it up presumably.
Hi, my client build that is built through my CI (Jenkins) returns a client outdated error when trying to join the server, its the same build, in our version control, I am thinking I have a file in gitignore causing the issue, where does a build check the build version?
just so i can include that file
FNetworkVersion::IsNetworkCompatible
@chrome bay shouldn't the subobject lifetime be managed by its owning actor?
When an actor isn't relevant the server closes the actor channel which destroys it for that client. The sub-object replication method you have currently likely isn't going to handle that for those sub-objects
So if a client changes in a way where that sub-object is no longer "relevant" to them, it's not going to be destroyed - it'll just hang around there with the old data
That's what I'd expect anyway
E.g. say you've made it so that sub-object only replicates to a given team, what happens when the controller changes team?
Unlike an actor, it won't be destroyed most likely - it'll still be there on the client, it just won't get anymore property updates
Shall i get NetworkVersion.cpp and ensure all my teams are using the same file in their Engine builds? seems like it pulls an instanced version from the project so it wouldnt make a difference?
@chrome bay so the relevancy is checked both on server and client if I understood?
Yeah, so, its kinda strange, basically my build sever (different pc, same engine version, project gets pulled from git repository before building, same project version) and it builds it via CMD using automation tool. When i use the build from the build sever and open up a dedicated sever I built from my desktop, the build sever build won't connect. My thoughts are that i have a file in our projects gitignore that has the version in it
Just Server
But what I mean is, the Server will clean up the actor channel when it's not relevant. It won't do that for sub-objects.
Ugh. This discussion reminds me that I need to attempt something similar to Ark's AI system. Only difference is I need to put the XRebirth spin on it and also simulate that data when the actual actor isn't loaded.
Sorry, A slight confusion on the roles of the gamemode and the gamestate. I understand that gamemode has the rules of this match (for example, "first to 10 kills wins") howeeever... who does the check? the gamemode itself or the gamestate? 🤔
If the gamemode does the check... does it then call a multicast gamestate to let everybody know the game ended? 🤔
it can do anything to update the GameState
like setting a replicated property (bGameFinished)
or have some kinda state system (which GameMode and GameState has) excluding the Base versions
@chrome bay @oak hill if the actor that replicates the subobject becomes not relevant it will destroy the Actor, unless it was loaded from package
even if you shove the UObject somewhere else from OnSubobjectCreatedFromReplication, it will still lose the Outer
basically, even if you were to manage to hack your way into a solution
it will be fragile, and that is the last thing you want from your networking code
Yeah, I can't see a solution where it works properly tbh
Separate actor is really the only way if you just don't want that data to replicate at all
Or some sort of "info" class that contains data for a bunch of containers like you said
Thanks!
Hi nice people today i got very confused by the magic of player controller. I have a custom class derived from actor(of course checked replicate), lets say its called Config. I used my pc to spawn this config class and set the owner of the newly generated object to be the pc, hoping the rpc(client to server) would work. NO. My hud successfully runned, but it didnt fire the run on server evenr from config class.
I tried the same setup for player controller, and magically it works
@tawny talon If I understood correctly. You're wondering why when you spawn this actor from HUD, it won't have server rpc capabilities, but when you spawn it from PlayerController, it does?
No. Just reread.
If the server version of your player controller spawns this config actor, then sets itself as the owner of that config actor, then it should replicate to all clients. Then if that one client that is the owner uses their HUD to get that Config actor on their machine after it's replicated to them, they should be able to use it to RPC to server through the Config actor.
So, if you cannot RPC through the config actor, then the most likely scenario is that you're getting the wrong config actor that the particular client does not own.
Not sure how you're getting the correct ref from the hud class, but you could store a replicated pointer in your player controller. Spawn the replicated actor, set it's owner to the player controller, and then set a replicated pointer to the replicated actor. Then you can get the local controller in the HUD class, and use that replicated pointer for the correct Config actor.
Whew. Finally getting comfortable with FastArrays and WeakPointers. Finally have both my replicated gatherable foliage and replicated building placement all in place. Both using subclassed foliage and HISM components for better draw calls. At least it's all working great in editor. I need to throw together a quick lobby system and try it out on multiple machines. But now I can actually design stuff again! Need to start working on the building placement system.
how do you handle multiple levels in multiplayer?
like a modular world with portals between the levels
(a bit like pokemon)
lets say in coop player A is in one level
and player B moves into another level
then player A's computer would have to load the other level and simulate it too
how would i handle that?
Thanks!
In my game, when a character gets tased, he ragdolls.
Problem is, bones aren't replicated, so if a client tries to shoot someone tased in ragdoll, the collision usually won't match up.
I can use death animations. My problem with death animations is that if you get tased on a stair case, for instance, half of your body will go through the stair case, as animations don't have collision.
Another solution is client authoritative shooting. This is a worst case scenario
Anyone have any ideas?
Common approach is to ignore ragdolls for bullet collision
I would prefer the players to be kill-able when tased
I was thinking that maybe it would be possible with a death animation + control rig to prevent going through floor, but I'm not experienced enough in control rig to know if that would work
Else, maybe client-side shooting authority for ragdolls
Use a physics constraint to ensure the ragdoll stays reasonably close to the capsule on all ends, and accept the clients hit if the hit is within a tolerance distance (when ragdolled)
If you're on dedicated servers then usually you wouldn't run any animation server-side
Hello, I created an actor component and discovered that ticking the checkbox for component replicates does not actually replicate the Component. I had to explicitly call SetIsReplicated() in the begin play of the actor component. Just wondering if this is a bug in the Engine or I'm doing something wrong. I googled and found this problem in 4.8 I expected it to have been fixed by now.
Any thoughts on this, please?
Also, do I have to do this for every custom component I make?
The owning actor is set to replicate. It's a character infact
The main reason I'm concerned with the Component replicating is that I have some variables in the Component set to replicate but they were not replicating until I did the above.
thats how components work
if i call a non replicated event from the gamemode, and it is also defined in the gamemode, is it the same as Run on Server?
You seem to be mixing up things
GameMode only exists on the Server. So when you have access to the GameMode to call events on it, then all of it will run on the Server.
Even you access other Objects/Actors from the GameMode, you are most likely still on the Server.
That has nothing to do with a RunOnServer RPC.
hey, I'm trying to save the player's data on the server, and load it every time the player joins it. any ways how to do that? maybe a Database that stores each player's state (for example, a variable for coins).
thanks for the help!
Need a centralized database server, that your dedicated servers connect to, update and download the player's state
any way to actually connect between the server and the database?
The database server can just connect directly like any web server to a mysql db
alright, ill look into it, thanks!
can i replicate variable only for one player? Who interact with object
yes, if you are on bp check the replication conditions on the variable
for example with COND_Custom or COND_OwnerOnly?
on server side i will make SetOwner for Actor
and SetOwner(nullptr) for stop replication, right?
DOREPLIFETIME_CONDITION(AMyCharacter, myVariable, COND_AutonomousOnly);
Can someone point me into the direction of why this is warning me about something? I get this log spam ONLY when a player is standing on top of a locally spawned HISM component, which all clients locally spawn.
LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: BuildingHISMComponent /Game/OWV/Maps/UEDPIE_1_GameMap.GameMap:PersistentLevel.CWorldBuildingManager_0.BuildingHISMComponent_0 NOT Supported.
Character Movement can't reconcile it for the movement base most likely
Since it's spawned locally
Hm. Do I ignore it, or? Semi annoying to test around the log spam. Would replicating the component holding that HISM instance work?
The actual HISM Component itself needs to be replicated from the Server in order to reconcile it properly
That or characters shouldn't be able to walk on it
More or less I was attempting a building system. Simple manager replicated and spawned from GameMode. Actor has a fast array. On post replication, it locally determines if the client needs a new component for that static mesh type and spawns it if needed before adding the instance at the desired location. Works fine, except for that problem. I'm not certain how to refactor that if I need to replicate the component. Cause each client would still need to locally add their instances and I wouldn't know if the component was locally replicated when the fast array replicates.
Ultimately you need to be able to reference whatever the character is standing on over the network, so locally spawned stuff doesn't really work for that
The alternative would be to spawn it deterministically and trick the network system to treat it as a "map startup" actor
Which @winged badger has done for some procedural generation stuff IIRC
Can components hold fast arrays?
for sure, anything can
I might just move the fast array to the components then. Then the component can do it's own stuff and it would for sure have the component there when the fast array replicates.
[Help] anyone know a simple way to replicate what time a sound cue is playing on the server when its replicated
Oh another thing you can do, I forgot
Is mark the HISM as "static" or stationary
I seem to recall it doesn't send the base then
Hmm. Can try that.
But that said, don't think you can make changes to certain properties then
Mostly, the instance just needs to be there, or not be there. Past that it doesn't matter for this. If that doesn't work, it won't be that hard to move the array to the component and just rewrite some functions in the manager.
@chrome bay Whew. That one line just saved me a few hours work. 😮 Thanks man.
NewComponent->SetMobility(EComponentMobility::Static);
Probably better for lighting that it's static anyhow.
It's a good habit to get into tbh. Landscapes being "Movable" by default is still stupid.
Haha. I was doing an AI test a little over a month ago... Had a directional light that doesn't move. Read somewhere on a forum randomly about lighting and characters and such that the lighting's mobility mattered. Changed the directional light to static and with 250 AI, my framerate went up from 45 to about 65. Insane how one setting can kill you.
If I am only going to replicate AI controlled pawns, I dont need to implement prediction, right? Smoothing / interpolation on simulated proxies will be fine?
Trying to understand FVector's NetQuantize. If I understood correctly. NetQuantize100 allows two decimal points. So... 4.15274 would be turned into 4.15? And this at the very least would trim off 2 bits. Since each float normally is 32bits, 4bytes*8. But NetQuantize can also lower that number even more than just the extra 2 bits?
compressing a float makes it lose precision, as you discard the data that held the decimals past the 2nd
but its just a normal vector with overriden NEtSerialize
How far can Netquantize100 compress though? If it's like an average of 20-26 bits, that might be worth it, but two bits doesn't feel like it's worth the effort.
NetQuantize10 is significanly smaller
It may very well be enough precision. Just building placement. I can't imagine that I need more than a tenth of a centimetre's precision for that.
Hello, is there a way to set my own server / client version for builds? Getting compatibility errors even on the same git repo
Somone here uses Advances Sessions Plugin and can explain how to create a Session only friends can find?
The "Create Advanced Session" Node has a option calles "Allow join via presence friends only". I thought this option is what I am looking for, but when set it to true then nobody see the created session. Also not friends.
How do I open a Session (and find it) which only Steam friends can find?
@tranquil beacon You're in for a rough journey if you have limited coding experience. Between Epic Online Services and Steam, you are probably best off using steam, since Epic Online Services doesn't have a ready to use plugin for UE4 yet (outside of third party / some init work on dedicated UE4 branch)
@tranquil beacon you are probably better off buying a course on sale on udemy that covers UE4 and multiplayer games
I don't get it. I think it can't be so hard to make a session which is only visible to steam friends. Or do I misunderstand "Allow join via presence friends only" and there is not even a possibility from steam and online subsystem to male sessions only friends see?