#multiplayer
1 messages Β· Page 732 of 1
Think of like this, the normal way a client can start the attack is by triggering the default action. Probably mouse click or something, and you have setup clientside logic to check if they are dead or not, great. Keep that stuff.
But a cheater will attempt to bypass the default click action to start an attack and will just call it directly by modifying the memory. This means they can skip the is not dead check and call Attack as many times per second as they want to. So you need the server attack event to also check if is not dead = T or F. @vagrant grail
nobody ?
You need to properly serialize the data for it to be passed correctly
(or at all? someone with more technical knowledge would have to answer that)
serialize is not means to just reduces the size passed on the bandwith ?
yes, it'll reduce the size. I don't think it'll send items without being serialized? Again, someone else would have to answer those specifics
It isn't just compression
thank you π
Most everything that 'does' things should be done on the server
Regardless of whether you have an AActor* in a struct, or as a loose property, it is treated the same way. The pointer itself is a location the actor exists in the client's memory. This is useless to the server machine. So when a pointer to a replicated object is sent, it is converted to a net addressable ID, which the other machine(server in this case) can use to find that actor in it's own memory, and thus convert it back to a pointer from the net id. This netID is the same as a loose property or in a struct.
remember that the server and client both have copies of the pawn, controller, etc. So the server should be seeing everything the client is doing and not need a lot of feedback from the client outside of what's available through movement and input
alright, thx π
What would be the best place to create a standard health widget on the client? I'm doing it in my PlayerController's OnPossessed function, but only the server is getting the widget created. On Standalone it works fine as well.
Here's my current implementation. It's super bare bones atm
a HUD class is typically used to manage this (you can spawn your UI in its begin play)
OnPossess gets called only on server, so it's only needed for a host player(aka listen server player), so you can do an IsLocallyControlled check on the possessed pawn, if yes do what you're already doing(or more correctly call the HUD event that does the creation of the widget). If not, do this: #multiplayer message
As said above, HUD is the class that typically manages widgets and creates them
Or in case of BP, a client RPC inside OnPossess to trigger the HUD event to create the widget
HUD
Anyone got any insight into this?
[2022.07.13-19.16.20:125][ 99]LogNet: ReplicationDriverClass is null! Not using ReplicationDriver.
[2022.07.13-19.16.20:125][ 99]LogNetCore: DDoS detection status: detection enabled: 0 analytics enabled: 0
[2022.07.13-19.16.20:126][ 99]LogSockets: Warning: SteamSockets: Cannot get information on an invalid socket handle, returning null
[2022.07.13-19.16.20:126][ 99]LogNet: Warning: Could not create socket for bind address 76561198033513709, got error SteamSockets: setsockopt SO_BROADCAST failed (0)
[2022.07.13-19.16.20:126][ 99]LogSockets: Warning: SteamSockets: Cannot get information on an invalid socket handle, returning null
[2022.07.13-19.16.20:127][ 99]LogNet: Warning: Could not create socket for bind address ::, got error SteamSockets: setsockopt SO_BROADCAST failed (0)
[2022.07.13-19.16.20:128][ 99]LogNet: Warning: Encountered an error while creating sockets for the bind addresses.
[2022.07.13-19.16.20:128][ 99]LogNet: Warning: Failed to init net driver ListenURL: /Game/Maps/MixtapeMansion?listen:
[2022.07.13-19.16.20:128][ 99]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = NetDriverListenFailure, ErrorString = , Driver = GameNetDriver IpNetDriver_0
[2022.07.13-19.16.20:129][ 99]LogNet: Warning: Network Failure: GameNetDriver[NetDriverListenFailure]:
[2022.07.13-19.16.20:130][ 99]LogNet: NetworkFailure: NetDriverListenFailure, Error: ''
[2022.07.13-19.16.20:130][ 99]LogWorld: Failed to listen:
[2022.07.13-19.16.20:130][ 99]LogNet: DestroyNamedNetDriver IpNetDriver_0 [GameNetDriver]
[2022.07.13-19.16.20:131][ 99]LogNet: Error: LoadMap: failed to Listen(/Game/Maps/MixtapeMansion?listen)```
Steam socket/subsystem plugins are enabled, added module names in the build.cs, edited the ini file to what the docs said, not sure what other setup is needed
Really the whole lack of documentation around this stuff is a real bitch
You better ask in #online-subsystems
Okay thanks! I've heard some talk about HUD and UMG, and I've heard some talks on older forums that using UMG only is preferred? I've been seeing a lot of conflicting info on that, at least where I've been looking
any chance y'all know how to keep the player pawn around when they disconnect? what i need to override?
is it AGameMode::Logout?
Correct. HUD is a legacy class where it used to be the one doing all the drawing on screen stuff and all that legacy bullshit until UMG came to the scene. Still that doesn't make the HUD not useful as it still proves itself as a good container and manager for all UMG widgets as it exists only for local controller @dusky scaffold
Ah okay, thanks!
If you want to make it persist seamless travel you override APlayerController::GetSeamlessTravelActorList and add it to the list
So I just make my widgets using UMG and use the HUD as a container to store them
Sounds good
Unless you wanna bother with Slate you're welcome too
Is there anyway to get network insights with PIE?
Might not be a bad idea to check out Slate at some point. I'd like to get a long term solution set up for dealing with HUDs, but the HUD/UMG pipeline sounds fine for now
Haven't touched Slate though so I know next to nothing about it lmao
You better know nothing xD
No to be serious UMG is just a wrapper around Slate and it was built so you don't have to mess up with Slate. But once you get better at UI and you feel that some functionality is "lacking", you start getting your hands dirty with it, though it's ugly as hell
I like keeping things Simple and Cleanβ’οΈ, so I'll cross that bridge when I get there
lol
That's our secret.
Have no UI.
Make everything diagetic.
Just opinion, it is not a implementation just yet;
I'm just looking for better idea, now i am making a recipe system into the multiplayer like a simple quest system.
the FocusedRecipe, which is a active recipe is currently progressing on
Recipes which is array of elements added by players..
When the player adds any recipe from the UMG button, i'm willing to call my game state class function from owning player controller something like AddRecipeToThePool(FRecipe..) which adds an element to the array. and i will also thinking to implement the FocusedRecip on PlayerState class, i don't know to be sure about that. I don't quite sure how kind of system i get in conflict if I added FocusedRecipe in the PlayerState instead of Character.
Looking for any better implementation ideas @dark edge I know you good at this
So how would you implement something like a basic quest system, which the players can add own quests to the quest list and focus only one in terms of multiplayer and sync in together somehow, that's kind of what I'm looking for.
I have that
some structure to represent everything you need to know about a quest/recipe
Yeah
ok so the pool is public and shared right? I can just make one and everyone sees it?
Is it mine or the game's?
It's public for everyone, no team's included. let's say all recipes/quests that we know.
anyone know how to get a list of currently connected netconnections?
On server shouldn't that just be the Player array?
all the playercontrollers
yeah, youre right
i am SO dumb
thank you
i put things in the PlayerState if i want them to persist even if my pawn is destroyed and i'm okay with other players seeing it. i put things in the PlayerController if i want them to persist even if my pawn is destroyed and i only want the current player to be able to see it. i put things in the Pawn if i'm okay with everyone seeing it and it's okay if the data is wiped when the pawn is destroyed. hope that helps.
Hi! does anyone know of any reason as to why this replicated variable is not valid in this case? if i check it from some other place, it's valid.
i think it's something really easy, but i may be too hammered right now, i'm gonna check tomorrow.
What class is this?
Found it, spaggheti code of mine
i tought i wasn't destroying it before that at any point, but i'm doing it.
It shouldn't matter as it seems it's getting executed on server(like down below in PC class)
yeah, but i'm destroying that variable before executing that piece of code
Ah that's β£οΈ
i'm gonna quick fix this and go to sleep, i'm too stupid at the moment to miss that one π¬
hi guys i made an online project in ue5 using advanced steam sessions. In my project players connect to lobby then game map with server travel command. Inside editor it works great but in package server is travelling but client is disconnecting when server executes servertravel NewMap Command . Anybody has seen this problem ?
sup. i need to somehow disconnect a player when they've failed some kind of validation. i see here NetConn->Close but it's deprecated. i'd love to give a reason, but i'm unsure what the API is. anyone have examples of NetConnection::Close?
these structs are in UE::Net and i'm not sure it's usable within my project
unresolved external symbol "__declspec(dllimport) wchar_t const * __cdecl LexToString(enum ENetCloseResult)" (__imp_?LexToString@@YAPEB_WW4ENetCloseResult@@@Z) referenced in function "public: __cdecl UE::Net::TNetResult<enum ENetCloseResult>::TNetResult<enum ENetCloseResult>(enum ENetCloseResult)" (??0?$TNetResult@W4ENetCloseResult@@@Net@UE@@QEAA@W4ENetCloseResult@@@Z)
unresolved external symbol "class UEnum * __cdecl StaticEnum<enum ENetCloseResult>(void)" (??$StaticEnum@W4ENetCloseResult@@@@YAPEAVUEnum@@XZ) referenced in function "public: __cdecl UE::Net::TNetResult<enum ENetCloseResult>::TNetResult<enum ENetCloseResult>(enum ENetCloseResult)" (??0?$TNetResult@W4ENetCloseResult@@@Net@UE@@QEAA@W4ENetCloseResult@@@Z)
oh i just had to depend on NetCore, disregard
π
Does anybody know why
FString ConnectString;
SessionInterface->GetResolvedConnectString(TargetGameSession, NAME_GamePort, ConnectString)
Would return the correct IP address but a port number of 0? It's preventing me from Client Traveling :/
Looking at the code for the Blueprint Nodes, they do exactly the same thing and yet somehow that returns the correct Port. What am i missing?
idk why the functionality differs, but try the Kismet equivalent of whatever node you're using
Would it be valid to store a player's health in the PlayerState instead of the Pawn?
It is, but it just doesn't make sense as it's pawn related
And you can always access it from PS
PS->PawnPrivate->GetHealth
Ah, thank you!
Is it the player's health or their pawn's health? Depends on your design
The player's
For my purposes both would work but I'd prefer to keep the health in the Pawn for ease of access
The question was more hypothetical π
If the players have a shared score, do I store that "score" variable in the gamestate and use the game mode to update it? or do I use the game state to update it?
By shared score you mean so other players know about it
There's one already in PlayerState
Use it
Personally I would handle everything in the game state (scores more apply to state than rules, you know what I mean?)
The GameState is available on clients and the server while the GameMode is only available on the server, so updating on the GameState may also be easier (though I'm not sure)
Not individual scores, a total score. It's coop so the whole team shares one score. So when one of them scores points, I need to make sure everyone has the same score.
Ah ok then GameState
And no GameMode doesn't have to interfere and update it
GameState manages it on his own
Technically you can also make it into a subsystem. I remember that was the example Epic did when they made the live stream on subsystems, but can't tell if it's a good example
Prolly an overkill
I like to do GameMode/GameState much like PlayerController/PlayerState, with GameState being mostly data only
Score is state, How score is calculated might be rules
They should have called it GameController instead of GameMode
True yeah there's a ton of overlap
@dark edge Follow your heart fs, whatever works best for you is the right way to go π
cant seem to get client damaging the server, server can damage client and death is replicated for the client. here's my blueprint
any help?
Why does that trace start from a run on client RPC?
Show your whole event chain from the input action / button press
it's from the event dispatch
gotcha give me a sec
that's the only relevant stuff for the line trace, cant fit the rest haha
ok so why is this a run on ownging client event?
Might still work but that's unnecessary
Are you setting the pawn or playercontroller as owner of the weapon when equipped?
only the owner of an actor can call a run on server event through it
yeah, disappears whenever it's picked up and respawns on both ends so as far as i can tell it looks replicated
K show that logic for when it's picked up or eqipped or otherwise set as The Weapon
Why aren't you gating by Authority in this
You're doing all this code on server and client
didnt know i had to do that, do i put the authority switch right before everything?
Overlap -> if HasAuthority AND !bIsEquipped -> Cast OtherActor to MyCharacter -> proceed to equip
! is a boolean NOT
So if the overlap happened on the server, and the item isn't already equipped, cast otheractor to character, if successful, equip it
Equip being:
bIsEquipped = true, MyCharacterRef = OtherActor, Set Owner on self to be MyCharacterRef, other stuff like that
you should replicate MyCharacterRef and bIsEquipped
or at least MyCharacterRef
holding weapon variable is actually irrelevant, i was going to use that for a setup later
You can use that to control equipping instead of shutting the collision off
but whichever approach
Why are you setting right away? YOu don't know if its gonna be equipped yet
First check that it's gonna be equipped, which is when you have authority, you're not already equipped, and the otheractor is Character
ah, i'll just get rid of that for now
That will set the bool to true on each and every overlap with anything
it doesn't do anything atm
does this work? i put the set is holding weapon variable at the end
sure that looks good
make sure you set the owner of self to be the character during your equip logic
never done that before, just grab the set owner function and set target to my character reference?
also, seems i cannot pick up the weapon anymore
on the server or client
Hi all.
Within the Lyra framework I'm using Server Travel, which works, but (in summary)...
LogLoad: Error: Old World TestMap not cleaned up by GC! Object TestMap:PersistentLevel.B_GGMannequin is being referenced by NameplateManagerComponent.IndicatorDescriptor:
(root) (NeverGCed) GCObjectReferencer /Engine/Transient.GCObjectReferencer_2147482645
-> TObjectPtr<UObject> UIndicatorDescriptor::DataObject = (Garbage) B_GGMannequin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^ This reference is preventing the old World from being GC'd ^
I've unregistered the Nameplate Indicator before Server Travel and even tried to Destroy the NameplateManagerComponent (disallowed) without any change to the result.
Any ideas?
generally you get that when something on the blueprint CDO ends up saving the world as its Outer
also, nothing to do with multiplayer
CDO? Which channel would you suggest?
class default object
it doesn't matter you destroyed a NameplateManagerComponent instance, the template is referencing the World
Ok, thanks for your input Zlo, I'll take a closer look, it's all Lyra code that bit.
can someone give me any advised for mutilplayer ?
i dont know how to start making a mutilplayer game
https://www.youtube.com/watch?v=JOJP0CvpB8w&t=14s
I would first give this a watch, its okay if you dont understand everything. Just try to understand the core system a bit.
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
Then you can follow something like https://www.youtube.com/watch?v=GcZQ2o6LpDI&t=659s
In this series we will be explaining how to add online multiplayer to your games. First we are going to explain how it works, then we will go into creating lobbies etc.
In Part 1 we begin with the basics, explaining how replication works, how to test online multiplayer, and how to add sprinting to your online game.
SUPPORT ME
Patreon I https:/...
thanks u so much
How do i constantly replicate variable from client to server?
Should I have unrealiable server rpc called every tick?
Yup
hello guys anyone here ? i wanna ask if u dont know how to get player name in game after login via EOS ( epic account in game ) propably it will be same name as player have in his Epic account
can u help me ?
#epic-online-servicesmight know.
yyea but noone online now π
can you test LAN connections on the same computer? Like if I open two standalone instances, could I connect one to the other?
you can
Hey, I finished the bp multiplayer tutorial from epic, after the travel from lobby to gameplay level they load the player info structure within the player controller. I then cast to the player character bp,, to transfer this structure. does someone know why they use the controller for everything? is it relevant for the networkrefrencing. and how do you know what stuff you do in the character bp and what in the controller?
I do anything that has to do with the pawn in the pawn
Like if I was making GTA, the pawn would have the walking and shooting stuff, the car would have the driving stuff, and the playercontroller would just handle pause and map etc.
I looked into the lyra example and there is none of the old stuff. I dont understand anything. lol
please can anyone help with this 
the #online-subsystems channel is dead af
there is such little documentation on this it's unreal (get it?)
This is when I am creating a session using the session's interface, code below
FOnlineSessionSettings SessionSettings;
SessionSettings.bAllowJoinInProgress = true;
SessionSettings.bIsDedicated = false;
SessionSettings.bIsLANMatch = true; // change when using steam
SessionSettings.bShouldAdvertise = true;
SessionSettings.bUsesPresence = true;
SessionSettings.NumPublicConnections = 5;
SessionSettings.bUseLobbiesIfAvailable = true;
SessionInterface->CreateSession(0, FName("Host Sesh"), SessionSettings);
copy and paste the error in google. helped me always.
I have certainly tried this 50 times
Nothing helpful comes up
Like I said, I feel I have exhausted all the options I have
sorry I have no idea.
Steam isnt developer friendly, you likely hit issues with running in editor / localhost. Multiple hosts also trigger issues.
You could try compiling the game and test it with two PC's, both using individual steam accoutns. Perhaps it will just work.
Tried this with a friend helping, didn't work
Disable the lan match, and go for online testing rather.
Yep I did that
As an alternative, you could try compiling the ye olde shootergame which also has steam setup. And it's kinda lightweight as i recall.
@worn wagon here it says disable the plugins
Couple of things you might want to try as I recently used the Advanced Sessions plugins with no issues: Are you using the default game/app ID? If yes then you might be getting to many results and you should apply a filter[1]. This will make sure the results returned are for your game. (The picture is from an older version of the plugin but sti...
I would try the socket one first because its mention the the log
I've been through this thread and that indeed gets rid of the errors, but then it's not using the steam net driver. I need the steam net driver, right? It has nat punching and actually makes it work with steam
Otherwise won't everyone need to portforward
in the tutorial I watched he said to add something with the steamsubsystem to he engine ini, did you do this?
ye
I tried man.
Na I appreciate it π
Ghetto, the nat punching is only required when the host is behind an complicated nat. For some people it's as easy as getting a port opened in the home router, and the ip/port becomes available. But for general speaking, it's better to have auto nat solution such as Steam yes.
I'd suggest you give a go with shootergame demo (or lyra?) as they have steam setup ready to launch. Once you get these demo games to run between you and friend, you'll get a strong starting point for figuring out the missing pieces in your project.
As it's not a dev friendly environment working with steam, you are expected to having a whole bunch of troubles until you get it right.
Hence the demo games, may give you a little help, without hiring experts for the task.
I'll give it a try if my next test doesn't work
A nice man in the #online-subsystems channel has said something helpful
Hey, little question about the debugging tool in multiplayer, I guess to have one PC for the server and 2 PC for the client (one for client, one for server)
This is a listen server setup?
it is
Yeah so server sees both players controllers, while the client only sees their own
so 3 total
Hi! does anyone know of a way to lower the graph settings when simulating on "Standalone"?
I have it low for editor, but when i play a level on standalone, i get max graph settings
You mean graphics settings like the scalability settings?
Yeah, but for the other windows, not the one on the editor
already found a fix
there was no fix, the graphics was not the cause of my performace problems, it was some error on replication
Any way to get "HitResultUnderCursor" from the client while being on the server?
i'm doing an RPC on client that updates a variables with another RPC on server with whatever it's undercursor, but it looks like a total mess.
Does the server need to know that ALL OF THE TIME, or do they just need messages like
"I clicked that actor"
You can certainly spam a hit result at the server every frame, but whether or not you need to is up to you
it's for my "Interact" Interface. I want to keep it as generic as posible, but some actors need that info
Only do it on Interact
Just pass the actor you want to interact with over to the server, it can do a distnace and LOS check if you want, then do the interaction
Nah I wouldn't do that, that's a lot of bandwidth for zero gain
maybe for a multiplayer painting game, but not for this
That's my current setup, it's awfull
Just do the RPC between the input and the interact call
so i can just ask on server side "give me this client hit result under cursor"?
Nah just tell the server who you want to interact with
it's a little bit more complicated than that
What's the exact use case
i have a big object with all the tile floors, they are components of some actor
Is interacting continuous or does it happen when you press a button or whatever?
You can pass over the specific component
i'm kinda wanting to keep as generic as possible. All i pass now is "Actor trying to interact".
so when you interact with the floor, it checks your hit under cursor and gets the corresponding component
with that it checks if your character is on that tile
Just send over the hit result when you press the button then
no need to send 100,000 of them over and only using 1 of them
i'm not updating it on tick, only on request
i'm gonna try and update that before the interact on the PC
I'd just send over the hit result with the interact
one Client-Server RPC
not a back and forth
Nvm, i just found there's some other problem first with how the actor is replicating.
i'm getting nothing when checking "HitUnderCursor" on the client, even when the actor is replicating.
Where's the best place to store and fetch a player's Steam Avatar, Player fetch themselves in PlayerState, then have whatever actor that needs it call the PlayerState by Controller?
PlayerState. Accessing that property on PlayerState varies from one actor to another
Got it - Issue I'm having now fetching it this way is I think Server isn't pulling it correctly but all Players are. So maybe I'll just set a special condition for Server. GameState fetches it for Server successfully. Is that okay?
It's always some combination of Server fetching successfully, vs all Players. Then GameState can fetch and store everything BUT the image itself for Players.
Why not just replicate it?
It's more an issue of where it's fetching from initially.
All data except the image propagate fine through GameState OR PlayerState.
If the property is being set on client then yes the server has no idea what that is
Was mostly trying to figure out a catch-all for ALL Player + Server Steam ID info.
OnOwningClient (Fetchimage) -> RPC on server (SetImage)
If you need to fetch the image from player's local files.
Hey, i am getting a error when getting a replicated property on UMG widget construct.
what is the context of this? i don't see why just don't do it on playerState begin play
Lobby system with Player info in the map, and I do - But it doesn't work for Server. Only Players.
ensure(Stack.MostRecentPropertyAddress); // possible problem - output param values on local stack are neither initialized nor cleaned.
where are you getting the Steam Picture? Api call, local files, ?
This is engine code, so no one would tell you what's the issue without seeing the call stack.
But in your case you are getting a replicated property early on. OnConstruct gets called several times. Use OnInitialized
Advanced Steam Friends Library fetch by Unique Net ID
please show me your call to set the picture, it should be perfectly okey with setting the prop to replicate and just change it on server
Oh and yes what do you mean by replicated property? UMG is client only?
Is the replicated property in the UMG class?
No
I have TArray<UObject*> replicated property in game state, i guess UObjects is not involved to replicate. It may be problem.
It's on my gamestate
Yes that's the issue if you haven't made your UObject class to support networking
Wait, maybe I need the 'Request Steam Friend Info' to preload first..
this is my setup on "character"
TLDR: #multiplayer message
put a "Has authority" after begin play and continue from "Authority" pin.
Check if UniqueNetid is valid (with a print) and also if the avatar is returning anything or of it's empty
Yeah I think I'm running into some race conditions with the load too.
whatever you need to set with the load, put it as a variable with "OnRep" and call the avatar update on that OnRep
Good idea
Just in case you are quite new to multiplayer, check the multiplayer compendium by cedric, it's on the pinned messages
I will work on Actor-implemented solution. maybe a just a ordinary actor with just a simple properties for replicating.
Speaking of new to multiplayer.
I'm having troubles with this actor (the hexagonal tiles)
I'm doing a "get hit under cursor" and it hits okey on server, but it doesn't hit at all on client.
The floor is set to replicate, the main actor is spawned on GameMode and each hexagon is a static mesh that i add when the actor floor starts.
Whatever fits best your needs. Actors support networking out of the box, but some people find them too much of a boilerplate code for what their needs are, so they use UObjects
Does anyone know why the "Hit Under cursor" is not hitting on client?
This other actor uses the same method to check with "HitUnderCursor" and works okey on both Server and client
π§
i also found that some hexagones are not replicating correctly, like the trees.
if anyone has any idea on why this things may be happening, i'm open to suggestions. I have run out of things to check
How can I debug voice chat? I'm trying to use 'stat net' but not getting much info from it.
Hello boys, If I change the charater collision inside the PC, do I have to change on server and on client? For now only have a custom event run on server setting enable character capsule collision. Because as u can see, the client on the right side is on falling mode. but he is not really falling because (I think) the server already set his collision capsule to enabled.
yes, you need to do same on client. body props are not replicated
i'd recommend use of NetMulticast for that
is the pawn movement "floating pawn movement" not replicated at all like the character movement component?
How does server/client garbage collection work in live games? In the editor, objects show up in the object list even if they are client side only. I take it that live game is different since certain objects only exist client side, and client side garbage collection takes care of those?
Trying to track down some garbage collection crashes, wanting to rule things out.
How do you know its a GC crash?
The crash log has "GarbageCollection" scattered all over it.
From what I can tell, its related to Dynamic Material Instances.
I didn't realize I was created them on the server until recently. Just wondering how GC is handling cleaning them up on the client and if they're stuck in memory on the server if I do something to replace an existing one with another. I haven't confirmed there are any pointers to the old ones yet though.
Can you change the rep condition in runtime??? ugh o_O (btw old msg because I was reading all the nonsense with OverrideWith)
FVector2d ViewportSize;
GetWorld()->GetGameViewport()->GetViewportSize(ViewportSize);```
This causes a crash when I play as a Client. But does not crash when I play as Listen Server. Why is that?
Use the debugger
Hi - If I attach my player to a character. Then play anim montage to that character. It appears shaky. Any idea why?
@bitter oriole Its because GetWorld()->GetGameViewport() ptr is empty in as Client Mode. Why is that?
Probably not created yet
When will it get created?
No idea. You probably want to check the timing for that
Nvm, it works when I just check for the ptr if its null.. after that its works somehow
Any ideas where to look?
I mean it looks like something didn't replicate yet and you have to wait later to call that code, using an if like you mentioned
Ok, I never made a multiplayer game. I assume by your answer, that this is usual procedure to solve such a problem? I am just worried that I may missed some other underlying problem
In multiplayer you can never assume any timing, that any given object has replicated, that properties replicate in order, or at all, etc
So you have to get defensive and rely on passive, observational approaches, like "hey this is valid, let's do stuff on it"
I understand, thank you.
you can assume one timing
GameState has replicated before any Actor on Client calls BeginPlay
How is listen servers in unreal? Anyone using it in prod for mobile?
Again?
Hi, how can I replicate the structs, actors and UObjects in the replicated TArray<ASomeActor*> declared in my GameState?
I have this on my GameState
Adding an element using RPC on the Server
The array of itself is replicated.. but not the actual objects in the array.
Ok, i got the answer
Structs, replicates only Struct members that have changed.
Is it recommended to use Object Pooling in a multiplayer game? If yes, do you have any resources on how to implement it?
and same kind of principles for replicated TArray<>
Hey! Anyone have the top secret scoop on what Iris means for the future of Unreal replication? Commit here:
https://github.com/EpicGames/UnrealEngine/commit/4aae8d3ed0bc8c1a6c293c780413e2c5f35150e8
Also has an overlap with the experimental Network Prediction plugin:
https://github.com/EpicGames/UnrealEngine/tree/ue5-main/Engine/Plugins/Runtime/NetworkPrediction
(Although, not a huge overlap with NP, but kinda wondering if it all ties together)
We are creating mm survival game. We use ue5.0.1. Game depot is on steam (not public) but we can download it from steam internal testing. We would want to make dedicated server up to 100 players. How should we do that? create server and upload it to steam and make that steam host it? We have already tried local server "port forwarding" but we want to test how it works with steam server + overlay etc
we also use source version of ue5
with what i estimate your current understanding is, there is no way you can get 100 players on same server instance
that takes experienced network engineering teams
and no, steam does not host your dedicated servers
Okay thank you! What is then best way to host servers?
Start by leasing a cloud vm, upload the dedicated package to it and run it. Work on from there.
Connect via IP, once that works look at setting up Steam OSS
After that investigate uploading your builds automatically
So its work if we lease cloud vm. Then upload server build (same as we do local dedicated server) to there. How expensive those are? Do we need get investors?
idk, depends on the specs of the machine required to host your server. Should be less than $100 a month during testing.
Okay thank you much!
we have now "almost" working beta test game. Server did work nicely (local port forwarded) with 20 players. But problem is we don't have budget yet. And its very hard to know how many players we get after publish (do we need 5x 50 players servers or 20x π One solution would be to pitch for investors.
How do I attach the player to a vehicle in a multiplayer game? This event works fine when running as the listen server, but as the client there is rubber banding and other issues seemingly caused by the character's collision not being disabled
Start off with a single $20mo instance. You are way out of your element IMO.
And don't screw up your auto-scaling backend or you'll have a $500k/mo bill because you had a bug and requested 100x the servers you needed.
Okay thanks!
Does EOS utilize both STUN and TURN for their NAT P2P API? Steam provides "Steam Datagram Relay" which includes TURN servers. I'm assuming Epic also includes TURN given they advertise DDoS mitigation but I can't find any published details of their backbone.
yeah I'll head over there but figured I'd start my networking question here. I'm at the decision point of buying into either the epic or steam networking ecosystem for crossplay
look up multiplayer vehicle movement prediction
it is attached, the client is just not in sync with the server copy
is there a process for hiding an actor that is not close to the client so the client get more FPS?
Relevancy
It's part of the engine
Edit the relevancy range to your liking
You find it in the replication tab of the actor
We were prototyping a ship game and had a lot of WFT moments, as ships are HUGE and the default relevency range was like not even to the end of our ship
Whatβs the default distance again?
Thank you
225000000.0
so the only thing needs adjusting is the cull distance right?
Yes
Technically you can edit too many things to bring better FPS and less cpu stress
But this is a good starting point
I mean depending on how many actors are you replicating and how big is your map so all not every tool out there is needed. But you can look up the ReplicationGraph, PushModel, FastArrays, etc...
NetManagers too
How to replicate thousands of Actors efficiently (network managers):
https://vorixo.github.io/devtricks/network-managers/
RIP to a 150m+ multicasted sniper shot πͺ¦
Hi! I'm trying to replicate an Inventory Component (ActorComponent) but the Equipments property only has a null element in it, instead of the valid AEquipment* I was expecting.
The InventoryComponent is added to my CharacterBase class like this:
InventoryComponent = CreateDefaultSubobject<UInventoryComponent>(InventoryComponentName);
InventoryComponent->SetNetAddressable(); // Make DSO components net addressable
InventoryComponent->SetIsReplicated(true); // Enable replication by default
and the property looks like this:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, ReplicatedUsing = "OnRep_Equipments", Category = "SSP|Equipment")
TArray<AEquipment*> Equipments;
But when this function is hit, the array contains only a null element:
void UInventoryComponent::OnRep_Equipments()
{
for (AEquipment* Equipment : Equipments)
{
AddEquipmentInternal(Equipment);
}
}
The AEquipment constructor has bReplicates = true;
What am I missing?
Did you overwrote the GetLifetimeReplicatedProps?
https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/Actors/Properties/
Also how do you add to stuff to the array?
Also SetNetAddressable() is redundant alongside SetIsReplicated()
I did, first unconditionally, now like this:
void UInventoryComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION(UInventoryComponent, Equipments, COND_InitialOnly);
}
Blueprint call that in turn calls ServerAddEquipment:
void UInventoryComponent::ServerAddEquipment_Implementation(AEquipment* InEquipment)
{
AddEquipmentInternal(InEquipment);
ClientsAddEquipment(InEquipment);
}
AddEquipmentInternal adds to the array: Equipments.Add(InEquipment);
ClientsAddEquipment is a NetMulticast:
if (!GetOwner()->HasAuthority())
{
AddEquipmentInternal(InEquipment);
}
What BP call? Also are you aware other non relevant players won't be knowledgeable of the equipment on client by the time you RPC?
For testing at the moment, the character and the equipment is spawned, then AddEquipment is called on the character's inventorycomponent in the level blueprint (with a HasAuthority check first).
Not sure I understand the potential issues I might run into with regards to non relevant players.
Probably at that point the initial bunch has been sent already, that's why you're getting null. There is some specific functions(all called before BeginPlay) that you can add stuff to that array for them to be sent in the initial bunch
First oddity: looks like the Level blueprint is called twice (and the HasAuth is true twice) (not sure if related to my null-element issue)
(testing with 2 players in editor)
Level BP is some weird ass place to do such a thing tbf
Probably very true, might move it out earlier rather than later
I never use it, and most people don't
It's probably used for some specific stuff that you don't need to worry about for now
I might have misunderstood COND_InitialOnly to also send when a new player joins.
related to your point about the initial bunch
Well it gets sent to a new player that joins as the actor that has that property gets replicated to him. But my point was that you are setting the property after the initial bunch has bent sent, aka, after the actor has replicated for the first time...
Could that be solved by just doing DOREPLIFETIME instead of DOREPLIFETIME_CONDITION?
Could be. Easiest way to know is test.
Alright I had some fixing to do in that level blueprint, it's a bit more sane now.
Still don't know how I end up in this 1-element in the array, but it's null situation.
I have no idea what's going on in your level BP and it's prolly what's causing you issues
I would just add elements to the array in the character class itself
Anytime in/after PostInitialiseComponents
How much will it cost to run multiple service from AWS for a full multiplayer game with average 20000 players a day
Not sure if this is the right channel but what needs to be done before testing Steam in engine? Do I need to upload a build beforehand? Every time I launch the game in standalone itβs using LAN despite properly setting up the config files.
Thereβs a built in calculator for that on AWS.
I might try to cut out the level blueprint, thanks for the help π
My guess is like $10k a month though.
Source build? Hell nah...
I mean a packaged build uploaded to Steamworks
Steamworks is involved yes, I just don't remember the specifics
There's prolly 20 million videos on YT that tell you how to do it
Do you remember is thereβs a way to debug it? Iβm not getting any sort of error messages on launch to help figure it out
There arenβt π
Those are the only type of videos I suggest watching though
Not the other types π
Logs only
They should be telling you what subsystem is involved and such
Hi! one question.
My current map setup is a bunch of hexagons that have a ST with info about them in, all in one array.
The meshes are all added as "static mesh component" to one actor that holds the map.
Does anyone can think of a better way to do the mesh part? Without losing that each hexagone has different graphics.
Picture as a example below:
are you using advanced sessions?
if so, remember to build on "Shipping" and add a file named "steam_appid.txt" with a text that says "480" inside of it.
Yeah, it does.
right is the session hosted and left is the session browser, i can connect without problem with lan/internet
What problem are you having?
do you get the popup of steam when you open the game?
are you talking about the editor or when packaging the game?
the file is for packaging, let me share my setup, it's not that much
Search for sessions:
Join session:
and that's it i think, nothing extra.
Plugings:
Do you have steam open while doing this?
oh right, i forgot about that.
I have this piece of text added on defaultengine.ini
maybe try with 480 to discard that as a problem
btw: i'm using it on the editor as standalone with Internet mode (not lan) and it works okey even if i don't have steam open
I think i used this for the blueprints if i remember correctly:
https://www.youtube.com/watch?v=r3UWKE4x-6o&t=253s
In this video I show you how you can implement the Steam Advanced Sessions plugin, so that you can make MBLS work with the Steam Online Subsystem.
Steam Advanced Sessions Plugin link:
https://forums.unrealengine.com/t/advanced-sessions-plugin/30020
Unreal Engine Steam Online Subsystem documentation link:
https://docs.unrealengine.com/4.27/en-U...
and the oficial documentation later on to get more details
what is the reason for this error?
Maybe check the video tutorial from start and do all the steps, maybe you missed something
but it's quite straightforward, did you add the plugings to the engine?
Te recomiendo que lo pases a ingles, no te va a entender nadie en espaΓ±ol : P
Hey, has anyone been able to connect to Playfab Hosted Servers?
You don't have GetLifetimeReplicatedProps function implemented
Maybe the 480 modification
Does anyone know why this may be happening?
The "Is valid index" goes ok.
But when i try to grab the array item at that same index, it fails ._.
The index is valid, so it's in the array bounds, but the data hasn't replicated yet
Like here: #multiplayer message
That solved it, i moved the reference to the ST array and deleted the other array, thanks
trying to learn networking... Is there something wrong with my RPC? or is my problem likely elsewhere?
`void AWeaponBase::HandleFireProjectile_Implementation(FVector Position, FVector Direction, FRotator Rotation)
{
FActorSpawnParameters SpawnParams;
//SpawnParams.Owner = this;
//SpawnParams.Instigator = GetInstigator();
AProjectileBase* projectile = GetWorld()->SpawnActor<AProjectileBase>(
projectileClass,
Position,
Rotation,
SpawnParams
);
if (projectile)
{
//projectile->FireInDirection(Direction);
projectile->movement->Velocity = Direction * projectile->movement->InitialSpeed;
}
}`
The projectile is spawned client side but doesn't appear to other players
What kind of RPC is this?
I defined it like this:
UFUNCTION(Server, Reliable) virtual void HandleFireProjectile(FVector Position, FVector Direction, FRotator Rotation);
hopefully that answers the question
Is the spawned actor replicated?
pretty sure it is
Where is the RPC called from?
I have a weapon actor which is held by a character that calls HandleFireProjectile()
the function is called on the weapon
Yeah that should work then. Nothing weird I'm seeing
It doesn't matter if the actor calling the RPC is replicated right?
well I already tried both :/
replicated and not
i'll poke around some more to see if I can find the issue
good to know though, ty
Is any way to know, when replicating an array, what elements have changed? i would like to avoid doing another array to keep track of the pending modifs
i would also like to avoid doing a check on all the array elements when only 1 changed
There is no other way but to traverse the whole array and compare it with OldArray. Problem is in BP you don't have that OldArray param in the OnRep
In cpp you do
Though in cpp you also have FastArrays where you get replication callbacks for the items that replicated
i'll settle with a new array of pending modifications if that is the case. I'll change it later on when i do it on cpp
that sounds really neat
Last one from today, this one have been bothering me for 2 days.
On server the hit works oney, on client it fails.
it's a really simple check hit under cursor
Any idea why?
Probably an input handling issue
Perhaps not on the client game world or getting input taken by something else
The input is triggering correctly, the "GetHitUnderCursor" is ok, but on the client it just doesn't hit anything
I would just breakpoint GetHitResultUnderCursorByChannel in cpp and see what's going on
It works okey on the client for the chests, but not for the floor (the hexagones) there has to be something weird with the replication setup of that actor, but i can't figurate out what
Whatβs the difference between βToggleSpeaking 1β and βStartNetworkedVoiceβ?
Iβm trying to setup optional push to talk but all the documentation is geared towards one way only.
Are you just trying to figure out what hex they're on?
What do you mean by the get hit under cursor is ok but it doesn't hit?
Hello, would it be an issue to multicast physics movements for a vehicle, but make those "reliable". It's the only way we have been able to fix the jittery issue for a physics-based multiplayer vehicle.
But I also often heard reliable multicast are a big no-no
hello @round yew it depends on the frequency you are sending them
also sounds like an odd approach to replicate a physical object in a server authorative manner
usually you would forward input to the server, feed this input to your simulation
and then replicate back the result to the clients which will be dependant of your net update frequency
within those network updates you interpolate the vehicle to the next predicted position using the physical state replicated back to the client
Do i need anything besides UE and some code for Online multiplayer?
@round yew https://github.com/UnrealMultiplayer/4_Krazy_Karts take a look here
yes, you might need an online subsystem, dedicated servers, a backend service.... and lots of patience
Ah and does the online subsystem also take of the saving the player stats
some do, steam for example lets you save specific player data
for questions about online subsystems there is a dedicated channel #online-subsystems, it's a whole topic by itself haha
Yeah bc i was curious since Sea Of Thieves is made with UE4 and is adding fully customized ships and that u can save the layout so i was wondering how. \
I haven't played it so I don't know exactly how it works to guess what they might be using
but you can perfectly hook your oss ID to an external DB in which you store game data that you can retrieve at any point in the game
also Unreal does have a saving system that you can use
ah
Ik that it does but i am new to it
Hello, if i have a "Listen Server" and one "client" and at the start of a round i need the "listen Server" to know about a varibale from the "Client" wouldn't i use a "RepNotify" for that Variable? Im asking because i just heard in a video that RepNotifys are a one way stret and only work from server to client and not from client to server
The replication system is indeed only from the Server -> Client. You will need to use a RPC to send the variable to the server from the client.
Well here are the days i wasted questioning myself why i can't get repnotifys to work. π
I am having this position issue when the bots are far off from the player. It seems like there's a checkbox that tells unreal not to render far off skeleton meshes?
What I am facing is - The bots seem to be stationary but when i inspect the position of the bots it seems to be changing but not changing on the screen.
My guess was that the area is huge and it could be some issue with things not getting replicated properly because the bots are far off.
If my main character is near the real position of the bots then they seem to be moving correctly but far off they seem to be stationary but actually moving when i look it into the details window
I am playing it as client
any guess what this could be?
Probably actor relevancy. Actors that are far away from a client's controlled actor won't exist on the client's end. When the actor comes into relevancy range, the server will tell the client to spawn them and will be begin replicating the data to the client. When far enough away, they get despawned on the client. The distance can be set per actor using the "Net Cull Distance Squared" - the number usually needs to be larger than the units you usually use as it's a squared value. So if you wanted relevancy to be within 10000 units, you'd have to do 10000^2 which is 100000000.
thanks for it. I am trying right now.
so this net cull distance should be applied on the character or the bots?
I guess it should be the character?
worked Thanks for it
But why was it even appearing if it was not within net cull distance. It shouldn't have appeared at all in client 's screen?
The outliner you see on the side I believe is the server's view of things.
If you mean in the viewport, I couldn't answer that myself XD
Hahaha. It appears incorrect on both when i unpossess the player and move the camera or when i am controlling the player and they appear incorrectly on the screen
Whatβs the difference between βToggleSpeaking 1β and βStartNetworkedVoiceβ?
If i have a "listen Server" and one "client" i would have for each one "GameState" right?
Have you tried tuning the physics replication settings?
So they share the same GameState?
When i use the "debug filter" from UE4 in my blueprints i see "GameState Server,spawned" and GameState Client,spawned"
That should totally be pinned <@&213101288538374145> (apologies if it is already!)
It's shown in the network compendium that Cedric made (which is pinned).
Yes, they share the same gamestate. It is spawned on both the clients and the server, but there is only ever "one" that exists that is replicated from the server to the clients. Any changes to variables made while running on a client would only exist on the client. Any replicated variables or events modified or executed on the server will replicate to all client copies of the gamestate.
Ah ha, alrighty then!
Also this one is superior π
Nah.
π¦
I think the Venn diagram one is better.
hey, I am looking how to override the network version of client/server so clients built with another engine can connect
from what I've seen you can override it in the ue source but you can also do it via ini?
Lets make a message with both and get that pinned. Problem solved π
[OnlineSubsystem]
bHasVoiceEnabled=true
bUseBuildIdOverride=true
BuildIdOverride=12345
something like this
how do I find the build ID?
Network Version and Determining Network Compatibility This article was originally was published for UDN When connecting two instances of the Unreal Engine, there is an initial compatibility check performed during the handshake process to determine if the connection process should proceed. While there are later compatibility checks performed aft...
That's the diagram's underwear. We try not to look.
lol
Nothing
There is nothing that only clients share but server doesn't.
what if its p2p π
It's not
I can find a command line override for it, which to be fair is also mentioned in the post. But there doesn't seem to be any config file options for it in the source. You can however as the post also mentions override the behaviour from C++.
So then you can just make a config option for it your self.
Although I'm not sure why you need to override it in the first place. If there's a mismatch, which the engine already automatically detects for you, it will obviously cause issues.
@twilit radish can I launch a server with a command line override to not do the version check?
If it's your own hosted server I suppose yes.
-networkversionoverride= seems to need a value though, I need to set it to accept different client versions
as we have clients build with different engines ;/
If I spawn an actor, how do I get a reference to that actor since RPC can't have outputs?
For that you will need to bind to the C++ delegate so you can dynamically determine it. The command line won't do that for you yeah.
All the command line argument does is say "This is my new current version"
If you mean that your client knows about it you just send a RPC back to the client from the server with the spawned actor as a parameter.
But do know that it may not have replicated yet.
So you will need to make sure it actually exists on the client first.
Maybe I should ask what you're trying to achieve?
Also why are you building clients with different engine versions? That sounds like a horrible idea. All it takes is 1 Unreal engine networking change internally and you get a mismatch π
Like this?
do i even need the last event? or can i just tag it to the end
No. Because that will likely cause the issue that your actor is not spawned on the client yet.
Well this is why I'm asking what you're trying to achieve. Why does the client need to specifically know about the actor?
because i need to update that actor's transform after spawning it
when i do, it only updates for the server
Is the actor not replicated?
I assumed it's being moved constantly.
But otherwise it should just set the proper location yeah.
Also if the actor is not replicated then you can't even change it on the client in the first place π
@clear copper You should do everything you can on server and have it replicate out.
gotcha
If you must do stuff local instantly then you're in prediction territory
ah that makes sense
I mean prediction is not a bad thing, but in this case I think it's not the right approach yes.
Specifically what are you trying to do here? What's the mechanic?
its like Orcs Must Die trap placement. when you hover on a grid, it moves the trap pre-placement around. I was hoping to have the clients see the pre-placement movement. instead of just the final build transform
so when someone spawns a trap actor for pre-placement, it follows their mouse. I wanted to show that for everyone.
hopefully that makes sense
I'm going to do some more reading because I think Im just a little far beyond my understanding of multiplayer
I mean the mechanic makes sense to me. Just not sure if how you want to do it is the best way.
thats fair lol
Because ideally you already have an actor on the client before it's even replicated from the server to the client.
Otherwise you need to spawn the actor on the client and replace it with a replicated actor later on that also needs to replicate it's own variables.
Seems really unnecessary.
You mean spawn the actor, then replicate it?
No. The client that wants to place the trap needs to have an actor represent the trap before it even exists on the server.
or spawn hologram without collision before spawning actual building, like Satisfactory does
Otherwise the client needs to wait for the server to create an actor and replicate it down to the client, which is weird I would say.
side question, do I need replicate AND replicate movement checked on my actor?
ah ok
SF?
Oh.
But I mean that's what they are after like they said. They want a "hologram" that then later on gets replaced by the real deal. Right?
But the thing is the initial delay. You don't want the client to wait for the server to spawn the "hologram" actor, that would be kind of weird if you ask me. But maybe I'm just seeing that wrong π€·ββοΈ
hm, it is possible to spawn it locally and replace local temporary actor with replicated
spawn preview on client (save to variable on PC)
send RPC to spawn preview
recevie onrep when preview actor spawned on client
replace temp preview with replicated preview
if you really dont want that few frames delay
I have this two variables. One is set if you are the "listen Server" and the other if your are a "client" how do i send that variable from the listen server to the client and from the client to the listen server? I tried RPC and Repnotify but i can't get it to work
@clear copper Does it matter to you/your game that there's a bit of a delay between the hologram showing up for the client placing the trap?
Nope
wait
I got it
Then I would go with Aquanox's solution / the initial idea I suppose. I think a good way would be to RPC to the server that you want to spawn a "hologram", set that actor's owner to the client who spawned it and then when the "hologram" gets replicated to the owning client it can from that point on move the actor locally and then send the location over to others.
lmao all i had to do was turn on replicate movement
If you're trying to send it in the Game Instance (which your screenshot somewhat shows you might be) it won't work - you cannot replicate within the Game Instance as it only exists on the instance of the game that's running (eg. the server's instance is not accessible on the client's instance). You'd need to replicate through the player controller or some other client accessible class.
Replicate movement does lag behind for the person building the trap and has no smoothing (so I was told).
But is definitely a thing you can do.
It comes from the GameInstance but the screenshot is from the GameState
Yeah luckily for my purposes it doesn't matter. I could see it being an issue in other games though so I'll definitely have to keep looking into it to do it "right"
It just depends on how complicated and thus 'hopefully' smooth you want to make it I suppose.
Yeah, for initial functionality and testing purposes a simple replicate movement works fine. But no harm in making it better
Like if you want the full deal you would need to:
- Spawn a local actor and move it around.
- Then send a request to the server to spawn a hologram.
- Once the owning player gets the replicated hologram replace the local version with the replicated version.
- Mean while in doing this all constantly send the location up to the server and replicate it to clients.
- Smooth out the movement on all clients.
Which is much more complicated as you probably can tell LOL
So then it's a matter of sending those values from one place to the other. Again, the server won't know what the client's game instance contains, and the client won't know what the server's game instance contains. So at some point, you would have to send the client's version to the server, and the server's version to the client if they're both supposed to know what the deck contains.
If it works for now and it's just for testing don't bother with too much of the stuff I just mentioned. Keep it simple and if it's needed adjust it later on π
yeah true lol thanks!
π
Thats why i'm trying to do that not in the GameInstance.
The Variables are set in the GameInstance but i'm getting them from there to the GameState or PlayerController doesn't really matter to me, but hwo would i send them to the other
Ah crap, just noticed it only works when the server spawns it, not the client -_-
In general the approach is from Client -> Server you do a RPC. And from Server -> Client if possible with a Replicated Property and otherwise with a RPC too.
You use Server RPCs (Run on Server Events) to send data from a client to the server.
A server can either use replicated variables or they can use Client RPCs (Run on Client events) to send the data to clients.
What do you currently have as setup?
When the player spawns the actor, it calls these. After checking "Replicate Movement" in the actor's bp, it spawns and follows the player's mouse. But only if that player is the server. The server can't see anything the client has spawned.
Well yes because the server can't magically guess where to place the actor. You need to tell the server where to place the actor from the client.
No.
You're currently doing this:
Client to server says "Spawn the actor please" and then the server multicasts to all clients to spawn an actor on that specific client.
What you probably want to do instead is spawn a replicated actor on the server.
Although.. :/
This is why I hate this in specific because it's a bit complicated lol. You need to predict things either way.
The quickest setup would be this I guess:
- Send a request to the server to spawn a replicated actor on the server and set the owner of that actor to the client who wants to spawn it.
- Once the actor is replicated down to the client constantly send a RPC to the server with the new location.
- Then you can check the "Replicate Movement" box and it will replicate to other clients. But then you need to make sure it doesn't move on the owning client from the server's request, which honestly I'm not entirely sure how to do from BP :/
No problem, ill just stick to the final placement for now. Maybe after some more experience I can do the pre-placement movement too
appreciate the help
What you can do is skip the prediction.
Then you would still do what I just said but instead let the server also say where the hologram is placed, but that does mean a bit of latency will be included.
But I guess that's not the biggest issue for testing.
like this?
Does the server already know about the client's picked hand?
no
Then this wouldn't work.
Yeah no problem, sorry I couldn't really help too much though. I'll try to build something quickly my self to see if I can get something to work that's easy to do from BP. But it's kind of an annoying thing to deal with because it ideally requires prediction π
yeah if you get anywhere with it just let me know! i appreciate it
ok, i have no idea what to do^^
Again, Game Instance only exists on the copy of the game that is running, so if I choose my deck while not connected to the server, and store it in the game instance, there's no way for the server to know about what I've chosen. Even if I was connected to the server, but I stored my chosen deck in my game instance, the server still wouldn't know about it.
In order for the server to know what I've chosen for my deck, I'd have to run a "Run On Server" event, not an "Executes on All" event.
Without really knowing the flow of how your game operates, I'd do something like:
Player Controller:
Begin Play > IsLocalPlayerController (True) > SendSelectedHand (Run on Server Event) passing my selected hand from game instance.
SendSelectedHand Event:
Get playerstate > cast to your playerstate > set Deck Variable (Should be replicated)
Now, what this has allowed is for you to store data about a player in the appropriate place that anyone could look up what the values are. There is no need for "P1 Deck" or "P2 Deck" just a "Deck" in PlayerState since each player has their own playerstate.
As for where you go from here, that "SendSelectedHand" event can also be used to check if all hands have been received by looping through the player array from the gamestate and checking that all hands have been received and begin to do what's next.
So, i save my deck that i have created in GameInstance and send that trough the "SendSelectedHand Event" and set it in my PlayerState. And now it is replicated and the other Player can access that?
Yep. Replicated variables in PlayerStates are accessible to everyone, and each player has their own PlayerState.
You can verify which playerstate belongs to who on the server as the playerstate's owner is the player controller.
I tried it, but still nothing
If i don't use P1Deck and P2Deck how do i know which "Deck" belongs to P1 or P2?
ok it worked, i made a little mistake^^ the part where i try to set the cards in the player state i did before i even set them up in the game instance, my bad^^ thank you for your help.^^
@clear copper I have a working setup that seems to work fine-ish with these network emulation settings (No smoothing for example). But it took me a solid 40 minutes to setup lol. Not sure if you want to go through that pain yet? I do need to eat right now so I'll see your answer in a bit hopefully π
Im eating as well, i'll ping you privately later today and see when you have time
you could just have set the network emulation profile to bad instead lol
Where's the fun in that though x)
Assuming you don't need prediction and a little lag sloppiness is ok, just do it from serverside. You already have the pawn position and aim rotation, so do all the logic serverside and just replicate the actor in Hologram mode. Then when placed, it's not a new actor, it's just a change of STATE on the actor
So to reiterate, all you're doing is moving the trap actor around in Hologram mode, then placing it is just locking the mode and activating its mechanics
You're doing nothing clientside but sending the preplace/place commands
you're already syncing movement and aim rotation
What exactly gets persisted through Seamless travel? It seems to function normally, but I don't want to run into issues in production with actors that shouldn't be persisted going to the next level...
hey, been trying to do this for a bit but i don't understand what to really do here, asked for help before but cant seem to get this working still. trying to let my client damage the server but im not sure how i'd even go about it to begin with. server can do everything to the client and the client sees it. something i learned about since i asked the question is that you need authority to deal damage, and apparently you have to set owner of the weapon? i was a bit lost after that, i'm a bit new to the whole ue4 shenanigans so i apologize if i don't understand what you mean if you're trying to explain something. here's my bp -
note this is in my gunbp
that should be working, I think. Use breakpoints (f9) to figure out what's happening and what isn't
idk if it's actually best practice but I've always just put a branch after my line traces so it can skip some functionality if it doesn't hit anything
when Executing ServerPRCΒ΄s the actor that you call it from needs to have an Owner set (SetOwner node)
maybe i've done it wrong? here's what i have it doing when the character picks up the gun (highlighted only relevant things)
(was trying to reply to this)
seems legit
ok, will give it a go. that could help
you can set the owner when you spawn that actor
I can only assume you're creating the gun through the player character's construction script or later, even
This would only work if its being spawned and not picked up at runtime
how would that work? wouldn't it need some input from the game to tell which player is the owner?
i just have it spawned on the floor
You probably have an Event on the Gun when "something" picks up the gun and that something needs to be your player
eventually i do plan to make it so all the guns spawn at your feet when you get into the game and you just pick them all up off spawn instead of doing a pickup system
oh, well just create an event for when it's picked up and fire it then
ok sorry you take over, we are writing the same messages π
so how would i go about telling the gun that i am the player, i'm a bit lost here haha
It's just to receive the mouse hit on a hex.
so the gun would have a custom event, and the player calls the event when the gun is picked up. You'd probably pass the character in as a reference as well
right, this is what i've got in regards to that
the "HitUnderCursor" checks for anything hitting on the "interacteable" channel. The loot chests on the map hit Okey (HitUnderCursor works).
But with the floor it doesn't hit anything (on the client only).
that works too. Just at the point where your game decides that it should pick it up, call "Set Owner"
gotcha
or this
ohhhhh
Why not just make a function to project mouse to hex coordinate?
Why even hit test the hexes
in different BPs of course
ConvertWorldLocationToHexCoordinate
although that would probably need to be a server rpc @stiff nebula
I forgot what channel this was
I already use the Mouse hit to "interacteables", they have an interface. i just check if something hit and trigger interact.
what do you mean, like i'd have onpicked up on my character BP or i'd put set owner in an event then call it?
@elder sage just saw your name haha
I think it may be some problem about the static meshes collision not replicating correctly. On server they work fine, the problem is on the client.
i'm adding them as static mesh component
you'd create the event in the thing that's being picked up and then call it from the character picking it up
that's why it passes a reference to the character, to be set as the owner
If by persist you mean literally same reference then non of the GameFramework objects does by default and there is no reason to make them so. There is a short period of time where you got the old and new references and you have to copy stuff over from the old to the new. That what happens for PlayerController and PlayerState for example. You can make custom AActors persist a seamless travel inside GetSeamlessTravelActorList
No hit, interact with hex at that location
hmm that's a good idea
This is just a small portion of a research post I'm working on. There are too many gotchas and stuff you need to be aware of
is this a built in node?
how could i tell the character it's picking something up from inside it's own bp?
?
is your overlap event in the weapon or something?
yes
just do it the other way around
Nah you'd just make a function. You already have the inverse right? For snapping your hexes
Convert world space to hex, and vice versa
Yeah, the math was insane. Just tought that node as default was weird jaja
offset with 2
Got some nice info for the math in here
https://www.redblobgames.com/grids/hexagons/
yap, i still would like to know why it's not hitting on the client. but i'm gonna leave that for later
im not sure how i'd go about that, the way i have it set up right now is that when i press fire it goes through an event dispatch (On Use Item) and then firing is bound to the weapon like so
which is the OnWeaponFire event you see here
I don't see how that's relevant tbh
is that just ass backwards or something, i took the blueprints from the firstperson shooting example
in theory you only need to set the owner one time when you get that weapon
like the other guy was saying, "Owning Client" only functions if it's the local Player Controller or something owned by it, meaning you have to call from your Character (is owning client) to set the owner of the weapon, otherwise it won't work
okay, i think i understand that
so it's fine if i call the event from the characterbp even if the event is created on the gun?
that's from the network compendium in the pins btw
oh cool, ill have a look at that
What do you mean by replicating its timer? Timers are not replicated. Also are you persisting the scene capture inside that function?
Any idea why APawn::OnRep_Controller not triggering when Player unpossesses a pawn? (In another words, when Controller changes to null)
OpenLevel is never a seamless travel
You need to make sure the actor of type ASceneCapture2D is persisting
Inside AGameModeBase::GetSeamlessTravelActorList
I mean TimerManager should be handled using UWorld which is destroyed on level change
This piece of code is making me think otherwise
If it's handled by GameInstance then yeah it persists without further notice
Nope. World.h
Wait I don't think I'm quite getting what you do?
Are you firing a timer?
Oh then that's not what I'm referring to
But it could be actually. You have to look at source to know
But most probably they are. I mean how else are they are doing this timer xD
I see. That's not my territory ^^
So this PostProcessing volume is placed already in the level you are traveling to?
I'm not quite sure how the backend of it works
You have to look into this
Really no idea
/** Time in seconds since level began play, but IS NOT paused when the game is paused, and IS NOT dilated/clamped. */
float RealTimeSeconds;
This is what it returns
So it's since level started
Not whole game
Strange...
Yep
hello everyone who reads this im ryan and im looking for some help i know how to make hacks and im looking to help the game devs stop people using hacks obv we can use eac but is there a way i can make the hacks and they ither get patched or it gets implemented into a anticheat (please @me if you reply)
Hi, it's me again with the chapter 93 of "why the hell my hexagones are not collisioning on the client"
i'm doing a linetrace to check and it just goes through the hexagones without a care in the world. It hits okey on the server, but not on the client.
Do i need to setup something else for the collision to be replicated?
Currently this is how i'm adding the hexagones to 1 single actor
SOLVED Finally: The collision type was changing when being added on the client side, for some weird reason.
I have been storing team colors (what team has what color) in my custom GameState class, but I'm running into a replication order problem on the client in multiplayer, as the character tries to get the team colors before the GameState class is replicated (I assume).
Is there a better place for these team colors to be?
I would rather not store them on the character itself, as it might be used elsewhere.
If you replicate the GameState class do you not also replicate the team color? Why replicate the team color and the GameState?
I assume the team color is replicated with the GameState but I think too late. The Character tries to look up its color by its TeamID and finds that the GameState is null.
You just have to deal with replication issues in MP like that. You can't guarantee replication order.
If the game state has been replicated, though, it should have all its properties replicated already - unless it hasn't replicated the changed properties yet.
Can you not do this in an OnRep?
You can indeed.
Oh well I have an OnRep_TeamID but that then tries to find the color in the GameState which, on the client, is null.
Is your TeamID not in your gamestate?
Each Character can switch teams during the game, so they have a TeamID property.
I think you should have an OnRep for your gamestate instead
That then reacts to TeamColors changing, and applies them to all characters?
I'm not sure what you mean sorry
Change it on GameState (OnRep) = Multicast to all PC/PS -> Update colors for each team
Depending on Zlo, this is the only thing that can be guaranteed: #multiplayer message
It's literally what he's facing, so I'm doubting it
honestly i would change it on GameMode and propagate from there
What would you put on game mode exactly?
I think I need the team colors stored on the clients, and GameMode is server only iirc
GameMode:
Team 1 = blue.
Team 2 = red.
Player:
Team: X
Color: Y
When team=color relationship changes on GameMode, grab all the players and tell them to update if they have that color
That's not a good idea at all.
Then I'm storing it two places, instead of one I think.
You want team colours readily available for everyone.
They are, GameMode has the last word on the matter.
You don't need to traverse players though
Game Mode shouldk change colours, sure, but it shouldn't store them.
I forgot to highlight it, but the gamestate is null in this case on the client.
It's called from OnRep_TeamID (an integer)
it stores the table of true, you do whatever you want with that.
The "table of true" ?
XD
Someone has a .png for this expression I'm sure π
You either need to set up some sort of async that waits for gamestate to not be null or use an OnRep for gamestate
At least those are the solutions I can think of
Maybe i'm missing something on what your desired outcome is, but whatever "rule" you want, should be on the gamestate. and the others should acommodate for that
There is one already
hmm in english i think it's "truth table"
Made by James
There is one what?
A "truth table" is a diagram showing the differences between argument values/outcomes in boolean algebra.
In my opinion (and yours may differ) the current state of things should be on the game state. The server still has authority over the game state. The game mode might store a list of team colours to choose from, but not the active state of the teams - it just mutates the gamestate from the outside.
GameMode
BeginPlay-> Set colors (When done, rpc to players ->Update colors)
Players
BeginPlay->Grab lastest color relationship
There is a newer link to that system in this channel, but can't find it @acoustic drum
this is what i'm saying. GameMode should save what color goes to what team, not who has what team.
maybe there is the confusion.
Where is it saving that color?
You can't RPC in GameMode
Map: Int(TeamID) - Color
or your custom ST.
that one should work, yeah.
Could do but afaik thats expensive as opposed to replicating gamestate
Though I find it awkward that I have to travers players each time a new color is set when I can literally replicate that property
I don't understand why you just don't have an array of FMyTeamInfo on GameState which has {Name, Color} or whatever
Replicate that, done
Correctme if i'm wrong, but you want a 1=1 relationship of team->Color globally.
And players can change teams or teams can change colors during the game, is that the intended behavior?
Why make the server do that when the client can
..do what?
Associate names with colours
When all it has to do is replicate teamID with colour
Not sure I want the players switching teams/colors, just the characters they can take control of.
Because the server is "doing it" once at the start of the match and then never cahnging again.
It is changing
That's a stateful action. If the client does that, other clients have no idea what happened
Since players can swap teams
And it's far quicker to replicate the change of colour, if it does change, once in the game state than to potentionally 50 to 100 players individually
The player's colour changes when their team does
and if a team color changes?
There is no need to change a "colour" specifically when a plaeyr changes team, you just change their team id - 1 replicated uint8
Then the change gets replicated to players and set accordingly in the OnRep
Then you just change the colour on the gamestate and it's replicated?!
Then every player on that team changes colour automatically.
why change it on all game states when you can just change it on GameMode and replicate from there?.
I thought your plan was to send an array of peoples names and associate their colour with the name
You cannot replicate a game mode
if a player changes their teamid --> Go to gameMode and grab the color for that
You can't replicate stuff that exist in GameMode
sorry, replication is not the word. propagate would be more adecuate
Why use the game mode at all? Game mode is for logic, not storing state.
Again why would you traverse all players and do it for each one separately?
I mean, you can store some non-replicated state information if you want, but everything that's repliated, like team colours, should be on game state.
if you change team=color relationship. you have to go to all players no matter what
if you store it on state, you have to go to all states and tell them the new relationship team=color.
You do. And the easiest way is to replicate a single variable on the game state instead of doing it to every player individually.
An RPC to each player will be less efficient than a replicated variable on the game state.
I just want to inject that I find all of this very interesting π
(and I'm taking notes)
I guess if you can associate players ID with colour and not resend the same array everytime (only the elements that change) it isnt so bad
You are already going through actors that changed a replicated property in the NetDriver. Why would you do another for loop for this?
You don't do that at all. Player ID <-> Team ID <-> Color
I must be misinterpreting this
struct FMyTeamInfo
{
FColor Color;
FText Name;
}
class AMyGameState : public AGameState
{
TArray<FMyTeamInfo> Teams; // Array index = team ID
}
class AMyPlayerState : public APlayerState
{
FText Name;
int32 TeamID;
}```
Anyone had issues using the gameplay messaging subsystem when running as a listen server or in standalone mode? Only appears to be working when connected as client, is this normal?
hmm okey, that makes sense
Ahhh thats why I'm confused, you're associating the team name with the colour not each player
Teams are part of the GameState no doubt. Whether you make a subsystem for Teams, whether you make it an actor component that gets attached to the GameState, or it's a simple struct property that is inside GameState, it's always in the GameState and it must be replicated in order for clients to know about it
Yeah. I'm sure it has some sort of system. That code is a very basic example.
Lyra has a TeamSubsystem if I'm not mistaken
Let's say I have it on my GameState (as I do), what would be a good way to get my Characters colored based on their (potentially changing) team?
There's some sort of friend/foe thing in the AI system too, which has the idea of a team.
(while avoiding the startup issue of a null GameState on the client)
Ah yeah right
Add an OnRep to the gamestate's Teams array
When that fires, just update your local UI/etc.
Before it fires, you're "not on a team."
Or whatever data structure holds your team data
No team name atm, so just an array of colors.
indices being team IDs like you also suggested
I would create a struct and place your color inside it.
It iwll make extended it easier later.
Got an issue where my boolean is not replicated at all, at least the OnRep is not executing, i got the UFUNCTION above my OnRep in the header, i set it on the server and it's transient so initialized to false by default
ItemEntry is also using an OnRep and it getting replicated without any issues
Transient is initialised to false by default? News to me.
Always initialise your variables
from what i remember yes
i'll try to initialize tho
Transient just means it won't be serialised.
and it also initialize it to default ? isn't it ? π€
In debug configuration maybe, but that's nothing to do with being transient.
That's what someone explained me a few years ago here, since there is no real documentation about transient π€·ββοΈ
Zero filled at load time doesn't mean zero filled at instantiation time.
Still I would initialize just to be sure
Yeah i just tried and same
It does not replicate π
And if anyone ask, i'm using Live Coding yes
ben's blog wasn't a thing when i started UE π€·ββοΈ
Try a complete recompile outside of the editor.
Have you added a breakpoint to a) where you're setting it to true and b) in the OnRep function?
Since 2017, but it's quite handy
yes for a, will try the b tho
My wild guess: Something else is setting that boolean to false, faking you into thinking the OnRep it's not called
Watch the boolean property when you debug and make sure it stays true
nah
it only getting set one time
in the code i showed above
the first one is in the constructor
Transient properties are always initialized to zero and are not serialized to disk. The time to use one is if the object at runtime will set the variable. For instance, letβs suppose you had a character that has MaxHealth as a value setup by the designer, which you treat as const at runtime. At runtime, youβd copy that value into a transient cal...
that's where i saw that "Transient properties are always initialized to zero"
a few years ago
He's wrong.
On some parts.
I could absolutely see a need to save "CurrentHealth" to disk.
It's a terrible example. π¦
yeah for sure, that was not my use case anyways π€·ββοΈ
I'd say transient variables are for temporary, runtime-generated values. Derived values. That sort of thing. Things you can generate from other serialised data or things which are by their very nature ephemeral, like sockets.
That's just sigh
Believe it or not, I was given this thread as an example when I asked what transient means a few months ago in #cpp
I was definitely 
so you agree transient definitely need a good documentation ? π
On reconnection for example someone would lose his current health I guess
Yeah.
Gotta talk to Ben
So apparently you can reset the game time during seamless travel if you override the UWorld::InitializeActors() method with bResetTime. Need to figure out how to do it in BP thoughβ¦
Didn't you say you are seamless traveling?
I am.
Ah ok so in seamless bResetTime is set false?
I believe so
Could I just run a function to reset the world time manually from C++ in GM beginplay?
That post about CurrentHealth angered me enough to actually log in to that page and post a reply.
Reset the world time?
Not entirely sure what it is
Whatever the time input node is using in the material graph
Itβs persisting with seamless travel
But not with OpenLevel
Sick. That makes it more accurate right? No flaoting point issues and such?
Yes because OpenLevel isn't seamless. Makes total sense. It just doesn't seem to be easily fixed without an engine modification
so i tried b), the OnRep function is not even getting executed π€·ββοΈ
Did you BP the CallYourFunctionTHing() or the if statement?
That's not a yes/no question.
Are you sure that the debugger is actually looking at the rigth instance of the engine ?
yeah i attached it to the good instance like usual π€·ββοΈ
but i'll try to debug it more i guess, i don't have other choices
Fixed my issue by removing intermediate folder, regenerating files and doing a complete recompilation of my project
so i guess it was a serialization issue ? on a transient property π€
Is there a way to get an actor out of dormancy only for one client ?
Well, the problem was definitely transient!
yeah glad we talked about it since it was the issue πΉ
Relevancy is how you specify who an actor is relevant to. I'm not sure how/where the engine decides that beyond the rep conditions method.
There's distance culling, I know that!
goes and posts another reply in that thread
Never tried it, but you can override AActor::IsNetRelevantFor and check if the RealViewer is the client you're referring to. If yes, return false
You've also got Dormant_Partial in the dormancy settings. In this case though, it would load on client but won't send updates
Yes, that's engine code 
