#multiplayer
1 messages ยท Page 500 of 1
I wrote that when i learned that stuff
You should place it into the GameSession class
And some stuff is simply outdated like the way to get the session interface
So create a new cpp class deriving from GameSession and have the GI call it on the GameSession instead of doing it itself?
Are you using this in cpp?
YEs
Yeah then that's fine
GameSession class has to be implemented by overriding the GetGameSessionClass function of the GameMode
Something like that at least
Just so you know
G2g sitting at airport
Ok thanks!
As for getting the session interface: this is no longer the best way? IOnlineSessionPtr SessionInterface = OnlineSub->GetSessionInterface();
If you have a chance to reply later
Online::GetSessionInterface or so
Great thanks! That probably removes the need to have to call IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get(); every time you want to get the interface
Will look at how ShooterGame does things since I believe they have all their session related code in AShooterGameSession
I wonder if ShooterGame is up to date in this regard
Thanks!
I see they are clearing delegates slightly different too : Session->OnFindSessionsComplete().Remove(OnSearchSessionsCompleteDelegateHandle);
Have also seen delegates being cleared this way OnFindSessionsCompleteDelegateHandle.Reset();
Assume they do the same thing as how you cleared the delegates in the wiki
Will read up those examples and try to see what to update
@thin stratus following your advice I realise it has to do with me assuming 'delay' is local to each player in the game mode, whereas it operates globally in the game mode - and when further players spawn when the first has triggered the 'delay' then any logic including and after their 'delay' is ignored - tried it with 4 players and as expected only the server and 1 client spawn
Don't entirely know what you meant, but the GameMode only exists on the server.
They were delaying the postlogin randomly
Delay is always shit in multiplayer
At least if it's to fight some intialization lag
From what I see, UT and ShootGame both use:
const auto OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
const auto SessionInterface = OnlineSub->GetSessionInterface();
if (SessionInterface.IsValid())
@waxen quartz I'm not an expert but I think any packet loss over 0.5-1% would be considered a very poor quality connection, I think 30-50% loss usually only happens for very short periods of time when something has gone totally FUBAR on the interwebs
(or maybe if you're trying to play on your three-doors-down neighbor's unlocked wifi)
alright good, thanks
if your game works fine with 50% packet loss it'll do well in any realistic conditions 
If your game works nicely with 50% packet loss, it is a single player game obviously. :)
LOL yeah it doesn't work nicely it just doesn't go to shit
Is there an equivalent to this BP event in c++?
/** Opportunity for blueprints to handle network errors. */
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "NetworkError"))
void HandleNetworkError(ENetworkFailure::Type FailureType, bool bIsServer);
Seems it is called directly from UnrealEngine.cpp and can be a nice way to react to network errors
However since it's BlueprintImplementable and not virtual, I'm not sure how the cpp game instance can react to it
@grizzled stirrup "The engine does perform a heartbeat internally, and clients will be notified when a timeout occurs through the UEngine::OnNetworkFailure() event. If you'd like, you can add your own handler for this event, or you can subclass UGameEngine and override the HandleNetworkFailure function. See ShooterEngine.h and ShooterEngine.cpp in the ShooterGame sample project for an example of overriding HandleNetworkFailure." https://forums.unrealengine.com/development-discussion/c-gameplay-programming/21485-where-how-do-clients-know-when-the-host-has-crashed
seems weird they wouldn't just make the gameinstance one C++ virtual too but oh well
Anyone know if theres a way to determine if all players have loaded the map from Blueprint?
NumTravellingPlayers == 0 in GameMode
i am assuming you're asking for after seamless travel
Yeah
number will change during HandleSeamlessTravelPlayer
That's a blueprint overridable event I assume?
either that or BlueprintImplementable
๐
Awesome, I'll give that a go in my lunch break. Thanks Zlo!
One more quickie, is there a way to do a ServerTravel in Blueprint besides exec console command, because that does not work in PIE at all.
nope
Damn
What is? The HandleSeamlessTravel?
HandleSeamlessTravelPlayer isn't BP exposed, but it calls HandleStartingNewPlayer, which is blueprint overridable
Ah
No worries then, I should be able to handle that then
Do I still get access to NumTravellingPlayers ?
yeah, thats just an integer in gamemode
@hoary lark Thank you very much yeah it's a very strange choice indeed
the parent function of HandleStartingNewPlayer (parent from BP pespective) just calls RestartPlayer
๐ค
void AGameModeBase::HandleStartingNewPlayer_Implementation(APlayerController* NewPlayer)
{
// If players should start as spectators, leave them in the spectator state
if (!bStartPlayersAsSpectators && !MustSpectate(NewPlayer) && PlayerCanRestart(NewPlayer))
{
// Otherwise spawn their pawn immediately
RestartPlayer(NewPlayer);
}
}
its just that, so you don't have to call the parent
@grizzled stirrup i got distracted the other day, did you manage those STEAM_CALLBACKs?
Yes just about thanks! Seems to be working great, though the only weird gotcha I've noticed is that I have to bind the delegate handles in Init rather than in the constructor for valid sessions to be sent through on the invite / join in progress callbacks
occured to ma later that with a question that specific you can just do a discord search for "STEAM_CALLBACK"
Yep I was all over every search I could find
Managed to find someone's semi related question and cobble it together
Very very little info on them in general though
and that stuff in steamapi.h is downright unreadable
It's a madhouse
macro defined over macro defined over macro
Especially for someone new to C++ like me
๐ Haven't had a chance to see the code there!
I'm honestly extremely surprised that there wasn't a single example of setting up the callbacks anywhere online, seems like a very common thing you'd be doing with steam (reacting to events from their interface )
Soooo many BP advanced sessions tutorials though all doing the same create / join ๐
i use uworks for that, so haven't had many encounters with raw steam API
Probably best to avoid it if possible
Luckily it's a one time communication setup and I shouldn't have to go back and touch the callbacks once they are working
Question: it seems when clients lose connection to a game or the host shuts down the server, they are unable to create new session OR find new sessions and are in a state of limbo unless they relaunch the game. Should you be destroying the session manually for any clients in any case where they are leaving a match?
There's this code from the ben tristem multiplayer course that destroys before creating a new one but I feel it's sketchy at best
{
auto ExistingSession = SessionInterface->GetNamedSession(SESSION_NAME);
if (ExistingSession != nullptr)
{
SessionInterface->DestroySession(SESSION_NAME);
}
else
{
CreateSession();
}
}
i wired that into MainMenu
So you destroy whenever MainMenu is shown?
yeah, its its own level
Using a similar line to the ExistingSession one there?
so it just tells the GI to destroy a session and show main menu on BeginPlay
only acceptable use of level BP imo
Nice!! Yeah that and showing loading screens ๐
I have a MainMenuPC so I can do it there
I assume SessionInterface->GetNamedSession(SESSION_NAME); will return the clients local version of the session?
What confuses me is that I read earlier that the session only exists on the server
So I am not sure why the client has to destroy it
There is conflicting info in the docs: they say you have to call DestroySession() on the client in the BP API docs but say that the GameSession is server only on the general OnlineSession docs
if you destroy a session that isn't there
you'll get a warning in output log
shrugs
nothing else
Funny that destroying the session in the client does take them out of that limbo state and they can host / join again
So may as well do it
Thanks!
@winged badger doesn't appear to let me access that variable
๐ค
Time to reparent
Ignore me - it works now !
hey
how do i make a line trace not replicated
even running an event from the client keeps it replicated somehow
and when the client has high ping, the locations are different and inaccurate
btw im using this to detect if the pawn is on the ground
i fire this event every 0.1 seconds
Line traces aren't replicated. You're probably calling some RPC or accidentally calling it from other places.
idk
maybe the location is different because the capsule is replicated?
as soon as the client has high ping, the line trace is delayed
Anyone know what 'Uses Stats' actually does in 'create advanced sessions' (of the advanced sessions plugin)? I guess it uses some kind of statistics? That I can inspect?
Having a small issue with with a 3D widget in VR. I know widgets and their contents aren't replicated. The host of the game confirms the start and clicks start (they have an option to check a box if there aren't enough players to start anyway). On clicking start it calls to the gamemode and sets everything in motion for beginning the match. This works totally fine. Everyone gets placed on the map and set up perfectly well. I just added this new thing which doesn't work and I'm not sure why. When the match starts, I want my lobby widget to display a "briefing" image. This image is there, but "collapsed" by default. It checks its visibility status with a variable on the instance. As far as I know, the clients can connect to the game instance right? When the match is started, the game mode kicks off it's countdown timer and then also casts to the game instance and sets that variable. However, the report from testing that I got was that the clients couldn't see this image. Only the host.
Yes, the variable is replicated.
GameInstance is for each time the program is run and is persistant
@somber glade You wanna use GameState i think.
ahh dammit thanks
@somber glade It already has all the match related stuff, don't gotta make your own
@somber glade https://docs.unrealengine.com/en-US/Gameplay/Framework/GameMode/index.html read this
Overview of the Game Mode and Game State
Yeah, I just had them mixed up ๐ Thanks for refreshing my memory
and that instantly fixes it
Just stumbled on this resource if anyone is having trouble setting up Steam Callbacks: https://github.com/da772/UE4_SteamworksCallbacks
Seems to have a good few examples of how to set up the callbacks
Does anyone know why most of the examples I have seen with Steam callbacks use STEAM_CALLBACK_MANUAL instead of just STEAM_CALLBACK which doesn't require you having to register the callback manually?
I am using STEAM_CALLBACK and at least for the join in progress /lobby invite callback it works fine
Is it possibly only for Blueprint reasons since delegates of this type OnFindFriendSessionCompleteDelegate = FOnFindFriendSessionCompleteDelegate::CreateUObject() can't be exposed to BP whereas if doing it manually you can specify a dynamic delegate which can be?
Don't think there is much to worry about with _MANUAL or not
Whatever works for you
For exposing session stuff to BPs you should use the Proxy class to create latent nodes
Great thanks! I don't need to expose to BP fortunately, just was curious about the choice for MANUAL
I see why creating your own GameSession class is so important now btw
Especially for cases when the GM calls HandleMatchHasStarted which starts the session in AGameMode
It's nice to be able to call the HandleMatchHasStarted super call a bit later in the GameSession to be able to update session settings before it begins like allowing join in progress
Funnily, the CreateSession node starts the session directly
Ohhh maybe that's why Steam doesn't allow the session to be discovered after the first player joins (when the join in progress bool is false)
And I've had to allow join in progress until the game has actually started
Based on your tutorial setup I had called GI->StartSession() when the game was actually ready to start but I see it is already called in AGameMode::HandleMatchHasStarted and possibly again via CreateSession as just mentioned
I guess the solution is NOT to call GI->StartSession() anywhere in my game code and let the session get started through the AGameMode call. Then make a custom AGameSession class, override HandleMatchHasStarted, don't call super and set join in progress to false before manually starting the session there
It seems ShooterGame doesn't call super either there which means this never gets called:
if (PlayerController && !PlayerController->IsLocalController())
{
PlayerController->ClientStartOnlineSession();
}
Is that an important thing to call?
Hmm that seems to start the session for each client locally via a client RPC: GetGameInstance()->GetOnlineSession()->StartOnlineSession(PlayerState->SessionName); so confusing since the docs say the session only exists on the server...
The Session should also exist on clients
Sessions are only information after all
Backend keeps track of that and who is part of it
Cool thanks so you'd say that PlayerController->ClientStartOnlineSession(); should indeed be called, and as a safeguard any existing sessions should be destroyed before creating a new session on the client?
Have noticed that if not leaving cleanly through the quit button (and manually calling DestroySession) or if there's a sudden loss of connection, the client doesn't have a chance to destroy his local session which means he can't create or find new sessions. Zlo had a good solution of destroying any existing client session when opening the main menu
Advise hosting for Europe, for a dedicated server
Hello Everyone,
Does anyone know how to check if my PC is connected to a proper internet connection or not?
open cmd, type in ipconfig
Is the correct way to replicate impulse to run the impulse on server, then send the hit actors world transform on multicast?
Also I'm having a strange issue where "walking" is jittery and laggy for clients but if they "crouch" or "sprint" it stops. But as soon as they start walking again it starts jittering and lagging. What causes this?
Are you sure the player's speed is the same on the client and server?
Should all steam callback code be wrapped with the async thread wrapper like so?
AsyncTask(ENamedThreads::GameThread,
[this]() { OnLobbyCreated(CurrentLobbyID); });
I often see it being done, in my case it isn't crashing without it but just calling the function 3 times even though it's only been triggered once (one join / invite accepted)
if the exec ends up in BP, it will crash frequently if you don't
otherwise, it might still crash
@jolly siren Yea maybe that's it. IDK I set that variable inside each character when they spawn and it's all the same value. I'll just hard set it inside each character and see if that fixes it.
If you're doing this Steam callback stuff, doesn't that tie you down to using Steam?
Would really seem quite limiting of using online subsystem stuff if you have to implement any platform specific logic, but that just may be an unfortunate reality.
@worthy perch Everything is set up in a generic way but in the case where you join a friends game or accept an invite via the steam menu, I need the game to react to that
So it's an additional steam specific callback
All the other stuff uses the generic JoinSession etc.
Really the only steam specific part is the callback itself, then it just calls the generic FindFriendSession function
So in the case where I was able to port to another platform, the steam callback functions wouldn't be called, and instead there'd be new callback functions for whatever platform that'd call the same generic session functions that the steam callbacks call
Where do you store a boolean value that everyone needs to know about called "KeyFound?" ?
You probably need to be more specific, particularly what you mean by "everyone needs to know about"
So I have a lot of puzzle related things such as finding a key to open locked doors, etc. I want it to replicate where if somebody finds a key, then everyone has it. Basically setting a boolean for everyone. Would that do in gamestate? gamemode?
GameState sounds like a good place for it. GameMode is only on the server, so that would be bad.
But pretty much any replicated class is capable of replicating to all clients, especially if it is always net relevant.
I want to confirm this is the right way to get something to happen on all clients in a MP environment? https://i.imgur.com/KOMvBRD.png it works as expected I just want to make sure the nodes are correct. Local Player Pushes button -> Server Call then Server Call -> multicast call then Multicast call -> do what I want on every client
The multicast is probably not neccessary.
You probably want to have some replicated bool on the Player instead.
any reason why to do that over having each client handle it
Multicasts can fail, whereas replicated properties will eventually replicate down.
OnReps are pretty cool.
In my opinion, manually assigning values to the anim instance especially through an interface is just more rough than it needs to be.
that last part is where the question of how to handle animations across clients comes in then
you can set the bool to the correct state on the locally executing client, then it shouldn't get the on rep.
right now I have the anim notify in the idle trigger the boolean back to false in the anim graph itself
that makes it possible to do local prediction
The replicated bool would propagate down the client, And the AnimBP through the update or by whatever way you want, would read this bool.
not particularly fantastic prediction, there's no rewind mechanism intrinsic to that, but multicast is unconditional and so you wouldn't be able to
yep its the setting the boolean back to false that would be an issue if I just replicate a boolean in the player
player sets bool -> anim graph updates in update -> animation fires then... how do I tell the player that the boolean is false now which would then replicate to everyone for no good reason?
Hrmm
trying to "learn" properly at this point, I can of course just make shit work but doing it efficiently and "proper" is the goal here
Seems like the replicated bool and the animation book should be separated
Well, there are better and more complex ways to do this that I'm not familiar with, so, perhaps I'm a bit out of my depth.
yep just taking all input till I get all the angles. There is more than one way to do it so I want to learn the plus/minus of them all of course
I reckon you could do this with just the one bool
However, you coud just multicast which calls some PlayMontage locally.
I personally like the idea of the animations driving the actions so I can make sure they are keyed up properly based on animation length and any variables around that
use the bool as a trigger and "consume" it back to false
multicasts can be marked reliable but you really shouldn't
And I saw that you mentioned dedicated server, dedicated servers by default, don't play animations on the skeletal meshes.
yep just meant dedicated server since I was just firing it on server and it was playing and I got confused (but that was due to it being a listen server so duh...)
stupid listen servers always throw up confusion since you scratch your head on why server calls are executing on a client lol
so for something like this, an animation, is not having it reliable a big deal?
because it means ue4 can't drop them if your bandwidth gets saturated
if it's a competitive tactical game where it's crucial that you see when your opponent is reloading always, maybe
If it fails, you crash. In a sivestream, they said they considered not even allowing Multicasts be marked reliable.
the same question applies to simply calling a fire then, client1 fires so how does client2 know client1 fired reliably in terms of damage and animation then. I guess replicating variables reliably is smarter?
you don't crash if the RPC fails
I'm pretty sure you do crash if a reliable RPC fails. But I could be wrong.
it just constantly retries it
if reliable replication crashed on fail, no UE4 multiplayer game would ever ship
ooh.. so would a reliable RPC then be when you see a chunk of lag then suddenly all the event fire off?
unless you mean something else
reliable just means TCP emulation (if not usage) occurs.
I dont need like "omg lag prediction and rewinding" in terms of my goal here but getting across the basics that seem to block people when learning MP for the first time is my goal. Animation and replicating basics like firing seem to be a super stopper
Run this event. I ran this event. I see you ran that event.
pretty much any replication seems to be an issue when learning lol but shrug
Working on a tut?
thats the plan
hmu tomorrow after ~5 est
nothing fancy just an intro get over the basics. Here is the tpp project, here are the anim starter stuff, lets make 2 people fight and make it look correct.
and to pound in the server controls everything aspect of replication lol
@severe widget will try and remember, I keep getting sidetracked with real work lately lol ๐ฆ
if you still need guidance
I was doing the replication aspect of animations earlier btw @worthy perch but stumbled upon the idea of interfaces and anim notifies so was trying it out but glad I asked i completely forgot about stuff not being reliable
I like the idea of data driving results, like the animation start/stop. I guess I could always have the notify tell the player the anim has stopped and flip the bool in there lol. to the graph!
hmm.. so how can you stop a variable from being replicated if you don't want it to be lol
I think just multicasting something that plays a montage would be the most effective/easy.
I thought about that as well but can I have the montage use blending so I can lock the hips and below to the current animation and blend in the reload animation like I can in the graph
Also, keep in mind, the client can overwrite a replicated property. The server won't know about this, and replicated properties are by default only sent on change.
Mathew, I think so. I'm pretty sure all the blending in and out is available in the animgraph with montages.
yeah if the local anim notify fires in the local graph and sets the local player variable back to false that would be fine but I would think that act would trigger the replication to other clients if the server does it.. Maybe uh just only do this on clients and not server lol
man... so many options
I like the options, giving people all the plus/minus of stuff is good imo
welp back to the graph then to try all of this out ๐
oh one last one
is there even any point in having an anim graph do anything on a server?
If you want the dedicated server to play animations.
like replicate the "is firing" boolean on server then only do the animations and setting the boolean back to false on the clients. the variables would be out of sync but I wonder if that would matter and I just realized it probably would unless I just had animation variables lol
why can't this be plug and play.... it's like work or something, sheesh
why can't light just travel faster
If you do CMC stuff, it's kind of like toggling a bool.
https://wiki.unrealengine.com/Authoritative_Networked_Character_Movement#Sprint
I personally haven't done this.
i have, it's probably not what you want for a beginner-ish tutorial (and i'm pretty sure it's CPP only). it does work nice once it's all done though ๐ฆ
is there even any point in having an anim graph do anything on a server?
And I just did a quick look, and it looks like networked root motion montages get played on dedicated servers.
I don't think you should put any netmode/authority checks in the AnimBP, is my position.
well I just tested with the variable, setting it to true in the player and replicating it and that works great
the issue is when the graph sets it back to false on the anim notify end it calls it on the clients and server
which then makes the server set it again which seems un needed lol
TBH any kind of "trigger" event I would start off with a function RPC, not rep'ing a bool
doing an is server check before setting it of course works fine, server sets it an replicates it, but I was trying not to replicate twice when I was using one multicast before
yeah that is what I have but the mention of an RPC failing was brought up
so basically trying ALL the options to gather info on good and bad for each
unless your RPC idea was server only and not a multicast
personally I'd do what you started with. as for a reliable variable rep vs a reliable function rep... especially for learning/non-AAA purposes/just building your game, use what works, not what is microoptimized
Also, multicasts and onreps are handled differently in C++/BPs. Very unfortunately confusing.
yep good to know all of this
would be nice to let people know "hey this is good to start with but if you need XXX or your goals are YYY you might need to look into ZZZ"
like no way in hell am I going to try and get into optimized client predictions or rewinding
if I found out later that rep'ing a bool was 9000x faster, I would use a bReloadTrigger and I would just initiate reload every time it toggles (also needing a bAbortReloadTrigger)
or otherwise ignore the setting of it to false
yep yep. Probably should not also tie in the actual reloading mechanic to the animation either I am realizing lol
because if your reload event gets lost... oy
sending one function RPC sounds cheaper than sending two bool RPC's (true and false to reset)
and send another function RPC abortreload if you abort reload
should be no need to send an isdone, in most common FPS type uses
actually question on that. assume a lag spike and you hit reload, it shouldn't reload or play the animation until your code goes thru to the server or should it play the animation regardless and the code is delayed?
I guess thats a design decision more than anything
I think the gist of networking is "nothing is the right way, it's just the way you need it to work to fit your design" lol
well that's where you get into prediction topics, gaining an understanding of how movement prediction works can of course let you extraplate over to other uses since it's all similar in concept
absolutely
yep yep so nailing the design at the start is important to cover, whoo learning ๐
100 person BR is going to have different design goals than a 5 person mmo hub based instance game
then after you design something like reloading prediction, you have to branch into cheat detection because prediction intrinsically allows the player to start shooting a full gun again before the server thinks he should... snowball effect. or you do it partway - show the reload animation locally but just let the player deal with a delay getting his gun filled up, usually it's less noticeable. I've seen that in a few small games I think
hmm even then you still have to have the server tell the other clients to play the animations so you can see the other player doing them so would you then have 2 calls? one for mechanic and one for animation but mark the mechanic reliable for example
you know making a game and not having to worry about this stuff must be amazing
like total ignorance
"hey bob why does our game use 1MB/s bandwidth" lol
I think I need to just realize you can't get around just simply doing some stuff unless you are a god tier programmer and can swizzle bits like a master and make every bit count
I actually haven't fleshed out the reloading networking in our project yet, I just spent a couple months doing our movement junk and moved onto other stuff ... but IDK, it might vary a bit depending on different genres of games. but usually yeah, the server "should" tell the player how much ammo he has (maybe just via a replicated int, in a simple doom-like shooter). having local prediction and correction checks the same way as movement should be able to make the whole process of server authority seem invisible as long as the connection is stable. but it's still, of course, complicated. hmm, i really need to think about this some more myself
hah
our game has jetpacks as equipment, like guns, and I ended up routing them through the movement component to build in fuel usage prediction for them. it works great
I think this is where people get stuck when learning MP
"simple" stuff becomes multiplicatively more complicated
sadly yeah, it's not a weekend activity, I took like a month or so part time on it, learning and implementing and fixing it up
๐
I think covering all the different ways to do the same thing is a great tool for learning and I've got 3 so far lol
well 3 that work, got a ton more examples that don't ๐
yeah. and this kind of thing, you really have to do it the naive way once to see how it doesn't work "nicely" to start grasping a handle on the difficulties prediction faces
yep yep ๐
sheesh even something like, hit reload and do you instantly get the ammo changed and the reload animation stops you from firing or do you hit reload, animation plays, then your ammo changes and you can fire or your option you mentioned do you allow reloading and can abort as well...
I only picked reload because I found an animation for it...
welp back to the drawing board, thanks for all the chat all ๐ so many problems
Should you really never use reliable multicast rpcs?
Has anyone played with the advanced session plugin? How do I use 'filter'? What can I filter there? My own settings? or?
That's sure @gleaming kestrel your settings
Thanks
@silent birch Here is what I am doing: I can set extra setting (like MyServerName) to a session, and extract it when finding sessions as well (as shown in the picture). But I dont get how to set or use the filter option? I can make a 'sessionsearch' struct, but how do I fill it?
I could simply filter the array after I got the session list, but .. then what does 'filter' do at the beginning? (looks puzzled)
( in know I did not connect the 'add', that is not the problem, its how can I fill the struct? )
Me for create a session I use this node
when you simulate packet loss with Net PktLoss=10 and you use reliable replication (either rpcs or variables), are the simulated lost packets "resent" since the replication is reliable? and is it the same behavior as with real world packet loss?
@gleaming kestrel technically a filter makes sure that the sessions are already returned filtered
If the make struct thing doesn't give you any options then you should ask the plugin creator for help
this seems to work fine ๐
If I want to do online multiplayer without port forwarding or such, do I need a steam app id? (that I have payed for that is)
I am not an expert on this (just building my first multiplayer game myself), but as far as I understand, it depends on the subsystem you use.
You can inspect them in the engine.ini (or somthing)
if you set it to 'null', you will be able to use standard tcp-ip network discovery
I think
You would need to do port forwarding stuff.
I guess you could use Steam OSS with 480, but that's limited in someway (that I forgot).
or not
You don't need a Steam ID to use Steam online
You can develop using the test ID
The question is whether you want to ship your game without Steam
Which for a multiplayer game is......... a really weird idea
getting a steam-game-id costs what, 85 euro or something?
$100
yeah so what I mean is, if I want online multiplayer without port forwarding, I can achive that through buying a steam-game-id right?
Yeah, that would work.
Hi, anyone knows how to replicate a ADefaultPawn over network? i was not able to find a good example with google..
meaning the movement (MoveForward,MoveRight etc.)
Probably a dumb question, but is there any scenario in which an actor does not have Role_Authority on the server? Provided the actor exists on the server, of course
Is calling MyDelegateHandle.Reset(); on a DelegateHandle doing the same thing as ClearOnFindFriendSessionCompleteDelegate_Handle(0, MyDelegateHandle);if the goal is simply to reset the handle in order for it to be used again?
Having some really strange issues where steam callbacks aren't resetting the delegates properly
Only way I can get it to work every time is by using the former instead of the latter way to clear the delegate handle, otherwise it only works the first time and not past that
All other session delegate handles get cleared the latter way and work fine
anyone has a good resource for my question?
@gusty raptor This is quite involved
The UE4 multiplayer mastery course on Udemy shows how to do it
@bitter oriole does it mean i have to do client side prediction etc. ? (like its not as easy as just replicating a variable?)
its basically just a flying pawn (like a camera) i'd like to replicate
Is your game competitive ?
Do you have dedicated servers ?
Do you need physics ?
its basically a rts , its gonna be a listen server, no physics
yup, its not a concern
It's impossible to not have cheating on listen right as the host would always be able to cheat?
Yeah
Then it's the easiest setup, you just need to simulate your camera with a velocity that gets updated with input
Then, the layer would RPC the server with location + rotation + speed
The server replicates that, probably as a struct, with COND_SkipOwner
And on replication, you do a quad interpolation for position, based on the average time between replication events
(The Udemy tutorial has all of that, though it also includes a more serious net model)
hah yeah i understand its hard as thats the easiest setup ๐
Wow that's a lot more than I thought but I assume the CMC does similar
Considering how much bandwidth it eats up
I mean I just upload two floats myself so that's 480 bytes/s at 60fps
Hardly a problem
I heard more that the frequency of RPCs matters and not just the actual data sent
But I have no real knowledge on the inner working so can't really justify that ๐
I guess since they are unreliable it's perfect
Yep the amount of bandwidth the CMC uses is dependent on your frame rate. It's the only way for the server to actually accurately reproduce the client's exact movement
I think in 4.23 there's a new project config setting to set the max net framerate? Something like that.
Hey, did with UE4.23 anything change with the Steam integration?
I can't get the integration to work. In all other older projects it worked just fine. I can't create and find a simple session or unlock an achievement.
@jolly siren hey I just wanted to thank you for your suggestion. I changed all my characters walk speed to the same instead of setting it through the 'event begin play' now it works perfect. I was pulling my hair out before. Thank you so much!!! :)
no problem, glad I could help ๐
@worthy perch Oh I'm very interested in that
That would mean RPC's etc. could only be sent at a max frame rate of whatever you specify?
Essentially making the bugs where you have to cap your game at 60 FPS when spawning / listening for invites no longer a problem?
240+ FPS in the main menu / when spawning in means trouble with the default settings
New: Introduced MaxNetTickRate, which defaults to 120, to limit how often the net connection ticks. This helps very high framerate clients to replicate without overloading their connections or wasting excessive amounts of bandwidth. MaxNetTickRate is configurable in .ini files by adding "MaxNetTickRate=120" (or your own value) to the "[/Script/OnlineSubsystemUtils.IpNetDriver]" section.
Beautiful
I'm going to set it to 60 as I don't see any cases where I'd need it higher personally
weird, I wonder what the ramifications of that are. in theory that should cause the client to desync from the server more (albeit on a very small scale, corrections might be unnoticeable)
Most servers only replicate down to other clients around 24 times a second in the cases of Fortnite right? So it seems potentially a bit redundant to send more than 60 updates a second to the server in any case
it's about you sending your updates to the server
server to other clients, yeah that can be whatever
Yes but if the server is sending others 24 then why do you need to send more than 60 to the server? Unless doing some gnarly lag compensation or heavily bound to the CMC for movement and need the accuracy
Luckily I am doing a co op game so I can get away with clientside CMC movement
So I can definitely send less updates to the server
right, that's just it - like normally the server can in theory "actually" 100% perfectly recreate your character's movement because you send it your exact movement every frame your PC ran, and the server CMC can run the math itself the same way. this gives the tightest possible movement tolerances for cheat checking, etc... I guess reducing the net tick rate would just loosen that up a bit. down to ~120 or even 60 it's probably insignificant, the more I try to imagine it
forcedly limiting game framerate always felt like a hack I didn't like doing anyway
Got it! I'd say even so since we watch movies at 24 fps, sending at 60 would be well within accuracy for most cases right? Like 60 updates a second is a LOT: probably more than detailed enough for the server considering most games wouldn't allow drastic differences in movement within the space of 0.016 seconds ๐
And yeah I hate forcing the limit
It feels very hacky
I'm going to remove all that code that I had been setting whenever the player was in the main menu or spawning now
Also I would say that if you did require the 0.016 second accuracy, syncing animation state 1:1 would be far more noticeable than differences in position
and I believe most games do not sync animation state at all
They just play the anims based on certain replicated properties like speed or direction
by probably-wrong napkin math, in a fully server auth game, I think setting max tick rate to 60 might cause a typical FPS character to be corrected as much as/less than 5 centimeters after a movement... it might be enough to just be noticeable sometimes, maybe become a minor nuisance in a game like Arma where you're trying to peek around corners really accurately... not likely an issue in a game like Quake
That's true, if going super granular like Arma then it makes sense
Most games however can be quite crazily out of sync without the client even noticing
All smoke and mirrors at the end of the day really especially with latency involved
the biggest thing is to make you feel like you're in 100% total control of your character. even small pops can really quickly ruin that immersion. but this seems probably small enough to be OK. glad I heard about it here ๐
Yep! These are the gems you miss otherwise, thanks @worthy perch ๐
Hi, I'm trying to get an experiment working where I start a 1 player w/ dedicated server in PIE, and then let the client request a server travel via RPC that uses UWorld::ServerTravel(). What seems to happen is the server travels, but leaves the client behind and disconnected. Confusing since the documentation here (https://docs.unrealengine.com/en-US/Gameplay/Networking/Travelling/index.html) says the clients will be taken along; is it maybe something that works differently in PIE?
Also, if I use APlayerController::ClientTravel(), the client travels, but becomes the authority, so I'm guessing it's not connected to the dedicated server anymore, and is just hosting the new map locally.
clients shot not call ClientTravel
Server calls ServerTravel which brings the clients with it
should*I
also in a dedicated server setup, clients should not tell the server to server travel
you connect to the server (say a lobby map). When server is ready, server will travel you off to the game map
also dedicated server testing in pie is a bit of a PITA
i prefer to launch the dedicated server process externally
Hmm, I have my project set up so I typically start PIE in a hub level, and it's client w/ dedicated server for that level (good). But if I 'enter a portal' to go to another map, I'd like to use a travel technique that preserves the separate client and server roles so I can test gameplay accurately.
It seems like the way I am doing travel just turns the client into a local server.
Also, calling a server RPC from the client player controller to execute the ServerTravel command would ensure that it runs on the server, right?
yes
hope this is the best channel to ask... In multiplayer i need to control exponential height fog per individual player for indoor/outdoor environment. Is there any native solution ?? The only fallback i have in mind is to add an exp height fog to the pawn blueprint instead of the level, which has many drawbacks, but seems the only workaround. Post process seems even more inconvenient to manage.
IMPORTANT! Since UE4.23 Dedicated Servers are broken. Even in an empty FPS example project I can't get a dedicated server to launch as a player controller is always invalid. In older versions of UE4 the same code and project works fine. Updating the project to UE 4.23 breaks it.
Does anyone knows a workaround?
wha? dedicated servers do not have, and never had, a player controller
Well, they do
The authoritative one for each connected player, if any
Obviously on start, none available
well there is currently never one for the server. Can wait forever
Helped me but am not in front of my computer there, I have a problem, I made that if the life of the character are at zeros the character that destroys and a widget is displayed to him then a level must open and it works well. But the problem is that when it is the customer who dies the level only opens at home and it is also what must happen while when the server that dies the level opens at all the world
@rich dune So why do you expect a PC to be valid here ? No connected client - no PC
I need the PC to create a session on the dedicated server
you clearly don't since that would make "create a session" impossible
without the PC there is no session a client could connect to. This is how I used it in 2 already released projects for years
probably works just fine passing null to it
well then how do I create a session?
if I pass null to it session creation fales due to invalid player state
@bitter oriole @fleet raven This is how a dedicated server on an older project creates the session. At the same time with the same setup. It's on steam, working perfectly fine.
How am I supposed to create a session otherwise on a dedicated server?
what this did then, is pass null
I have never used a dedicated server, or advanced sessions, so I have no idea
Just saying there's no way you ever had a player controller on a dedi startup
what do you exactly mean @fleet raven
get player controller on a server before anyone joins always has and always will return null
so, maybe that create session node you're trying to use is broken now
Then something massivly must have changed with UE4.23. I don't know how I should create a session now
The node use lan of the create session actually works?
Yes lan works with null
but guess sessions are also broken in UE4.23
Well the list of whats not broken gets shorter and shorter ๐ฉ
Sessions are not broken
@rich dune The basic problem is that you're looking in the wrong place
PlayerController always was invalid on dedicated at startup
Going back to UE3 a decade ago
This stuff doesn't change
that might be true, but how else do I create a session on a dedicated server
Looking at AdvancedSessions, the player is not used on dedicated servers, so it's not required, was never used, so you don't need it.
Just don't pass it.
That's it
will test right now again
@bitter oriole Tested it now and it does not work. Sessions seams to get created but there is no session available
If you want to specify a specific gamemode before creating a session (passing in a const FString& InGM to the CreateSession function and setting it like so: SessionSettings->Set(SETTING_GAMEMODE, InGM, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing); What exactly is the string that you specify? A full path to the GM blueprint?
So debug it
Well I actually have not much to debug at this point
Have you tried setting the join in progress bool to true?
Seems to count as being started in some cases even when just created or one player joins
well this is just frustrating. UE 4.23 is such a horrible bad version for me at this point -.-
Works great for me ๐คท
I'm having constant crashes or strange errors that sometimes pop up while console development, some features are entirly broken and can't be used on some target platforms and now Multiplayer is also somewhat broken and does no longer work like in versions before
Might be down to AdvancedSessions since that isn't an official plugin from Epic
no same behaviour with the default session stuff
Multiplayer in 4.23 works fine for everyone
Sessions work fine
Your project does something weird that maybe worked previously and now doesn't
So debug it
this project is entirly empty :D
There is nothing to debug.
it's a blueprint FPS template, the default Steam config integration, a create session in the gamemode and a search session funcion in an empty main menu map printing out strings.
this is the lowest you can go and it still failes
I'm sitting here for a week trying all strange combinations and the only thing left I can say is. UE 4.23 is broken and in older versions it works
Okay well, revert to 4.21 and enjoy life
I can't, Publisher is requesting a prototype in UE4.23
You'll have to change publishers, since 4.23 is broken apparently
seams like it
For what it's worth I have working sessions & MP on 4.23
Epic shipped some version of Fortnite on a similar version at some point
And it's not even the .0 release, we've already gotten the first hotfix
It's much more likely that your project specifically does something wrong
that does not mean much. there are massive issues in consoles which are not fixed for 2 major versions now
You can either be in denial and go back to 4.21 forever or actually try fixing your issue
I'm sure there are 5,000 bugs in 4.23, but sessions and MP at least work correctly as far as I can tell
I would like to fix it. but I'm all out of ideas what to test and where
already done
Do a simple listen server, create session, search session
everything tested. listen sessions work, dedicated server sessions not
the exact same setup is always working in 4.21 and not in 4.23
it does not matter if i convert the project from 21 to 23 or 21 > 22 >23 or create a entirly new project in 4.23 with the same setup. it always failes in 4.23 with dedicated server
maybe try creating an entirely new project with a different setup?
which setup?
if your goint to test by creating a new project why would you create the same setup you had before?
well the setup I have is bare bone
This is normal since you probably download the plug-in on Chrome but a plug-in 4.22 or 4.21 you have to download the 4.23 otherwise nothing @rich dune
find it hard to beive that dedicated server is broken
also you could just try redownloading ue4
I'm already testing with 2 different PC's with one PC rebuilding UE4 2 times over the week with the same result
Before you got the 4.23 it worked? @rich dune
yes I can create this in 4.21 right now and it works on first try
But on 4.23 it does not work? @rich dune
starting to feel like your just pulling some late April fools joke on us now ๐
@timid moss blizzcon is apparently coming but no thats not a out of season april fools joke ๐ฉ
@silent birch Exactly in 4.23 it's not working
OK then download the plug-in 4.23 not 4.21 or 22 @rich dune
I am talking about the subsystem 4.23 online plugin @rich dune
I am passing in a gamemode string that is the full path to my gamemode blueprint and then trying to filterSessionInterface->FindSessions() with this query setting SessionSearch->QuerySettings.Set(SETTING_GAMEMODE, InGM, EOnlineComparisonOp::Equals);
However it never filters and always joins me with any available session even if it is using a different gamemode
Do I have to manually do an if check like if (SessionSearch->QuerySettings.Get(SETTING_GAMEMODE, RequestedGM) == InGM) ?
If so that seems to make the EOnlineComparisonOp::Equals kind of pointless..
Can be @grizzled stirrup
testing @grizzled stirrup
Hey guys. I am trying to figure out the best way to replicate aim offset of the character mesh for my FPS game (when player looks up other clients can see your mesh look up). I have the calculation working but my problem is it only shows up on the client. I have looked up how to solve this and it looks like people online are saying to make the offset variable replicated and then do a server RPC every frame to update it. This will work, but doing an RPC every frame worries me. Is this how everyone does this? Or is there a better way?
@timid moss Here's how I do it:
// Replicate the view pitch of this player to everyone except himself
FRotator CurrentRot = FRotator(CurrentViewPitch, 0.0f, 0.0f);
FRotator TargetRot = (GetControlRotation() - GetActorRotation()).GetNormalized();
FRotator FinalRot = FMath::RInterpTo(CurrentRot, TargetRot, DeltaTime, 5);
CurrentViewPitch = FMath::ClampAngle(FinalRot.Pitch, -90.0f, 90.0f);
That's on tick and CurrentViewPitch is replicated to everyone except the owner
How does ShooterGame match a simple string to a gamemode here?
const FString GameType = TEXT("TDM");
const FString StartURL = FString::Printf(TEXT("/Game/Maps/%s?game=%s%s"), TEXT("Sanctuary"), *GameType, TEXT("?listen"));
Found it, you can create an entry in DefaultEngine.ini like so +GameModeClassAliases=(Name="TDM",GameMode="/Script/ShooterGame.ShooterGame_TeamDeathMatch")
Hey guys. So Iโve recently been playing with the voice module, and I get my microphones audio data captured into memory and compressed. Iโm trying to replicate this audio data to client that are close to me. My first thought was RPCing the server with the data then I got a warning about my array being to large. I know that I can change the max array replication size but I was just wondering if there was a better way to do this
@supple pelican you may want to just use in-world voice chat
What do you mean?
@supple pelican https://forums.unrealengine.com/development-discussion/audio/1437038-ue-4-19-native-spatialization-how-to-use
Hi, we are trying to use the new UVoipTalker (available since UE 4.19) in order to have users' voices spatialized.
We've already modified some previous versions of
@timid moss if you are really worried about bandwidth... it is possible to compress float values and send them over the net packaged as uint16 (2 bytes) or even uint8 (1 byte). but it might not be smart to bother until you've realized you're starting to have a problem and it would help. (i'm not smart, so I wasted the time and did it from the onset) https://hastebin.com/azosidapab.cpp
I canโt pipe the data through Steam OSS or whatever. Project wonโt be using steam or any OSS for that matter.
Is there a free service I can use to master-list hosts?
I'm trying to get hit result under cursor for objects in a client rpc and it returns false always, the collision settings of the actor are in the #blueprint channel, idk if it's a multiplayer or a blueprint issue so maybe someone here can help
is it always possible to use an already existing Third Person Character blueprint in Multiplayer
@gleaming vector Hi! I was having a bit of a search re UObject replication (initially for use in an inventory system where Outer may change) and ran into quite a few comments from you a few months ago. Are you still happy using replicated UObjects for your use case or given another shot would you use something different? So far replicated UObjects are working out ok for myself though I'm not too deep in the rabbit hole just yet. Also did you ever find out a good solution for having Outer changes replicated, or was creating a fresh UObject the eventual solution there? Thanks a lot ๐
i ended up duplicating the object
the response i got from epic was "nope you can't do that" in a lot of words
Ah that's a little frustrating, but good to know that's the case. Given that do you still feel that replicated UObjects are a good fit? (using something like AActor seems too heavy, esp for something that doesn't have world presence)
yes
Awesome. thanks a lot! ๐
basically
in my usecase
I basically had to replicate properties
and there was a lot of per-type properties that I really cared about having, but didn't want other objects to have those properties
const int32 Method_Rename = 0;
const int32 Method_Duplicate = 1;
void UArcItemStack::TransferStackOwnership(UArcItemStack*& ItemStack, AActor* Owner)
{
const int32 TransferMethod = Method_Duplicate;
if (TransferMethod == Method_Rename)
{
ItemStack->Rename(nullptr, Owner);
//Recursively rename out substacks
for (UArcItemStack* SubStack : ItemStack->SubItemStacks)
{
TransferStackOwnership(SubStack, Owner);
}
}
else if (TransferMethod == Method_Duplicate)
{
UArcItemStack* Original = ItemStack;
ItemStack = DuplicateObject(Original, Owner);
//We don't duplicate our sub objects here, because PostDuplicate handles it
}
}```
is there a tutorial somewhere to use an already done TPS character controller blueprint and make it multiplayer
@viscid bronze the default TPS character uses the character movement component (CMC) which supports multiplayer movement all the other stuff you want to add doesnt just magically work for multiplayer
look up some replication tuts on youtube if you want to learn more
alright, cool ill try that, thx @faint dock
I'm a noob to networking, but am looking to better understand how UE4 utilizes C++ and multiplayer. I was beginning with the Action RPG documentation and live streams, but they mention Action RPG is not designed for multiplayer. Instead, the hosts directed those interested in networking to the Shooter Game example. Does Shooter Game utilize Epic's Ability System similarly to Action RPG? Will these live streams on Action RPG help inform how Ability Systems works when cracking into Shooter Game?
There is a lot to unpack here
@lunar sedge ShooterGame doesn't use GAS, and the action rpg example is a full pledged singleplayer example of how to use GAS.
Something that Epic is missing on their examples is a GAS appliance for multiplayer environments, for that you'll need to do more diggin.
However if you are getting into multiplayer I would recommend you understanding the basics. There is a great resource shared here and PINNED in this channel which is the "cedric eXi" network compendium which will walk you through several important concepts of networking.
My first recommendation for you is to do a toy project using the basic multiplayer features UE4 offers (RPC's and whatnot) and then deep dive onto your preferred specifics.
The three concepts you need in UE4 for multiplayer are replication, RPCs, and sessions. GAS is a huge plugin that can be useful for some games, though I wouldn't use that without learning the rest first
Hi, when i spawn a blueprint actor it seems to replicate, but a c++ not. do blueprint actors have some net settings enabled by default?
I have used Cedric's previously, but will jump back in and see if I cannot glean some more from his awesome work. Thanks, both.
why do actors on level replicate very slowly? I have several thousand which should replicate only one variable. before I spawn a character replication goes slower and slower, after spawn it seems faster but not for a long time. MinNetUpdateFrequency = 50, NetUpdateFrequency = 100
basically I have to wait minutes to get all actors replicated
Relevancy might be a factor here, but... thousands of replicating objects may be a bad idea
MinNetUpdateFrequency = 50, NetUpdateFrequency = 100
Those are some big numbers.
and I expect big replication but it's slow
might need more bandwidth there, and using replication graph to keep the server from dying prioritizing 1000 actors between more clients
there is no other actors or data to replicate on scene
server seems perfect, no hitches on it
does this variable ever change
everything is tested on same pc
100 frequency for a single byte with 5000 actors means 500KB/s bandwidth, which is way more than makes sense
UE4 has several limits on bandwidth that needs to be adjusted here
no it's COND_InitialOnly
that changes things I suppose
Assuming you just need that one property replicated and nothing else, would setting NetDormancy matter in this case? I would assume it would help.
we tried that but had no luck, maybe we don't know how to use it properly
have you tried using the network profiler
never is it difficult to setup?
Nope, very easy.
ok I'll check that. I hope it'll show me where the bottleneck is
Does your output log/s say nothing?
I just see that OnRep function is fired with slow rate
it goes from 10 actors/sec to 1 per 5 sec
maybe I should attach controller and spawn character right away to make NetPriority calculate correctly idk
If I had to guess, I'd say you have a CPU problem from the large amount of actors with high netupdate frequencies.
Hey there. Unsure whether I should put this here or in #umg. I'm having issues with user interfaces in multiplayer, and I think these issues stem from my not knowing the best practice for setting up UI for multiplayer. Currently, when I want to show something on the UI when a after something happens to a pawn, I use a run-on-client RPC, getting the pawn's controller, and using IsValid to call all of my UI events. I know there must be a better way, but I haven't found a definitive answer.
The current system keeps drawing the UI twice on the server (when packaged) but I'm not so much worried about that as I am about actually doing things the right way. Something tells me that issue should disappear if I actually get a good system in place.
UI is local only, server should not really handle any UI logic. it shouldnt even have UI stuff on the server unless its a "listen server" with a player controlling it
I'm using a Listen server. sorry - should have mentioned
the the UI should only be on the local player
gated behind IsLocallyControlled
to show the widgets
Okay, there's an IsLocallyContolled node that I should use when calling widget events from a player pawn?
ui shouldn't really be called from replication (i mean a client rpc from the server is ok to show a widget on demand if the server wants the player to)
Okay. Client RPCs if I want to call widget events from server side things like the game mode BP, and IsLocallyControlled for pawns. I'll see if I can't come up with a streamlined system using those
yeah
gamemode would have to client rpc on the player controller
like i have a lot of my client rpcs on my player controller
server can just grab a controller, and call a client rpc on it
and i know it will fire on the owning client
like the gamemode will show the end game screen to all players, so it calls a client rpc on the player controller
Okay, that makes a lot of sense. I'm in class so I have to go - thanks for your help!
hey guys any good references for docs ? The docs in the oficial site don't explain it in enough depth IMO
explain what?
Just general networking and maybe some more in depth examples and such
no specific game type or anything just curious about it
Pinned messages. "Network compendium" by Exi
they need to remove slate
and update it for UMG
no one wants to learn slate as learning resource now UMG is available
I have a problem with AI character replication. I have a default mannequin, with an AI controller, driven by a simple behavior tree. All it does is run between 2 target points. When I have 1, it seems to work fine even with multiplayer. When I add 1 more, it starts to break down. The characters start jumping around randomly. When I add 6-7, it breaks down completely and all the characters are warping constantly. All the replication settings are default. I'm not sure how to start debugging/tweaking/fixing this.
Odd thing is: in the unreal editor, it doesn't break if I have only 1 player + dedicated server, but it does break when I add a second player to it.
consider taking a video, and check through all of the Stat Net statistics for weird things. look for net saturation. @exotic axle
(actually, I just realized I don't know how to watch Stat Net on a dedicated server, lol)
The player controller by default only replicates yaw actually, but input events happen only on the client, and you are not sending your axis value to the server currently
Wait, so all input events aren't sent to server at all?
The event itself no, but the player controller and the character movement and pawn all have functions that take care of this
Things like Add Yaw Input, or Add Movement Input
these functions take care of this for you
I see
The player controller however as stated before, doesn't replicate Pitch, but idk if you care for that just yet
Not really
But thank you
How would you handle this situation then: I need the player whenever not moving to face the camera's direction
are you using the default character movement component? it has a setting to "use controller desired rotation"
on tick, if velocity is nearly 0, print current velocity
But its not 0, the player is actually moving on my screen
hold on a sec. you're getting the velocity of the player controller. do you want to get the velocity from the character movement component instead?
Well is it wrong to get the velocity of the player controller?
the player controller actor isn't the player character actor
I have no idea what the "velocity" of the controller actor would do during runtime TBH
you should be able to GetVelcoity from either the character actor, or its movement component (if you run it on the actor, unreal will pull the velocity from the movement component for you)
fix that first and see where you're at
In my game I made a system of random spawn level elements, and the problem is that for example at this point there is a weapon that spawn and the server sees it well but the customer sees something else
sound like the thing you spawn is not replicated
I'm confused I am trying a system with n players (with dedicated server), up and down move back and forward and left and right rotate around the local z axis. So far my back and forward movement replicates so all other player see it (I don't know why as I don't use character movement component or manually replicate it but it just works). My rotation replication is fine AS LONG AS the player does not move back or forward at the same time. Here is what I do
The rotation replication works on the spot, but as soon as I move back or forward as well, the rotation appears fixed from other players' point of view, though not the owning player's.
It is replicated even in multicast @spaq#4532
For the character of the game I also made a random spawn and it works but the problem is that for a player there are two characters who appear
@twin juniper i wouldn't use Reliable RPC's in a Tick based function
also this here
you are setting the rotation to 0
everytime back or forward is pressed
the 0 is the amount of rotation that is added
you are setting the rotation to 0
no the function just adds a rotation
I also did a get - set
to try and update it on clients
thats why I added the function with 0 input
I will post photos not screenshots because the discord on my computer is taking time to open (it does not even open but it just loads) sometimes I post screenshots because that's my father's connection
I can get location to replicate, and rotation to replicate, but not both at the same time ๐ข
think you'll need to share more blueprint code and behavior. you've implemented your own custom Add Movement Input function for your custom pawn then? does the character "stop turning" when you're moving or does their orientation reset to north?
or using the default AddMovementInput with no CMC attached?
as soon as I change the location, the rotation resets to north
but I can turn on the spot and that replicates
resets to north from other clients' PoV, from player's pov is fine
whats CMC if I may ask
your movement isnt set to control rotation?
or w/e you are using to move the actor forward
char move component, think you said above you don't use it
oh yes. I think I used that at first but add movement input replicates for some reason
what does AddMovementInput even do if a pawn doesn't have a movement component
maybe share your ServerInfo RPC too just in case
you're also apparently rotating your mesh component but not your actor, is that what you think you want?
sorry, you're doing some weird things here. on clients, you rotate the mesh in local space and then you set their pawn's control rotation to their pawn's current control rotation?
Please So who can help me?
Is this the best way to check if a session exists? if (SessionInterface->GetNamedSession(GameSessionName)) My game crashes when I'm playing directly in the map in PIE without going through the main menu to create a session and Session->StartSession() gets called so I want to make sure it isn't null before starting.
Actually that does not seem to work either ๐ Still crashes
Check your logs <GameProjectDir>/Saved/Logs
Sounds like something a bit more screwy is going on there.
Nah it's just that when playing in editor directly on the map, the session is null as I didn't go through the usual process of creating one in the main menu
It works fine just crashes if trying to directly start or update a session that doesn't exist
So just wondering if I can check if the session itself is null, if not then it's assumed to be testing and doesn't need to call the functions
Can do a bool in my GM but it's less flexible as I need to remember to turn it on / off when testing for real
Why not add a branch if it's editor?
I think there's a node for it
yeah apparently With Editor node exists
Build powerful visual scripts without code.
๐
So if youre running in editor and the session is null, create it ๐
Hello again
Hello
Do you have a solution to my problem?
What's your problem? I haven't been watching the conversation
OK
In my game I made a system of random spawn level elements, and the problem is that for example at this point there is a weapon that spawn and the server sees it well but the customer sees something else
For the character of the game I also made a random spawn and it works but the problem is that for a player there are two characters who appear
So there are two problems
So based off what you've told me, your client AND server are spawning the player
Only the server should handle it.
Yes
Skimming the above you said you're multi-casting
That would run on server and client
Why not Run On Server instead of multi-cast?
The problem with my random spawn is that if for example on a wall the server sees that it is a weapon that appeared and the customer sees for example a knife, but that's not what must happen, he must see the same thing
Yeah so the server needs to tell the clients what it should be seeing
So server would say "Okay client, I am spawning A ROCKET LAUNCHER at Position 1"
If your spawnable item is replicated it should actually spawn from the server onto the client in the right location if I remember correctly
My random spawn code runs at the beginning of the game and is done in the blueprint level
I don't think blueprint level is the right spot for it but lets work with what you have so you get the concept
Got a screenshot?
My random spawn is a custom multicast event
kittens is right. you need to spawn stuff on the server only.
I will post photos not screenshots because the discord on my computer is taking time to open (it does not even open but it just loads) sometimes I post screenshots because that's my father's connection @silver lotus
Sorry @silver lotus
No worries mate.
The only time you spawn anything on the client is non-gameplay essential things like decals and stuff
Cosmetic. That's the word I was thinking of
yep. spawn it on the server, if the actor is set to be replicated then the server will handle creating it on each client for you
Switch Has Authority is a great node you should look at @silent birch - It returns Authority or Remote.
That would probably solve your issue in the blueprint level class.
Ive not used a level blueprint before, but I believe that every player executes it
OK
@silver lotus Thanks for the answer- only problem is that I often do test with valid sessions in the editor if I go through the main menu. I'm sure the is a way to test if a session is null or not
Thank you it work @silver lotus
For the character of the game I also made a random spawn and it works but the problem is that for a player there are two characters who appear
For this problem, who can help me?
OK
I try
It did not work
This problem is only at the customer's @silver lotus
You have no solution?
You're spawning two players. In your spawning logic, do a print string
If it says CLIENT: Hello and SERVER: Hello
It means your running that logic on both.
OK
The server is responsible for all player spawning, and I would put money on it that you're spawning them on both ๐
you're doing the same thing but this time, your character is probably marked to replicate properly already (your guns weren't). your server spawns one, your client spawns one (from the multicast), then the server tells the client to spawn a copy of his
^ That.
Are you multicasting for the spawn?
You told me to put run on server and I make them @silver lotus
Do a print string on that function.
I did it and this chain of expression was only played once
is your player replicated
Not sure mate. Maybe @hoary lark has an idea?
Finally it does not only happen at the customer's, because I tested the game on a player and that's also product @silver lotus
There is no more problem. The problem came from the World settings that I did not choose Game Mode and I chose a game but the default pawn in the world settings I did not put anything but because of that at the beginning of the game the customer n no character to control @silver lotus
Why
Sorry, I'm not sure I understand what youre saying.
Youneed to define a default pawn in either a Game Mode (Which then needs to be set as default) or do it in your world settings
But I already have a random spawn so why put something in the default pawn of the game mode? @silver lotus
Because that's how pawns get spawned by the engine?
OK
I know. But it is also this default pawn there that in the level there is an actor of more @silver lotus
So how make?
Where do you guys do all your stuff like spawning pawns and handling state changes? I have it in Playercontroller right now but I'm thinking Gamemode would be the best way to do it?
GameMode and GameState
thats the idea behind them
remember GameMode is server only
Yeah I'm thinking Gamemode. I'm trying to set things up in a robust way so the game pretty much flows the same whether standalone, server, or client. I'm using highly modular player pawns, does using RepNotify to trigger setup code sound like a good approach?
Here is a snippet I use all the time:
by Yun-Kun 06-02-2017, 03:37 PM
GameInstance (an object spawned when you launch the application and that remains the same until you close it)
GameMode (spawned when a level is loaded)
GameState (spawned by the gameMode)
PlayerState (spawned when a PlayerController is spawned = when a player arrives in the game)
You have to pay close attention to what you do and where you do it when coding a multiplayer game. When it comes to singleplayer, you can't really "have it wrong" except for GameInstance stuff.
But here are the general guidelines I follow:
GameInstance - Holds any non-pointer persistent variables (persistent means that you need to store in between two levels and that you don't need to store in a SaveGame)
GameMode - The overall game manager - starts and stops the current game space you're in, handles the GameStates and how they rotate - an example might be "King of the Hill"
GameState - Keeps track of every data relative to the current state of the game (timers, scores, winning team) that all players in the game need to know about, handles scripted events related to the state
PlayerController - HUD, Camera, Mouse, Keyboard, Gamepad, Inputs calling actions on the Character.
PlayerCharacter - Actions in response of Controller's input + Holds personal infos and stats (Health, Ammo - but Ammo might on your Weapon Class if you can switch Weapons).
PlayerState - Holds every variable non related to the PlayerCharacter that needs to be known by everyone (best scores, current killing streak, player name...)
So I sort of figured out the cause of my issue earlier. The reason why the mannequins I had were warping around was because their network priority was too low, so the problem fixed itself when I upped the net priority. But that means the game is net saturated even though all I have are 2 vehicles and 7 mannequins running around updating at 10 times / second. Any idea why that could be? (I'm not sure how to read the net stat counters, which numbers are high/low, relevant irrelevant... etc)
how is 8 kB saturated?
It says num client saturated = 2 ยฏ_(ใ)_/ยฏ
And I have 2 players
So I assumed both connections I have are saturated
Also, if I lower the net priority of my mannequin characters, they warp around. I was told that the net priority shouldn't matter unless the game is net saturated.
the default bandwidth settings are very low - I think about 10 KB/sec up or 0.08 Mbps. I increased mine a bunch. 4.23 also has some "net tick rate" setting added that should help, we discussed it in here... yesterday?
Floss Last Tuesday at 9:45 AM
I think in 4.23 there's a new project config setting to set the max net framerate? Something like that.
@exotic axle go find that convo if you're using 4.23, else you can look up how to increase your project's bandwidth limits to more modern levels instead of UT2004 levels
Lol, got an error compiling my own class because I stupidly called my project 'NetworkGame' (which turns out to be ambigous), so I renamed my project and map folder, reopened: nope. Broke the project. Renamed them back: Nope. Project broken. O..M.. G! lollll! (have to start again.. AGAIN...) /make note to self: never use names that can be ambigous ...
Use backups you say? /make note to self: make more backups.
Is it possible to talk directly from a client to client, instead of having to make a server call then propagating it? Going from client 1 -> server -> client 2 can add a decent amount of ms that might be able to be avoided if I could just go from client 1 to client 2.
I have my own custom movement component with prediction built in, and I was wondering if it was possible to pass over the predicted state from a client to the other clients before the server simulates it and propagates the real game state after.
@hoary lark thanks
@waxen quartz It'll be really hard. You'll probably have to do nat punchthrough etc. And what are the chances that client to client ping is faster than client to server to client?
@dark edge yea it sounds like a real pain lol
Isn't it almost always faster? Fastest way is a straight line, if you reroute through server you will always add extra ms
My game uses listen servers so I'll probably end up doing nat punchtrough anyways
@dark edge I'm doing my random spawn code in the blueprint level. But I also tried in the Gamemode
@waxen quartz P2P in games is generally a bad idea
you want to have a server. I remember reading an article on the subject, some old RTS games did use P2P, but it has some clear limitations, and for instance for a FPS it's a nogo
@glad wharf yeah generally speaking. In my case it's basically a fighting game, 1v1, and since I'm using listen servers technically speaking cheating is possible
ah yes indeed
@waxen quartz if it's 1v1 then there's already only one client...
Sorry I didn't specify, it can also be 1v1v1 or 2v2
But most of the time it's gonna be 1v1 anyways
I wouldn't worry about it. If you go dedicated then the servers are gonna be on a nice fat pipe and if not, the server is in some random dudes basement which would be just as far as anyone else in most cases. Only time you'd have extreme ping differences are if some are on a lan together and some aren't.
Yea you're right, I was just wondering if anyone has done something like that in case it warranted the effort. Thanks
Hello again
@waxen quartz if Crowbcat has made a video making fun of it then you don't want to touch it with a 99 ft pole ๐ https://www.youtube.com/watch?v=38sPNZ8QHO4
(actually I would love to see some example of a coop P2P FPS... not sure if any have ever existed)
when calls RestartGame from GameMode
does that clear everything, variables, arrays, actors..etc
?
from source code i can see that restartGame do ServerTravel with "?Restart"
parameters
Is it normal to get a lot of lag when I simulate multiplayer by opening multiple screens
@twin juniper You mean with lag low fps? Then yes
Any resources I can read up on for groups of zombie-like AIs in multiplayer?
large-ish groups, around 100 total entities
Even disabling most of the collision/overlap checks, disabling shadows and similar stuff I get unmanageable fps drops
Similar to this stuff
Days Gone - Saw Mill Horde Walkthrough (Biggest Horde Battle) You will encounter the Saw Mill Horde near the end of the main story in Days Gone. It is one of...
the biggest impact is going to be the movement componen
also Animation Sharing is a thing now
as they use the same animations, you can share them
Yeah we are already thinking about nuking the movement and doing our own thing
would animation sharing only work for actors that are all synced?
it uses blends,
and it pools the animatiosn
animations
so they don't have to be doing the same thing
but if they are it shares
Ok, I'll look into it, that should help on the client side
dedicated server?
yeah
like notifies?
yeah
notifies still fire on server
just bone locations cant be used
as they don't update
:/ so I'll have to move away from attached weapon collisions to hitboxes
server will be in A or T pose
@hoary lark Well I don't have ubisoft's budget to be able to afford dedicated servers, if the game gets large enough that cheating becomes a concern I'll look into it lol
Aren't all co-op fps games p2p? Or are you not including listen servers as p2p
Also my game at most will have 4 players in a short match and in the common case will only have 2
P2P isn't listen server
Listen server is one player hosting and every player connected to them
Dedicated server for 4 players is dumb, unless you are doing a competitive game. 2/4 players is extremely often done with P2P/listen server
As to client-to-client connections, Steam does NAT punch for you if you're on Steam, but you can't have P2P in UE4, not easily
is a listen server good for 12 people
12 is a bit much I think
@bitter oriole yea it's a comp game, that's my main reservation with listen servers. But most fighting games are p2p anyways so I wonder how they do it lol
Most fighting games have very simple netplay setups
They're more predictable
You can easily have each player detect cheats, and simply ignore them
You don't have to pay for servers yourself, communities can host them themselves via 3rd-party providers
Pretty common setup
Need a reasonable audience for the game to make it worthwhile though
^ though you'll always need your own official servers to maintain the community
yeah v true
Personally I just stay away from anything competitive - I don't want to spend half the dev time doing anticheat
@bitter oriole yeah I was thinking of a system like that, since damage/knockback/etc. Are fixed values I can always validate it with relatively simple math. I'm not sure what to do if it's the client that detects the inconsistency, there's no client_validate LOL
And yeah I agree with the anticheat sentiment.
@chrome bay that would work in most instances, the problem is that these are short-matches that just start and end. It's not some persistent universe like Minecraft, imagine how clunky it would be if you had to set up a server before playing a street fighter game.
tbh I would just develop for both
HLL was developed only for dedicated servers and sometimes that makes testing things a real nightmare
Listen server won't even run
@chrome bay HLL? Hell let loose?
and yea you might be right, if cheating becomes a problem then I can just pay for dedicated servers and it shouldn't be too hard to switch over to them. It still bugs me for 1v1s to add unnecessary ms though.
(I'm reposting this as the multiplayer channel is probably a better place for an answer)
I've been trying to solve this issue for a few days now without luck. Doesn't seem to be much documentation on it. Disabling replicate movement at runtime causes player's speed to change. Here are steps to reproduce the problem:
(4.23)
- Create FPS template (BP)
- Open the player character BP
- Add input node which calls set replicate movement passing in false
- Start game on default level with 2 players
- When you press the input key that you chose in step #3 (on the client), the player's movement will stop replicating as expected, but he will speed up super fast for some reason
This issue does not happen if set replicate movement get's called on begin play. It seems to only happen when called during runtime after initializing with begin play
probably because your acceleration got stuck
Hmm, wouldn't the character movement fix that locally?
Because it should control the characters acceleration
Maybe disable replicate movement and code your own movement replication?
ah wait are you using cmc?
Yeah
I'm using cmc
I want to use the default replication because it handles the client side prediction well enough for low ping
I'm just trying to understand why I can't disable the player's replication without this happening
@winged badger If you disable movement replication when your velocity is 0, the glitch still happens. Which means the acceleration isn't getting stuck
Does the player speed up on the server or on the client?
client
Not solution
For one-offs like playing a sound or spawning a particle, do you guys multicast the spawning of it or just replicate the actor?
Me? @dark edge
multicast @dark edge
don't replicate it
make it local
only try to replicate something if it affects the game and all clients need to know the latest information on it
SFX, FX, visual details should be client side and multicasted
https://cdn.discordapp.com/attachments/549632636642000908/632321308256108574/WireFrame.jpg
For example on this, all the individual meshes (masts, sails, etc) are not replicated. Any updates I call multicasts for them. No point in replicating them because there is no need to have them be updated constantly.
The only replicated visual assets are the purple static meshes (individual cannon actors) and the ship's hull.
SFX, FX, visual details should be client side and multicasted
Multicasted?
if you're doing one off events or objects that are only going to be updated by events multicast them rather than replicate them.
Oh, makes sense. I think you meant should be client side **or** multicasted
mast sails, etc are only going to be changed via damage or movement modes.
so a multicast event is called and the client updates their local copy.
same would apply for one off things like firing a gun/cannon/weapon, you'd create the FX & SFX locally from a multicast.
not really @worthy perch client side and multicasted
perhaps I should have said client side and the events to update them are fired from the server to a multicast.
so don't tell the server create a new SFX/FX and set it to replicate
tell the server to tell all the clients to create a new SFX/FX locally and have it not replicate.
Smart
which handles local FX stuff, every client has one
What does it do specifically?
i use gameplay cues, which is part of GAS
when i fire certain cues, if they are local only, then they wont be multicast out
the clientfxmanager intercepts them and just plays them local, bypassing the multicast. If it does need to be played to everyone, then its played locally on the client, and multicast out ignoring the client who spawned them, then on the client side, there clientfxmanager intercepts the cues and plays them
so its like we can limit what gets sent over network or what should be played locally
some cues should not be played for everyone
i dunno its just a system i came up with lol
clients handle the spawning of the FX themselves
based on a GameplayTag
For the character of the game I also made a random spawn and it works but the problem is that for a player there are two characters who appear
I know where the problem comes from. That's because for the client there is the random spawn character that appears and the character put in the default pawn of the game mode. Apparently the default pawn character only appears where the client spawn not to another place
@silent birch https://youtu.be/V_YiDqXU-Gs?t=2093 check this tut it might helps you
Blueprints has unlocked the power of programming to designers and artists the world over. As you learn to use Blueprints and create more complex systems, you...
If you make an INITIAL_ONLY replicated variable and a client joins after the initial bunch has been sent out, will he receive the correct value?
The value I'm trying to replicate here is a score limit which is completely static past entering the game
But the clients need to know it to display it on the UI
Alternatively would it be more efficient to pack all of my state replicated properties into a single replicated struct? (containing 4 uint8's: ScoreLimit, CurrentRound, RedTeamScore, BlueTeamScore)
it does as far as i know
Thanks
So but The video did not help me
then i dont know how to help you
So you do not understand what I mean? @faint dock
you get 2 player pawns spawn at beginplay?
Yes
and you spawn 1 player random and 1 player does not spawn randome what you dont want right?
Do you know the default pawn? @faint dock
not sure what you mean
Do you know the world settings? @faint dock
which one
Probably spawning a pawn twice
i guess so too
but the video i sent should help there
he needs to override the playerspawning logic in the gamemode
In unreal you have to choose the character that goes spawn and it is this character who spawn with the client which makes that two characters spawn the character who randomly spawn and the character who is designated for spawn by default
like i said you can change all that logic in the gamemode
How?
watch the video
OK I will try to look at it again @faint dock
they do a randome spawn for the player i guess like you want it
but its for splitscreen so you have to think a little different
The problem is only at the client not the server @faint dock
At the server that spawn well @faint dock
i dont know how to help you could be 1000s of things that are wrong here watch the video they do it right
When I do not designate the character who is going to spawn by default (in the game mode) the client does not take control on any actor, so at the customer's place it is unpossession @faint dock
so the pawn spawns on the server and client but the client does not play the pawn?
pawn = character
At the client nothing spawn (if I do not designate the character who will default spawn in the Gamemode) @faint dock
4.24 is deprecating a lot of publicly exposed replication-related methods and creating getters/setters for them: https://github.com/EpicGames/UnrealEngine/commit/88a68fa9a0f7bd1230d530e430c1261004f60f18#diff-8c479d4069f4f5736ec2094fa5e77fe0
stuff like bIsReplicated
this is good, but heads up to people updating
I still have not solved my problem
@gleaming vector Its actually about time they did that
Finally the second character that appears always appears when I test the game in 1 players this second character spawn always and always in the same place But only when I appoint a player who goes spawn by the game mode
Is there any obvious reason that this isn't replicating?
USTRUCT()
struct FMyMatchState
{
GENERATED_BODY()
UPROPERTY()
uint8 ScoreLimit;
uint8 CurrentRound;
uint8 RedTeamScore;
uint8 BlueTeamScore;
FMyMatchState()
{
ScoreLimit = 0;
CurrentRound = 0;
RedTeamScore = 0;
BlueTeamScore = 0;
}
};
UPROPERTY(Replicated, Transient)
FMyMatchState TDMState;
Can you use a single UPROPERTY() to cover multiple properties?
ahhhhhh that's it
thank you
Completely blanked on it
One side question, would it be more efficient to send one of these structs to each client via a client RPC once every round rather than having it replicated?
Seems like it would be more logical since these values don't change often
I would say no. At least, not meaningfully. This is a pretty small struct anyway, on a single class too.
Cool thanks again for the help!