#multiplayer
1 messages · Page 207 of 1
Yeah you can't stop a multicast so you gotta filter afterwards.
I also doubt if it's ultimately cheaper to have a specific actor for this stuff that has net relevant for overridden
Yeay same idea haha
Net groups are also a thing , right
hey i have this ui problem when i test in PIE as listen with 3+ clients or as only clients all works but after i build the game and try it it dosent work :/?
the functionallity works in the built game but the visual part dosent work :/??
ideas ?
If there is a manager in the world with a random seed that show or hide actors from a list (them all are placed in the level statically in the level editor), technically the only thing that need to be replicated is the seed from the manager and the event call to show or hide them, right ? (so don't need to replicte each actor visibility etc)
Thsts 100% how not to get help.
why
lol ty
"zoning" networking question
Hello! I'm developing a top-down multiplayer game where there will be smaller "arena battles" between <10 people at a time. I have nailed down this basic multiplayer step already but I want to implement two new features:
- MMR - I will make a separate rest API server for this which will also handle login and stuff, maybe in combination with steam and other things. Any tips here are still appreciated but I will probably figure this out.
- In-between queueing for games I want people to be able to "zone" into a neutral safe-zone where they can interact with people and form groups. If there are too many players (maybe like 100) people will be zoned with players that are similar ranks to them or friends or friends of friends. I don't need help with the specifics like who is zoned with who but I need help with the general problem of "zoning".
Questions:
- How I can best achieve this "zoning"? I suspect that it should work similarly to how world of warcraft does "cross-realm raids".
- What is "zoning" like this called?
- How do I run multiple "game instances" (like lyra experiences) on a single server? Is that good practice?
This is how ^
ok
could u help tho? look in ue5 general
When I grt home maybe.
What is the technical reason why the Server gets lower FPS than the Client? Is there any way to optimize this?
It doesn't really. It just doesn't need to run at a higher fps in most cases. If you mean a dedicated server.
If you mean a listen server, it just has to handle extra stuff.
There is already an extra FPS problem in the game, and on the server, this FPS problem increases even more. And this is Listen Server unfortunately.
Feels more like sitting should be it's own animation blend state, I think? People in the animation channel would probably have better info on the best way to implement that in a scalable way.
But for the enum I recommend changing that to a GameplayTag. And if you're using GAS you don't even need a container. You can simply apply a GameplayEffect to the sitter with a tag specified. If the owner of the anim has that tag on their ability system component, sit. A montage could maybe override that and blend to the sitting mode and then the sitting state I assume.
I think I can reframe my problem a bit:
Let's say I run a dedicated server ("Server") and I have two clients, "A" & "B".
If B is in an e.g. Lyra Team Death-Match experience then A can obviously use the Main Menu experience before joining B's game.
Extending on this, it means we can have players be in totally different experiences at the same time on the same dedicated server instance.
How does transfering players between these experiences behave exactly?
Can we host a team death match game and a capture the flag game that works as expected at the same time with different players?
How does this scale? If we have 50 players in an experience and then host 100 of these experiences at the same time what would happen?
That's not quite how this works.
If the DedicatedServer is a DeathMatch, then that is what it is. B is just connected to it.
A has no correlation to B or the DedicatedServer at this point. It is running it's own thing until it connects to the DedicatedServer.
Similarly If you want to run dedicated servers for DM and CTF. Then you need two dedicated servers. One hosting DM, and one hosting CTF.
Oooh okay. That makes sense then. This narrows my problem down quite a bit.
@A... Thanks a lot. Does it sound reasonable to have a restful api server to handle spinning up dedicated servers for some experience to handle instancing and such? Or is there some related or similar premade solution available?
I haven't personally handled setting up backends of that scale, so you'd have to poke at others. But hanging around long enough I would assume there's no premade solution. Usually that's custom territory based on the game as far as I know.
Which extends quite far by now lol
The server is responsible for a lot of things that clients are not. Unreal’s default networking is simple, but being simple has a cost. Every frame the server calls UNetDriver::ServerReplicateActors and has to build a potentially large list of actors that are relevant to each connection. This can be an expensive process when there is a lot of replicated actors, then there’s the default property comparison logic of UPropertys that are flagged as replicated. The server will run a comparison of these properties to decide when there’s a delta that requires the property be packaged and sent. Not to mention all the extra stuff a server needs to do to maintain authority over specific actors, particularly movement. There are ways to optimize all of this, but that’s the gist of it.
Guys I have weird problem I am throwing bombs which should do damage by hit but server call below is never called when i debug it when I debug upper call it is called but i dont get in server node never only client
any ideas ?
thus i cant do any damage then...
A lot wrong there
But to start, did the server spawn this actor, and is the actor replicated?
As the server, is it possible to retrive information via an interface? I want to retrieve what item a player is holding through an interface (GetPlayerCurrentlyHeldItem) but it always returns invalid :(
The interface runs on the player correctly from the server, but as mentioned previously returns null
The actor is set to replicate
It’s possible, but the item it’s retrieving would need to have been updated to the server first. If the client is the one making changes to their “currently held item”, without notifying the server. How could the server ever retrieve the correct information?
I don’t really give design suggestions, just know that if the client is making changes to their currently held item, they will need to tell the server what change they made. It’s as simple as sending a Server RPC when the client makes a change .
Alright, thank you!
Hi, I'm having an issue with setting clients rotation after they interact with a draw to face the draw, it sets their location no problem but doesn't do the rotation.. the weird thing is that if I exit the draw then re-enter it.. it works? that doesn't make any sense to me lol surely is the exact same code running when I opened the draw the first time, what could make the second time any different? Any ideas what could be causing this? Also, that ClientSetRotation event is being called every time the client opens the draw
I cant upload the vid here so its here - https://drive.google.com/file/d/1JUh4p4NTzrEsAFORXPTC72oVav7xrY0q/view?usp=sharing
yes and yes, whats wrong there
Unless you’re only setting Hit events explicitly on the clients, the server will fire the hit event themselves. You don’t need an RPC to apply damage. You can either turn off the hit events on clients and only enable it for authority, or you can filter out the other connections before applying your damage. You also are using GetOwner, and that assumes you’ve already set the owner to be a client, but every other client that executes this hit event will just drop that RPC because clients can’t call RPCs on actors they don’t own.
yea i wanna tell target who is damage causer
is that wrong way?
so should be only like this
Use a Switch Has Authority before the cast.
why and for what node authority?
Huh
When i play game as listen server it works when i play as client doesnt work
maybe bombs are spawned incorrectly
they are spawned and attached below plane
Post pictures
of spawn ?
i have 6 bombs in row this is how is first spawned, event is called after begin play
Is your BP Proximity Fuse Night Witch blueprint marked as replicated?
And also, you probably don't want to multicast a spawn as that ends up creating seperate copies on every machine.
when I dont use multicast i dont see bombs on client only on listen server :/
If you use a multicast you're creating separate actors on every machine.
There's no networking separate actors like that.
If you spawn a replicated actor on the server, then that actor can be replicated to clients.
So how i should spawn it via event on client or server event?
If you're trying to have a client request the creation of such an actor, you'd normally do something like Input > RPC To Server > Server Spawns Actor
just this but then it is not visible on client 😄
Is BP Night Witch something that the player possesses or is an owner of?
its posseses by player I am playing with it
its plane
its child actor of main actor divided to characters which are playable
I am making a mod for lockdown protocol game. I wrote such a code, but only the server can be invisible and everyone sees it. the client cannot be invisible at all. what I want is that the client can also be invisible. how should I do this?
Ok, so if it is player controlled, and you're RPCing to the server on the BP Night Witch, then certainly the server is spawning it. So long as it is marked as replicated, then a replicated copy of the BP Proximity Fuse Night Witch will be spawned on clients. That's how replicated actors works. There may be something else interfering with the BP Proximity Fuse Night Witch that could be destroying it. You can verify that they are being created by putting a print string on begin play of the BP Proximity Fuse Night Witch and you should see prints for the server and any clients.
Clients won't be able to call RPCs to the server on "Mod Actor" unless they own the actor which it doesn't look like you'd be doing here.
I get it, weird I spawned them now On server call 😄 and they didnt attach on plane they stayed behind me in air :ddd and more than 6 ah
attach actor on actor is propably not correct to call on this RPC server call
yea spawned 2 bombs but somehow got more prints
i should use authority node from begin play to call server call nah?
now correct
2
Well begin play fires on both client and server. if you're calling an RPC on begin play, you're probably going about what you're trying to do wrong as you shouldn't need your clients trying to tell the server to spawn something on the plane, and because begin play fires on the server already, it wouldn't need the clients to tell the server to do it.
in other language use authority is ok yes
😄
did it like this
Yes, but do you also need to have that spawning as an RPC? That RPC can be called at any time in the future by a client.
after all bombs are thrown BombSpawn should be called again after some delay, but now I need first find out why they are not spawned attached to plane
But do you need the clients to tell the server to spawn the bombs? The server can just as easily keep track of how many bombs are remaining and the delay to respawn them without the client telling the server to do it.
I have this for bomb throwing , and when last bomb is away it will count delay and call spawn idk I think its client job
prove me wrong
anyways I still need find out why they are not attached to wings 😄
but in air behind plane
Inputs only happen on the client. You have a client changing replicated variables locally.
i will deal with this later now I need get that spawned bombs on server event to be atttached to wings
now they are staying behind plane rip
omg i clicked replicated movement and its kinda wierd
weird
something wrong here
when i play listen server its ok.. 😄
Do you have any idea how I can make him invisible?
Do you have some kind of movement component on the bombs that may be activated?
You're using the correct node to change the visibility of something, but I don't know enough about the game you're trying to mod and what you have access to in order to modify a specific actor.
In order to call a server RPC, the client must own the actor you're calling the RPC on.
nah its very weird
this is all
hello Im on eps four of the multiplayer tutorial but when I hit Host Session it doesnt take me to the level ive selected https://www.youtube.com/watch?v=oUxSdX6SxvQ&list=PL6AQiNvVMdLuvzE2nT_S2brtsBC2c8lNt&index=4 the steam overlay does pop up which is strange that I cant host?
Any help would be awesome!
In this series we are setting up the connections for online multiplayer using the base Steam sessions that come with UE4.
In Part 4 we connect our game to Steam and connect our players together.
SUPPORT ME
Patreon I https://www.patreon.com/ryanlaley
Buy Me a Coffee I buymeacoffee.com/RyanLaley
Donations I paypal.me/ryanlaley
PRIVATE 1-2-1 SE...
can a pawn have an owner if it's not possessed?
Have you tried if it works when you set "Use LAN" to true? If it works, then it is likely that there is an issue with your steam configuration.
I think any networked Actor can have an owner. Since a Pawn is also just an Actor I don't see why it should not be possible.
Thanks!
For a good gaming experience, does it make sense to use Unreal's Default Steam system or SteamSocket?
I would be grateful if anyone who has published a game on Steam before could answer me.
I believe so, but changing possession of it also changes ownership.
Ive found that restarting my ue4 has been helpful as of late thanks tho i might need to verify my ue4
Normally, no. But that is overridable in C++.
Would calling SetOwner() do it too?
Probably but it it's not normal. I did this in our latest project, but it wasn't because of lack of possession. But because they were AI and I needed a player to own them instead of their AI controller.
If you don't need possession, usually you don't need a Pawn either.
does gamemode allow for map usage since its server only and i wouldnt need to replicate anything?
You mean a map variable type? Maps can be used in any class. They just can't be replicated.
yeah so lets say i use it to do stuff in gamemode, that stuff will still be replicated to the clients right? since gamemode is server only
But that's not what matters. You use a variable type for what your needs are, not because they can or cannot replicate, nor does it matter what class it is in.
And no, anything in the game mode is not replicated to clients.
Any code that executes in the game mode that calls replicated functions in replicated actors or components can be replicated to clients.
oh
but isnt gamemode the server class and server the truth in terms of multiplayer?
so supposedly lets say if i spawn an actor through gamemode shouldnt the clients see it too?
Hey, I'm sure you get asked this question asked a lot, but I'm super unsure how to fix this after reading on the forums.
A widget calls this Update Name event when a button is pressed, it works on the server but doesn't seem to work at all on the client. This is what the blueprint looks like... not sure why as this seems to be super straight forward
If it is an actor marked as replicated, and it happens to be relevant to the client, then yes.
You can only call Run On Server events on actors that a client owns. A "BP Stop Sign" doesn't sound like someting a client would own.
ahh ok, so what could i do to fix that ?
You have to call Run on Server event on something that the client owns, and then when running on the server you can call to execute code on the desired actor.
i see i see, thank you! im gonna look more into these conditions,im trying to proc gen+ place monuments and i believe gamemode is the best way to replicate the seed and spawn in those monuments
The game mode would not be the way as the game mode doesn't exist on clients.
The game mode can control something else that replicates that data, like setting the variable on the gamestate, or you can have some other replicated actor that contains that seed.
yeah i have a replicated actor and it does contain the seed, im using gamemode to spawn that actor
with the seed
yeah this makes more sense, just gave the algorithm a shot, the algorithm works however they dont spawn on client side, so ig ill use a replicated actor and execute replicated event on it using gamemode to actually spawn stuff?
What you probably want is use a RepNotify on the Seed property to then begin whatever generation you want.
Again, would need to be on a replicated actor of some kind, whether GameState or some other.
totally forgot rep notify that actually makes it more easier atleast for the proc gen part
thank you again!
Ah ok I see, yeah, just did it on the player pawn. It worked, but I don't want to use the pawn bp for everything. A central actor for everything would be better, is it possible for the client to own it?
Yes, but that in a sense would require you to be able to have the client request to own it which would still require that RPC.
You probably want to implement a more generic interaction system that allows the client to request to the server they want to do something to any actor, and then have the server call an interface on the desired actor which can then perform the requested interaction, or utilize a component to communicate to the actor.
alright got it, thanks a bunch
Guys I have spawned actor via RPC but still event hit and overlap is executed only on client side when I debug it any tips?
Have you guys seen this? (Yes I know another unreal Dear imgui plugin but its the remote drawing that I am talking about)
https://github.com/VesCodes/ImGui
I was going to implement some debugging widget stuff with slate until I hit a road block with no FSlateApplication drawing or anything happening on a server, this implementation with imgui however is actually crazy useful for debugging (at least for my uses, I implemented the library today and have everything running well, I can have N clients and a dedicated server debug imgui window drawing their own stat and information, helps me visualize any data that's off (atm I am implementing a weapon system so lots of little side affects in a network context like mismatched ammo counts, equipped slots etc)
Anyway just wanted to share because I had no idea about the existence of NetImGui Server and how its implemented here
(A dedicated PIE with 2 clients) This is more or less the end result (minus the bad bareboneness, still only just setting it up) where you have the server in orange and the two clients in blue, each displays their own instances stats and I can manipulate and interact between them all
I haven't tested it outside my own local machine but I would assume this also works for VPS's and whatever else you host stuff on (it says people use it for embedded device stuff too like switch and mobile)
When you hard travel everything related to worlds are destroyed. Any Actors of any kinds go kapoof. All UMG widgets are removed from the viewport.
On arrival, the login process begins which leads to a server telling client to create specific gameplay actors. See PostLogin. Specifically...
AGameModeBase::PostLogin -> GenericPlayerInitialization(NewPlayer);
AGameModeBase::GenericPlayerInitialization -> InitializeHUDForPlayer(PC);
AGameModeBase::InitializeHUDForPlayer_Implementation -> NewPlayer->ClientSetHUD(HUDClass);
Client has no GameMode. So I'm not sure what you mean here?
Right. This never runs on a client. It'll be Server only.
Client doesn't have a GameMode.
/** Set the client's class of HUD and spawns a new instance of it. If there was already a HUD active, it is destroyed. */
UFUNCTION(BlueprintCallable, Category="HUD", Reliable, Client)
ENGINE_API void ClientSetHUD(TSubclassOf<AHUD> NewHUDClass);```
Client has no GameMode.
If you have a GameMode on a machine, then it isn't a client at that moment.
If you start the game, you should start in a main menu. At this point your application is standalone. You are the "server". You are not a client.
When you connect to another machine, regardless of whether it is a dedicated server or another player hosting as listenserver, your application become a client.
When you host a game as either a listenserver or run a Dedidcated Server instance, that application is Server.
Following the above, when you are a client. You can never have a GameMode.
I'm not sure if you are wanting it to start from the main menu. If you're wanting to test directly in a gameplay map then you just set the checkbox for it.
You need to start on the MainMenu map. Your DedicatedServer will probably need to have an OpenLevel hack or something. Unless there is a better way to do that, I'm not personally familiar with setting those up yet, just the overall idea. But that should drop your PIE instances into the main menu. Then you can do "Open 127.0.0.1" to connect to the dedicated server instance once it opens it's level.
Has nothing to do with GameMode
Most people maintain widgets inside of the AHUD class.
One is spawned per player, only on their local machine.
It does.
You always have a GameMode. This will just use the project default. If that isn't set it'll use GameModeBase I think.
Are you building on Lyra?
This is why I said to look at that function callstack. Clients do not have a GameMode. They are told to create classes from the server. Server has a GameMode. Server says "Hey, spawn this HUD class", which it pulls from it's own GameMode
I'm not sure how GameInstance is connected here? But no.
There are some pinned blogs on multiplayer structure. Source code also.
well load a level instead of connecting to a server should give you a game mode locally. We created a special game mode for our lobby.
well only if you are connected to a server, otherwise you have a GM but not a full fledged game experience as you don't (shouldn't have) server code on the client side
"client" isn't really a client until it connect to a server.
What I mean by connect to a server is connecting to an instance that is running an unreal game.
Playfab or backend service are entirely another thing
Post login in game mode is called on server when a client join. Got nothing to do with user login, e.g google, steam play fab, you name it
I think learning multiplayer game from youtube is kinda wishful. I'm on my first game and I won't bother with data base and all that stuff.
I'm using steam and keeping it simple
Learning UE from youtube in general
is wishful thinking
99% is just follow me but I will not explain why I'm doing it
Hi all, me and my friend are currently learning game development in UE5, we are watching tutorials and have bought a couple courses but all of them lack much detail on multiplayer functionality, we are looking to create a game with dedicated servers so people can host their own servers and have their sessions/player data etc logged on said servers, any pointers/guidance would be appreciated! any docs or guides/courses would also be great.
My best advice: Do a single player game. Doing proper multiplayer adds soooo much more headache, and as you are "currently learning game development" you really shouldn't start with a complex topic like multiplayer.
Make pong. If you survive, do something more complex.
i like the challenge 😉
I also like the challenge and 6 years ago I started to make a MMOish self hosted game. Our backend worked etc. but we didn't have the ppl to actually create enough content. now we do single player and that was the best decision taken on the porject.
i have already got my basic gamemode setup with unreals dedicated server build from source, with movement replicated etc
movement replicated is literally built in though
do a singleplayer game like the rest said
Well done! (seriously!)
so many boomers here
Networking, at it's core, is easy and simple.
If you need something on all clients and it needs to do something. Then it needs to be replicated. If it has state, that needs to be replicated within it. Replicated things are spawned only on server.
You can only RPC through replicated actors and with certain ownership conditions. You use Server RPCs to set state or Client RPCs to tell clients to do things directly. Do not use Multicasts until you fully understand replication.
Past this. It's just the constant battle of using the most basic data you can to replicate, and infer as much as you can on the client to set stuff up correctly. And doing so in a friendly way so that it doesn't look bad.
thank you!
We don't doubt your capabilities and like Daekesh said, good job on what you have achieved so far!
But why we say you shouldn't be too ambitious about your first project is learning game development / unreal at the same time you're building a big multiplayer game, will tax your inspiration to keep the momentum
that's my two cents
I've seen too many people starting a MP project as their first, and stop working on it after a few weeks/months. If you want to learn to code or game dev in general, it can't feel like a burden
i appreciate this, i will expand my knowledge on replication before i toy with multicast in that case!
Don't use multicast. Ever. Until you know exactly why you need it over regular replication.
thats the thing dude i spend all my time on computer i just sit there bored so i decided i'd like to develop a game so i thought why not make a multiplayer for me and my friends, i have all the time in the world to work on this and i appreciate your opinion, hence why i asked for pointers and guidance, but i have to learn somewhere right?
yes i am learning c++ along the way, well both blueprint and c++ to be precise
And we're saying to start small and learn the basics, before going onto a bigger project that might ruin your inspiration to make more games when you realize how much work is left
i have no prior experience with c++, the stuff i am learning is from courses/tutorials
Nah, scratch is a great way to learn c++ 
I did exactly this when ue4 came out. Fun experience. Multiplayer too.
could you recommend any of the stuff you watched, doesn't matter on subject as i'd like to learn abit of everything really
Lol there was nothing for ue at that time.
I don't even remember how I learnt cpp tbh.
Umg didn't even exist. 😦
I learned C++ on a whim because it was becoming clear that nativization was getting shitcanned and had too many random bugs. And that BP was not going to work for any scalable project. Was also learning networking at the time as well. No regrets.
It's a fantastic tool.
And there were no slate docs. So I wrote my own version for fun.
you see this is what i like to hear, i would love to learn in this exact same way!
http://www.learncpp.com is the usual link.
BP function libraries were what started it for me. Still a great way to learn C++ in Unreal because it forces you to learn a lot of the macros and specifiers.
tbh my only experience so far with c++ is adding custom variables into GUS 🤣 but hey im trying to expand my knowledge in each subject
thank you i will bookmark this and have a look!
Learn Slate if you want a bright future migraine.
what is slate if you don't mind me asking?
The c++ ui framework that backs umg.
okay noted, thank you guys for the recommendations, this gives me stuff to do instead of sitting twiddling my thumbs lol
Realistically you don't need to care about Slate past input handling unless you plan on doing editor extensions. UMG can fill pretty much all gameplay UI needs.
Yeah. Though it can be useful to create umg base classes for easier c++ integration.
Even then, you mostly make C++ classes to do minor or easier things in that widget for itself. Never tie your C++ gameplay code to your widgets.
Hey guys, I'm working on a basic MP, steam-only game. It's a BP-project using the Advanced Sessions Plugin. I've run into a strange problem when clients join lobbies.
If my game mode extends GameModeBase, clients join and are correctly assigned the default pawn. The server can also call ServerTravel and everything works as expected—server and clients travel to the new map.
If my game mode extends GameMode, however, joining clients aren't given a pawn at all. When the server calls ServerTravel, nothing happens. The server and clients don't change maps.
Is this expected behavior?
I can force a pawn to be spawned and possessed using HandleStartingNewPlayer, I just thought it was odd that I'd have to do that with GameMode but not GameModeBase.
I'm still confused by ServerTravel not working at all though. From what I've read GameMode is supposed to have more multiplayer functionality built-in
Did you also change your GameState?
Yep! I've made sure to match GameMode with GameState or GameModeBase with GameStateBase in my testing
Could check your match state at servertravel time. This is the only change GameMode would do over GameModeBase.
bool AGameMode::CanServerTravel(const FString& URL, bool bAbsolute)
{
if (!Super::CanServerTravel(URL, bAbsolute))
{
return false;
}
// Check for an error in the server's connection
if (GetMatchState() == MatchState::Aborted)
{
UE_LOG(LogGameMode, Log, TEXT("Not traveling because of network error"));
return false;
}
return true;
}```
Not seeing anywhere that state is set to Aborted other than a disconnect though.
Unfortunately it's a BP-only project. I don't get any errors in my console though
oh wait - I do get "LogGameMode: Not traveling because of network error" after all. Hrm
Well this is interesting. If I run in PIE, match state goes from InProgress to Aborted almost immediately. In Standalone it doesn't go to Aborted. This thread: https://forums.unrealengine.com/t/4-14-servertravel-with-more-than-the-server-doesnt-work-in-pie/376392/18 has more info on the issue. Dang PIE
UPDATE: I was able to figure it out. In my Editor Preferences, I needed to set Play Net Mode to Play As Client. Something about starting off with a server and clients auto-joining made GameMode immediately abort, which quietly broke a lot of things. Now, builds, standalone, and PIE all behave the same way.
Bug still present in 2024 (ue version 5.4.1), lol, seems part of greater problem with server-client communication in editor. Dedicated server and client has multiple problems in editor. Basicly, y still will be kicked out in pie if you connect to server. Join session not in pie but standalone or open level, open command, result to “do no...
eh - no
I'm trying to replicate a TArray<UObject * >. I found the ReplicateSubobjectList in ReplicateSubobjects is deprecated, and the new documentation https://dev.epicgames.com/community/learning/knowledge-base/7y39/unreal-engine-using-the-replicated-subobjects-list seems to only support single UObject, but not TArrays of them. Is this not supported at all anymore, or do I have to do something like wrap it an another UObject?
fine with me tbh.
iirc, you now need to manually add and remove replicated subobjects when you add them to your array. I believe there's also a flag (something like bUseReplicatedSubobjectList) you need to set in the constructor of whatever is replicating the array
Thanks! For anyone else who has this problem, I missed 3 steps:
The replicating actor needed the flag set
AMyActor::AMyActor()
{
bReplicateUsingRegisteredSubObjectList = true;
}
and the UObject needed to override:
virtual bool IsSupportedForNetworking() const override { return true; }
Then I added a function for adding to the uobject array:
void AMyActor::AddUbjectToReplicatedArray(UObject* NewObject)
{
UObjectArray.AddUnique(NewObject);
AddReplicatedSubObject(NewObject);
}
Hi, currently working on 5.1, using Steam advanced sessions, and struggling to solve a damn Ping issue.
If I don't use Steam sockets, I'm not able to return the ping when browsing for sessions (ping always shows at '9999'), if I use Steam sockets, I'm able to see the correct ping, but then the clients can't join any sessions, i've spent 2 days looking for solutions without success, it seems that I either have to upgrade my project to 5.4 (which fix the bug with steam sockets), or build my project from source, which seems like an overkill for just a ping issue.
Did someone manage to make steam sockets work with 5.1, or maybe there is a work around I haven't though of? Thanks for your help
here what i am doing ,
in the editor i setup with 3 new windows clients and a dedicated server
i create a server in one of them with advanced session plugin
then in the two others i find and join the session .
in my custom c++ playerstate i have this code to get the unique id
FString AMyPlayerState::GetUniquePSID() const { if (GetUniqueId().IsValid()) { return GetUniqueId()->ToString(); } return FString("Invalid ID"); }
GetUniqueId() is a function of the base playerstate .
now with umg i show the GetUniquePSID but for some reason is the same for all clients
however when i retrieve the playerarray from the gamestate and get the corresponding GetUniquePSID of each playerstate they are differents .
any idea on what's going on, i am fighting with this problem for few days now .
Anyone have a good resource (vid / doc / tutorial etc) for creating a team resource system? Ie, Team 1 gets "10 resources" every X minutes and then any player on that team can "spend" those resources
This should be handled by the server , saving the team resources and etc on game state and just replicate the values to clients and when a client use a resource send a RPC to the server to decrement that resource
I'm very intro level on all this stuff. Any documentation or other resource I can read up / watch to help me walk me through? Not even sure what to search
Basically, you have game/match state for each map which is replicated to clients and holds the game match data as score and etc
You will just create a replicated variable as your team resource and use a RepNotify to replicate it to all the team player clients
And when someone wants to use a resource you will send an rpc to the server telling it that user X from team Y used resource Z and just decrement the amount
It should be very easy to implement takes like a couple of hours
About docs/resources actually no there’s not afaik
This is a gameplay specific mechanic
So you won’t find other games implementing it this not very popular so isn’t worth to make a tutorial about it
I can just create this replicated variable to start ticking upwards when the game starts and track it from there?
You don’t need to tick the value upwards, as I said basically you create the variable on the server as replicated (and it will replicate to all clients) and just set it to replicate by repnotify and when the repnotify fire you can just change the value of the copy of variable locally (useful for ui stuff)
And if a player wanted to use a resource he will send a RPC to the server telling it that he used the resource and to decrement it
And once the server changes the value of the resource on it it will be replicated to other players as well
I recommend you reading more about the gameplay framework and the RPC system
You can dm me if you want more help
Gotcha. I'll look into that stuff. Appreciate it. I just started like a week ago but instead of just following tutorials I'm also trying to do a side project to learn. Even at a small basic scale I'm seeing gaps
Will do, I'll give it a shot first, thanks
I recommend Stephen ulibarri tutorials if you intend to fully understand all aspects of the engine
I actually have his C++ course
YouTube tutorials can vary in their content quality/ a lot of them give bad advice
It’s a great one
There’s another one for multiplayer games
Should help you get a better understanding about replication and rpcs
Yeah I have zero programming knowledge so discovering BPs has been a life saver
BPs make sense
Yeah it’s easier to work with, C++ can be a nightmare sometimes
Anyways good luck !
Thanks! Appreciate the help
Why is this replicated variable not changing for the client?
I am setting it on the gamestate with an event only the server calls (LoadMode here)
and he calls it
for the server, the value of the variable is changed. For the client, it's not, although it's replicated
usually I know, when a variable is replicated and is changed, it changes for everyone
is your actor comp also replicated tho?
🍻
what is always relevant"?
Everytime the net update it will filter the actors to update based on the actors frequency (how often the actor should update). Then afterward it will filter the actors if they are relevant or not.
Actors that are not relevant will not be send update / replicated.
E.g. when actors too far away, it can be set to not be relevant, thus the server can save bandwidth by not updating irrelevant actor.
Look into actor relevancy in the pinned section.
Always relevant probably means that it will always pass the filter. Though I haven't use one my self.
i see i see, i believe this is probably useful for players that walk around the map?
Many possibilities, designer choice.
Common usage maybe actors that are soo far away or not in anyone view
If they don't need to be updated then you can save bandwidth by not making them relevant
i see i see
i was trying to spawn an actor using gamestate, however gamemode to request the gamestate to do so, weirdly marking always relevant on the spawned actor makes it spawn on clients and if unmarked it doesnt, i do believe i dont need to tick it on but it got me curious
Wdym by game mode to request game state
Game mode only exist on server
If you want client to spawn replicated actor, the player has to send server rpc
Server rpc = hey server please do this function in your machine
i want the server to spawn a replicated actor
Ok but you can't get game mode as client if that's what you are doing.
no im calculating positions and setting up the actual gamemode in gamemode and sending that data via an interface to the gamestate which calls a server event to spawn in the actors with the info
I don't know if you need interface here
Sounds like misuse of interface
Anyway the basic is, if server. Spawn away.
If client, run a server rpc that spawn the replicated actor
game state is ?
What about game state
im calling the server rpc on gamestate yet the actor doesnt spawn on clients
i know i cant use gamemode because its server only
Clients don't own game state afaik
They should just read and receive update from server
Have you read into ownership?
If not then you seems to be lacking a lot of important bits in multiplayer basic
i did but i get more and more confused with all the different methods that i come across
Pinned section got those covered
ill look more into it ig
By default client only owns their controller and character/pawn
So you need to route server rpc in either of those 2
You can set ownership to client but that has to be granted by server
Client cant make rpc calls on actor it doesn't own
im trying to use pcg and spawn in lets say monuments, i dont think controller is the right class?
atleast because this is like lets say level setup
for now im trying to spawn in these monuments at the positions
You can only use rpcs on actors the player own, period
Doing otherwise will just drop the rpc call
Repeating my self here but you can grant ownership to client from the server but I don't think people end up doing that anyway.
Prob just have a component in the controller class that does things
Also generating stuff sounds like something the server should do then replicate to client.
yeah thats exactly what i was thinking about, i want this to be done by the server, however i think i should first read into pinned and compendium before i implement it
Clients can only do “Run on Server” RPC’s from Actors that the Client already own. The Server owns the GameState therefore you can’t make any use of “Run on Server” events. The GameState should only be used in conjunction with the GameMode class to replicate variables or make Multicast RPC’s to the clients. GameMode is used for server interna...
oh
"The Server owns the GameState therefore you can’t make any use of “Run on Server” events."
this is exactly what i was confused about
what owns the gamestate
@daring gorge
yes?
Was mentioning for the link but phone lagged out
thank you! the literal second line cleared up my confusion
also another thing that got me more tangled up was how different classes were shared, i remember an image i once saw vividly where gamestate was client and server and thought i could use state however now its clear
Why do the client have a say on how pcg are spawned btw?
I mean it varies by design
But I would thought server should be the one that tell it self to generate
Clients don't even need to do any logic, it simply receives the replicated actor
the client doesnt have a say at all, what confused me was why my actor wasnt spawning for clients but for server only
Is your actor marked as replicated?
it is indeed
Yea then there's no need for server rpc at all
I'm not familiar with #pcg-framework
Not to mention in multiplayer context
Good luck though, hope you figured it out
even a normal actor, my mistake was using a server rpc on gamestate
Well if it is generated stuff you don't need to do server rpc at all
Server just spawn it. Client just receive.
No need for any rpc
yeah, i think im not getting my doubt across well because i was more confused on which class to use to actually spawn something for the level
You can have a manager that only exist on server
The client doesn't need to know anything about it
Client simply gets the replicated actor
While server does it random generation, determine location and spawn the actor
If server spawn and the actor is marked as replicated. Client will eventually get a copy
so i shouldnt mark the replicated property for it to be server only if im right?
Only thing that needs to be marked as replicated is the actor you are spawning.
right, that makes sense
thank you so much! i appreciate your time and information, helped a lot
All the best
thanks!
Does it ever make sense for me to check if I'm the server or the client before making a server RPC call if UE is ultimately smart enough to figure out the context of where that RPC is being called for? It looks like I could save myself a Branch node.
From ChatGPT (which I assume could be wrong, I'm curious if folks here would correct it):
Server RPCs (Server keyword in UFUNCTION) are designed to be called by a client and executed on the server. However, when the server calls a server RPC on itself, the engine still follows the RPC mechanism, but with a key difference: it recognizes that the server is both the caller and the receiver.
The server will internally process the call, but Unreal Engine will bypass the network transmission step because there’s no need to send the data over the network when the server is calling itself.
That is true. An RPC does not send if its already in the context its needs to execute, when you trigger an RPC it will call ProcessEvent which long story short builds up some flags and then here decides if its a remote/absorbed or local function,
- Remote being an RPC
- Absorbed meaning do nothing, think of a client called a NetMulticast RPC
- Local means we are already in the context, we can execute it locally
btw this stuff can be figured out yourself rather than relying on guess work from an LLM, just saying
Appreciate that explanation, and that's a good tip, thank you, makes sense. In your opinion, does this make Branch (if you have authority, call AuthDoOperation, if you do not have authority, call Server_DoOperation->AuthDoOperation) redundant and just more verbose for very little upside?
On a client, this is where it ends up.
I personally like this workflow when I can, it keeps all logic shared and any server specific things I either protect in the main SomeFunc with HasAuthority or in the Server_SomeFunc Ill wait for the return type of SomeFunc and act accordingly. It really depends on the context though
void Server_SomeFunc()
{
SomeFunc()
}
void SomeFunc()
{
if(!HasAuthority()
Server_SomeFunc();
// Stuff
}
btw all the magic is inside of
int32 AActor::GetFunctionCallspace( UFunction* Function, FFrame* Stack )
Interesting just how many of these there are
Not really, its just context dependent is all
Different objects are used in different contexts and need to get their space relative to that
Hi all -- I am moving a non-character actor on the server, and the movement on the client is jittery. I've solved this on actors before by doing client side prediction of the movement and handling the replication of a location and lerping to it if it's over a threshold distance away.
Are there any built-in tools to help me do this? It seems like a common thing for replicated actors and I'm hoping there's an easier way for me to implement this.
Thanks!
Production-ready tools? Probably not. Character has the CharacterMovementComponent that does all the prediction, correction, reconciliation, smoothing, etc.
Experimental-wise, the Network Prediction Plugin aims to fill that hole. Together with Mover it could become an alternative to the Character+CMC, and you can reuse the Prediction logic in that plugin for your own custom setups too.
But I wouldn't suggest using it for production yet. Probably a 2-3 engine versions too early
Thanks! I'll re-implement the local prediction and lerping then.
Put it into a component if you don't want to redo it all the timr
Time
There's an option to uncheck Run in Single Process
just don't run it under a single porcess as noggs stated (better anyway) you don't need to package anything for this.
never tried, maybe? I used the same classes, and branchend (for editor, ifdef for package) server/client code
if / else
(though maybe the engine brings smth build in to split classes for server / client) but if not, you could also put your logic in some sub classes you instantiate from your game instance based on the target (simple GI Subsystem with instantiate subsystem only for client/server would also work)
hm your nodes could just do nothing on client / server but I didn't do crucial logic in BP
ifdef doesn't work in editor as you compile for the same target, so it was some combination using macro magic
Hey man sorry for the late reply, I wrote you a big message then my internet went offline, it came back on by yesterday, an unexpected offline week... lucky me I have some offline stuff about learning blueprints to get me busy.
Thanks for your help, I guess I'll stick with BP only for now, focusing more on the gameplay.
The thing with UE, Blender... is that we just need 72 hrs x day, leaving 24 for real life. About that I guess you need to do something you like without caring too much about the market, even if that means working on an open world map who I agree it can take forever, but at the end you'll feel happy cause you had fun doing things you like, even with some headaches 🙂 I'm too working on only one project, the others are just prototypes I made for not losing the ideas, I saved them for a future reference.
Thanks again for the insights, It's my first year with UE, and previously I only used AGS for few months, and I had a lot of fun making 2d point&click games, still missing it to be fair... I had a .TXT file on desktop with all C# stuff I was learning during the journey 🙂
Feel free to DM me if you feel stuck on ideas for your game, I lack coding skills but sometimes I still have some good ideas, I have a sailing ship too (not a pirate one, just a ferry)
Thanks for the video, looks funny and interesting 🙂
What's the best way to identify a player persistently and replicated? What I'm trying to do is store scoring info for the player, like their name and points, such that it's still visible after they disconnect, and when they reconnect they are set back to their points, something that can be traced back to the player state so that for example they can see their score.. Currently it's using the player state itself but that would be destroyed if the player disconnects and I'm currently getting other (de)referencing issues.
Hi, Can someone tell me why my clients are 1 number behind ie... They are displaying the server's previous number instead of the current one.
I am incredibly new to multiplayer so still trying to wrap my head around it. xD
My thinking is that if the server (ie... the authority changes a replicated variable value that value is passed on to the clients automatically ? (The true and the false is what to do if a client)
I'm pretty sure there's a setting for how long to persist a PlayerState after disconnection
but you can always save
Didn't quite think of saving/copying, I'll look into it thx
Yes, but you are only ever updating the display on the timer.
use an OnRep instead of a timer, the timer should run on authority only.
Authority:
Beginplay -> Timer -> change variable
Everyone:
OnRep -> Change Display
You have a timer running on every machine, and the ONLY time your text render is updated is when that timer fires. This is the a race condition like 3 different ways.
Actually one thing I've noticed that might be related, while replicated values do replicate to clients, if they're constantly replicating it might be too much data and you could notice the value stuttering. I was making a timer client-side and found this issue, though a simple workaround was to use an unreplicated client timer then update it with the replicated value as needed, like every second or when a state would alter the timer differently than the tick
@dark edge Ok thank you !
You was right adding a RepNotify and disconnecting the "client" now puts the number in sync with the server.
@fiery wadihttps://www.youtube.com/watch?v=JOJP0CvpB8w&t=802s
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...
Key word is eventually
watch that whole video
I just got this as well thought it might help https://www.udemy.com/course/unreal-engine-5-multiplayer/?couponCode=SEPTSTACK24B
but i will also watch that video ! 🙂
Q : If i choose Replicates on the Actor's root then are all components automatically replicated or do you need to check Component Replicates on each Component also ?
Am asking as I noticed theres a Component Replicates option on Text Render Component and some others.,, I did read somewhere that if a Actor isnt set to Replicate that a Component will not Replicate even if the Component Replication checkbox is ticked, Which is what prompted me to ask the above quetion 🙂
The actor needs to replicate for any of it's components to replicate yes. Replicating one component will not affect another.
And of course, only the properties that are actually marked for replication will replicate. I doubt text render component has any replication logic.
If the server calls a function from one of the player controllers say:
void ACPlayerControllerSeek::StartCache(TArray<ACameraActor*> CacheCameras) {
CacheCamerasArray = CacheCameras;
PreCacheCameras();
}
To set that cameras in the array as you can see there, this function need any type of replication or anything ?
If you want the client to run that code, then yeah, it would need to be a Client UFUNCTION
Quick question - is it possible to debug the dedicated server which is run on the editor? by unchecking run under one process
Why are you trying so hard to make clients and server have different classes? This isn't at all how the engine is designed to run. A dedicated server is nothing but an copy of the game running without a renderer.
I am performing tank barrel stabilization in a multiplayer system. In other words, the tank is turning to the left and I am giving the barrel a right turn value equal to the tank rotation multiplied by the minus value. In this way, the barrel always faces the same direction. I am experiencing a shaking problem as in the video. The shaking on the...
Looks like it's because the barrel is updating first and then the tank body. Thus causing it to flicker.
You would be able to debug it either way
If it’s under one process then the engine is basically just ticking two different worlds and ifs seperate then both instances still are running at the same time and refer to the same symbols so you can break point and debug either way
Executing a game in editor with a listen server mode and itself + a client the log return that the first game controller call is on a Standalone Net Mode and the next one pass under Listen Server, is that normal ?
Yeah that video is useful 'cos single player games are mostly about psychology. Multiplayer games can be fun just shooting each other like playing in the park without anything fancy so that's just more technical infrastructure and coding wise. If you want to avoid frustrations and publish games start with single player and the basic rules of multiplayer are pretty easy you can even do simpler games in blueprint only if you're not aiming to do fortnite. If it works in multiplayer it also works in single player so you can do both if you're only looking for simple things like say a chess game that's 1 on 1 and you're just replicating the positions of the pieces that each player moves, well you do not need C++ for that and this doesn't involve any Gas or anything like this either.
If you get time I would recommend learning C++ but you'll probably need to do some Udemy courses. You can do that alongside but honestly there isn't a huge point to C++ unless you're gonna do a framework or complicated things or multiplayer (because there are a few limitations of blueprints in multiplayer). It's kind of handy if you need to like make a complicated tick function that runs every frame then you can do that in C++ to make it faster and it's great for understanding how unreal works. However life is short and I haven't had any time to do blender since I started this C++ project but technically I am doing fortnite. I found that open worlds are hard to do 'cos of things like the land gets loaded on all clients anyways so if you have 100 clients and a huge map it's not really built for this. I've found some tricks around this but this is easier with the type of game I'm making there is hardly any land haha. Okay I'll add you as a friend so you can ask me any questions if you get stuck or if you want any course recommendations.
im trying to implement spectator mode, where dead players can see from the perspective of players
when a player dies, I run Set View Target with Blend, on the dead player's player controller, targeting one of the living players
this kind of works, because the camera now is following the player, but it is not applying its rotation, so the spectator is stuck looking south
if I try to adjust the rotation of the camera with set control rotation, it does nothing at all
I tried to run unposses on the spectator's player controller, and this makes the set control rotation to work.... but the camera no longer follows the target player
I'm kind of lost, anyone has any idea or suggestion?
How do I go about replicateing detaching? attaching works fine but detaching does not
Worked nicely after changing that and the TArray to const ref, thank you so much!
Hi guys, I'm having issue replicating Launch Character despite calling it through a replicated event. It's happy on the server and stutters like crazy in the client. In the video, the two left screens are clients, the right is a server.
Can I get a helpful hint here? Been working on this several days, followed every relevant lead on google, unreal forums, and YT tuts.
Launch Character is usually meant to be called Predictive and only really for a one-time boost, like a LaunchPad.
You would call it locally and then via a ServerRPC. There is no need for the Multicast.
And that coooould still cause corrections fwiw.
Will cause corrections
Na, LaunchCharacter is strangely enough quite fine
I’m using it as a one-time boost, not for consistent movement
Maybe if you use something in the environment like a launchpad it'll be fine
Like a wave dash of sorts
I wouldn't call the Multicast fwiw
But yeah, a Key -> Dash/Boost is usually not possible without C++
Well, without corrections
Yeah that needs to be predicted
Is that specifically a launch character quirk?
Entire games are made without a single net multicast (beyond what the engine itself uses) 😛
No, that's you just sending the Client, who would already predict the velocity change, that they need to boost again
Client boosts, tells Server to boost, Server tells everyone again to boost.
Redundant even
So I dont need to be calling a server event that then calls a multicast event for all my stuff? That’s what has made everything g work so far
Consider using network emulation settings
That'll give you ~150ms latency
I have with the default client latency 30/60
Am*
The point is that the CMC already does the ServerRPC part, and you usually add additional "Key -> Stuff Happens" things to the CMC in C++.
If you add them in BPs, then you need to at least do the ServerRPC, but you will also most likely have corrections.
Cause there is a lot more to predictive movement than that RPC
If everything else has worked via blueprint, is it still best to move it to c++? Or just leave it if it works? All my other movement, throwing a physics object, etc all working with blueprints with a similar server -> multicast setup
That can't actually work, so you're seeing false positives
First step is to figure out why you're seeing sane results
In most cases, users who think their BP setups work have never properly tested their game in an actual Multiplayer setup or have found some edge cases.
How? Not in a smartass way, I just genuinely don’t know. I have listen server + 2 clients all replicating other actions, with network emulation client side 30/60
a Physics Object thrown by a Player should have problems. Either it's laggy cause it was only thrown by the Server, which leaves the Client with a lack of Interpolation.
Or you are throwing it on Everyone with a Multicast, and then you won't have deterministic physics on everyone and people will see different results.
Whenever I have to deal with throwing stuff I use a ProjectileComponent, cause that at least does some smoothing on clients.
Physics are almost always a nogo
I’m syncing client states after certain things, maybe that’s what fixes? I’ve a “ball cam” to follow movement and it’s sync’d among the 3 screens when it’s thrown or hit, even very fast
Welp, I can only tell you what I experienced the past 10 years.
That boost will s*ck in BP only
Unless you don't care about cheating and just set the CMC to Client Authority
But never tried that
I definitely don’t want any of that. I’ll look into putting it into CMC for sure
There are pins on this channel with some simple code samples for that
Vaei's post that is pinned iirc
The samples included are generally states that you enter, like prone/strafe/sprint/etc
I would model that ability closer to how CMC handles jump
This one? #multiplayer message
This one
Cheers. I’ll study up on this
Cross reference it with how the engine handles UCharacterMovementComponent::DoJump() because that's relevant to your wave dash
Hiiii!
But i am unable to debug the server side code when it’s not running under one process
What about as Listen server the server should be the active process in that.
is it same as dedicated server. If yes then I can debug it
It's not the same as it's also a client but I imagine in seperate processes it might be doing just the server part or well atleast it should have the server in that mode regardless.
I see! So to debug them properly the only way is to make different builds for client and server. Thats just too much time consuming
I'm not sure what you're attempting to do. I just use one process and this works fine. Seperate is better 'cos sometimes it will work in one process but not separate but single process works fine too.
Some things aren't on the server or client at all so you should first check you're not attempting to debug something that's not even on the server at all.
righttt. I wanted to debug scenarios where things don't work in single process
That's not gonna help if it doesn't work in one proces it probably won't work in seperate process. I usually do that to ensure that it will work in shipping etc. once it's working but some people use only seperate.
I need to do the logs.
it works in one process but sometimes the behaviour is different in separate processes
Yeah then maybe you made some mistakes somewhere, the single process is a bit more forgiving. Try Client Mode and use GetNetMode() to check if you're on the server or client. Do this in single process and hten in seperate processes to see if there's any difference if you're getting the server in both or not. It should say Dedicated server or client depending on which one youre in.
got it! Thank you
Do you guys use Validation on all Server RPCs ? I feel like it doesn't make sense sometimes, like when interacting with something, I just check if the trace hit bool is true and if the object matches the requirements, if I put these requirements on validation, the client gets disconnected for simply pressing E on nothing for example
It rarely makes sense to use the actual Validation method as that'll kick people for cheating if it fails.
You should definitely validate what your clients do, but that method is too extreme.
Ah I see
Unless you're validating the use of admin commands or something?
Something obviously wrong.
So validate only when really necessary, like something that could be cheated
No I was talking about validating the Interact server rpc
Like interacting with a door or whatever
You could validate the distance they're interacting from.
Yeah I did something similar to that, but the problem arises when you're pressing E by missclick for example, the server will return false on validation for a mistake
Like if you didn't mean to interact at all with the object
You can't "misclick" and interact with something 5km away unless your game code is fubar.
I don't know how to explain? Imagine a scenario where you're new to the game and testing inputs, you press 'E'. You send a server RPC, and then you get kicked out because validation returns false. But now as I'm typing this, I think I missed the part where you should check for the same condition on the client before sending the RPC?
My point is that if you press 'E' you aren't going to just interact witha specific object no matter where you are, are you?
You're going to interact with the one that's in front of you.
Yes exactly, but what about pressing 'E' when you're looking at the sky for example?
Yes that's what I said here, I think I missed the part of doing the check locally before letting the server validate
The server should only ever get "valid" rpcs.
So always check locally first. 🙂
(unless somebody is cheating)
Yeaah haha I don't know how I missed that
Valid does not mean correct. It just means it could be right.
Like 1 + 2 = 7 is valid. 1 + 2 = elephants is not valid.
Yeah I see what you mean
A "valid" call is on something that's usable and nearby, in range. A "correct" call is something you're able to use nearby and allowed to because of game logic, where the invalid one might not be usable yet because of game logic.
Yep, and I somehow just forgot about the "correct" call and took it out of the code when implementing the validation
Forever editing my sentences.
Hahahaha happens
Thanks for not only this info, but all the other infos I get when I CTRL+F this channel hehe
Np. 🙂
Hello!
Does someone has some experience in netcode? Inpterpolation?
Better to just ask your question
If I am making a custom movement component that inherits from the pawn movement component. Would it force me to use the predictability system like CMC + GAS?
because that's the code in Unreal which makes the SendClientAdjustment() to CMC
What is your movement component for, players or AI?
Players
it is for players but there can be plans for AI in future but the priority is for players
@grand kestrel
So what is your reason for creating a custom version instead of using CMC
Can't really give advice with a lack of details
its because I want to be deterministic in what is going on between the frames
and it's a fighting game so I think I'll need it
Oh. Yeah that's an exceptionally complex topic
You need a separate thread away from the game/render thread
And fixed point numbers instead of floats/doubles
And input polling from within the separate thread
Sounds like you want GGPO
But GGPO requires a deterministic physics engine that Unreal doesn't have
GGPO is for Peer to Peer
I would have more than 2 players
something that brawlhalla uses
i think they use server-client
I would be simulating most of them. Won't be using their physics
Yeah GGPO is no good for >2 players
You will still need everything else I said
The good news is that building a physics engine for AABB (axis-aligned bounding-box) only is significantly easier than building a full physics engine with OBB (oriented bounding box), spheres, capsules, and so forth
I understand the fixed point issue but why is there a requirement of input Polling from a separate thread?
Because if you're polling input from the game thread then the inputs will differ at different times
And determinism breaks
Physics engines occur in multiple stages
- Hashing (usually Spatial), to pair everything that can collide with what it can collide against
- Broad-phase collision, to determine if their bounding boxes overlap
- Compute linear/angular velocities
- Integration (of velocities to transform)
- Sim recording/replaying
- Repeat step 1 because they've now moved
- Narrow-phase collision, to determine is their actual collision shapes overlap
- Contact solver - what happens to shapes that collided
- Constraint solver
But because you only need AABB you can skip step 6/7, and you probably don't need 9
You are welcome to reference my own physics engine, but it is extremely early days and doesn't even work yet, but these three things might help:
Comparing overlaps between two AABB
https://github.com/Vaei/Tether/blob/b0215dc3541f3e0ad02e0c47692064b76a0f770f/Source/TetherPhysics/Private/Physics/Collision/TetherCollisionDetectionHandler.cpp#L328
Creating a single thread away from game thread
https://github.com/Vaei/Tether/blob/main/Source/Tether/Private/Threading/TetherPhysicsThread.cpp
I didn't expect this much from a simple 3d fighting games. This sounds like I might need to think in a different way now.
Unreal isn't built for fighting games or anything that requires determinism at all
Deterministic physics engine is not generic at all, and only suits very specific applications, so engines don't ship with them
"simple" and "game" dont go together
Fighting games in particular are deceptively complex
RTS as well, probably even more so
Every game is deceptively complex
In their own ways
This is the common misconception from those that dont make games for a living lol
The other thing with fighting games that makes ready-made solutions unavailable is that for myself, as a programmer, despite being a reasonable artist, the art requirements are so extreme/severe that it just isn't worth building for
Fighting games live and die by their characters possibly even more than their actual netcode/gameplay
So even though I could integrate GGPO into Unreal, until someone with those art skills and budget decides to hire me to do it, I'm not going to waste my time
I'm not sure if there are other types of games that can benefit from determinism, but I think its really just fighting games and RTS
Im sure there are benefits, but whether or not they require it is a different story.
no good news for me lol
do you think a game like brawlhalla had to go through that much?
Fallguys might benefit from a deterministic physics solution, to maintain more accuracy, but Im sure it runs fine without it, mostly because Players dont really notice or care for the most part.
my game doesn't even require blending of animations
I don't know what Brawlhalla does tbh
I played it a very long time ago
IIRC it had some issues of its own
so what if I move with the physics solution unreal has?
and do a simple netcode with my requirements
- Determinism is out the window
- You'll provide servers that benefit the closer player, OR
- Players will host that benefit the hosting player, who can cheat
And, players will complain about your netcode
You could look at a hybrid approach with an authoritative middleground; I suspect Tekken 7 did something like that, but they're not exactly heralded for their netcode either
Lockstep isn't an option with that many players, it won't be responsive enough, unless you're making... An RTS
As far as Unreal's server-client models go, I'm not sure they're well suited to this
uhmm it happens in most of the games isn't? Someone closer to the server is obv benefitting
And as an indie the last thing you want is to pay for dedicated servers
So you're basically left with listen servers
The host will have 0ms latency, everyone else will be based on distance to host, and host can cheat
I think Tekken 7 uses something entirely different again, where it introduces input delay while waiting for input from all players
So its nasty if there's any latency
I mean in games like CS GO, Valorant - players closer to the server are benefitting more
There is only so much you can do to combat latency
Its a fundamental restraint of the physical world.
So if you:
- Create deterministic physics
- Predict the inputs like CMC
- Implement record/replay for your physics
- Synchronize from server/authority
- Implement latency compensation
I think that's the best outcome with Unreal's server-client model
The reason this feels exceptionally complex compared to other game types with Unreal, isn't because its more complex, its because Unreal doesn't have an out-of-the-box solution available for you to use
Its actually less complex if you were to build both systems from scratch
So the main thing is the physics here
right! I have been looking into how CMC is handling interpolation. My game would be way simpler in terms of movements but as you have mentioned it's the physics that needs to be deterministic. What exactly is the issue with Unreal's? why isn't it deterministic?
CMC I guess defers the update of the capsule component
Because determinism requires fixed-point math which is useless for anything that doesn't require it
That generally means you use int64 instead of a float/double and avoid division
And, as mentioned, running in it's own separate single thread with input polling from that thread instead of passed in from the gamethread
that can be done by converting the timestamps to int?
Its not timestamps I'm talking about
Its transforms
There is no feasible way to do it, changing UE4 from floats to doubles was an astronomical undertaking, changing to integer math is all but impossible
I have seen CMC quantizing the location, rotations as well in their system
You'd have to build your own physics engine that uses fixed-point math
That's just compression, it loses even more data, which is exactly what you want to avoid
Using fixed-point math, or integers/whole numbers, means there is no rounding and nothing to lose
And that is essential for determinism
righttt
You could have a int64 for Location.X
And then a uint64 for decimals of Location.X's int64
That's how fixed point math often works
got it! looks like I would either need to compromise or implement a solution
and a solution doesn't seem like an easy way
You can get away with
1. Hashing (usually Spatial), to pair everything that can collide with what it can collide against Simply compare all shapes from other characters of within x dist
2. Broad-phase collision, to determine if their bounding boxes overlap
3. Compute linear/angular velocities Just linear
4. Integration (of velocities to transform)
5. Sim recording/replaying
6. Repeat step 1 because they've now moved
7. Narrow-phase collision, to determine is their actual collision shapes overlap Using only AABB there's no need for narrow collision
8. Contact solver - what happens to shapes that collided
9. Constraint solver You probably don't need constraints either
It shouldn't really be too complex if you understand the basics
Gather all the bounding boxes from each character & Match them against each other
Check if any of those overlap
Compute linear velocity (just add or subtract velocity based on input)
Add the velocity to the transform
Sim record/replay (this is literally just recording timestamps for transforms and reapplying them)
Check again if anything overlaps now that they've moved
If they overlap, push them away from each other
that's very very insightful. Really thankful to you
so the bounding boxes you are mentioning is gonna be handled in the separate thread which will take input polling and handle physics?
Everything would be handled from there, it would have to update at a fixed time step
yeah I think it's gonna be important to do that
Check back in 5 years when you're done with the first draft of it.
Imagine how much you'd learn tho 😛
I was just collecting my requirements and I think i need physics only for collision detection. I would be simulating the rest of the stuff. Can I improve the unreal's physics by using fixed time step? I am trying to narrow down the parts that I'd need to do on my own. http://www.aclockworkberry.com/unreal-engine-substepping/
Unreal doesn't have fixed timestep unless you use Async Physics
CMC also doesn't care about physics timestep, it's independent from that
I have seen it defers the movement of capsule component once everything is updated
I am not sure if Async physics can be used in my case but this physics seem to be an issue for now and I need to figure out a way to make it fit to my requirements even tho I might need to compromise with a few things
If I think of my game then all it might need is AABB collision.
The capsule is just deferred until the character physics is processed. The character isn't a physics object, it's kinematic.
But character "physics" are not rigid bodies
So they are unaffected by the physics scene
so if my characters dont use rigid bodies at all then is it safe to use it for my game?
sorry if its a dumb question but I am trying to get more clarity here 😦
The only place where I need Unreal's physics is just for the collision detection, thats all.
It's a Kinematic body. It's still part of the physics scene, it's just not "simulated"
uhm 😭
so its just the capsule component which is making it a kinematic body? I am using a Pawn btw with a skeletal mesh. I think the mesh brings some physics too?
everything with non-query collision is a kinematic rigid body
But that doesn't mean it's a physics simulated object
It's just part of the physics scene and is known to it for collision
you're actualy movement simulation doesn't have to be done inside the physics engine, which is how CMC works.
I see! So basically with what I have read I can understand this is happening because physics runs on a different thread and it will make it all tough while syncing and saving replays
CMC is deterministic IF you run at the same framerate, and on the same hardware and with the same compiler flags
But then so is Chaos in that regard
What's the issue you're having?
Yes! if capping the framerate can help then I can go with it. This will make it more accurate.
I should clarify, it's deterministic assuming all simulation parameters are identical - which in a multiplayer game, they almost never will be
I was actually working on my own movement component. Very simple if we compare to CMC. I was asking if I use Movement Component for prediction system then would the architecture of the system would be more like CMC + GAS? I got those suggestion while I shared more info about it
This is the point about determinism, absolutely everything that effects your sim also needs to be part of that deterministic step - otherwise, implicitly, it's not deterministic
If you have two clients controlling players that have blocking collision to each other, determinism is literally impossible with a predictive model
I think I should test a sample project to see how bad the collision is in multiplayer at different pings. Will make me to understand how well it works.
it does consider collisions in CMC right? To predict if it doesn't bump into something
oh it handles collision in its movement updates
Hi, I have a basic movemental players for Listen Server project but client pawns movement is bad. How can I improve it? 🤔
- in video, left large disc is Client and brown is Listen Server. all have same settings and movements.
Hey, can I spawn replicated actor from client actor thats has no replication ?
Yes. But it won't replicate.
you can't even enforce it right? Cause there is no network channel to send info ?
Things only replicate when they are created on the server.
I got spawner actor without replication. And they also got player few player stats (i know it should be player state) but lets ignore it.
Maybe I could enable replication for SpawnerActor, but use only Events to spawn on server, and keep all stats local ?
hello, i want to communicate with external services, i was wondering, is it possible to create a simple ssl tcp socket without using external libs?
anyone know of a way to have something like this but have replicated secondary worlds? My goal is to have an open world online co-op zelda like. Typically in these games there are buildings where the interior is bigger than the exterior and or dungeons are separate levels. Other than hiding levels like this under the map (not a great option), this type of plugin was the only thing I could think of.
https://www.unrealengine.com/marketplace/en-US/product/multiworld
Hi I'm facing a problem with the replication system, I'm developing a voxel game, and as chunks get created and destroyed on the server, it seems that the destruction is not always replicated on clients, resulting in inconsistent actors count:
my man how many chunk actors do you have?
What does a chunk represent, a chunk as in Minecraft, a subset of a few hundred or thousand voxels?
or is 1 chunk 1 voxel?
1 chunk represents 16x16x16 blocks rendered as one mesh
Show how your destruction is replicated. When does a chunk get destroyed, when all blocks are empty?
It gets destroyed when players are too far away from the chunk
I have a list of all chunks that must be maintained (ToLoad) and compare with the current loaded chunks, I destroy all the loaded chunks that are not in the chunks to maintain (ToLoad)
It seems to be working great, as on server, it maintains the correct number of chunks per player (in the current case 32 per player)
But on clients, many chunks aren't deleted
OK so each client has chunks in a radius, and server sees the union of all clients chunks. So if Client A has 50 chunks and B has 50 chunks and they don't overlap, server has 100 loaded, that about it?
how do clients know about the chunks being loaded and unloaded, the spawning and desruction of replicated chunk actors?
I don't think you will ever find a real world use-case where CMC is deterministic
CMC is still affected by render tick too, it isn't running a fixed timestep
All its doing is adapting those intervals based on the render tick delta
CMC is literally designed for non-determinism
It will never be compatible with creating a fighting game where determinism is required
Has anyone using Iris successfully got Subobjects to replicate?
Oh good point, I should have asked it --
Basically, I'm running into this, and I'm a little stuck on how to fix it. I've followed the docs, I've added the RegisterReplicationFragments() to the subobject. I've got bReplicateUsingRegisteredSubObjectList = true; on the owner object. I've called AddReplicatedSubObject(TheSubobject) on the owner.
Edit:
It's worth noting that the owner is a freshly spawned Actor
Edit 2:
A clue:
LogIrisBridge: Error: ActorReplicationBridge(1)::BeginInstantiateFromRemote Failed to find Outer [NetRefHandle (Id=596):(RepSystemId=?)]NOT_IN_CACHE for dynamic subobject
This is in ObjectReplicationBridge
Note the Iris section at the bottom https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-uobjects-in-unreal-engine
I thought about it and figured out I can solve my issue by not using a capsule component on the pawn. Rather I can create a simple custom sphere collider which can handle most of the collisions of moving objects. I think Divine Knockout also uses that technique to get rid of it in an easy way
in cmc are movement mode changes replicated and predicted?
Exactly
Well, the chunks are created on the server, and as the chunks are replicated, it is also created on connected clients, the replication of created chunks works fine, the problem is on destruction of replicated chunks
are they just destroyed on server, that's it?
Yes
That is weird, you doing anything non-standard in the destructor or end play or whatever?
Any idea whats causing this? Sorta a weird issue. These balls are spawned in as server, then switched to client. The balls seem to work, but then some of them freeze and eventually extrapolate and then freeze again. I am using SmoothSync with sync ownership set to true
solution found: Multicasting the client ball switch fixed this
Why simple physics replication is not ideal?
is there some optimal way to sync them instead of doing Multicast with timer / tick intervanls ?
or maybe its due root component being default ?
If you find a way to replicate phys well please do let me know
I may be stupid here but this does not work.... When client clicks button it does nothing. Server has to click it even though server does not have gun its I know it reads the click on client because it prints the string
I want to learn replication and serialization in detail by going to the engine source code, but other than starting with AActor and FArchive I don't where to begin reading. Does anyone have any suggestions on that?
Take a look at FHitResult::NetSerialize
UPackageMapClient is also a good class to look into.
For example.
Here is where Actors are literally spawned on the Client when Replicated.
Hello im trying to replicate all of the points across to the players all players will have the same amount of points I tried to use a for each loop for the players with no results any help would be grand!
You just have to set it from a server not a client, it will handle letting the other clients know its value
Oh so should i just run on server or give “has authority “
Ideally probably both but if you have it as a server RPC then its already promised to only run if you are a server
You should check out the pins and some docs
I see ill look into it thanks for a lead!
I would delete what ever you have in these 2 pictures
Don't use multicast for stateful behavior
Score should be handled, added and counted by server only. Client should only receive the updated value from the server.
Unless client can set it's own value by design but I doubt that's what you want to do.
So where would the most optimal place for this be I just have it running on the game instance so the variable is held and transferred betwwen levels where should i put it if i want it to run purely on the server and send to all players
Is there a way to maintain the same random idle animations between server and client? It's not that big a deal if I can't do it, but it's still overall better
yeah in a roundabout way that's sort of what I meant, in reality, you're never going to simulate with such repeatable input
You just make sure that the code only run on server machine.
Depending on what tou are doing rpcs shouldn't shouldn't be needed at all, unless the client have a say.
Picture a coin collecting game where upon contact with the coin, score gets added.
You can just care about the collision that happend on server machine.
On overlap-> has authority -> authority pin -> set score.
That's it no rpc or other things needed.
If score is marked as replicated the client score will eventually be updated
Got it ill give it a run through in the morning thanks for the help!
hey all, maybe a simple question, maybe not; when I have an actor and sub components that I don’t want to replicate but are still part of a multiplayer game, is their logic executed on the listener server or on the client where they are spawned? To clarify, I have a player that I don’t want to replicate (I know, strange game); who is responsible for ‘executing’ it?
I admit I’m a bit confused by all the tutorials and guides I've read in the past days (so zero practice or most)… I’ve kind of lost the thread and I’m trying to find some ‘solid points’… thanks in advance
Not sure I follow your question, but if a non replicated actor is spawned, it is only spawned and executed on the machine that spawned it.
sorry if the question isn't clear it's because there 's quite a bit of confusion in my head .. so if I want an actor to not replicated at all all I need to do is to spawn it in the client (would it get automatically the ROLE_Authority ?) otherwise if I want it to be "replicated" it has to be spawned by the server itself .. ?
Yes. The actor must have Replication enabled too.
so if I just set "replicates = false" in a server spawned actor then it would just run there and not notified to the clients
yes
so last question (and thank you for helping a noob) .. the player itself in a multiplayer context is mostly run in the local client, replicated on the server and then .. replicated to all other clients ?
That's quite a big question, but essentially, yes. At a basic level the owning client moves via the Character Movement Component which replicates desired movement to the server (and predicts it locally for that client). The server validates the movement and then broadcasts it to all clients.
when you say movemente does it also include the animation running ? like walking , jumping and so on ?
usually the animation is driven by reading values from the client/cmc not replicating state directly.
so in order for the clients to see the ‘correct’ animation, I need to make sure that the internal state I use to decide what to show is properly replicated… but at that point, I don’t understand, is there a moment when the remote clients automatically ‘execute’ the player’s code, apart from the part that comes from the server .. or do I need to do execute it via other means (ie RPC) ?
It depends how you write your code. If a replicated actor exists on a client, then, for example, BeginPlay is called on that client, owner or not. It's up to you if you decide to execute any code for it or not.
okay thanks again, I'll stop here 🙂 .. what confuses me a lot is that is just by setting some replicates flag to true thing start to 'almost work'; but understanding what to do to fix the parts that don't requires experience and probably a lot of trial and errors
Yeah it takes a bit of time to get a feel for how it works. But when it clicks it all makes sense.
I replaced default root component with phys mesh and it works pefrectly
Who must be the owner of actor to do RPC? Player pawn or controller ?
testing with advanced sessions plugin, how do I simulate connecting with a steam account (including using a real one)
because it keep failing when I'm trying normally(?)
i'm pretty sure the CMC is deterministic, since it uses sweeps and traces as opposed to simulation physics. it just isn't at a fixed tick rate
whoops i was scrolled way up
it is, if you can keep every influence deterministic too, which in reality is almost impossible
Heya guys,
Does each client get its own player controller?
I assumed it would, but calling getPlayerController(0) gives errors on clients. Do we need to pass their specific client index?
This is specifically used for player controls, so no replication needed
Yes, each connection (including a player acting as a listen server) will have a player controller that’s only relevant to them. You don’t need to change that index if you’re not using split-screen.
The errors you’re getting are most likely stemming from the context you’re calling the function in
The player controller atm, contains references to the HUD and stuff. So if the player gets damaged, it updates the hud.
However calling GetPlayerController(0) gives errors that it's not found, or server only or something
I heard of using GetController instead, as GetPlayerController(0) seems to try and get the server version?
I'm a bit confused on what the difference there is. Like why would there be 2 different functions that essentially do the same thing but, not
It all depends on the calling context
Is the server executing the logic that calls Get Player Controller? If it is, it will return the server's local player controller.
No it should all be local
Like the players own movement controls, pulling up their inventory, etc.
Pictures will make this go a lot faster
The logic
It just doesn't like me using GetPlayerController(0)
It's just this, not much logic to show
(Note: This is an angelscript plugin, not C++)
GetPlayerController(0) is just nullptr
when playing as a client
Oh pff, never touched Angelscript. Sorry
Well my advice is still the same, it's the wrong calling context whoever it's being done
Yes but telling me it's wrong is not very helpful lol. I can see that it's wrong
Lmfao, goodluck
Just trying to figure out the right way to get the local player controller
As GetPlayerXXX seems to be server only
This looks very helpful, thankyou.
So it seems like there's no static way to get the local player. That was my issue, relying on anything being able to get the player reference at any time.
Will have to modify a bunch of stuff and drop the static references. Sadge
When I press 'N' I want locally spawn ai controller with running behaviour tree. Its working on netmode: 'standalone' but not in 'play as client'. Can anyone know why that happens. Ai controller is not replicated.
This is in Ai controller and print gets always printed but behaviour tree never runs
This breakpoint gets alerted only netmode standalone
Generally speaking, anything that needs the PC, has access to it already. You can also do GetAllActorsOfClass<APlayerController> and then for extra safety, check that it is the local player.
Oh awesome, because each client would only have their own player controller in their game right?
I don't remember the exact syntax in AS though.
Yeah
Could also iterate playerstates as well. They have references to the controller
It'd be null if it doesn't exist
Oh sweet.
Then I after finding the local one, I could create my own static "PlayerController". So everything is able to reference that
Very cool, should work perfectly. Thanks man!
Eh - I wouldn't do that. Just do a static method that gets it.
So you don't need to worry about properly cleaning things up and all that.
But would the static method run GetAllActorsOfClass<APlayerController> every time? Or iterate the PlayerStates
I fear that might get slow on multiple ticks
It won't
Oh lol
GetAllActorsOfClass is pretty much a dictionary lookup at the end of the day
So what am I thinking that is really slow, is it unity?
No. You just haven't measured anything.
I think it's unity that has a GetAllActorsOfClass that's stupidly slow
Unity doesn't have actors
There is also a huge misconception that GetAllActorsOfClass is slow and it doesn't help that there is a warning on it as well.
But that hasn't been the case in a very long time.
As for the playerstates - you'd be iterating, maybe 4 elements. I'm assuming you're doing a 4-player coop game, as that is the more sane thing to do rather than some 32 player pvp game or w/e
And iterating 4 elements is dirt cheap
Loading a texture will cost more in performance
Yeah, I dabbled in Unity for a few years and have their inefficient methods stuck in my brain
Nice knowing unreal has their shit together lol (mostly)
Ehhhhhhhhh
Alright well thanks for the info man! Extremely useful
tbf, it's computationally expensive because it's a terrible solution in the first place
same deal in unreal land
GetAllActorsOfClass still iterates over all actors in the world, not just those that of that class type. It's a relatively expensive operation.
No it won't
GetAllActorsOfClass uses an internal hash map so it's faster than you think. Still a brute force solution that has many better approaches
It does.
You don't have to take my word for it, look at the code
I literally did
It's just a TActorIterator
Specifically because of a talk some time ago in #gameplay-ai
void operator++()
{
// Use local version to avoid LHSs as compiler is not required to write out member variables to memory.
AActor* LocalCurrentActor = nullptr;
int32 LocalIndex = State->Index;
TArray<UObject*>& LocalObjectArray = State->ObjectArray;
TArray<AActor*>& LocalSpawnedActorArray = State->SpawnedActorArray;
const UWorld* LocalCurrentWorld = State->CurrentWorld;
while(++LocalIndex < (LocalObjectArray.Num() + LocalSpawnedActorArray.Num()))
{
if (LocalIndex < LocalObjectArray.Num())
{
LocalCurrentActor = static_cast<AActor*>(LocalObjectArray[LocalIndex]);
}
else
{
LocalCurrentActor = LocalSpawnedActorArray[LocalIndex - LocalObjectArray.Num()];
}
State->ConsideredCount++;
ULevel* ActorLevel = LocalCurrentActor ? LocalCurrentActor->GetLevel() : nullptr;
if ( ActorLevel
&& static_cast<const Derived*>(this)->IsActorSuitable(LocalCurrentActor)
&& static_cast<const Derived*>(this)->CanIterateLevel(ActorLevel)
&& ActorLevel->GetWorld() == LocalCurrentWorld)
{
// ignore non-persistent world settings
if (ActorLevel == LocalCurrentWorld->PersistentLevel || !LocalCurrentActor->IsA(AWorldSettings::StaticClass()))
{
State->CurrentActor = LocalCurrentActor;
State->Index = LocalIndex;
return;
}
}
}
State->CurrentActor = nullptr;
State->ReachedEnd = true;
}```
I also actually measured it with 100k actors in the world. Guess how long it took?
^^ Iterates through all actors
I'm thinking of TObjectIterator, mb
But yeah either way, it's a brute-force solution for when you have zero other alternatives, so of course it's "slow" relatively speaking
Oh - sorry, it wasn't 100k. It was 300k. #gameplay-ai message
^^
Sooooooo slow
Your test was flawed.
Okay. Keep avoiding fine solutions 👍
You need to use the Unreal Trace to get accurate performance measurements.
There's a scope cycle counter on it for a reason
Material changes should be onreps anyway. They're stateful
why ?,
or well if u mean they wont be changed for "newly" join players i get taht
i wont have that issue in this type of game
GetAllActorsOfClass does utilize the TActorIterator which is more performant than a standard brute force approach to getting ALL actors, its by no means a dictionary look up. It still heavy and has pretty substantial overhead to it, just not as heavy as a manual iteration through all actors in a world
^^
Can't argue with that test
This can also break it down for the entire process https://www.casualdistractiongames.com/post/2016/09/15/Inside-UE-Source-FUObjectHashTables-the-magic-behind-GetAllActorsWith
And there have been games that have shipped with using it on tick with no noticable performance issues.
I literally thought the same as most people until I was challenged to actually read the code and test it in a packaged build. I was proven wrong.
Is it the best solution? No. Does it work for what they need? Yes.
Of course you won't notice the performance implications of using it a couple times. But it's a poor recommendation, and it has a higher performance cost then just doing something else that isn't taking a lazy approach.
Also - make sure you're only calling this from something that has network ownership
yeah the player is calling it
Destroy All Humans 2 used it on tick.
Was just fine
I also told them they could iterate the playerstates - which is also a valid approach.
They have options. They can pick what they want
As for doing it occasionally - they likely only needed to do it occasionally as well.
So again, it is fine
That's just cargo cult thinking lol
It's bad advice to even tell him to iterate over all player states with GetAllActorsOfClass, there's already an internal PlayerState array that's held by the gamestate. Just because you can doesn't mean you should.
I didn't say to do that
I said to use GetAllActorsOfClass with APlayerController
Not with player states
tbf you also have FPlayerControllerIterator
There's plenty of other ways to get the player controller without needing to use a lookup lol.
It does, but it's still an overhead.
@quasi tide hmm its changing on the server but not for the client for some reason :/
It's obviously not for(AActor* Actor : Actors)
Ye. I don't use it.
Might be a relevancy issue
wdym ?
And I literally gave them multiple options. Even telling them that everything that needs access to the PC typically already has a way to access it.
Did you even read what was written?
🍿
The actor is too far from the player to be considered network relevant. So they don't get the rpc.
So this isn't a recommendation to use GetAllActorsOfClass lol?
I think you have some reading comprehension issues
I didn't say that I didn't give that recommendation.
It does have some overhead to it, definitely more efficient than a manual iteration over all actors. The performance implications wouldnt scale linearly based on the amount of actors, but it shouldnt just be used in place of a proper reference to an object I think is what Elliot is saying
Generally people still start attacking others competencies when they are frustrated and emotional in arguments. So have fun, I'm done with you. Quit being a child.
I've told you multiple times my position. Saying it again won't change much.
If you think this is emotional...I don't know what to tell you
When it comes to adding background music to multiplayer games how would someone recommend going about this? Should I spawn like a music manager bp or something to handle it?
Told them that things generally already have a reference ✅
Told them about GetAllActorsOfClass<APlayerController> ✅
Told them they could iterate the player states ✅
Literally just told them various ways to accomplish what they want
Yes, it does have some overhead. But it is blown completely out of proportion by an overwhelming majority of people.
I agree on that. I think a lot of that comes down to teaching a beginner to not rely on certain things. If they think the function is free then they might think to use it everywhere
The more narrow the class search, the better it will be
@quasi tidehow can i resolve that then ?
I even tested with a 12 hierarchy deep class structure.
Yeah and newer developers over use inheritence and will make this search less performant than it could be because they'll be looking for some base class rather than some composition style structure. A lot of it comes down to putting the fear into new developers so they dont have a reliance on "easy" functions
So far, in an actually packaged build - GetAllActorsOfClass has performed far better than what a vast majority of people say.
Can't dig too much. Have a work meeting
I think we are all on the same page though, its a good conversation and gets the gears turning. I dont think any hostility was necessary though
Consistent statements that I said something that I didn't also isn't warranted.
The passive aggressiveness also wasn't needed
But I digress
I can see how I was talking could be considered passive aggressive. So I apologize if I came across as such.
Hey, so I'm looking at this code and a bit confused as to why PrepMoveFor isn't implemented for sprinting. Shouldn't it be updating bWantsToSprint there? Every other doc I've seen overrides both SetMoveFor/PrepMoveFor https://github.com/Vaei/PredictedMovement/blob/main/Source/PredictedMovement/Private/Sprint/SprintMovement.cpp
@quasi tide hey no worriest just update: i put the functions closer to the character and it worked so im guessing it had with the relevancy part ! thanks
bWantsToSprint updates from compressed flags
Anyone got time to look at my Character rotation BP? What's happening is that it is not replicating at all no matter which way we have tried. The logic for rotation works for singleplayer:
Do I not also need to update it in case of a server correction before replaying moves?
Hm that was an overly short answer, 4am brain
To elaborate - PrepMoveFor is to prepare client-side moves, which are then sent to the server
But we don't need to do it there, because we send them as compressed flags instead, so by the time PrepMoveFor is called it already has the required state
Also worth referring to ClientUpdatePositionAfterServerUpdate, where we specifically ensure that the flags don't change, this is where PrepMoveFor is called from
Basically, its handled by a separate routing that is much cheaper (because packed into uint8)
Ah I see now, thank you!
im looking to have a widget get spawned on every clients screen when a player gets killed, where would i go about doing this ? gamestate?
anyone know how to set a session's name?
one that will pop up after get server name
(can include some string splittings too)
It's a SessionSetting. Either via C++ or AdvancedSessions
Anyone have any experience with AnimNotifies and dedicated servers? When I run the game as a listen server everything runs fine, but when I run it strictly as a client, some of the animnotifes just don't fire correctly. I'm not sure if there's a setting or other variable I'm missing.
Create Advanced Session has extra settings array
can this be explain by unreal? client actor is in different place 🤔
show your code
https://blueprintue.com/blueprint/e65dr0hz/ its in event tick
this actor is create on server side and the just replicated, but it just asking for owning player pawn location
What is this thing?
what thing
actor that has box collision to check if I can spawn there helicopter
so somebodyu can select place?
You got way too much going on in there lol.
OK is this like a game where you control one character or is it more like an RTS?
Do you walk up to the box, press a button, then choose where to spawn a heli, then spawn the heli?
its mod for squad
i found some comment about rebasing, so maybe its not unreal related but squad actually
Could be that it rebased on the Client but not on the Server
But I thought that it still translates back and forth if needed.
why do you have a client RPC here
just tick -> locally controlled? -> calc rot -> send to server
it is, :D, but im clueless why Soldier on server coordinates stay the same after rebasing
I have an AnimNotify that I trigger on the 20th frame of my animation montage. For some reason, it's triggering on the client but not the server. I've verified that the montage is running on the server. Why would the notify not trigger?
How do I change the “Server Map” at runtime? Like i m a little confused abt this. Do I need to make separate instances of server builds for different maps and create new servers for all those builds?
Is it a listen server? Is the montage being played on a client's character? Does the same notify actually trigger on the server's own character?
this is run by a player controller
what object should i get to get that players playerstate ?
index of a controller should be local ?
If this is within the player controller, the player controller itself has a variable referencing its playerstate.
Project Settings -> Maps and Gamemodes or something like that
And then you can change the default gamemode, map, game instance etc
Heya guys, so I was asking before but still have a question:
Does APlayerController actually exist locally for clients?
On my PlayerController, I simply log GetControlledPawn(), and it shows me this:
The server creates a playercontroller with it's ascociated pawn.
When the client connects, it creates a pawn, and then another 2 playercontrollers with no pawn.
What's going on here?
Like what's the proper way to control a client's local character (controls/hud)?
- I can't properly get the PlayerController, and PlayerState seems to be mainly for replicated values only (health/etc)
hmm the server is the only one that can access the gamemode right
can remote clients activate "events" on the game mode even
no
but a remote client can access the game state wich in return can access the game mode :/ ?
or game state is only servert also ?
only player state is by remote ?
client *
Its all in the network compendium, I recommend you study it thoroughly. It has all the info you seem to be needing/missing, what objects exist on what (server/client/both), and much more. Cant link the thing atm, it must be pinned somewhere around. C:
This does not iterate all actors.
It iterates a hash map of all those contained actors
But not all actors.
I said earlier it doesn't literally iterate all actors
A more accurate statement would have been it iterates over all subset of those actors, so poor wording on my part.
@cursive steeple yeah i know thanks ill look at it
I was going off of what you said directly after that. But still. It's not a bad function. People are just whiny about stupid shit because they work with idiots who won't stop doing stupid things, and it's easier to perpetuate doing things in complicated manners than to simply use tools smartly.
It's easier to whine about how bad this function is cause someone might actually use it on something iterating hundreds of thousands of actors. And it's easier to tell people to put a fucking interface on everything instead of casting. It's actually quite useful, and several places in the engine actually use it, and people shouldn't be discouraged from it either.
There's a use-case for it for sure, but it's way more commonly abused then it is used in good context. As you said.
It should by no means by a replacement for good programming, and that's where the issue lies.
There was even a talk recently at UE Fest where a studio actually would fail a Data Validation check if a Get All Actors of Class or Get Actor Of Class existed, they only didn't outright ban them because they're good for quick mockups.
Is there a difference in terms of optimization between replicated on OnRep variables?
In general, should I favor replicated or does it not matter?
The variable in question is an enum that changes every 20-30 seconds. OnRep would make my life easier for late joiners, but I can probably put some logic on begin play if I should avoid OnRep.
tried it out and it worked thanks for the help
So can someone just point me towards what actor/object should be used to actually drive the characters?
Of all the info online, I can't find the first step lol
The hud should be derived from values that are alreadly local to the player
Can you clarify what you mean by the other part? "Controlling the character" - because, that's what the player does.
Were you asking me that?
Yes
The issue is this Unit = Cast<AUnit>(GetControlledPawn()); returns null
From within the player controller
In BeginPlay, is it too early?
Potentially, yes
I have an array of replicated subobjects on a component. Is there a way to have uobject properties on those objects replicate too?
I tried with to reference them on an array on the component and use the same method i used for the first objects, but it does not work
It says LogNet: Warning: UActorChannel::ProcessBunch: ReadContentBlockPayload failed to find/create object. RepObj: NULL, Channel:4
Is there any events to subscribe to or auto called functions when it runs?
I think the onrep for the pawn is a virtual. If not, you can check for the client acknowledge possession event (I forget the exact name, sorry)
Ooh smart. Yeah it's OnPawnPosessed or something
Cool that's a great start. And one last question:
When logging that on the client, it logs:
Server: null
Client: null
Is there a reason the client is logging as the server as well?
Or is the server also loading up the clients playercontroller and logging that?
Server has all player controllers