#multiplayer
1 messages · Page 427 of 1
no, only one person spins a dedicated server
Yes
all clients just use the regular client executable
I understand
But my "players" in general
when my game is released
and players want to play multiplayer
they have to jump through the hoops of getting the dedicated server executable, setting it up, and running that separately in addition to running the client game?
Again, not great, but doable
Question regarding data persistence for items. I’m using an external DB to store player equipped items but am curious whether it makes more sense to store item attributes in the DB as well or just keep those static in the game executable, and just query a reference to the specific item name in the DB. Any thoughts?
Tough question, and a common one. I've found that Unreal's editor for DataAssets is a bit more focused and better at formatting data and working within the Unreal system than an external editor (such as a spreadsheet program or database editor)
In other words, I've opted to stick with editing stuff inside of Unreal as much as I can
@jade gazelle What kinda system are you using for that? Like CPP SQL calls to DB's and stuff or?
thinking about implementing a system similar but have never done it before
@ocean dust I’m leaning towards what you are suggesting and keeping the attributes in UE and just referencing the specific item from the database. Seems like that might make more sense and be less strain on the DB as well
@radiant crag I’m using Postgres for the database.
Right now I’m prototyping with a BP plugin I found to do direct connection to the database but for shipping and moving forward I’m going to transition that to using HTTP connection to a PostREST server
How to simulate lag when using dedicated server?
run the same pk command on server
I'm going to try this first but thank you! Net PktLag = <ms>
Normally, the RepNotify should be called on the client when the actor becomes relevant, right?
I just want to replicate actor visibility. The listen server application decides visibility, writes it to a repnotify bool, and in its OnRep SetActorHiddenInGame is caled.
However, visibiltiy is only initialized if I set the actor to be always relevant, otherwise it remains visible on the client even if its hidden on the server
@thin stratus can linux steam dedicated servers accept connection from windows steam client?
@zinc canyon according to video 4 from this site https://www.unrealengine.com/en-US/blog/blueprint-networking-tutorials RepNotify is reliable. Check your net cull distance squared.
Yeah according to https://docs.unrealengine.com/en-us/Resources/ContentExamples/Networking/2_3 it should be called when the actor becomes relevant, with the correct value
I got question about quite basic stuff. I posted the screenshoot of the packaged game. Local/Remote role is the role called on the character. PC Local/Remote is the role called from character's controller class. How is it possible to have different roles? Why character from listen server got remote role autonomous proxy? When I test it in PIE or on dedicated server this divergence does not occur. Is it a bug?
I'm having some issues with joining dedicated server via standalone with Steam enabled. The server log doesn't show any connection attempts and the client just says that the netdriver shutdown. Ideas?
show the logs @solar halo
sec
@solar halo we had exact same problem recently. It just stopped connecting to linux dedicated servers with steam enabled, even through it was working fine before
What was your fix if any?
@thorny kelp can window's clients connect to linux dedicated servers ?
@umbral adder yes
@umbral adder we test both on ubuntu and centos
amazon gamelift servers are configured similarly to centos
@solar halo still figuring this out. Temporarily removed steam parameter from server startup. From game.exe -steam -lan to game.exe -lan
I have another project that works 100% fine with connecting to dedicated servers, but this new project just doesn't.
@solar halo probably steamid is invalid?
@thorny kelp u recommend gamelift or ec2 instance?
@umbral adder we straightaway went for gamelift so I can't tell
ok
how much per month?
@thorny kelp
@solar halo server dint even start properly lol
i really dont know but the server started incorrectly
see logs carefully
try to rebuild again
I have lol
@solar halo How's your client built ? Standalone or in editor ? Development / test or shipping ?
Dev build as Client with Unreal Frontend.
So a packaged game.
Uploaded to Steam also.
Is it started from Steam ?
@solar halo try adding this to your DefaultEngine.ini
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver"
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
Already in there an exact replica.
In Unreal Frontend I'm building WindowsServer and WindowsClient.
@bitter oriole for shipping ded server what are the extra steps we need?
only to put the dlls right?
For shipping it just needs to be started through Steam, won't work otherwise
ok
Oh also as a Development build.
The weird thing is it works fine when I add UWorks to the project.
I don't want to have it as a dependency so I'm reverting to the original Steam OSS.
There are no traces of UWorks in the project either.
@thorny kelp Gamelift any good and how was the implementation of it?
Dedicated servers I usesteam=false
Hm, do Splitscreen Players not go through the default "PlayerCanRestart" stuff of the gameMode?
I have delayed start enabled and create a splitscreen player in the test editor level, and that one seems to get a pawn
The main one properly spawns without pawn
Hm actually seems to be the other way round. The main one isn't calling it
🤔
Seems like the first player calls "PostLogin" while the MatchState isn't WaitingToStart yet
Sometimes I would really wish for these things to be consistent for all players etc.
Failed to produce item: GameServer.pdb
Can't seem to find anything online on this, anyone know why I don't have that file?
I've properly generated project files & compiled
Hey, does anyone know if its possible to use the new Steamworks SDK with UE without modifying the engine source? Or do i have to use the old version thats currently supported?
By default, if you're not using the engine source code, you won't be able to update the steamworks SDK and have to use the provided version.
gotcha, thank you @swift topaz
A few weeks ago I've seen a comment on how someone implements replicated Animation Montages. He made a class and passes an instance of it with all necessary data like the Montage itself and what drives it to a Character that then plays the Montage. Is that common practice for replication? And does anyone have a tutorial up for it or some references? Unfortunately I can't find the comment again and I don't want to use the Animation Blueprint to handle some montages
Does anyone know how to replicate a blueprint physics objects that doesn't require an event tick?
Or does anyone know if this'll clog the network? I basically need dozens of physics objects to push around
but they have special functionality like being damaged and broken, so they have to be a blueprint.
you can try replicating the FTransform and Velocity only on frames when velocity changes
let the clients calculate in between frames on their own
and by "velocity changes" i mean acceleration/force changes
Is there some guides how to implement VOIP? (better if it will be blueprints only)
What's a good number for net frequency update in player character for a 8 player multiplayer game? Just need an idea for it an min net frequency update.
@ripe cypress you can go all the way down 5Hz no problem, but that increases round trip times
most modern games use about 30hz
Anybody know why a game would freeze for ~5 seconds when respawning a (local) multiplayer character?
alot of code on begin play
Thanks
Is it possible to get the current session CSteamID??
wanna call ActivateGameOverlayInviteDialog but the LobbyID parameter doesnt seem to be exposed on the subsystem, and theres no function to get it on the steam api
@thin stratus thats the player's ID right? i need the lobby id
https://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AGameSession/KickPlayer/index.html
Is it possible to use this method and the "Kick Message" to pass data about who won? As well as other stats? If so, how would you go about doing this?
Forcibly remove player from the server true if player was able to be kicked, false otherwise
Never mind, I found it out:
{
}```
We simply need to override this in our player controller. However, would this be transferred even considering we would be "client traveling" to the main menu? Actually, this function is not virtual so we can't override it. It's a useless function
You should be able to override it; the _Implementation function should be marked as virtual automatically.
Would the PlayerController still have this data? Isn't the player controller destroyed upon level load? Therefore, when the player is kicked, they would get this information, and then it would be destroyed?
I know that when we call KickPlayer() it loads you to the "DefaultMap"
Ok so I'm having some roadblocks on replication graph
My main concern is how the lists are handed off to players, and how the spatialize actually creates the local nodes
I checked the shooter game example but that didn't really clear much up
And right now I'm using a MySQL servers to store player inventory, and wondering what the best way to organize this data is
I'm an SQL noob and it seems hacky so far
I'm using a map to map strings to in-game objects and rebuild inventories that way. It doesn't seem right
hello. I've been always from working with UE4 for a while, but I just read the updates and the Replication Graph sounds awesome. however, I stopped programming because running UE4 from source in order to be able to make a multiplayer game gave me a lot of headache, so I ended up stopping
my question is, for people that work with recent UE4 versions, can you make a multiplayer game without having to building from source? it felt really clunky from me, a non traditional programmer, so I gave it time
thank you!
You only need to build from source if you gonna compile as Dedicated Server
if its a listen-server multiplayer you can do without it
@shell sinew
yeah, I wanted to use a dedicated server. I had a lot of transition weird bugs and I honestly didn't have the head for it by the time. thanks for the quick answer @twin vault
I'll probably check it out either way whenever I get a break
the Replication Graph may be even more polished by then
thank you :D
i personally only ever build from source
for personal projects and professional ones
it's not htat big of a pain
Is this safe? Or am I going to run into issues where it gets destroyed on the server and never get torn off on the client?
void AFPSGunPickupZone::BeginPlay() {
Super::BeginPlay();
if (Role == ROLE_Authority) {
// Destroy the gun pickup zones if pickups are disabled
AFPSGameMode* GM = Cast<AFPSGameMode>(GetWorld()->GetAuthGameMode());
if (GM && !GM->GameVariant.SpawnPickups) {
TearOff();
Destroy();
}
}
}
void AFPSGunPickupZone::TornOff() {
Destroy();
}```
are you destroying twice? is TearOff supposed to be the same as TornOff?
is TornOff a multicast to destroy on client?
Its not needed to destroy on client if the actor is replicated, one destroy on the server will destroy on the client too
@jolly siren
TornOff is a core engine function. It is called on the client
Networking - called on client when actor is torn off (bTearOff==true), meaning it's no longer replicated to clients.
oh mb
sorry meant to link actor one sec
Networking - called on client when actor is torn off (bTearOff==true), meaning it's no longer replicated to clients.
Networking - Server - TearOff this actor to stop replication to clients. Will set bTearOff to true.
didnt know about those
But yeah normally calling Destroy would destroy them on the client too. The issue that I was running into with just Destroy is that since I'm doing it in BeginPlay it happens too early on the server, before the replication connection has been initiated between the server and clients. So it is destroying on the server only and remaining on the clients.
And I was trying to find a solution without adding a hacky delay
careful @jolly siren , 4.20 added an ensure checking bHasBegunPlay
and doing stuff like Destroying an Actor from BeginPlay might result in "failed to route BeginPlay", along with a 30 second or so freeze that comes with failed ensure
where is that ensure?
I'm not even sure if how I have it is safe. I was wondering if the bTornOff could fail to replicate sometimes since I am calling Destroy serverside after setting it
sometime after it runs the component's BeginPlay
anyone know if the Gamelift plugin for 4.16-4.18 works in 4.20? It's the latest version I can find on the AWS website
you could run into it if you derive something from that class
then your derived class BeginPlay would call Super::BeginPlay, which would call Destroy, which for some reason sets bHasBegunPlay back to false
and... yeah, ensure
hmm okay, do you know an alternative to what I'm trying to do besides just delaying?
are they placed on a map, you probably shouldnt spawn then at all
if they are, is there any function before it gets replicated so you can block their spawn maybe
yes, they are placed in the map
LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: bHasBegunPlay [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\Components\ActorComponent.cpp] [Line: 1007]
found the log from that incident
as long as you can avoid that, it should be fine, and it was apparently an ActorComponent, not an Actor
ahh okay, that is good to know. But is it okay to call Destroy() on the server right after tearing off? Or could that cause it to not actually get torn off on the client (i.e. bTornOff replicated variable)
you could probably hook into some PostReplicate stuff
but i don't know them off the top of my head
TearOff should have an immediate effect though, client doesn't need to be informed the Actor is TornOff iirc
well it does need to be informed since I'm calling Destroy clientside within TornOff()
hmmm
i see only one call to TornOff()
DataChannel.cpp line 1740 (on 4.18)
should work tho
just not sure 😃
its likely to be gone before its evaluated for the next replication
at very least it will be bPendingKill
right, yeah testing it seems to work. I'm just worried about the rare cases where it doesn't. Since it seems like the actor could get completely destroyed server side before bTearOff is replicated
depends on the NetUpdateFrequency and GC cycle though
it might cause an occasional crash
there might be alternatives, like tossing those on their own StreamingLevel and just not loading it unless its the right GM variant
I don't think it would cause a crash. I think it could possibly not get destroyed on the client sometimes.
Yeah, I've thought about that alternative too
its the multithreaded curse
Also thought about just hiding them and forgetting about it
eventually GC will ninja it at just the wrong time
you could probably use GameState to signal to clients it should be destroyed
just a theory, but if you have a replicated boolean for that and DOREPLIFETIME it before the Super call (provided that does not crash)
it should be replicated before MatchState, which signals BeginPlay should be called on clients
now there are at least 2 maybes with this approach
the variables do replicate in DOREPLIFETIME order tho
does anyone have any recommendations for learning replication in blueprints. More specifically with the thought of an FPS in mind. There is almost no information anywhere on this. Youtube, answerhub, google. I understand the concept of replication somewhat, but when i start to apply it to projectiles and the characters moving and ADS and all that good stuff that comes with an FPS nothing works properly. The client can see random things, the sever can see random things the client is doing. I dont know 😕
There is ALOT of information about replication. The issue is that its not an easy concept to completely wrap your head around from a beginners point of view.
Read Exi's compendium in the Pinned Messages of this channel.
Persist with it, you wont understand it overnight.
It is not a small subject to tackle and has broad reaching effects.
Download the Multiplayer sample projects and go through them, try and understand how their interactions work.
Do research. Play around.
You will get a better understanding over time.
ok. guess its just not a direct, clear topic
Anyone have any best practices tips for replicating a high volume of projectiles at fast speeds? This is a bit on the extreme side but I'm looking for as many performance improvements as I can. With dedicated server unchecked I get flawless movement doing this, with it check on the second cast it gets super choppy and projectiles start to jump.
Also - I have nothing running in the construction script right now as I read that may impact performance. I set velocity of begin play and use the built in projectile movement component.
can you treat the whole thing as 1 effect/object?
Nope, they are all individual projectiles that can have their own effects/explosions/other stuff. This effect is also just an example but I know in the future I will have multiple players and monsters casting abilities.
@tawny parcel don't replicate the effect, just replicate the damage i think
anyone know how to print log to dedicated server console using blueprint?
printstring
it doesn't work on dedicated server console
DevBuild or Shipping?
Yo, question about the build in Spectator System:
What's the proper way to swap a Player over to being spectator?
Previously I actively spawned a Spectator Pawn for them, but I assume UE4 has some build in dicision stuff that would do that already if I set some vars true or?
I would assume the spectator pawn already exists by default
if you have set one in gamemode that is
other than that, I guess it's just a matter of possessing it
I'll see if "RestartPlayer" has a path of restarting the player as spectator
Trying to look for reasons why i cant find sessions on a packaged game, but google only show results about the appid, which is not my case
using those
settings:
OnlineSessionSettings.bShouldAdvertise = true;
OnlineSessionSettings.bIsDedicated = false;
OnlineSessionSettings.bUsesStats = true;
OnlineSessionSettings.bAllowInvites = true;
OnlineSessionSettings.bAllowJoinInProgress = true;
OnlineSessionSettings.bAllowJoinViaPresence = true;
OnlineSessionSettings.bAllowJoinViaPresenceFriendsOnly = false;
OnlineSessionSettings.bAntiCheatProtected = false;
OnlineSessionSettings.bIsLANMatch = false;
OnlineSessionSettings.bUsesPresence = true;
OnlineSessionSettings.NumPublicConnections = 5;
search:
SessionSearch->bIsLanQuery = false;
SessionSearch->MaxSearchResults = 20;
SessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);```
on a packaged game, different computers, different accounts..
Joining through presence and through invites works fine
only searching will return bWasSuccessful == true but 0 sessions on the array
Using steam
I would set bIsLANMatch to = true
SessionSettings.bUsesPresence = true;
SessionSettings.NumPublicConnections = 4;
SessionSettings.bShouldAdvertise = true;
SessionSettings.bAllowJoinInProgress = true;
SessionSettings.bAllowJoinViaPresence = true;
SessionSettings.bAllowJoinViaPresenceFriendsOnly = true;
SessionInterface->CreateSession(0, SESSION_NAME, SessionSettings);```
Custom APPID?`
Might just be that 20 results is not enough and it gets flooded with 480 appID results of other games
yes, custom appid
@thin stratus what do u want to spectate?
Ehm, the match? :D
ohh ok
spawn actor of class spectator pawn
possess
and then set view target with blend
Set View Target with Blend
@thin stratus makes sense?
I'm very well aware of how to do that. My question was more towards using UE4's build in system to already mark the player as a spectator.
Thanks for the help though
ohh ok
wtf
why does ULocalPlayer::GetNickname() return the computer name by default
this causes the computer names of all clients to appear in the server output log
for some reason FOnlineIdentityNull::GetUniquePlayerId is returning a string id that contains the computer name and FOnlineIdentityNull::GetPlayerNickname is extracting this string
wow all this only subsystem stuff is so amazingly convoluted
Yeah SubsystemNULL gives you the PC name by default
GetPlayerName of APlayerState does the same
https://www.youtube.com/watch?v=_dgBsA9xgmI i am just gonna put this in. Looks like a good vid 8:09 is the good part
[00:20] - Start [01:50] - ServerSpawnProjectile Event Creation [05:10] - First result (before compensation) [08:40] - Final result (after compensation) and s...
Predict Projectile Path (Advanced)
Input parameters to PredictProjectilePath functions.
Can I pass FTransform as reference in RPC? I'm calculating the values of quaternion and position locally on client and then I call RPC with signature void ()(FTransform&). Is there any doc where I can read about that? Couldn't find it myself. EDIT: I found that https://wiki.unrealengine.com/Replication#Function_Call_Replication here it says "// NOTE: all functions can have arguments, they will be replicated automatically over the network. // NOTE: UObject based classes (or derivatives) should be passed by pointer () and will correctly // address the version of that object on the receiving client or server (unless that object is not // replicated, in which case the pointer will be NULL)."
@thin stratus doesn't the one in player state only do that because of what localplayer returns, and passes to the server?
Could totally be. Not that into the whole process of playerName atm
it's appended to the join url as Name=Bla and then the game mode puts that in the player state
I think (?)
glad I don't have to use this overcomplicated online system stuff and can just make my own thing next to it with 50x less complexity
It's not that complex though. Iirc the Subsystem has the Change to override the name
e.g. steam returning the steam name
That's mostly all
The GameMode sets the name otherwise
oh
I wonder if things still work if I just disable the OnlineSubsystemNull module
ha it worked
now why does starting a listen server / dedicated server from the same game install use different config folders ..
Guess cause you want to have different settings for a Client (even if ListenServer)
why would I want different settings for a listen and dedicated server but the same settings for a client and listen server?
I think someone just didn't think when setting this up
anyone know why steam session don't update player count? Do I have to update session info for that manually or?
@fluid flower It only counts authenticated players. So you will want to setup the steam authentication stuff (see shootergame)
thanks, I'll check it out
can't find where they setup steam authentication, could you give me a pointer in which file to look perhaps?
- **New: **Added support for the IP net driver to optionally use a separate thread to receive packets.
- This is a useful optimization for platforms where the socket system calls can take a while.
- Can be toggled by the console variable net.IpNetDriverUseReceiveThread.
- Added a Shutdown function to FSocket that wraps the BSD shutdown function. This is used to cause the Wait() call on the receive thread to return when the net driver shuts down.
- Added an IsSocketWaitSupported function in ISocketSubsystem so that callers can find out if the system supports the FSocket::Wait() call. If not, the net driver won't use a receive thread.
- The BSD socket implementation of Wait() now interprets a negative timeout as no timeout.
- New: Added support for IP connections to optionally make the socket send call on a background thread. It helps platforms where the socket send system calls can take a while. You can toggle it using net.IpConnectionUseSendTasks.
^-- anyone know which platforms they are referencing that are slow to do send/recv?
that also seems like with some modifications it could be nice for getting ping without game thread tick aliasing..
thanks.. thought it might be intel after the meltdown/spectre patches
Hey everyone. Still sort of new to UE and had a question about blueprint optimization. I notice on a lot of tutorials and examples I research that people tend to spread out functionality over many, individual blueprints and then reference them together when needed later. For me personally I have been having a lot of success keeping things fairly centralized in the player controller & player state, but was wondering if there are performance reasons not to do this
performance reasons yes - but your performance couple of weeks from now
got classes are inherently unmaintainable
and the more stuff you add, the worse it gets
Kind of what I was worried about. Didn’t want to get to a point later on where I realize the whole thing needs to be reorganized and rebuilt
it also makes you unable to reuse your existing code
without resorting to c/p
and after you start with that, there will be more and more occasions where you need to modify something, and forget to do it in one of the x spots
So for like an inventory system for example, I should build that as a stand-alone BP rather than integrate into the controller or state?
you can make it an ActorComponent
then you can just slap it onto other Actors as well
(both PC and PS are Actors)
Ahhh that might be the way to do it
i have 11 objects handling my 5 slot inventory
an ActorComponent that acts as a Manager for the entire system, each slot is also an ActorComponent, and each slot has an Object that manages the item activation
this is far from being the only good approach, its the one that works best for my game
Interesting, I wouldn’t have thought about having a component for each slot
what about a component which replicate an array of UObject or struct (items)
and help to manipulate items
Going to do some testing tonight with it. Need to find a way to parse the data pulled from the DB into inventory struct items
I'm using basic structs and it's working out great
Do you have a texture 2d slot in the struct for icons? Or something similar like that?
Is there something similar to the MessageBus that works in multiplayer?
If i just want to publish a message without an object reference
how client can receive data from the server?
I want to connect to the server, and receives data from the server, what function should be use?
Hello how i can create more users from server using new plugin Pixel Streaming ?
And it's only works on local network
are you hosting online @granite dome ?
I think you need to host your server online on a service like amazon AWS for it to be accessible worldwide
You need a Subsystem that has a MasterServer.
E.g. Steam.
Otherwise you can't find the session.
Question come up so often, I didn't read the Pixel Streaming part
Pixel Streaming was that WebService stuff
but looks hard to setup
Maybe that helps
gave it a go during the preview 4.21, and I had a fuckload of errors in the browser console
@thin stratus Thanks
It's easy to setup but only for one PC
when you send to another PC on the local network you can also interact with the same actor :/
And yes i see that link but no more tutorials how to set up for more players on other sessions
isnt it supposed to create a new session ?
i search only for local and only one session
and no more information how to create on a server or in the internet
Yea but it's nice) To make pixel stream
why does ACharacter::OnJumped run on the client controlling the character and the server, but not other clients?
shouldn't the movement replication be calling it there too
use case: want to play a jump sound from there
and also do some stuff in the anim bp
am I missing something here? attempting to send an unreliable rpc that the client has jumped would likely not be synchronized correctly
looks like it should be in OnMovementModeChange instead of CheckJumpInput
you can override the movement mode changed and add your own OnJump i guess
or directly inside it
huh, how would I check for having jumped there
doesn't seem like there is a jump movement mode
yeah only falling
lmk if I should share elsewhere! ❤
@proper olive We sure do mind (: #old-rules please.
You could, if at all, share it in #lounge
thanks!
Hi, I'm currently using IsNetRelevantFor to filtre which pawn can see other pawn but it's pretty slow
Is there a way to speed up it or an another approch ?
I have a general question that I've been struggling with. I'm making a multiplayer Wave based zombie game. My question is where is the correct place to put my variables such as: "WaveNumber", "WaveOver?", "NumOfZombiesPerRound", "MaxNumZombiesAlive" ?? Do I put them in Gamemode? Or since I'll be updating these variables throughout the game should I put them somewhere else like gamestate?
clients have no need to know any of that
Ok so Gamemode will work then. Thanks. 😃
So, I am making a game which heavily relies on objects accurately simulating physics across 2 or more clients
is that even possible?
Yes, you need to replicate the objects like everything else. This will affect your Servers Performance alot tho.
Well its one or two objects at a time
I care that its accurate
what should be my way of doing the spawning
is it ok if the objects are spawned in the editor
or do I need to delete them on begin play and replace them with meshes spawned only on the server
Nope, thats not either, everything is a big mess right now
I see people on UT, replicate movement on tick from server to client
but I am struggling to find out how to do that
i am BP btw, but I have a programmer guy in my team. We are doing the EpicGameJam
as long as you have an object that is set to replicate you should be able to see it on all the clients
and if its a character that you are trying to replicate make sure you have replicate movement checked and that the client is sending movement requests to the server
I am replicating physics movement of various static meshes
right now I have just this, trying to replicate the transform value to clients
however it always comes up empty, no matter what condition I set it to
it looks like it should work in terms of replicating that variable
but if you're trying to replicate the position of the cube to the clients like that I wouldn't recommend that approach
the transforms come up as 0 filled on clients
and the actor's replicates property is set to true correct
on the server yes
hmm
actually it wasnt
that seems to be the issue, its late lol, I assumed I had replicated server side already
but how you would go about it
the whole game is based around physics combat
so it has to be accurate across all clients
i did something similar to that before
let me look at it
ok
so heres the thing about physics
it can't entirely be replicated
as it would be way too intensive for the server to have to push all that data every frame
so what i would do is i would have the actor replicate movement and such but also do what you were doing before and have the server send the client the position it should be
to verify that the client physics simulation is accurate
Cool,
and would I be able to somehow do the oposite
client to server
then the server checks and fixes stuff for other clients
as its a game jam after all, its just to deliver a fluid experience, with accurate-ish gameplay
it should do it automatically
the movement still gets replicated to the server
it just isnt always accurate
right
itll eventually get out of sync
the reason is because the client isnt actually updating the movement
the server is just registering that the client's actor is hitting it
but when theres lag or desync then thats when the client's physics object gets messed up
so the only thing i can think of is to have movement that the client sends to the server and has verified, then that movement is applied to the server version of the physics actor, then that new transform and velocity is sent back to all clients
y, I am way too sleepy to try trhat now, but its something I also had in mind, thanks for the help, might DM you if i run into trouble :p
Tomorrow that is
np man and feel free
cya
a player can join the server just fine, but when he quits and then tries to rejoin, he isn't able to. Is there something I need to do when a player logs out so he can rejoin?
if player closes the game completely, he can rejoin. But can't if he quits back to main menu only instead of closing the game, then reopening it.
call DestroySession most likely
Hey folks is there a way to have an array that's populated at runtime on both client and server, but also replicates changes? I want to avoid the initial replication of the whole array if I can.
Tricky, the Conditions for Replication might have a "Skip Init" or so, but nothing for skipping some operations runtime and some not.
You could probably do that in C++ I assume with adjusting the Conditions at Runtime too
I was thinking of doing that, but as soon as I flip it, it will send the whole array, right?
I wonder, why do you want to replicate it at all if you are able to fill it on the Client ?
to update changes. Eg. a chunk of voxels that can be destroyed
I would do this: Mark it as Init Only and do all other changes via RPCs.
That way, new Players get the updated Array when they join.
And RPCs only have to submit the change, not the whole array.
I have abilities that create many individual pieces of things, like a wall of fire, and each individual piece of the fire could have water applied so it becomes steam. The initial state would be all fire, then it would change at some point. The changes are predicted and the onrep kind of acts as a catch to make sure nothing goes wrong
if it has to be RPCs then I guess that's that, thanks 😃
It would be one of the only ways to keep the bandwidth low
There is probably better ways in general to handle such a system over network
If you work with seeds and only pass the seed, then your chunks could load and unload on the client without needing the server.
Cause they will be the same based on the seed.
right, but once you have modifications you would either need a replicated replay log or replicate the state directly
Yeah, directly is a problem for players becoming relevant later
Cause they wouldn't know about the change. That's what RepNotify is for after all
if using RPC, yeah. That was the nice bit about using OnRep for it
You could make an Array of a lightweight struct that represents the Replay Log
But that's also a lot of data
Hm
it's not that much data tbh - I usually have either 16 or 32 'blobs' of state
each one is USTRUCT(BlueprintType) struct FMRepElementInstance { GENERATED_USTRUCT_BODY() UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ElementInstance) EMElementState State; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ElementInstance) float Magnitude; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ElementInstance) FVector Location; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ElementInstance) float SpawnTime; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ElementInstance) int32 Faction; };
yep, each time the element changes state the spawn time gets reset
Location can't, that's a good point
oh I had that in case my prediction was wrong, that's right
but that shouldn't happen anyway
What is the easiest way to setup MP for playtesting, with 2 players, is there a way to do that trough editors, to somehow connect two editor PIE into one session?
Is there out of box support for two servers to communicate with each other? At most I would be looking to have a shared game state that would need to be replicated between them, but they would be responsible handling everything for their own clients.
@high current if you click the dropdown menu next to play there should be an option for number of players
@jagged garden that one I know, but can people on other machines join that session
Has anyone here been working with a custom OnlineSubsystem in 4.21?
Well that was my question
so the only way then is to compile a dedi and connect to that with packaged game?
yeah if u want it to connect from another machine im pretty sure thats the case
although there may be another way
but idk
anybody have some saved recommended reading for optimizing bandwidth? there's lots of stuff out there on optimizing graphics which I've taken advantage of, would really appreciate any links or suggested keywords to look up (I do know there's the new replication graph in 4.21 which I'm looking forward to, so that's cool)
im not sure how relevant this is to you specifically but this is a really good pdf
I'm going through that now. The only two general things that I could recommend are "don't send it" and "don't send it as frequently". Those are your two major optimizations.
Outside of that, it gets real specific, real fast about how to optimize packing data structures.
Reducing what's being replicated is always going to be your biggest win and that's what makes Replication Graph awesome.
Also, how might I be able to replicate the player camera pitch
So I am currently working on having chairs that player characters can sit themselves in, and in the pursuit of that I am trying to lerp their position and view into an appropiate place for the sitting animation. One problem that I need to deal with is the actor's movement being updated from the server when they are doing this at the same time, causing very noticable stutter. What is generally the best practise to deal with this? Is it possible to temporarily ignore incoming replication for movement? Do I snap the character in place serverside?
@jagged garden yeah that's how I learned everything* lol but it's always good to do a refresher
@winter plover for that exact effect I just snap clients and interp the server. Gotta have priorities
I figure it comes down to anything else - eliminate big hoggy variables wherever possible, but if there's any tools for analysis yet that would be cool, actually I know there is - I've used it before, but it's pretty complex
general reading is just nice to have when you're burnt out of work 😄
I mean like if it's the server's character doing it
if it's a client I'll just bypass the whole blend
and stick em in front of the chair and then do the animation
there's only 1 server and then all others are clients
in the traditional method
what am I doing, don't take advice from me 😄
right what I mean is, that I want the interpolation ATLEAST for the local player
yeah
I would be okay with skipping the other ones
yea
sure just use "is locally controlled"
and run the interp there, then when it's finished, have the server update everyone's version of the character?
oh right I might have been doing things a tad complicated
in my current version I start the animation and lerp at the same time
so they kinda glide into the chair
that make sense, I mean nothing wrong with that
client movement always looks choppy when I'm the server, tho. I'm putting aside gameplay for now and gonna focus on network optimization. I know that as a client, everyone's animations look smooth, and that's sort of a UE4 problem in general, but I don't know if there's any workaround for it
like server seeing clients as choppy, clients seeing everyone as smooth
actually yea I think just lerping the player locally BEFORE requesting to sit works alot nicer
thanks for the input, sometimes I tend to not see the forest behind the trees
I'm here if not for the forest
whatever that means 😄
can anyone tell me if I package both distribution and debug builds, can they play together on the Spacewars ID? Cause my playtesters are like obsessed with hitting semicolon and messing things up when they don't know how it works, but i'd like to keep it on my own system if I wanna enable it
i regularly host DebugGame version from VS with live one that is in sync
that way when i crash, i crash with the Debugger on
ok that's good to know 😄
What is an easy way to do a game over when all 4 players die? Do I display a widget saying Game Over then destroy the session or is there a way to return them all to the lobby together?
You do what you want to do tbh
Ok, for now I have 2 players, I am appying a dynamic material on one's mesh, and changing some params
@cedar finch You can send them back to the Lobby or display a gameover and let them disconnect.
All the same work in the end
how do I get that to be visible
for the other player
multicast seems a no go, as well as running the script from game mode
Material changes aren't replicated. Means you have to replicate them yourself.
Since the Material is probably in your Character Class, you will want a RepNotify variable of that Param
And in the RepNotify function you modify the Material Param
@high current
@thin stratus Thanks lol I'll try sending them back to the lobby. I like games that do that. Some games just return everyone to the menu witch makes it a pain to have to re-setup the lobby and invite your friends back. I'm sure it's probably easier though to just end everyones session and open up the main menu.
Cool, thanks, although that means no timeline 😦
Sending them back to a Lobby Level is just calling "ServerTravel LobbyLevel" again @cedar finch
@high current Why not?
Sure, but what keeps you from calling a CustomEvent from within the Function?
I swear that wasn't a thing in 4.15 😄
but yeah you are right
I spent too much time in UT editor
what exactly should my setup be
as it is still only showing on the initiating client
For the reveal, I assume a simple RepNotify boolean
Cause the whole thing only needs to know if it should reveal or not
You don't seem to use any other parameter
And you obviously need to let the Server change that variable
Not the initiating client alone
Wouldn't multicast
late joiners/players that get relevant later will not get the reveal even then
That's what the RepNotify is for
So I have a variable "Wave Number" inside my Gamemode. I get that variable inside my PlayerHud in order to display the current wave number on everyone's screen. Clients don't see it though. Do I have to pass the variable to Gamestate or something else in order for clients to get the variable since gamemode is server only?
@cedar finch you declare the variable inside your GameState yup
also you can set it on both with a setter function to make sure GameState variable is updated too
@rare cloud Ok thank you.
When I am playing on a network, or even two instances of a standalone game, basically anything but 2 players in one editor instance, if its on a listen server, the second player rolls back quite frequently
if its on a dedi, both players roll back
during movement and physics interactions
Roll back?
You mean their location gets rest?
Are you modifying their MovementSpeed somewhere?
I think I actually fixed it
every single component was set to be replicated
inside the character
but I actually don't need that, as when it comes to physics, my events are on the server, and clients don't simulate anything locally
Hey guys when i start a game with 2 players both seem to controll the same character and i cant figure out why
Without knowing more about your Code, we don't know either :P
Has anyone tried integrating gRPC into UE4? (Not to replace existing networking, but communicate with other meta game services)
@thin stratus Well really there isnt much to say, the controller is the base one and the character is kind of custom but not on the setup, so i would think it should work. Could it be that i have posses set on disable?
@low pond, https://github.com/iniside/ue-grpc
@rare cloud I saw that one, even added a issue to it to understand the currents status and it compared to another project
hi, how do I create a multyplayer game with a client - server system? Do you have a wiki to advise me, updated with the EU 4.20 engine?
Hey SirTheo
where are you starting? Have you learned about replication & rpcs?
Also are you doing blueprints or c++?
yes, but how can I divide the two systems? UE4 makes it possible to start the game in "dedicated server" mode. I want to create a client and a server that communicate.
Nice! yea. I can maybe help you a bit.
tho first, are you using c++ or are you using blueprints
I prefer to use blueprints, but in order to create a server it is necessary to create the code in C ++
Also, are you trying to get a server / client thing working in the ue4 IDE? Or ... are you wanting to build the server separately (aka a dedicated server build)
the second option, a separate server
nice.
Ok here's what you gotta do.
- add some c++ code to your project (pretty sure you still need to do this)
so that means, you want to create probably a c++ folder at the root of your assets, open that up, add some class. It can be of any type, and call it ...whatever you want
you will probably have to restart your project after that.
okay next?
next:
- Look in your project source, (are you using vscode? or nah) Try to find the <YourGameName>.target.cs file
in that same directory you'll want to create a Target for your server:
Mine looks like this:
PlayerVsServer.Target.cs
using UnrealBuildTool;
using System.Collections.Generic;
[SupportedPlatforms(UnrealPlatformClass.Server)]
public class PlayerVsServerTarget : TargetRules
{
public PlayerVsServerTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Server;
bUsesSteam = true;
ExtraModuleNames.AddRange( new string[] { "PlayerVs" } );
}
}
Keep in mind to replace PlayerVs with your game name,
wait
in <name game>.target.cs I have to overwrite the code, or create a new file and name it <namegame>Server.Target.cs
sorry, create a new file in same directory as <name game>.target.cs, called <name game>Server.Target.cs
Let's continue in private messages, I don't want to bum anyone out.
In 4.20, after creating a Server Target in my source, I build a Development Server and it outputs as <projectname>.exe in Binaries > Win64. Isn't this supposed to be <projectname>Server.exe? or does it not do that anymore?
hmmmm
The server will still be called Server.exe
but it needs some of the game files to launch the server...
Do you use the project launcher to build your server? or do you do it from vscode?
Visual Studio (version 2017 Enterprise) actually
Ah ok! I've started building a different way, want to try it?
sure
I'm using the "unreal frontend" or "project launcher" tab...
it actually saves me a ton of time...
I'm assuming youv'e got your server target correct, & you'
& you've got your dedicated game logic all ready.
Aka, starting sessions, starting a listen server when the game is launched in "dedicated" mode.
If not, this is still useful stuff.
not yet - I'm using a test project. My other project is ready to go, but I don't want to do anything until I get this process down lol
gotcha!
so just using a test project in the meantime
makes sense. I use git to make sure I don't make any big mistakes... anyway here's the project launcher flow:
open your uproj, go to "window > project launcher"
using perforce here, but still, don't want to cause issues cause I'm also upgrading the source code to GameLift (amazon servers) cause they don't support 4.20 and I'm not going back to 4.18.
(ouch!)
I use azure because I'm b8'nd from amazon.
Ok so let me know when you have your project launcher open
quick question - I want to make sure I'm using the correct launcher. Prior to yesterday, I only had the launcher version of unreal and then yesterday I downloaded the source version and after compiling engine source, I ran Local Windows Debugger to open launcher and then I created my project from there. I also have the project launcher installed from before though, so how do I open it making sure it's the correct launcher other than running from Visual Studio?
Ah yea. So if you're ever worried about which unreal engine your uproject is pointing to -
right click on your uproject, go to "Switch unreal engine version"
Then navigate to the source you want, be it the binary, or the source built.
Personally I use the sourcebuilt version, just incase.
ok loaded from my source built
After you do that, I think it's good practice to right click on your uproject and go to "Generate VSCode solution"
Just loaded the default Unreal Project Browser
<took everything over to private chat so we don't flood this one>
@tawny mason TBH, no idea without seeing the code. Generally Contorller and Character is a 1 to 1 relationship.
A Controller can't possess two pawns and a pawn can't be possessed by two controllers.
Possess even calls Unpossess. So if they are control the same character, then you are doing something odd in your code.
Soooooo
What is the "proper" way to swap a Player over into Spectator Mode?
UE4 has bOnlySpectator, which is basically for people that should never play.
But also bIsSpectator, which is never set to true anywhere
At least I couldn't find that.
It seems like the PlayerController has a State System
In which you can swap from Spectating to Playing
But that doesn't change the boolean of the PlayerState in BeginSpectatingState
It does set it to false though in the EndSpectatingState function
But that seems to also work with bOnlySpectators (which is kinda weird)
In PostLogin it seems to use this for "MustSpectate" when they are "onlySpectator"
So not sure if the bIsSpectator is even meant to be used for normal spectating players
int32 AGameModeBase::GetNumSpectators()
{
int32 PlayerCount = 0;
for (FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
{
APlayerController* PlayerActor = Iterator->Get();
if (PlayerActor && PlayerActor->PlayerState && MustSpectate(PlayerActor))
{
PlayerCount++;
}
}
return PlayerCount;
}
This is really strange. Why having bIsSpectator and bOnlySpectator where the comment for bOnlySpectator clearly states that this is only for players that should never be spawned and then only using the bOnlySpectator one for everything?
bool AGameModeBase::MustSpectate_Implementation(APlayerController* NewPlayerController) const
{
if (!NewPlayerController || !NewPlayerController->PlayerState)
{
return false;
}
return NewPlayerController->PlayerState->bOnlySpectator;
}
Looking at it I would say the Spectator System was either never fully implemented and thought out.
Or I really don't get how these two booleans are supposed to be used.
And then there is bPlayerIsWaiting, which apparently has to be false for the player to really not spawn (even with bOnlySpectator being true) >.>
Looking at it I would say the Spectator System was either never fully implemented and thought out.
Or I really don't get how these two booleans are supposed to be used.
Yea, its a pain point to say the least.
Its sort of left to you to synchronize state between client and server. Then there is of course the Unfreeze function + timer which just changes state again. Always felt kind of dirty using the timer / unfreeze to drive such an important aspect of gameplay.
Problem is that I'm using UE4's system of Restarting the Player.
And that does also check for Spectators.
indeed
it "mostly" works for us, because we've had to add some extra RPCs to keep things together...
I would've assumed it works like this:
bOnlySpectator - Player is only a spectator, will never play.
bIsSpectator - Player is currently a spectator, might play in the future again.
bPlayerIsWaiting - Player is a Spectator that wants to join the match again.
I'm trying to get an overview of what functions to override/use to get this properly working
yea it makes sense that way. I know reading the code in the past I found a couple pitfalls here. For example, if the spectator isn't replicated, things become a little trickier. Afterall, you don't really need the spectator to be replicated and if so, only to owner.
Yeah, but that only entails the Pawn
I'm not even that far yet
I simply want to say "Player XY goes from Playing to Spectating."
And then use "bIsSpectator" to put him in a different list in my UI
As far as I can see, I def have to override "GetNumSpectators" and change it to use bIsSpectator.
Or rather write my own function
Cause they see Spectators that aren't ONLY spectators still as players.
Which I guess makes sense in some cases.
I think we ended up doing a ClientGotoState function in the player controller to accomplish that portion. As for the number itself, I can't say we've had to tackle that, sounds like you're on the right path.
Yeah, they seem to call this:
NewPC->bPlayerIsWaiting = true;
NewPC->ChangeState(NAME_Spectating);
NewPC->ClientGotoState(NAME_Spectating);
For seamlessPlayers that return false for "MustSpectate"
The bIsSpectator boolean is missing though
right. sounds like you've reached the edge of the what's default supported.. I'm guessing bIsSpectator wasn't ever realized to be used in conjunction with the state of the PlayerController like this..
Yeah, so either you are only spectator or not
Welp, guess I have to poke around the function and see what needs to be overridden
😐 good luck! If you have some amazing realization it'd be nice to see how you improved it
for us it just wasn't worth spending time more than minimally working for our game, so we never dug too far in except to bug fix sync issues between server / client due to how death occurs for us
Yeah, I will let you know
How can I generate a random value and keep that across all clients
Is there a way to uniquely Identify a session we are about to travel to.
So suppose I have hosted a session with a particular map. And a client finds, joins and then tries to travel to that map, but before the client travels.
I destroy my session on the server, change the map and host again. In this case the client joins the new map on this server because of the way client travel works for NULL online subsystem (haven't tested steam yet).
Is there a way to stop this before hand using a session ID of sorts, as in a way to join/travel only in that particular session with a specific map or settings for a single host.
@glacial hamlet So, I'm not 100% sure that it's working yet, but I did the following:
- I override
void APlayerController::BeginSpectatingState()and callSuperand added the linePlayerState->bIsSpectator = true;to properly mark the Player as Spectating. - I override
void APlayerController::EndSpectatingState()and copy paste the original implementation of the parent. Then I added areturn;right after the UE_LOG, so that we can't use this when marked as SpectatorOnly. - I override
bool APlayerController::CanRestartPlayer()(orbool AGameModeBase::PlayerCanRestart(APlayerController* Player)) and add!PlayerState->bIsSpectatorto the condition of being able to restart. - I added two new Functions to the PlayerController
void StartSpectating()andvoid StopSpectating().
4.1. InStartSpectatingI callChangeState(NAME_Spectating)as well as make sure that the Player dies when already playing. I also remove them from the team they are on (if they are on any).
4.2. InStopSpectatingI callChangeState(NAME_Inactive), which will end the spectating state and place the player into the "You can now be respawned" Inactive State. In addition I also find a new team for the player.
@glacial hamlet
Not 100% sure if that covers all of it yet.
@thin stratus nice investigation, the unreal spectating stuff is very very old dusty code and we decided to skip it altogether for that reason, I hope it works out for you!
Yeah I'm not 100% sure yet how the Freezing is handled though.
The Inactive State marks you as not frozen after the MinRespawnDelay
I'll probably also override void APlayerController::BeginInactiveState to instantly unfreeze
yeah also the whole state stuff, not just in spectating, there's some of that named states in gamemode too
blegh, skipped all of that and never looked back
Not sure if setting the MinRespawnDelay to 0 would work, as calling a Timer with time 0 usualyl doesn't call the timer at all
what's the result you're looking for btw?
In the end, just a basic "opt out of actually playing and enter spectate mode"
Similar to how CounterStrike does it
ah yeah
we also had some other issues with spectating, where the spectator has super jarring camera movement
sorry not camera, actual other players were jaggy
Yeah but that's further into movement
This is mainly about flagging the player as spectator
And being able to work with the booleans to show them in different lists
as well as making sure that they are skipped for respawn events and such
yeah I understand, I honestly would suggest to skip their system, but if you're close to fixing it, i hope it works!
We have another GameMode that would place you into Spectating when you die, as you only have one life.
So that all needs to work hand in hand and I think with the provided changes that might work
Ah well, the system of calling "RestartPlayer" etc. works without issues
It's really just the bIsSpectator stuff that wasn't working
yeah I do use RestartPlayer etc as well
So the BuildIn respawn system of UE4 shouldn't have issues
yeah that all works fine for me
Ah ok, thought you included that in "skipped all"
Well, I#ll make sure to put that into my wiki up until I have time to maybe write a small post about it on the UE4 wiki
if it ever gets fixed (broken format)
spectator part I meant
For some reason when I package my Dedicated Server, it's just completely empty
It's 2000kb file
but when I open it in a hex editor, its just 00000
Hey, I am trying to do a little procedural room creation, I have 3 rooms that should be attached to something upon begin play
Now the issue is that I cant get the static meshes to show up in the right location
as they are below the level in the editor, and on runtime i set transform to a blocking volume that has all of the things in the room as its children
objects inside blueprints that are physics, show up, and stay in place, its just that the static meshesh, even though everything is set to movable
dont move
and what ends up happeing to the clients, is thatas soon as they enter a room they get teleported physically to the location in the editor of that room
Oh, fixed it
the array holding the shuffled procedural rooms wasnt replicated, so each client was in a different room
With match making when ISessionInterface::StartMatchmaking is called how is the caller meant to specify relevant player data for the match maker?
Where would you guys typically put a loot system that is handled entirely by the server? Game mode? Actor Component that can be attached to each individual NPC? Somewhere else?
Basically. I have a player inventory system already set up but need a method for the server to create temporary, global inventories that anyone can access for when an enemy dies
im working on something exactly like that
i have a replicated inventory component on the actor itself that the player can interact and take items from
Ahhh, cool. So you have it as a component on the individual NPC.
yeah
That seems like the logical place but I wasn’t sure if Game Mode would somehow be more secure
Trying to be very careful about everything I implement and make sure there is no way to backdoor or abuse the system
How do you prevent multiple people from simultaneously looting and creating duplicate items? Do you have a boolean check or something to see if another player currently has an active loot widget?
yeah i do
the only thing i was worried about with that is what if they opened it at the same time
but idk if thats an issue
Yeah I don’t know how many milliseconds you would have to worry about that being an issue
Or if player latency would affect that
Something to look into
as long as the variable is being set on the server i doubt there would ever be any overlap
now that im thinking about it
I don’t know enough about the specifics of networking to know how much of an issue that would be... maybe there are 2 checks, one to open the loot window and another to actually loot an item. That way if 2 people somehow simultaneously created a widget there would be another system in place to prevent multiple items being distributed
I think the likelihood of 2 people opening the window at exactly the same time, and then looting the same item at exactly the same time would be pretty small
Right
I’ll have to do some testing later tonight. For the enemy inventories do you just have each enemy randomly generate a number of items from a data table or something like that?
yeah i use data tables with ids
Cool, same here. The other day I was trying to decide between putting all items on my database server but opted for now to just keep them in UE. The database server just stores what itemIDs are in what slots in the players inventory
Can probably bypass that entirely for enemies since there’s no reason for them to have persistent data
right
Are ragdolls supposed to be replicated? I have my characters replicated but when they die and ragdoll kicks-in then the ragdoll clearly detach from the regular version in the server(that stays put where they died)
imo its too much strain for the server
if its not critical to gameplay then u shouldn't
@thin stratus Hey! Re your q about how to spectate. In my game when the player dies, that message gets sent to the game-mode, then the game-mode deides whether or not spetating is legal (Aka in a team game if someone dies I dont' want them to spetate & give info about other players to their teammates, but in a free-for all, go straight to spetate when you die. Makes sense that game-manager controls that for me.). Then the game mode makes my player controller possess a spectator pawn, instead of its character pawn. Then again GM is responsible for handling a message like - the player wants to spawn.
What do you guys think about that approach? I've never used the bIsSpectator, unless mutating it directly...
so does UE4 out of the box support HTML5 Clients that can connect to a listen or dedicated UE4 server? I saw some older posts about adding a separate plugin/library but no real mention on if it's updated or built in working now. I see it tries to connect to a different port but no options in the settings to enable web socket support
Anyone know how to increase the UE4 server tick rate?
Everything I find online isn’t helping.
With NetServerMaxTickRate in the engine.ini
is there such thing as replication id?
normally, in a game, when I compare the same replicated object over the game, the result is that they are equal. but once I join/rejoin an existing game, they're are not equal anymore.
is there a better way to compare replicated actors?
example code:
OnDie(this)
OnDieEvent_Implementation(AActor* ActorKilled)
{
if (ActorKilled == this)
// here!
}
this happens on a custom ACharacter class
Networkguid should be same i think
nevermind, everything's fine except that when joining in progress, other existing object are not being registered to our custom event system. 😅
@limber plaza The later Process of possessing a Spectator etc. is not the problem
It's more about making sure that UE4 internal also handles you as a spectator
BEcause I am using the RestartPlayer stuff
- I'm worried that other Session related things might turn up returning incorrect data if bIsSpectator is being used wrong
I could easily ignore the boolean and create my own system, but I rather make sure it works with how the engine wants it
Hello
i am having a problem with steam server
i am sure i have set every thing Correctly ,,
once i try to join the game,, server crashes
This is the log file
LOG
i have been tackling this error for weeks with no luck
has anyone run into an issue in >=4.20 where seamlessly travelling to the same level sometimes fails for connected clients?
I hope not lol
it's completely random and the client gets "Unable to travel to '<path to map here>' - package is not a level"
Is that in connection with a subsystem
this comes from FSeamlessTravelHandler::Tick() when LoadedWorld->PersistentLevel is nullptr when there's a valid loaded package and world.
Do you see any changesd compared to 4.19?
I'm currently working with 4.20, but the MapVote feature isn't final yet. Will have to wait 1-2 days before I've done that. Until then I can't test traveling atm
Well "can't" in the sense of not having the time
But I'll keep it in mind and notify you if I run into the same issue
that was where we discovered the issue, GetWorld()->ServerTravel("?restart") was also triggering it
going to see what changed in 4.21 if anything, haven't upgraded yet
though i discovered an odd thing, we have a TransitionMap set but it's not added to the cook list
@lost inlet
i am having a problem with steam server
i am sure i have set every thing Correctly ,,
once i try to join the game,, server crashes
This is the log file
anybody
I got the html5 networking working but from what I can tell you can't have HTML5 networking and the normal networking at the same time on the server so no 1 server with web and standalone clients connecting?
Shouldn't the underlying code be the same?
@summer rivet
I mean, I can connect to a PC Server with a Phone for example
yeah but that's using the same network driver isnt it? from what I had to do for HTML5 was replace the existing one with the experimental HTML5 driver
I barely understand the engine part of UE4 networking so maybe I am wrong and they can both exist. HTML5 uses a separate port so that part won't conflict atleast.
I never used more than one NetDriver
I do however know that the NetDriver thing is an array of definitions
So there could be more than one placed into it
well I guess that's what I try and find out now then lol 😃
damn but the DefName would be the same which would be a problem I would assume
maybe? I dunno lol that's where my lack of knowledge breaks down heh
Yeah, so do you have to use the WebSocket NetDriver?
well if I want to connect to a HTML5 client it does
Thing is, PS4, XBox, Google, iOS and PC are all different systems and you can crossplay them
So you don't have to use the specific NetDriver
If you use the IP one it should also work
At least worth a try
@summer rivet
well I don't know how to make it work then
using the default driver and HTML5 client it tries to connect using web sockets on 8889 and fails
Hey guys, do you know how can I modify Player State Score variable ? why I can only get it but not set it ? i'm trying to set up a mp scoreboard (edit: I guess i need to create my own player state and player state variables ... strange)
Hey Cedric, WHY
Hey this is a very hilariously stupid question but here it goes anyway:
Let's say I'm running my dedicated server build on my compy, w/ steam subsystem all configured to my appId, session started, and the map open w/ listen param, (...waiting for players!). Is it correct to say I should be able to see this session & join this game from my WindowsNoEditor client - on the same computer?
Expected answer: Yes.
how does the default C++ player state get the player name, I would like to recreate that in my own player state with BPs
It has to do with which subsystem you are using I believe.
So if you're using steam, it's going to use the steeam user name. if you are using null subsystem - then I think it's like... the name of your computer?
yeah, but how can I get that
nvm, I think i should stick with getting all pawns spawned
I am banging my head against the wall, trying to make a hud system that shows all the currently connected player's health
to everyone
Sorry! I'm actually not really understanding the question I realize.
You can get name from player state, in blueprints.
Y, Ik, but I am not using that player state
Erm. Oh. Why not? It's useful!
Oh ok you're saaying you have a custom player state. that's ok though
As long as your player state inherits from player state, it has a "name" property on it.
Yea that may be another topic, but I think health is best stored in your Character / Pawn
Why? Because that's the thing that is taking damage.
Other things will probably take damage too, other objects without a "player state" for example.
I have it there ofc, but I need to get it to other people's hud
Ah gotcha.
keep in mind, I am not thinking straight due to game jam stress, so some obvious solutions might not be apparent with me :d
Haha! Np, so your original q -
you -do- have a player state, for each player.
and you can just get "name" from it...
rite?
D'oh!
I need a color associated with a player
I suggest blue.
so I am thinking I use the game mode, to assign a map
playercontroller/color
then in the widget, get that color\
nod makes sense.
Mmm... no. GameMode is only owned by the server.
But, game mode can assign the "team" parameter on a joining player's state, and that player state property can replicate.
Well I think it makes sense on player state actually! Because... Ethin is Orange, no matter what dude he's possessing, he's orange (on the scoreboard). Orange is he.
oh yea, since I am not using names
But the color property on player state will replicate from server to all clients
i can make use of my custom player state
You have the power.
see I told you it takes me a while to get obv stuff 😄
it doesnt seem to work
I even have a print string that is supposed to print the color in the character itself, on begin play
Is the first screenshot in the game mode
Yes
Correct me if I’m wrong in your case, but it doesn’t seem like the “handle new player” is being called when a player joins
The event “postlogin” should run when a new player joins
@jagged garden could very well be
Thanks for the help, i will try again after i get a couple of hours of sleep
Np
Maybe to check if it’s being called add a print string after you set the color that says something
oof why is it so hard to figure out if your logged into steam in engine or not, need to swap between using steam name or platform username
oh dur has subsystem =
So does the player controller exist serverside and clientside?
ClientSide, but the server has access to it - other clients do not
Gotcha, okay then this might not be a multiplayer issue, but I keep getting crashes when I try to handle cheats in a custom controller class
ABasePlayerController::ABasePlayerController()
{
CheatClass = UCustomCheatManager::StaticClass();
}
bool ABasePlayerController::ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor)
{
if (!HasAuthority())
return false;
bool handled = Super::ProcessConsoleExec(Cmd, Ar, Executor);
if (!handled)
{
handled &= CheatManager->ProcessConsoleExec(Cmd, Ar, Executor);
}
return handled;
}
It crashes on the handled &= CheatManager->ProcessConsoleExec(Cmd, Ar, Executor); because CheatManager is null
I thought if there was a client/server player controller, it was crashing on the client because you wouldn't want to have the CheatManager client side (sorry, I'm pretty new to writing network code 😦 )
not sure about cheat manager, if its something to even be adjusted i imagine server would have to tell the client to turn it on
out of my scope of knowledge :<
Yeah handling console commands in generally seems like sorcery ha. Couldn't find too many good resources on the net for it
all of the AFTPawns or all pawns in general?
If an Actor is destroyed by the Server and that Actor is replicated, then all Clients will also destroy that Actor.
Are you sure that "all the pawns" are of that type?
Replication does not get turned off because its end of match
Are you sure that "all the pawns" exist on the Server and your Client didnt accidentally spawn one itself.
If a Client spawns an Actor itself, the Server wont know about that Actor.
Hey,
If I have an Reliable UFUNCTION, and that function has other functions inside it.
Do they need to be marked as Reliable as well to make sure they execute? Or do they "inherit" the Reliable property?
Reliable is a UFUNCTION specifier that is used in conjunction with the RPC specifiers Server, Client, NetMulticast. It is only use is to identify if these RPCs are required to ensure that they are acknowledged as having arrived on the other end.
Yeah I know I need Client / Server / NetMulticast.
But do I need the specifiers on the other functions inside?
The RPC (function with those specifiers) is changing the network context of where the execution is.
MyServerFunc()```
Calling the above function is sending an RPC to the Server from the Client to then run that code on the Server.
Anything inside that function is already being called by the Server, because the function itself is declared as an Server RPC
You dont have to specify other functions as RPCs
@fossil spoke Thank you
anyone know of a UDP plugin for UE4
need to send/receive udp data at a high tick rate
@safe marsh What exactly would you want from that ? Pretty sure UE4 does UDP already
I mean UDP support is ten lines of C code
Look into FSocket, FUdpSocketReceiver
There's a Rama tutorial on the wiki too, IIRC
hey guys, do you why Set Timer by Event runs only on server ? can I make it so it runs locally ? (nvm, the replication params do not show after event is delegated ...)
@safe marsh i wrote a custom udp class that does what your after can send data locally between two editors or packaged games and even across internet for example with one program beimg hosted on aws recieiving data from any other computer havnt got round to making it a plugin just yet as ive been working on other stuff . but ive exposed it all to bp functions so its easy and highly custpmisable
thats cool man, yea need to send/receive data from a non unreal server
@safe marsh If you really need to send lots of UDP, Blueprint won't be a serious option
What exactly are you trying to do ?
There might be easier options that hardcore UDP
cant really speak about it as it's an NDA project in tencent
😦
well I can say at least I am streaming controller information
and it's prototype, not commercial, so it doesnt have to be performant
That's not really going to work well with Blueprint imho
UDP is lossy, so you're going to be doing some pretty complex processing to handle cut strings etc
yah I am using finterp between lost packets
but it's the spec I've been asked to use
I am gonna try to build one of the UDP plugins, I have seen some sample ones online but am not 100% sure how to build it
For gameplay programmers writing C++ code.
seems prettydecent
Anyone know why cheats wouldn't work with a custom cheat class?
Are they just not setup for networking situations by default?
Doubt a lot of people ever touched the cheat engine of UE4
I assume that even the stuff called from the cheats will have to be RPCd to the Server to work
Yep, seems so
Looking at the shooter template, it basically forwards any additional arg from a custom Exec command locally and uses ConsoleCommand() to send it to the server
kind of a strange way of doing it
Anyone know what I need to do to an AI Bot so they go properly into the NAME_Inactive state?
They sit at NAME_None when being created and my respawn loop requires NAME_Inactive
how can i make an actor replicate to all clients except 1 in c++?
ah, ill have to look into that. thanks
What is the return value of the GetWorldDeltaSeconds if executed on dedicated server?
The deltatime of the server?
Sorry i shouldnt have put the ? That was the answer
It will be the DeltaTime of the Server.
I was quizzical because the answer seemed obvious
Oh, i though that dedicated servers returned 0 as deltatime or something like that because they are not rendering the game
I think i still dont understand the delta time 😦
They dont render a viewport but they still need to process information
So their deltatime should be really small?
Think of it as TPS (Ticks Per Second) instead of traditional FPS
their deltatime should be around the configured TickRate
(even if the server execute faster, it will wait)
So in clients the tickrate is determined by the configured one or the frametime if it is greater than the configured one
But on dedicated servers they are static (the configured one) right?
So if i execute GetDeltaWorldSeconds in a component i need to execute SetComponentTickEnabled to true right?
The DeltaTime isnt tied to a component. It is how fast the last tick was executed
You can read it without your component needing to tick itself.
Allright
The question comes because i am calculating the remaining time for certain events, so when one event is finished, for each event i need to recalculate its remaining time to finish. But there might be some precision errors
And the new calculated remaining time for one event could be 0 or even negative
So i need to clamp it, but i needed to figure out what should be the minimum value
Wouldn't using a simple timer for that be better?
And i thought the delta time
Yes im using a timer, am refering to the time of the timer
The shortest remaining time is plugged into the timer time
DeltaTime is just the time between two ticks
Timers already keep track of their own time dude
Oh so i can put a value like 0.00001?
struct ENGINE_API FActorSpawnParameters
{
FActorSpawnParameters();
/* A name to assign as the Name of the Actor being spawned. If no value is specified, the name of the spawned Actor will be automatically generated using the form [Class]_[Number]. */
FName Name;
/* An Actor to use as a template when spawning the new Actor. The spawned Actor will be initialized using the property values of the template Actor. If left NULL the class default object (CDO) will be used to initialize the spawned Actor. */
AActor* Template;
/* The Actor that spawned this Actor. (Can be left as NULL). */
AActor* Owner;
/* The APawn that is responsible for damage done by the spawned Actor. (Can be left as NULL). */
APawn* Instigator;
/* The ULevel to spawn the Actor in, i.e. the Outer of the Actor. If left as NULL the Outer of the Owner is used. If the Owner is NULL the persistent level is used. */
class ULevel* OverrideLevel;
/** Method for resolving collisions at the spawn point. Undefined means no override, use the actor's setting. */
ESpawnActorCollisionHandlingMethod SpawnCollisionHandlingOverride;```
if i set `Template = AActorChild`, will the spawned actor have the same properties as the child too?
I thought they were limited by the tickrate
A Timer executes multiple times per tick if the time is smaller than the tick rate
Owo
@thin stratus So i will plug a static value like 0.01 or something like that
e.g. if your Timer loops every 2 seconds and DeltaTime is 4 seconds, the timer would execute twice in that tick
If you put 0.01 in the Timer seconds it will execute every 0.01 seconds
If ticks have a different value, the timer might execute multiple times during that tick
Or not at all if the ticks are faster
So it would be better to clamp it to the tickrate?