#multiplayer
1 messages ยท Page 645 of 1
Usually you start by checking the values that stat unit console command shows to determine if the issue is game thread, draw thread or GPU and then you either do CPU profiling or GPU profiling
Not sure what you mean
A teammate has made a client/server network independent of the engine and I am looking to implement it with unreal. The network: https://github.com/raytureWORLD/un1verse
Depends if you just want to completely ignore the entire Unreal multiplayer, or make Unreal use this for replication
From the looks of it, it's option A
So you'd need to make this into an UE plugin to expose all features and then use that interface
What about the second option?
Second option is way beyond everyone's knowledge here
Spend 5 years remaking the engine basically
Oh alright, thank you
Hi everyone, I'm looking for help with replication. Here's the code: https://pastebin.com/i8d5qkL5
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Basically, weapon swapping doesn't seem to be possible on the client, only the server. However I can use the weapon spawned from BeginPlay on the client. I'm only running spawnactor and destroy from the Authority, so not sure why its not working.
i found answer to my question:
float NetCullDistanceSquared Square of the max distance from the client's viewpoint that this actor is relevant and will be replicated.
What's the logic chain between your clientside input and the serverside weapon swap function?
https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/QuickStart/ , Navigate to the Level Editor section and click the Play menu. Find the Multiplayer Options and Change the Number of Players to 2. , Press the Play button. The main Play in Editor (PIE) window will start a Multiplayer Session as the Server, and a second PIE window will open and connect as the Client.
Create a simple multiplayer game in C++.
but in UE4.26.2, "Multiplayer Options" are different from the tutorial, it's like this...how should i set?
Hello everyone.I am spawning a non-replicated actor across all clients using a function that runs on server and then calls a multicast.It is spawning perfectly.But when i am destroying it using same Calls on server->mulitcast then it is getting destroyed on server but not on clients.I am making a battle royale game where there is hundreds of loot which player dont even touch.SO i thought it is waste to replicate them.PLz help me.Thank you
Loot as in items that players could pick up and then potentially use?
Yes.
You want that set as a replicated actor and nix the multicast.
But the non-replicated actors that are placed in map are getting detroyed but not the one spawned by player
I am dropping some of them from my inventory
so, the multicast wont work
I believe that's because the server doesn't necessarily have reference to the ones spawned on the client and the ones the clients have are not referencing the same thing on the server. They would only have the reference to the one that they have.
since the object isn't replicated, the server has no knowledge of it
so if you replicate a reference to that object, the clients will get nullptr
and you'll see a warning in the output log about the object not existing
the reason being a non-replicated actor doesn't create a package map entry
so there is no way for the server to send a valid net id
Initially when i press on widget i am sending that actor object reference to server from then i am sending that object reference to clients via multicast.Weird thing is that reference is valid on server but it is null on all remaining clients??
it just doesn't exist and it will never exist (you made it not replicate)
So what can i do now??
is this a listen server?
no dedicated server
@twin juniper just use replicated actors and don't try to fight the engine
yeah, just use a replicated actor here
If it's good enough for Fortnite it's good enough for you
set the net update rate to be relatively low
like 10
(it defaults to 100)
and if it becomes an issue, use replication graph
basically every actor in fortnite is replicated
I doubt you are doing more than fortnite
they do a lot of shit lol
Haha.Trying to beat epiccc.
Thanks @gleaming vector @dark edge @sinful tree i will take your advice.
no.Just assuming
ok, that was a rhetorical question anyway... don't optimize unless you know what you are optimizing ๐
okay bro
there are better ways to optimize networked actors than trying to fake it
any references bro for advanced networking??
Assuming you've already read the networking compendium read up on replication graph
okay thanks
Trying to destroy actor for everyone..what am I doing wrong
@round star if the actor is replicated you should just destroy it on the server and that's all
If it's not replicated, then you also can't perform Multicasts in it.
And if it's replicated but not owned by the Player, then the ServerRPC also fails.
So generally speaking you are doing multiple things wrong :<
Hey guys! I use Advanced Sessions Plugin.
https://forums.unrealengine.com/t/advanced-sessions-plugin/30020
And I want to check if the match has started.
Players must not enter the game when the game has already started.
Any ideas?
https://answers.unrealengine.com/questions/905823/how-to-check-if-the-match-has-started-before-joini.html
And I don't know how to get the current session to modify the tag or settings.
Advanced Sessions Plugin Updated 12/03/2020 Plugin now has two modules, one is AdvancedSessions and one is AdvancedSteamSessions, this will allow me to tie more Steam specific functions in without forcing the steam subsystem to be packaged out with projects that donโt want it. New Parvan/Metahusk has made a menu example project that also sho...
If you are using Advanced Sessions Plugin, look for "Find Sessions Advanced" and "Filter Session Results" nodes - this should allow you to take the output from "Find Sesssions" and then make an array of filters.
Hello everyone. I realize that Handle match started iterates through all the PCs and restarts the player(Spawns them) but when a player joins in mid game, what spawns them? I'm trying to make it so it changes the spectator mode instead.
What function in Gamemode spawns the player upon joining the game?
@sinful tree Yes I know that. But how do I set the settings for the current session for the filter?
i asked around yesterday about ue4 multiplayer, apparently you only need 2 games made in the base game engine with ports open to connect over the internet into the same lobby
What does having open ports mean?
and
How would the connection work? Would you need an IP address, or is it possible to have a server list of all currently open servers?
What does having open ports mean?
Person who is hosting needs to open Port 7777 (by default) in their Router.
How would the connection work?
Would you need an IP address, or is it possible to have a server list of all currently open servers?
That comes down to what #online-subsystems you are using.
NULL, the default one, only allows direct IP connections (so you need the IP of the person who hosts, and that person has to open their ports), and LAN Sessions.
A Session is just information about the Game that is hosted and has to be created for the Game to be findable. But again, with NULL, only via Lan.
If you want the Server List, you need to use an #online-subsystems with a Master Server (or code your own). One example is Steam. Steam has a free test ID that one can use, but in the end you need to pay the fee for getting your own and then give them % of your earnings.
@viscid bronze
Ok i understand, thanks
So if i am hosting listen server with my computer, they will have to join using my ip address right (the one i can find when i type 'whats my ip' on google)
I saw something about static and dynamic ip, apparently only static ip works, should I be worried about that
For an actually released game, having to use an IP to connect to another player is not reeeeaaallly up to date anymore
Static vs Dynamic IP just means that you will have a new IP next time your Router Resets or your Provider forces you. I think that's once per day?
So you need to re-handout the IP every time.
Static IPs wouldn't change, but at least in Germany you can't get one without being a Company.
Or at least without a Business Contract
But every users would need that, so you better look into something like Steam
Does anyone know how Team Fortress 2 did their Arrow projectile prediction?
its just a personal project that i will maybe finish and put on itch io for free so i dont really care
so basically you would have to tell the other person your new, current ip when you want to connect again?
Yes
didnt you say that cost money? im not really looking to do or release anything professional im just trying to make something that can do basic online
Yeah, then just stick with the known limitations
ok
but it wont affect the connecting or the connection once he types the correct ip in right
No, the IP reset usually happens over night and depends on your provider and probably also country. You actively have no internet during that time anyway
ok got it. this should be enough to work with for me. thanks!
What's the most straight forward way to keep the velocity in sync on ProjectileMoveComps?
Feels like just setting it to RepMovement and setting Velocity on Server won't work.
Client probably tries to move with 0 Velocity and then gets only the movement updates.
Multicasting the Velocity on firing feels bad for anything joining in later or getting into range.
OnRep would need to be kept updated all the time.
Almost feels like the Velocity should be replicated by default.
LogProjectileMovement: Verbose: Projectile BP_Gadget_Grenade_Frag_C_0: (Role: 3, Iteration 1, step 0.011, [0.000 / 0.011] cur/total) sim (Pos X=8073.389 Y=647.758 Z=-5583.217, Vel X=2219.959 Y=106.909 Z=-3393.692)
LogProjectileMovement: Verbose: Projectile BP_Gadget_Grenade_Frag_C_0: (Role: 1, Iteration 1, step 0.011, [0.000 / 0.011] cur/total) sim (Pos X=8073.010 Y=648.000 Z=-5623.699, Vel X=0.973 Y=0.047 Z=-3909.737)
Seems I'm right about the velocity not matching. Only the falling part (-z) works cause it simulates that anyway.
ShooterGame to the rescue
/** update velocity on client */
virtual void PostNetReceiveVelocity(const FVector& NewVelocity) override;
Thanks James, for pointing to the ShooterGame in a thread from 2016 :P
I'm pretty noob to c++ side of things but is that basically extending the component to also replicate Velocity so the sim between updates is more accurate?
The function comes from AActor
Velocity in Actor has to be explicitly written to right? Like if you're rolling your own movement comp will the actor derive velocity or does your component have to write to it?
As far as I can tell, it inherits the velocity
ShooterGame doesn't do anything but implementing that function and setting the move comp velocity with it
So if I got it right in Shooter game the server PMC simulates, actor position and velocity replicate out, and client-side PMC uses that replicated velocity?
Yop
Hello, can anyone tell me why a "print String" connected with Boolean "HostReady" after "BooleanEqual" is always False but after Event "HostReady" is true?
It is still False after "BooleanEqual" after triggering the "hostReady" Event
PlayerState
Trying to build a "waiting for Players" thing
When someone starts to host a Game, the level loads, and the "HostReady" is set to True
When a player joins and the level is loaded it sets "JoinReady" to True
Okay, one problem you have here is that you check both booleans in the same PlayerState
While they are most likely in 2 different ones
Server and Client
So the Check itself should probably live somewhere central
best would be your GameState
And the other thing is: You don't need a Looping Timer
You have 2 events that call when the boolean changes
Just check once on each call
Or rather tell your GameState to check
GameState has an Array of Players (PlayerArray) with PlayerStates
So yo ucan loop over the states and do your test
Well i wanted to try this GameState out and noticed i totally forgot to change it to my costum made one.
How do i open the Standard GameState?
@ancient badge just make a subclass of it. That's the usual approach
@ancient badge also, think State Driven. The state is the composite ready state of all the players.
When a players ready state changes, run bIsGameReadyToStart and check if everyone's ready.
you mean make a gamestate myself
There's nuances with timers and stuff but basically it's the State pattern
im only using blueprints
if im not using GameStateBase my level isn't loading rioght
This is all possible in bp
That sounds smelly. Make a custom GameState and PlayerState early and get it working. You can start with GameStateBase but you might be rebuilding a bunch of functionality that already exists in game state
Hey,
what is the best approach to create a crafting queue? should i start the timers ( to wait for example x seconds for something to be crafted ) on the server or client-side?
and how to avoid spamming rpcs to start/stop crafting
I have a costum PlayerState and GameState, i just didnt set the GameState in my Level that i'm working on
@modern cipher I would handle crafting in a component which interacts with your inventory component. Crafting orders can be structs (make this item, it needs these items and takes x seconds)
So queueing up a craft just adds a struct to the queue
And at each craft beginning and execution it checks that materials are available.
yeah i have the structure setup already i was thinking about the timers
do i have to check for a timestamp or something before adding the items to inventory?
some players might cheat if i make timers client side
Id go server side for sure. Only actually run the craft on the server. Just send a client RPC to update the UI (server just started crafting this item and it'll take x seconds)
Can reuse same struct as when you add to q
Or just repnotify CurrentCraftingRecipe
yup i have repnotifies i just send rpc to start / stop crafting a specific item
ok, i got a fix for the GameState Problem
@thin stratus Do i need to fill the PlayerArray or does this happen automaticcly when a player joins?
Happens automatically
ok, my client was to fast. But a 1 sec delay in it and now my Player Array has the correct length.
I'd RPC AddToQueue, RemoveFromQueue, ClearQueue, PauseQueue, ResumeQueue.
Thank you @thin stratus Thats a lot easier.
But now i have the same problem i had with "GameMode" and "Event OnPostLogin" try.
When i call an RPC from my PlayerState, it only get called on the "Liste Server" Player not on the connected one.
Sorry?
If you perform a ServerRPC on the PlayerState, from your Client, you will be on the Server side of that Client's PlayerState
If not, then you are doing something else :D
Ok
I'm looking inside the Game State if 2 Players are ready, when PlayerArray has 2 i cast to my PlayerState to get a reference to my Costume Event that i set to "Run on Server"
What comes after the Event is only executed on the ListenServer
Probably doing some really stupid shit here XD
@ancient badge That sounds all fucky. It should be done like this.
Input(checkbox or whatever) -> Client to server RPC in PlayerController or maybe PlayerState (not sure if you can RPC thru PlayerState) -> set bIsReady on PlayerState -> run CheckIfAllReady on GameState
The Ready Check is working fine
If that 2nd screenshot is your ready check it looks all fucky lol
Do players set if they're ready or are you just trying to fire up when there's 2 players connected?
The ready Check is only the PlayerArray -> Lenght -> Branch the rest is for calling what should happening in the first screenshot
when 2 players connected
I'm fairly certain there's an auto start based on number of players in game mode but anyway, just check number of players on server after one joins and fire it up. No need to get any PlayerControllers etc
Hi, does someone know if is there any way to posses a pawn client side?
My problem is i have a pawn that does not replicate, and spawn on begin play server and client side, after that i want my client player to posses the client pawn and the server player to posses the server pawn
How am i supposed to fire that event if my GameState doesn't know where that event is?
So, BeginPlay doesn't call on Persisting Actors, right? At least it doesn't on mine.
What other options do I have to re-setup the Actor?
This is a TeamInfo Actor, that has some Objectives it should spawn on BeginPlay.
I could persist those too, but then I would still need an event to reset the objectives after the travel.
So either way I would need some alternative to BeginPlay for persisted actors :<
Can't you just make a dispatcher if one doesn't already exist for the map travel event?
Surely GameMode knows when a travel has happened and can fire a dispatcher
Guess so
But not sure about the timing
If the GameMode calls that too early, it's also shite
The GameMode is going to be changed after all
So I would need to know when to actually listen to the new gamemode
So same problem(?)
What's the last thing to load up on travel?
Maybe the GameMode can get all actors with interface I_HackyRestart on StartMatch or BeginGame or whatever it's called nowadays. Maybe even on BeginPlay
Trying this now
void UPSTeamObjectiveManager::GetSeamlessTravelActorList(bool ToTransition, TArray<AActor*>& ActorList)
{
for (APSObjective* objective : Objectives)
{
if (!IsValid(objective))
continue;
if (objective->ShouldResetProgressOnTravel())
{
objective->ResetProgress();
}
ActorList.Add(objective);
}
}
So resetting them before traveling and not after...
The goals don't depend on the map at all?
Sorry?
GameModes have supported Maps. And the GameMode defines the TeamClass, which has the ObjectiveManager, which has the Objectives.
@thin stratus I mean does the ObjectiveManager have to examine the map for placement etc?
Nope
why can't I replicate a map?
The only container that supports rep is an Array
I have map in gamestate, shouldn't that automatically be replicated to clients?
Maps don't replicate
Period? I see, Is there an alternative method?
You mean map like the container right? Not map as in level.
yes, container
Yeah you'll have to figure out another approach. What are you trying to do?
You can't replicate TMaps, period - unless you go the route of custom serialization in a USTRUCT
UI stuff, When a player selects a team, it sets their number and a reference to themselves in a map
Just use a TArray, it'll replicate faster than a map could anyway
And provide a lookup function
I'll look into that, never used it before
were you talking about "insert?"
Jam is saying, instead of
TMap<FName, FYourStruct>
you do
TArray<FYourStruct>
and just do
struct FYourStruct
{
FName Key;
...
the method you use to mutate the array doesn't matter- except that adding things to the start of the array will replicate any elements after the insertion point iirc
Hey, sorry for the delay. I'm not exactly sure if this answers your question, but here is what happens:
- Client presses "SwapWeapon" button:
PlayerInputComponent->BindAction("SwapWeapon", IE_Pressed, this, &ASCharacter::SwapWeapon); - SwapWeapon() is called by the client, sets CurrentWeaponSlot and calls SpawnWeapon()
- SpawnWeapon() checks if it has authority, then destroys the old CurrentWeapon and spawns a new CurrentWeapon.
- CurrentWeapon and CurrentWeaponSlot is replicated to the client.
Since the class SWeapon is replicated, I would expect that the newly spawned actor should appear on the client. However, idk why the client can't swap weapons.
Where's your RPC? Where's the part where the client sends the swap weapon command to the server?
I don't have that.
Should I basically do this: UFUNCTION(Server, Reliable, WithValidation) void ServerSwapWeapon();?
Ya. Idk if the c++ syntax is right but that's the idea
Okay gotcha
I wonder why BeginPlay is able to spawn the weapon from the client, but the client's input cannot do it
Is that because BeginPlay is called serverside per actor?
It won't be locally predicted but that's the first and simplest way. Just Input -> RPC -> DoStuff()
BeginPlay is called both sides
Okay thanks I will look into it!
If you're gating by Authority it only proceeds serverside
Ok so update... Now I actually am able to swap weapons (and use them) on the client ๐ And I can see the server do it as well. Now I have a small problem where the previous actor is not being destroyed (so the new weapon would spawn inside of the old one). I'm not quite sure why because I'm calling Destroy on CurrentWeapon..
Calling destroy on server?
I am so lost. I am trying to destroy an actor. it destroys for the server never for the client. I spawn the actor from the server at a target point and simply call the server to destroy the actor when its interacted with
The client still has the actor remaining. All the components within the actor are set to replicate
the event wont run on the client
Server spawns these actors at target points. This function inside gets called when the item is picked up. All the components are set to replicate in the actor and the actor is set to replicate
I..dont..get it
@round star that's a weird way to architect things. The old item destroys itself after adding the new item? And all this is in the item BP?
the item gets added to an inventory then I destroy it from the world
Oh ok so basically adding a struct and destroying the actor
What's spawning these items actors?
gamemode on begin play spawns actors at target points
@round star for a test, on begin play for the pickup, delay a few seconds then switch has authority and destroy self.
Does it destroy client-side?
@round star you 100% sure your client is connecting?
any good tutorials on MP?
there is one on Udemy, but not sure it covers server setup and the like
I want/need something from start to finish
Thanks for trying to help. I still haven't figured out what the problem is. I am using UE5 ..so uhhh that may be the issue XD. Im not making a fully working game more messing around. I think it is just bugged/broken because I and switched the spawning to multicast in game mode ( just to see what happens)..and when switching it back to the way it was the actors are broken they won't even show up on client and (sometimes on server)
The code is very basic too. Even just using an actor with a mesh to test it also does not work ๐
I cant ever recall having a problem like this
Oh if you're on ue5 then good luck, it's pretty much experimental at this point
How does UE4 handle Level Blueprints across clients? Do they replicate??
Can anyone tell me a good tutorials of unreal networking with cpp ?
Destroy is being called by the client on the server, yes.
{
ServerSwapWeapon();
}```
And then in SwapWeapon() I'm calling:
``` if (CurrentWeapon)
{
CurrentWeapon->Destroy();
}```
oh nvm I read the pins
So I logged whats happening and on the client, when I call SwapWeapon, I get this output:
LogTemp: Destroyed weapon on Server```
So I'm not really sure why the actor is not being destroyed.
This is the code being used: ```UE_LOG(LogTemp, Log, TEXT("Destroyed weapon on %s"), HasAuthority() ? TEXT("Server") : TEXT("Client") );```
Is there a way to make console commands ghost/walk commands work in listen server?
Oh my god. I finally figured it out, hallelujah. Turns out the BeginPlay call to SpawnWeapon was screwing me over; It looks like it was being called client-side for both players, and then for some reason the server wasn't able to delete the weapons.
i have a component attached to each character for their inventory. when a player controller temporarily possesses a different pawn, like a vehicle, i want them to continue interacting with their character's inventory component -- but because the character doesn't have an owner after it is unpossessed, all server RPCs targeting it will fail
is there some way to unpossess a pawn, but keep ownership of it? or am i taking the wrong approach?
should i just forward inputs from the character to the vehicle instead of changing possession?
does anyone have any experience creating custom data channels on the netdriver?
@jade oar Might be able to help you.
basically, I'm networking some entities in an ecs, and I have given up trying to get this working with a replication proxy actor
so, I'm thinking, open a data channel for every connection
and start sending data
my question is, if I open a channel on the server and start sending data over it, will the net driver or net connection notice that and create the appropriate object on the client?
it looks like it might
i just have to make sure the channel is defined in this ChannelDefinitionMap
his gif and not deleted but mine when his get clapped and it get deleted ?????
Turns out.. ..it was a problem with ownership. Having a server event run from the client to the actor is what was needed
so u think he dont get clapped? hes wrong sometimes he not god...
blast, i can't just spawn channels
is there a plugin out there that creates a custom net channel?
or, hmm, maybe i make the channel through net connections
uhm, because i have a set of messages i want to send
and the only way i can think of doing it with messages is with RPCs
and that's a mess
hey guys something that I forgot and that my fish brain can't seem to remember is how to I manually control when a AGameMode begins the match (StartMatch())?
also, I have some very dynamic data i want to replicate
i basically want to shape the packet myself
thats fine, im talking about using a single actor as a network manager for all your objects
i tried that, the problem is, as I said, how dynamic the data is
fastarrayserializer + fastarrayitem with TWeakObjectPtr + TArray<uint8> Data
as long as you can make the objects net addressable
oh, im not using uobjects
I've got an ecs (powered by flecs) that i'm trying to replicate the entities in it
i've got some real mad science shit going on here
ID + TArray<uint8> then
yeah, that was what i was thinking originally, but you have to infer message stuff
as long as you can find the corresponding entity on client
and it can pack/unpack its own data
like, what happens if component 3 doesn't update that frame? I'd want to remove component 3 from the list
but, not infer that component 3 was deleted
i realized I just needed a straight up packet thing
its capable of individual per item callbacks on client
so whats stopping you from doing updates on post replicated change?
also, why use a FFastArraySerializer's delta serialization when i'm literally going to be sending a specific set of data per update packet
like, I want to send a packet "For entity 10, update component 2 with { DATA }"
and so on
and then two other packets, "Create entity N with components { X {DATA}, Y {DATA}, ... }"
and "Delete entity N"
this protocol ends up looking a hell of a lot like just packets, and a FFastArraySerializer is not the solution there
probably a network manager actor that is in charge of sending and receiving strings/arrays of information
that was my initial thought
then your receiving end sorts what to do with that info
the array serializer
it was untenable
lots of inferring from the 3 events what was going on
and not an explicitly designed protocol which is what I wanted
fair, fastarray will eventually break if the system is extended, even if you make it work originally
right
if I added "For Entity E: Add Component N {Data}" and "For Entity E: Remove Component N", how does that look there
like I said, I've got some mad science shit going on here
and I think it's working
based on your info, it seems to be a 3.5-layer process. What's wrong with sending
- ID : FString as byte array
- Main Command : Fstring as byte array
- Data : byte array
3.5-4) Data parser ID, so the receiving end knows what type of data it is
I havent gotten to the protocol yet, I'm still trying to open a custom data channel
well, right now i'm dealing with a crash in flecs
which i think is due to a 0 size struct i was using a handle
that was exactly what it was
my kingdom for a delegate that fires when the net driver is created
Except "open" lacks an IP address as a parameter here
Should work, ports need to be open.
Is this dedicated server or p2p?
oh the ServerIPAddress variable is pulled from a text field
it is then appended to after "Open "
listen server, so p2p
how do I open ports?
Listen != P2P
You open ports in your Internet access point's settings
This will need to be done by every hosting user
Or you could use Steam and not bother
Port does not need to be open if you are using Steam or Epic onlinesubsystem.
Which you should if you are doing p2p, else you will have to figure out NAT punch thorough, because most of every player has port closed.
(It's not P2P, it's a listen server)
so every single player that wants to connect or be connected to
or just the server player?
the server itself is a player
Yes, that's a listen server, not P2P
Just the server
ok got it
Unreal doesn't have p2p, I'll definitely need to start calling it listen server.
what will onlinesubsystem help with
make it so that the server players will not have to open ports?
Yup
wait what is p2p defined as
Player to player
yes but i thought since the server is a player this would also be p2p
Listen server has one player have full authority (and ability to cheat and kick players) on the entire game
P2P has players talk directly to each other
So they're more indepenent
got it thanks
i know the thing is free, is it complicated to setup
ok got it thanks
Not really, there are tutorials on youtube.
It's more that you depend on a service like Steam, EGS, GOG, console platforms, etc
alright, thanks
this is just a personal project so im not looking to rent any services so im just using basic connect by ip and basic stuff
ok got it
Opening ports in your router's interface it is then
Also didn't i already answer this yesterday for you?
By now you could have googled how to open ports
won't the online subsystem work? if i dont want every player that wants to host a server to have to open ports that is
Sure it will but
you depend on a service like Steam, EGS, GOG, console platforms, etc
yeah sorry about that
i think im going to ask a bit more to get an idea of what i can work with though
so i guess it wont work if i dont rent those services
Rent is the wrong word but yes
Less "rent", more "get them to carry your title on their store"
To be fair Steam mostly works with the test app id
If the discussion goes further about subsystems, please move to #online-subsystems
the free test id doesnt work over actual internet does it
its fine i think im just going to open ports
Yes, it does.
Did you see Cedric's message above ?
ok got it ill move channels
Hey guys, I've been trying to learn about replication in UE. I've started with some basic stuff like Rotation. Which i cant see to get to work : / Player presses Enter and rotates actor cube in scene. Server player successfully does this but clients do not:
https://imgur.com/a/9qAhIJ9
The Blueprints:
Clients can't run RPCs on unowned Actors. It works for the main one there as this is a listen server, and since they're the host, they can replicate the changes.
Instead, set it up so your character does an RPC to the server, and the server then takes over and proceeds with the rotation of the cube multicast.
Character -> Execute On Server Event -> Run "Rotate Cube" on Cube target -> Cube can proceed as is.
Ahhhh! Okay, I must have missed the Clients can't run RPCs on unowned Actors when I was reading the compendium, I will try this right now. Thanks !
this doesnโt work because pawns check that they have a valid controller before applying move inputs. anyways, they use information in the controller to scale inputs and stuff so working around that fact doesnโt seem to make sense
seems like you want to decouple the pawn from any non-movement related state, otherwise you entangle the ownership domain with the concept of possession
so i guess i need to put the inventory on a separate actor
@twin juniperYou're using Set twice.
Good eye Authaer XD
As you're on a character blueprint it won't work how you want. Each copy of the blueprint has their own set of variables. So if you and I were in a game, I would have a third person character and you would have a third person character. When I press the 1 button, the server is setting my character's variable to 5, and only on the server. When you press the 2 button after I've pressed 1, then the server would be reading your variable which is whatever you had your variable set to as default.
Even if you were to set the variable to replicate, all that would mean is that when either of us press the 1 key, the value would replicate to the client's copy of the third person character.
If you want all third person characters to have that value set, then you'd have to get all copies of the third person character, loop through them, and set their value, but again, this would still mean each character has their own copy of the value so the value could potentially be different from one character to another unless you always change it on all characters.
If you want just a variable that is not specific to any single player or character, then you should probably create and set it within the game state and have your characters read the value from the game state instead.
something that always puzzled me about replication: what's the right approach to handle server authoritative variables that i want to "predict" on the owning client, for example, shuffling items around an inventory. i don't want to wait for an OnRep or something from the server before the item visually moves, because that feels laggy, but if there is an unexpected collision or something (for example because the server decided to add an item to the inventory at the same time a client is moving something there), i want the server to correct it
i guess that scenario is actually somewhat complex.. if the client is able to make several inventory moves before getting an update from the server, it will potentially have to roll back some or all of them depending on what it eventually hears from the server. so immediately i need to do something tricky like keeping some counters in sync between client and server and maybe a queue of client moves for rollback
Having written a couple of inventory systems. I strongly urge you not to do client side prediction for that kind of a system. It's not something easily correctable without a full value refresh, and it can easily spiral out of control. People are willing to have slower inventories based on latency if they just work correctly.
(As an example, Destiny 2, a heavily inventory based AAA MMO, noticeably does not do any prediction on any inventory action no matter how trivial)
Game State is the place to store variables that aren't necessarily specific to a single player. Like team scores.
Player State is the best place to store any values that are specific to a player that need to be accessed by others. For example, a player's specific kill/death count. You wouldn't want to store this on a character as then that value is tied to that character and if that character stops existing (lets say they were killed and the actor was destroyed) then the score goes away with them. You wouldn't want to store this necessarily in game state either as you'd then have to keep track of each player somehow within the game state, which player states are already doing. You wouldn't do this on the player controller either, as each player has their own player controller, but they are not accessible to other clients.
thanks all, it just didn't occur to me that it was actually that complicated, i thought i was just missing something. point taken ๐
I know someone made an inventory using the GAS which probably was built with the intention of having client-side predicted inventory... Paid plugin ๐
(Not cheap either @_@)
I mean, sure, it's always cool to have prediction
People usually don't worry about that
It's doable. But it's not network friendly. You would need several edge case checks in place and even then order of operations in networking with unpredictable traffic is hard to work around. But as a solid point, people will 100% care if it messes up once a week a lot more than if it's slightly laggy. Laggy is a known issue with networking. Bad values just make your whole game look bad.
@twin juniper you can somewhat think of the game mode as the game controller analogous to how a player controller works for a player.
is there a way to piggyback client/connection-specific data when replicating a server value to clients? for example, i have a struct that contains an inventory snapshot (shared across all clients) and a sequence number (different for each client). i want them to update atomically on the clients, because the sequence number is related to the particular snapshot, but i don't want to duplicate the snapshot for every client. is replication the wrong tool for this kind of thing? maybe i just want client rpc?
are you talking about arc inventory? maybe i'll just buy that
Client RPC or replicating an Owner-Only value to something owned by the client.
I have a question I feel is pretty basic for any veterans here. I have an object that I attach to the player using attach actor to actor. When I do this the client who attached it to themselves now owns it. However what happens to ownership once it becomes detached?
How can i set the ownership back to the server
I get different behaviours if I am testing a server with clients window...versus all client windows
I guess the real test is packaged, hosting, joining and playing lol
When it comes to editor stuff though, how should I do these tests?
With the server/client windows I get my desired behaviour
but I am not sure if this is right..as in tutorials they show only client windows..but the behaviour then is incorrect
Hey guys, got a hopefully simple question to walk through.
I am trying to build an RTS (fun and original, I know). I am trying to accomplish the ability for the player controller to spawn buildings / units in my early prototyping using the keyboard, this is pretty doable. On spawning of actors, just pass an integer variable that I call team to the newly created actor so that the actor's team variable matches the player controller. Cool. The problem I have is assigning the player controller a team. I think I have it solved, but when testing it my server and client show differnet team values on print (like shown below)
My question is, since the server knows what team each player controller has, does this mean for sure now that I will be able to pass the correct team values to my pawns? I am testing this on a listening server and getting confused by the client printout
In my picture, I activate my hotkey to test my Player ID and team number after assignment in both the client and the server and get these results
From the screenshot it looks like the property is not set to replicate or hasn't replicated yet. Otherwise it should match what's on the server. But if you never rely on that value on client side, then you might not even need it to replicate and can just use it on server.
hmm, if the HUD and the PlayerControllers are both clientside, I think I will need to replicate it so that I can have a filter that says "hurr only select/command units with a matching team as you" -- is this something I handle from the header in my playerstate? I suppose I could just crack open the engine and see how they declare the Player ID
excuse my ignorance, I'm still trying to climb the learning curve for UE/C++
UProperty(Replicated)?
If I understand you correctly you will spawn a new building and tell it which team it belongs to. And the spawning you should do on server only and those values seem to be set correctly there.
Yes, to set a property to replicate you can use that. Or ReplicatedUsing if you want a callback on client when the value changes.
thanks for your feedback, this has been helpful.
Just so I am understanding this correctly, when my playercontroller controlled on the client Window issues the command to spawn something, the server will know player controller with team X is spawning a building, the server should then handle everything, right? I actually don't know how to differentiate between telling the server to spawn something or the client, I just set the spawn code up in my customer PlayerController Class/Blueprint
Correct. The client should only tell the server "I want to spawn this kind of building right here". Then on server you double check if client really can spawn that kind of building, like does he have enough resources, is the technology unlocked etc. And if the request is valid - you spawn it.
There are multiple ways to check if something is running on server or not. One way you could do it is to check IsNetMode(NM_ListenServer). Or NM_DedicatedServer. Depending what you use.
and "on the server" in this case would just be sets of parameters contained in the game state / player state / or a custom data structure? Awesome, I think I get it now. Or, at least I understand it better
(for resource check)
Yep. You just check some variables that you need to check for that building to be built. The idea is that you shouldn't trust the client blindly. Since you have no control over that machine and the player could cheat for example. Of course if you use a listen server then it's not as important, since it means the server will be one of the players anyway.
Thanks for taking the time to explain it to me, I now feel much more confident.
can clients access replicated objects that are not relevant to them? in other words, can i use network relevancy as a permissions tool?
i guess i was thinking that if a client could magically learn the network name of an actor that's not relevant to them, it could start calling server rpcs on that actor and do something that they aren't supposed to do. but server rpcs are only callable by an object owner anyways..
No it's not possible
If a runtime-spawned actor isn't relevant, then as far as the client is concerned it doesn't even exist
Even if they theoretically called a server RPC on an actor they don't "own", the server would ignore it
When i detach an actor how do I set its ownership to the servers again.
Or rather..how can I just have the server retain full ownership always so I dont even have to worry about it lol
afaik there is no such thing as "server ownership" -- actors are either owned by another actor, or they are unowned
to make an actor unowned again, just SetOwner(nullptr)
Roger that
When I attach an actor to a player. calling a server function to detach it doesn't work, instead it works on client side function..so idk..but I am also a total n00b with nertwork
"nertwork"
maybe you can clarify exactly your setup? do you actually care about ownership or are you just struggling to replicate actor attach and detach to all clients?
player state, and you'd make sure that the server sets the value
take a look at ShooterGame
they implement scoring
Well the server and clients can pick up the actor and it shows up for everyone else and they can drop it and others can pick it up. An issue I am having is I want to be sure no one can 'steal' this actor from someone else when its attached to them. This works perfectly fine, HOWEVER...if the client had any previous actor attached, if I try to 'steal' someones equipped actor it attaches any previous actor the client had. I am setting their pickup to be empty after dropping it and I have a 'pickedup' bool as well it checks and the print string shows it doesnt get passed it. So idk
I know that was a mouth full lol
doesn't sound like anything is wrong with your approach, definitely sounds like a bug in your code to drop items
How would I make a multiplayer vr game?
@wary jay The same way that you make a multiplayer normal game. There's not really anything special about VR. It's just a different control scheme. Much like the difference between designing for console vs PC.
Just think about it this way. Put info about a player in player state. Put info about the game in game state. So if it's a basketball game, each player stats would live in player state, but the team scores and timers and other data about the game would live in game state.
Or if you're making battlefield, and individual players kills, deaths, and score live in player state, while the time left in the round and other data can live in game state
Hm. Should I be setting owner in the character for the actors picked up or in the actors themselves....
Has anyone developed in a small team of 5 people ? How did you solve the version control setup?
What's the problem with version control ? Just use any, usually Perforce
This is SO strange. I cant resolve this issue of the player reattaching a dropped weapon when theyre not even anywhere NEAR it. The only way the function ever gets called is by going through a line trace. Yet the function is somehow getting called anyway and I cant make a lick of sesne out of it
It even shows the branch for false (no hit) firing my print string..and then the function after true FIRING..
im pulling my hair!
Basically just curious where people had the actual server running. And since it's a multiplayer game it would be great to have a way to test play it across the internet as well
You'd rent some VPS box and run the Perforce server on it
Same goes for the game server really
I've used Digital Ocean to host a perforce server in the past
it's like $5 a month
and free license is plenty for a small team. You have 5 accounts and 20 workspaces
as for hosting servers, you can host on your own local machine, or just boot up a cheap EC2 instance on AWS for w/e OS you're running and shut it down when you're done.
I host perforce and game test server on same Digitalocean box
As a bonus, don't have to do server builds, can just launch a headless Linux dedi in a few seconds
Is there a way to set what options are passed to AGameModeBase::InitGame when running PIE?
crazy custom data channel networking coming together
I've just got a timing issue right now where sometimes it tries to register the channel definition before the netdriver is created
Entity Component System?
really hard to diagnose without looking at the code. maybe post a screenshot of your functions that call attach/detach?
yeah, im trying to network one
nice!
flecs, specifically, but the tech im building will work for any
Unity DOTS wishes it was actual ECS
I'm trying to open a network channel directly on the net driver to define a simple protocol for the server ecs world to communicate with client ones
that's pretty cool
but i've got a timing issue where sometimes clients begin play before the netdriver is created
a coworker is going ham with getting ECS working in UE4 for just single player stuff
his results so far are astounding
yeah
I'm doing it for bullets in a shooter
we've got some bonkers numbers
for how many projectiles can live at a time
tens of thousands
the limits we've found are it interacting with UE
putting together data in a form that UE can read it has been most of the work
he basically threw out UObjects entirely
we're looking at doing mostly the same
just push data directly to niagara
create a single particle system, update a float3 buffer in it
write to that buffer every frame from the ecs, it's insane performance
he had over 5k actors on screen doing boid movements and had ~680 fps
like, totally bonkers shit
anyway, I'm writing a way for the server to send data to clients regarding the ECS, and I tried to do it with a proxy actor but it wasn't working too well
so I figured, just send packets directly, but opening a socket to do so is not ideal
network channels, on the other hand, have a packet-like interface (FOutBunch/FInBunch) that I can implement a simple network protocol
it's been awhile since i've messed with sockets directly in UE
i'm a bit foggy on the details
that approach could work though
iirc UE serializes all of it's packets before sending them. They send them in byte chunks, and keep the size small.
it's been a bit since i've looked that deep in the engine though
yep
I'm putting this right above that logic
so it adds my """packets""" into that logic
the same way it works for actors, control, and voip
i just can't figure out when to catch the moment the NetDriver is created
Do you not want to modify source?
no, this is a plugin
Ah. Well shit.
I'll poke around the engine and see if I can find anything that'll help
like, what i should do is add this to the config
but i dont know if i can patch engine configs from a plugin (you probably can)
@gleaming vector i'm fairly certain you can. I know you can specify which netdriver should be used, so there's probably more config options you can utilize
Took a look through the engine. UPendingNetGame is loaded prior to the world as a server is opening a new level. it broadcasts the FNetDelegates::OnPendingNetGameConnectionCreated delegate.
/**
* Delegate fired when a pending net game has created a UNetConnection to the server but hasn't sent the initial join message yet.
*
* @param PendingNetGame pointer to the PendingNetGame that is initializing its connection to a server.
*/
DECLARE_MULTICAST_DELEGATE_OneParam(FOnPendingNetGameConnectionCreated, UPendingNetGame* /*PendingNetGame*/);
static FOnPendingNetGameConnectionCreated OnPendingNetGameConnectionCreated;```
that's right as it's being created
that lets me handle the client case
i was hoping there was one for the server case, but this works
that's actually ran on the server
what i really want to do is add to the ChannelDefinitions config in NetDriver
but I can't seem to get this ini to load
/**
* Commandline override for the net driver.
*
* Format: (NOTE: Use quotes whenever the ',' character is used)
* Override the main/game net driver (most common usage):
* -NetDriverOverrides=DriverClassName
*
* Override a specific/named net driver:
* -NetDriverOverrides="DefName,DriverClassName"
*
* Override a specific driver, including fallback driver:
* -NetDriverOverrides="DefName,DriverClassName,DriverClassNameFallback"
*
* Override multiple net drivers:
* -NetDriverOverrides="DriverClassName;DefName2,DriverClassName2"
*
*
* Example:
* Use WebSocket for the main game net driver:
* -NetDriverOverrides=/Script/WebSocketNetworking.WebSocketNetDriver
*
* Use WebSocket for the main game net driver, and the party beacon net driver
* -NetDriverOverrides="/Script/WebSocketNetworking.WebSocketNetDriver;BeaconNetDriver,/Script/WebSocketNetworking.WebSocketNetDriver"
*/```
those are the overrides
you can specify in the config
right, i dont want to override the net driver
i want to add a channel config to it
made a DefaultECSProjectiles.ini and added this to it [/Script/Engine.NetDriver] +ChannelDefinitions=(ChannelName=EcsChannel, ClassName=/Script/ECSProjectiles.ECSNetworkingChannel, StaticChannelIndex=-1, bTickOnCreate=true, bServerOpen=true, bClientOpen=false, bInitialServer=true, bInitialClient=false)
but no luck
I believe it needs to be in DefaultEngine.ini
^
UNetDriver specifically calls out that config
I had just found that actually xD
If you're planning on distributing this plugin just add it to the readme that you need to add that line to DefaultEngine.ini. Or write a setup utility for the editor that sets the config up and saves it.
it's workign!

I have successfully created my own data channel, all clients get it, and the server can send messages over it
this could have been way easier
but it's working
Niiiice
sweet
When a player drops an item and presses the key that does a line trace for something to pickup..it runs the function to attach an item. The previous item the player had that is no where near the player..despite the print string CLEARLY showing that there is no hit and cant get by the branch still calls this function and attaches it and I am baffled beyond
Maybe you have a reference to the item stored in your logic that you're using in the line trace and it's not getting cleared before your executing your line trace.
The line trace checks if the actor implements an interface than I call the interface
if it does and I attach the actor I store it in a variable. When I drop it I clear the variable
post some code
Nice!
You plan on making a youtube video to give an overview?
Does it work for arrow and movement syncing?
im getting movement syncing working now
i haven't done actual projectile mechanics yet
that'll come after I figure out replication
Cool
how would i make my own player database?
How are you planning to sync movement?
Use PlayFab
now that I have a transport layer, i plan on writing a sync component and system
and just sending all the data to all the players
containing what info?
So client lerp position to server position with prediction offset?
Yea that's I am doing for arrow projectile, tho I wonder how Team Fortress 2 does it, does anyone know?
PlayFab let users to create account for your title and have all the stuff you need for account database. Look it up
I understand what playfab does
Oh so server does not spawn projectile instead uses hit-scan only and client spawn projectile just for the visual?
yep
for bullets
im pretty sure that they spawn entities for non-bullet projectiles
Ok
Is there a reason why you wanna create your own player database system? it's time consuming
I've already done so. I enjoy that kind of work
Nice, with AWS?
Nope
Spring boot java program with MySQL database for persistence. I handle all the calls via a REST Api so if my source ever gets exposed the player data storage methods are still safe.
Playfab is great for quick testing and basic integration during development though. Their pricing isn't too bad assuming you're making a profit.
Thats awesome! Nice job!
Lot of work tho
learning it the first time was
I actually learned how to do it thanks to my final project in college
we needed to build a database to store stuff for the app we made as part of our capstone
one of my group mates had found out about Spring Boot and I adapted it to work with UE4
that was a learning curve for sure lol
I should write a guide on it probably
Player data storage is a pretty simple CRUD app. Auth can be interesting but that's true of pretty much any web service... playfab's APIs for that are nice but most of its value lies elsewhere.
i had integrated it with AWS Cognito
and then eventually integrated AWS Cognito with EOS as an open id provider
originally I was using JWT tokens, but that got a bit messy with longer play sessions
like player names, skins, stats, etc
playfab or a custom solution is your best bet then
alr thanks
Dope!
Lol why not use someone elseโs SQL jk๐๐
Lol
guys is there a good tutorial for how to make online multiplayer game with dedicated server that build with anti-cheat system?
Aside from the general concept of building something server-authoritative, no. Creating or integrating an anti-cheat is not something you will find a tutorial for.
One of those counters for countering -> don't tell people how you're protecting your game, otherwise they may figure out a weakness by what you've told them you've done.
@hollow eagle @sinful tree so can u guys tell me best tutorial that talking about multiplayer - with dedicated server with practice not just academic informations
There is no difference to writing listen vs dedicated servers aside from not assuming there's a local player (you shouldn't do this anyway) and dedicated servers generally have some more code stripped out for performance reasons.
Follow any multiplayer tutorial to get started. And if you're new to unreal's networking and replication, read the network compendium in the pinned messages in this channel.
@hollow eagle @sinful tree thank u so much
Still haven't figured this out, it's related to AActor::IsNetRelevantFor and the delay it takes for actors to stop being relevant
The server won't close the channel straight away but even if it does it's not high-priority traffic and will still take an arbitrary length of time to reach the client. It's generally a bad idea to have the relevancy timeout low because objects that are flittering between being relevant/non relevant due to range can cause massive spikes in bandwidth as they spawn and despawn repeatedly
Calling ForceNetUpdate also resets the network frame for that actor, so if anything it will take longer to close the connection by calling that.
If my Actor has SetReplicates(true);, client can't write on the actor Location/Rotation ? Or i need to enable SetReplicateMovement too
Hi, guys what's best way to create server for mmo, what would you recommend?
@twin juniper Client can write/set anything they like, but typically they shouldn't change anything which is replicated.
If movement is not replicated, clients can move the actor wherever they like.
I donโt understand why location and rotation are separated from bReplicates.
The bReplicates flag is only meant to mark an actor to be considered for replication in general. But then you have to mark specific properties that you want to replicate. bReplicateMovement takes care of replicating all the necessary properties for movement.
In other words if you have properties set to replicate on an actor, but bReplicates = false on that actor. The networking system won't even check that actor at all, won't even consider it. And nothing will get replicated.
Ikr, that wasnโt my question
Alright, thx for the clarification!
Essentially since not all actors can move, movement replication is toggled separately. It avoids replicating properties that aren't needed.
Even if an actor donโt move itโs essential if itโs replicated to be sure people will not write on its location to teleport it to themselvesโฆ
It's irrelevant what the player writes on his location. Everyone else would see what the server tells them to see and they can't change the server value. So kind of a pointless cheat to only teleport yourself on your own screen, while the server still considers your correct location.
Is there a way to use console command ghost in a networked game in development build? Seems to be disabled
How it can be irrelevant since itโs not replicated
They can do that anyway, it doesn't matter even if it is replicated.
Even if you send data to a client, there's no guarantee they are actually using that data.
Servers should make no assumptions about data coming from the client, it should validate anything the client tries to do to change the state of the game.
Well for my case I was asking for my pickup actor, if the pickup actor location is replicated and the client is trying to write on it the server pickup instance will correct it with its location ?
If a client moves an actor, they only move it locally. They would have to send an RPC to the server if they want the server to move it.
The client cannot change the servers' state of the game by doing stuff locally
Thatโs not what u said there
Replicating a variable only means that the server will send that variable to a client when it changes, that's all it means.
A client can do whatever they want with that variable locally
But the server will correct it
No it won't
Or it only correct if the client is trying to change the server variable
The actors' transform is just a replicated property. When the variable is received by the client, the client applies that change to their local instance.
But the client doesn't have to do that
But when the server is applying ยซย correctionย ยป then
the server doesn't apply corrections
All the server does is send data to a client
It's up to the client what they do with that data
Yes but
Imagine bBool is true on server and false on client, server will not apply correction ?
No
I saw somewhere that yes
If you change that value locally on the client, the server doesn't know about it
The server will only send a value if it thinks the client has a different value - and the only way it can know that is by tracking the state that the client most-recently acknowledged.
But how since it is replicated
I don't know how else to explain it
Ok ok
The server keeps a "changelist" for each client. When a replicated value is changed, it sends it out to clients only if the new value is different from the last one. It will only ever send that property if it changes on the Server. It has no idea if the client manipulated that value locally.
Clients essentially have a "copy" of the game running on their machine. If they make changes, that only affects their local copy. If they want the server to change, they have to explicitly tell it to do that.
And so thatโs where anti cheat come I guess
To protect client manipulation
But Iโm pretty sure last time I tried to modify my health variable with cheat engine, it got corrected with the server value but anyway ๐
Hello, I'm working on multiplayer game and I've got a question : is there any best practices for replication handling? I know about OnRep call back, but how do I handle moments when I try to get reference, that is not yet replicated from other object?
I'm using waiting macroc rn but not sure whether it is good idea
@foggy rain things related to game overall usually in game state, things related to specific player in player state.
updates always on server-side and replicated to clients later
how update called (from game mode or from RPC) is varies
Thank you!
If I need to update some variable from GameMode, should I use RPC to update the changes on clients too?
If they are replicated no
Oh, in UE I can just mark a variable as replicated?
Well since Gamemode is only on Server what do you want to update on Client ??
And yes
I just want to update amount of damage in PlayerState
Got it, found replicated DOREPLIFETIME things.
Then yeah if you manage that in Gamemode you should do an rpc to the player state
And replicate it only if needed.
But if variable is marked as replicated, can I just set it from GameMode for server? Will it be replicated automatically?
You still need an RPC (if not set from Gamemode)
You should give it a try
You will have a answer to your question faster ๐
Thanks! Will try
anyone ever seen PacketHander isn't fully initialized and also didn't fully consume a packet! This will cause the connection to try to send a packet before the initial packet sequence has been established. ? We are on 4.25
this gets constant spammed
what state packethandler is in? ( breakpoint on message and check object)
1>D:/Projects/UnrealGItLab/TBSGitLab/AdvancedTurnBasedTileTool/Source/AdvancedTurnBasedTileTool/WorldStuff/TBGameStateBase.h(30) : LogCompile: Error: Replication notification function OnRep_TurnManger not found
just why?
is it implemented, that's just a definition
i got it))
not
there is no UFUNCTION
it is not serialized)
seems i need some rest)
@spice night anims donโt auto replicate so u have to multicast them
When a player joins mid game. Is the event post login what I should use? Or how do I notify the server there is a new player and assign its controller and spawn the player at my locations
Can you not use a replicated UObject class from a different module? The object replicates when the class is in my main game module, but not in my other module. It's really weird.
I'm trying to get familiar with how to use the IOnlineIdentityInterface... I can login successfully on the client, but how does the server query the user's account information? A lot of the methods want to take in the player's local user index... not quite sure how to get that on the dedicated server
I'm trying to get a user's auth attribute if that helps any
UObjects are not replicated. AActor is the first class that implements replication.
@sinful tree yeah, I know. I have implemented the things needed to make them replicate. It works in my main module, but not in my other module.
I have my projects module (ie ProjectG module) and my other module (StatSystem). When I have the class defined in my main module it works, but it doesn't in my other module.
If a client uses 'get all actors of class' and the in class is the player state, will the clients get valid references to all the player states?
If that's what you're looking for, you should just do this.
Thank you this is what I was looking for!
I appreciate it ๐
if i were to run the third person demo in multiplayer would it work?
Any good video tutorials for replication? I know about the networking compendium, but I feel like I need a video tutorial to better understand this topic.
I also know the ue4 learning live stream for replication, but I felt that it didn't go in to enough depth
Is there a callback anywhere for when a net connection is accepted?
hello everyone.I am trying to implement player count in my game.So every time a new player joins it will call onPostLogin on GAMEMODE and we will add player controller to an array.then We will do a for loop on that array and call a custom event on that controller which then calls a custom event that RUNS ON OWNING CLIENT.I am getting player count but the references i assigned at begin play on my controller are getting null even though event tick is saying it is valid.Am i doing something wrong.??
Here is my gamemode implem calling player controller custom event
Player controller event
I am creating statsUI if we are remote player.It is displaying on screen as well.But this variable is getting invalid in above custom event
You're potentially doing multiple things wrong here.
First, why are you maintaining an array of player controllers yourself? The engine already does that for you. Second, you can already access the number of players on any client by looking at the list of player states. Maintaining a count per-client manually with events is going to be incredibly error-prone.
/**
* Delegate fired when encryption has been setup and acknowledged by the host. The client should setup their connection to continue future communication via encryption
*
* Binding to this delegate overrides UGameInstance's handling of encryption (@see ReceivedNetworkEncryptionAck)
*
* @param Delegate delegate that MUST be fired after retrieving the encryption key in order to complete the connection handshake
*/
DECLARE_DELEGATE_OneParam(FReceivedNetworkEncryptionAck, const FOnEncryptionKeyResponse& /*Delegate*/);
static FReceivedNetworkEncryptionAck OnReceivedNetworkEncryptionAck;;```
that might work
Admittedly this is better done in C++ as I don't believe the player state array is exposed to blueprint. But you can even do GetAllActorsOfClass for the list of player states and then just count the result every so often. Or do it when a player state is created. Or any number of other things that won't be as error-prone as manually maintaining that list.
whenever my ECS goes to replicate, if there is a new connection since last it replicated open the channel, send the hello packet, and then queue up a bunch of ecs state data
It's read only from BP
well there you go
I don't usually do networking stuff in BP so I couldn't remember ๐
I checked in the engine
there, the list of players - already accessible on all clients without any extra work.
since I was looking for that delegate for Roy lol
As for maintaining an array of PlayerControllers in the game mode. That's quite useful sometimes. It gives you a nice cheap accessor to the controller after they login. You'll just need to be careful incase your player changes controllers in the middle of the game, which isn't common.
Ehh, not really. The engine already maintains a separate list of player controllers.
where?
In UWorld
you can't access it directly
ofc not xD
but it is exposed via a few functions
Specifically, you can use a player controller iterator
which does not iterate the full actor list
yeah, the controller iterator
loops through active player controllers, which is a far smaller list
*player controller iterator
there's both a controller and player controller iterator
yup
probably to separate out AI
since it splits from AController
there isn't a way in BP to use that unfortunately
but sending the size of the players array from the gamestate is a much better option
You can use GetPlayerController which uses it, but it's a bit inefficient
if you're just trying to get the number of players in the game
anyway, my transport layer for replicating an ecs to clients is working
sweet
now to do the higher level change tracking, network entity ids, and sending data to clients
Hm. When my character is running when I join the server it jitters (as if it doesnt have permission from server to change its speed)..however I have it setup so it does, and it works perfectly fine when doing the server/client windows in editor.. ........so now I am confused as hell
GetNumPlayerControllers exists in UWorld as well, no BP equivalent though
This could be a number of things tbh
Yeah some of those functions should probably be exposed... I guess you can just use the number of player states to index into GetPlayerController
still inefficient though since it creates a new iterator every time...
yeah
@twin juniperAssuming your BP was created from GameMode and not GameModeBase, you have direct access to NumPlayers which returns the number of human players in your level.
You'll need to loop through your player states and send a client only event on them, which could then be sent to the player state's controllers.
no, please don't do that either
he's limited to BP only
every client already has access to the full player state array
in blueprint
just grab the number off of that
I don't think that's replicated?
Anyone know anything about running events from Host to all clients from within a Widget Component?
We currently have the host only spawning a widget on their hand in VR and when they hit buttons it calls to the Gamemode to then move the client and the host. In a solo session it works but the moment a client joins it stops working.
Widgets should only exist on the owning client. If you want to call a Multicast RPC, which is what it sounds like, you'll need to call that on the widget's controller.
Yeah, so what I do is run it on the hosts end to the gamemode and then multicast RPC it to all the clients
I've tested it in a non-VR project by just spawning a widget on the host and then on click calling to the server and doing a print string in a multicast function and that worked
It just stops when its a Widget Component in world space
I've got a couple questions.
- How do I choose the port number for the dedicated server I'd like to connect to.
- can I test connections from the editor client to an external dedicated server?
I know by default its 7777 but I don't know if you can change it.
You should be able to connect but there will more than likely be issues. You can run Standalone via editor to connect to dedicated servers
Running a server on a different port was pretty straight forward, it's finding how to manually edit that for the client I can't find any info on, sadly.
standalone makes sense.
You can use sessions to connect to different servers. As far as connecting to a different port on a machine hosting multiple servers you may just be able to use open ip:port
Yeah derp that does seem to work. I was trying within the editor and wasn't seeing the results I wanted so assumed it didn't work. Tested in a built client and it in fact does. Thanks ๐
np ๐
Game Mode doesn't exist on clients.
You can use Game State if it's something that's not specific to any single player.
@hollow eagle and everyone for solving my question.But can i add my own variables to game state and player state??.
yes
make a subclass of either, set the classes in the gamemode defaults. Same way you would to use a custom player controller.
you don't need to add any variables just to get the number of players though - again, just get the player states array from the game state. The number of player states in there is = to the number of players
yeah thanks.
Is there any way a particular player (client-side) can tell the server to update a particular actor's NetUpdateFrequency during runtime? The catch is that I want it to only affect one player, not all players. Is this possible?
I created a game state and i added a variable.I then set is as a default game state in world settings.But when i set my game state EVENT BEGINPLAY is not getting executed??.What is the problem??
event tick and remaining all are getting executed by EVENT BEGIN PLAY is not getting executed across the game
Is your gamemode set to delayed start or stuff like that?
c++ wise or bp wise ?
There is nothing built in like that. Any reason why would you like to do something like that?
Default game state is GameState in gamemode.If i change it to any other one then event begin play is not getting executed
Did you mix up the base classes for gamemode and gamestate?
They either both need to be Base or the non base one
Default game state is GameStateBase.Sorry for that.I created subclass of GAMESTATE
Yeah then your GameMode also needs to be GAMEMODE and not GAMEMODEBASE
So check that
Your log should actually tell you that
Now i created a GAMESTATEBASE subclass now everything is working fine.
What is the diff b/w them??.Which one should i prefer??
@thin stratus It's now working.Thanks
Base one is simpler for more general singleplayer projects or non matchbased multiplayer. Everything more complex would use the none base version.
(is usually always use the non base one to not limit myself)
Dang i see. Im trying to optimize my RTS game which has alot of units as much as possible. I've already done replication graph but i feel its not enough
Yeah, I handle that the same way as the teleport
Tl;Dr - On Join add player to array of players, when server runs event do a foreach loop over all of them and then do a server call to all of them and tell them to do RPC thing
We got the systems working across a network on overlaps but not on the widget component itself ๐
Where can I learn about gamemode
I want to create gamemode for a multiplayer shooter
reading source code is a good place to start
Ok
Was there anything special required for an AnimMontage to properly play on a ListenServer?
Break pointing shows that both Players (Server & Client) want to play the correct Montage and the montage length is also correct, but the ListenServer just doesn't play it.
Both go through the same code paths
That is Server killing the Client.
Client killing the Server works for whatever reason.
Only thing that would be different here are the NetRoles based on who kills who, but why does that affect AnimMontages :<
Anims should only be played on clients right?
even on a listen server
it would just execute weirdly in that specific case
Why would an Animation not play on a ListenServer :D
Also it plays just fine if they are the ones that get killed
my guess is something to do with the host is ROLE_Authority so it screws something up
Yeah someone is weird. Even with 4 Players, if the Server gets killed, it plays the Montage.
If the Server kills a Client, it doesn't. All Clients always play all Montages.
Mรคh.
Obviously no warnings or errors in the log either
Guess I have to step through the code a bit
They don't like to listen.
Hello, I'm working on multiplayer game and I've got a question : is there any best practices for replication handling? I know about OnRep call back, but how do I handle moments when I try to get reference, that is not yet replicated from other object?
I'm using waiting macroc in bp rn but not sure whether it is good idea. For example, i want to get a game state at the client, but it is not replicated so how do i handle it?
the game state is replicated
are you working in code at all?
most of the functionality you'll want to use for networking is in code only
Generally speaking, if you need to be notified when a reference is available, you would set a RepNotify variable
Ah wait macro is not a good idea
i know that it is replucated, but u know, it takes time on the client to get it so it can be null at the moment of request.
So i just use delegates then? i mean i can use RepNotify, but only for fields, but how do i handle cases where i do not hold a filed in a class, just get it as a variable in the method
Yeah, a combination of Delegate and RepNotify
If it's invalid on Request, bind to the delegate
And broadcast it in the RepNotify
so for example for this request i need to hold a delegate somewhere?
not sure that i can ovveride some repnotify in bp
GameState is a bit annoying
Not possible no, certainly not per-connection. As for Replication Graph, the base implementation locks those values in initially. My advice would be to set NetUpdateFrequency to the lowest value you possibly can, then use ForceNetUpdate when changing properties. You can consider network dormancy too, but you have to be cautious as that can cause more overhead if not used appropriately (e.g, frequently entering/leaving dormant state)
I made that work via some C++
can u show you solution for this problem with GameState if it possible, please?
I made a UWorldSubsystem child, added a GameState pointer to it, as well as a delegate, setter and getter.
BeginPlay of my GameState, I get the custom WorldSubsystem and set the GameState with this. That triggers the Delegate.
Thats unfortunate, thank you for the advice though. I may just end up going that route
And in BPs I can then use the Subsystem to get the gamestate or bind to the delegate
(in c++ too of course)
@wet dock just keep in mind though the update frequency most of the time is only going to affect server CPU time, unless you're changing properties at a high rate too.
Thank you, that cleared my mind a bit about all this replication stuff)
Hmm ok, will keep that in mind as well when looking into it
I still don't get why my ListenServer refuses to play the Montage on a Client's Character.
They both seem to enter the PlayMontage code just fine. LogAnimMontage also seems to print properly. What the..
Reload montage plays just fine
It starts working if I call DetachFromControllerPendingDestroy on death, but that f*cks with all sorts of other code that expects the pawn to be valid while dying.
Do interfaces replicate?
no( why? that hurts
Interfaces can't have UPROPERTY()'s at least
So there's not really anything to replicate
What do you mean exactly by whether interfaces replicate?
I mean can i get obj that implements interface on the client?
Oh, yeah totally
That information is already available to the client, doesn't matter if it's replicated or not
i mean can i get an object from the field, like this ? Coz the array is empty no matter what
Oh I see, no that won't work.
Interface pointers can't replicate, but just replicating an array of actors would do it
i hate my life) Seems i need to rework it again)
Then you just recheck the interface implementation on the other end
To be honest, the engine could do a better job here of not letting you mark stuff as replicated unless it's actually supported.
Still baffles me they haven't done something about that. Marking variables as replicated in widgets for example... wtf why.
XD
I thought about other solution (kinda weird one) . I thought mb i should create an actor that implements that interface and use it instead) Make the abstraction for the abstraction)
Shouldn't need to, that defeats the purpose of the interface then
Just have an array of actors, and cast/call the interface functions on each end of the network
yeah right) Thank you)
Btw is it better to just cast to interface or check it via " Does implements interface"? im just not sure why this function exists when there is a cast to. Mb there is some trick behind this function?
In blueprint at least I don't think it matters which you use but I'm not entirely sure
In C++ you can only Cast if the interface was implemented in the native class
Since it doesn't know about BP implementations
Got it, Thanks)
Anyone tackled a ledge detection/climbing system lately?
Wondering if there are any straight forward ideas on how to implement that smoothly, probably with the CMC in mind.
"Simple" run up wall and grab ledge for starters
Glass was doing something with ledge detection couple of years back
even posted a tutorial for that
or, rather, the entire project
Yeah looks more like general covering, not climbing
think he still needed to detect ledges
Probably traces, which is fine. Mostly interested in how to tie that into the CMC.
It's a bit sad. You really have to go away from UE4 to find something else than a BP Tutorial.
Overgrowth seems to use a sphere and cyclinder collision, which would be a capsule for UE4. Looks cool
The other thing I'm worried about is Root Motion. I'm not using that and I often feel like if you aren't using Root Motion, you will have a hard time with stuff like this. Specially the "push up" logic.
And Root Motion + Multiplayer is another story afaik
GameplayTasks can handle root motion
we are using them for trickier movements, like jetpacks
Sounds pretty involved if that isn't setup at all though?
i don't know too much about them, Kaos implemented that system and we were too swamped for code reviews
but it looked fairly simpel to implement
as in, the next day the GameplayTasks with RootMotion were working
Wasn't your project using GAS?
Hey Guys, so I'm working on a multiplayer project, currently trying to do an inventory system. I had it working before, but for some reason I'm not sure what I changed and it just stopped working. That said I feel like I'm not doing it the correct way.
Starting in the inventory WBP
Which goes to the Player Controller as a owning client event, to then call a server event also on the player controller
Server event on the player controller
Which then goes to the GameMode
What would the correct way of doing this be?
Random question, why is Net Cull Distance always squared? What is the benefit of that?
So engine does not have to calculate the square root every single time they calculate distance to an actor. They can omit that because they can compare it with squared Net Cull Distance
Thanks, it feels like an odd optimisation but it does make sense
I have made a game with the OSS and the SteamSDK. I want to just play with friends online. Can I use the default ID that the Steam Example project uses (Spacewar) or is it illegal or something?
how do i remove all the widgets of one player's screen only?
remove all widgets seems to only keep removing the server player's widgets, no matter which player is calling it
You probably don't want to do it this way. You're opening up an avenue for cheating as you're letting the client tell the server what "item" it is they want to give directly. For example, if I was keen on packet or memory manipulation, I could inject what the item is and the quantity of them before it reaches the server, giving away items that may not even exist at all in my inventory.
At most, the only things that the player should be able to tell the server about the item to transfer is a reference to the container it is in (in case you have multiple inventories of some kind), an inventory slot # the item is in, and a possible quantity, and after you're on the server side, the server should verify the contents/quantity and perform the transfer based on what the server has in memory for your inventory.
It's also very difficult to tell where you may be encountering an issue with your system as there's too much behind custom nodes in your CE_REQUEST_GiveItem event, but you haven't defined the "Destination PID" on the CE_PC_SERVER_GiveItem event path but you are trying to use it within CE_REQUEST_GiveItem, so that could potentially be why it's not working currently. Otherwise, based on your intentions, it looks like it would work.
If I understand it correctly, it's ok to use the Spacewar ID so long as you're not trying to sell / release the game.
Oh ok then thx for the answer.
Are you calling it on the player controller or character on a "Execute on Client Only" event?
before i wasnt so it would clear the player that pressed it and the server
but now with this whenever any player calls it it will only remove the server's ui
ok after i changed the spawning from not replicated to run on owning client it seems to remove both the player and the server's ui
Hey nerds, I am trying to send a command from the client to the server through the game state. The idea is the client should be able to designate a movement position with their mouse, and then the blackboard should capture that position as a FVector. My code works for the server player, but client players are not able to execute. All characters on the map are controlled by an AI controller. here is my code
I capture "selected actors (characters)" in my PlayerController ; do I have to replicate these to the server so that I can pass them properly to the GameState? In my game state class I have a function that gets the AI controller from the selected actor. Getting AI controller from passed selected Actor yields nothing if it is owned by the client, I believe? but the Gamestate is supposed to be on the server, so I am getting lost on what to do next. I am able to get all functionality to operate from the server per usual, but not this not now
Player Controller .h:
UFUNCTION(Server, Reliable,WithValidation)
virtual void MoveReleased();
Player Controller .cpp (SelectedActor is created in a different method)
//Get click location as MoveLocation variable
/*Loop over selected actors*/
gamest->SetManualMovementBPKey(SelectedActors[i], MoveLocation);
/*End of Loop over selected actors*/
So right now SelectedActor[i] is not replicated, only client side. So,...
In my GameState,
header
void SetManualMovementBPKey(ACharClass* Selection, FVector location);
and gamestate .cpp
void ARTS_GameStateBase::SetManualMovementBPKey(AFTS_Droid* Selection, FVector location)
{
AAI_ControllerClass* aic=Cast<AAI_ControllerClass>(UAIBlueprintHelperLibrary::GetAIController(Selection));
aic->SetBlackBoardKeyObjectValue(location);
}
and finally in my AI controller class:
header
void SetBlackBoardKeyObjectValue(FVector location);
.cpp
void AFPS_AI_Controller::SetBlackBoardKeyObjectValue(FVector location)
{
GetBlackboardComponent()->SetValue<UBlackboardKeyType_Vector>("ManualMoveLocation", location);
}
When I run this on my server window, the blackboard value is set properly! success! but when I use the client windows to try this, the blackboard key remains null for the selected character. Any advice?
server RPCs can only be called by clients who own the object they are invoked on
check the logs, you should see warnings about it
You would need to tell the server which actors you're interested in moving. The server should then verify that the player wanting to perform the move actually has permission to control the selected actors.
That's the _validate() suffix'd method, right?
From what I know of it, yeah. XD I've never used it myself yet.
if _validate() fails, it will kick the client, so only use that if you are really sure the client is doing something wrong when it fails
In my code above are there any minor tweaks I can make to it that will make it work, or am I just missing some giant sweeping concept here? I have to go slave away for my corporate overlords soon so I'll try to review responses and get back to work in the afternoon
Sqrt is slow, so if you're just comparing 2 distances to see which is bigger, you can skip the sqrt and save some CPU
I understand sqrt is slow, but pow2 is quite cheap. So I would assume the engine would ask for Cull Distance and do pow2 on it on runtime.
Hey, I'm using CharacterMovementComponent and I trust my clients for replicating their movement. Any clues on how to setup CMC to support client-authorative replication?
These two options (also available within the class default settings) can make the client authority on the CMC.
anyway to bypass the 'advancedsessions is not compatible' error when packaging causing a cook to fail? I use it in UE5 and it works perfectly fine when testing. Does all the things is normally does without a problem. So obviously it works.
nevermind fixed it
I just had to change the engine version in .uplugin lol
@gloomy tiger What's your use case? That sounds like a weird way to do things.
@dark edge Thanks for asking. Well, we are pursuing ways to decrease multiplayer lag.
And it's a hard guess that trusting clients when it comes to movement might improve it a little.
It might save you from some corrections, but that might be it
It still sends the data to the Server
And it still replicates it to the simulated clients
Yep, I mean - we are trying to tune all the things we can.
Our biggest bottleneck is when it comes to zombies. We have a hard-limit of 50. When 50 zombies are spawned, it's a big nightmare.
They follow players which are replicating their position very often, and as such, I suspect that when a player changes its position, our zombies are also updating their position/rotation and replicating back.
That's a big, big, big nightmare.
By the way - do you guys have any suggestions here?
(Zombies are using CMC)
whats that command that shows the debug collision of teh character when trying to sprint on the server
...lol
How much would be considered a 'lot' of outgoing bandwidth >.>
Weird. In my packaged build the physics of objects and sprinting of characters stutters
but in editor it works totally fine
with multiple clients
Is GameState around on the server when GameMode calls InitGame?
Trying to avoid having duplicate properties stored on the GM from the Options string that are then used later to set GameState properties
Just would like to set them directly on InitGame
Sprinting..... You testing with network quality simulation?
I'm guessing no
Not sure, but you have InitGameState you can use
And having the duplicated is not really a problem and more or less how Epic does it too
Ok good to know thanks!
Yeah ok, thanks for the response. I think I do want to change it up a bit to have less stuff coming from the client like you mentioned. The destination id is just because I'm sort of half way through trying to fix it. The issue I was having is that when passing through a reference to the clients Player Controller, I wasn't able to get variables from that player controller on the server, it just wouldn't return anything.
Will keep duplicate params. Is it common to use the GS version as the main one for queries though? Just so you aren't referencing different properties that are the saame thing which could make tracking down bugs harder?
Well, google the average upload of a use and divide it by the amount of clients you can have in your game.
I usually stick to GM when it's server stuff and GS if it's for clients and visually
Then GS is fine
It really shouldn't matter
wouldn't overthink it
Do what feels best
I could also just cache the options string in InitGame and later on extract the relevant vars and directly set them in the GS I suppose
That way no duplicate params and no guessing if GS is up
ListenServer is a player that hosts and acts as the Server
If that player leaves/quits the whole server dies
I usually extract all I need from the String in InitGame and then set the stuff that clients need to know in InitGameState.
But sure, you can do that too if you want
The OptionsString should already be cached
No but you should have the options string
It exists in BPs, so there should be a variable that is literally called OptionsString
Haha yup there is!
In AGameModeBase
Thank you
No need to extract EVERYTHING in InitGame anymore, just server stuff
Can just get all the options at a slightly later point
Many thanks for the help
Well a Multicast in a playercontroller doesn't make sense
It only exists on server and owning clients
So servers will only call this once
Hello. What is an ideal way of getting movement acceleration in an online game? I tried using AddForce/Launch Character to Move a character but when I set replication to true, the clients just jitter while the server is able to move. The clients can also see the server move as expected. I am using blueprints
@boreal geyser adjust the acceleration settings in the character movement component
hey peeps, trying to replicate an animation
heres what i have done
i have a float which is my reloadTimer, this is a replicated float
i then fetch this float in the anim BP and if it is greater than 0 i set a bool to true (isReloading)
and then my animBP state changed acording to that