#multiplayer
1 messages ยท Page 206 of 1
Basically if the host moves a block, the client connected to the host may or may not see the block move
sure, but do you set the actor to replicate movement?
if it's moved as a result of something that isn't just the actor moving you may need to replicate the transform in some way yourself
I don't know what "moves a block" means here
if it's like a board game you would probably want to send just the idea of the "board state" and not the raw position of the mesh if possible
but either way is fine
did you enable replicate movement on the cube actor?
not yet, im researching that now, thank you
That was the problem! Thank you so much!!!
Got a stupid question
Where does the LocalPlayer live in the network? I know how the gamemode/state, player controller/state/pawn & UI are and how they interact but I can't find out where the ULocalPlayer lives
It doesn't
If I want to create a dedicated server but the number of lobby is on demand (created per user login)
I suppose one of the way is to have a virtual machine on the cloud that create and destroy instances of the session.
But I heard direct coms is not recommended and a middleware as a medium between player and the data base/ server is required. But how does that work?
A matchmaking service, which is likely exposed to the client as a web service
how should i duplicate object with DuplicateObject (particullary UStaticMeshComponent) and replicate it to client? because currently these line do spawn mesh on server but do not replicate this component to all clients
UStaticMeshComponent* NewWall = DuplicateObject(InitialWallMesh, this, *FString("Wall Mesh").Append(FString::FromInt(Walls.Num())));
NewWall->SetupAttachment(RootComponent);
NewWall->SetWorldLocation(SpawnLocation);
NewWall->SetIsReplicated(true);
NewWall->SetStaticMesh(InitialWallMesh->GetStaticMesh());
NewWall->SetWorldRotation(SpawnRotation);
NewWall->RegisterComponent();
Walls.Add(NewWall);
AddInstanceComponent(NewWall);
but if i just create new component like so it works fine:
UStaticMeshComponent* NewWall = NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass(), *FString("Wall Mesh").Append(FString::FromInt(Walls.Num())));
NewWall->SetupAttachment(RootComponent);
NewWall->SetWorldLocation(SpawnLocation);
NewWall->SetStaticMesh(InitialWallMesh->GetStaticMesh());
NewWall->SetWorldRotation(SpawnRotation);
NewWall->RegisterComponent();
NewWall->SetIsReplicated(true);
Walls.Add(NewWall);
AddInstanceComponent(NewWall);
but i want a duplicate of it actually. to avoid copying meshes and collision settings, as well as materials
So it's purely local to each client? Like the HUD?
Great, that fixes a very annoying problem I've been having with a game instance subsystem
I'll convert it to a local player one, cheers ๐
Are you replying to me? How can I do that?
Especially this one
Is this what Iโm looking for https://dev.epicgames.com/community/learning/knowledge-base/7y39/unreal-engine-using-the-replicated-subobjects-list?
I'm working on a simple idea, like a walking simulator with some interactions, driving or take a bus, something like that. I'm thinking on make it multiplayer to make it more appealing, when users can share some stats/items, take a bus ride with other users (I guess it's hard to replicate that one..) I'm still unsure to go that route, or just making a "simple" single player game.
I haven't tried GAS yet, I guess it gets easier with a tutorial, you're right, I haven't considered that C++ can help to understand blueprints better, I'm always worried that spending a lot of time learning new things can lead to have a lot of unfinished projects...
Thanks for helping, being alone with all those thoughts isn't easy, what about your game, are you being able to successfully replicate things like sailing and other stuff?
yes, this should help assuming you are in a version that uses the replicated subobjects list
Is there any code example of cmc implementation of actors being able to push the character / does someone have any suggestion on how to implement it?
What do you mean exactly?
You can impart forces on the CMC
You can "launch" a CMC
There are a few options
A client moving another client's cmc predictively?
Having the character being pushed by any moving actor collides with it (including character to character collisions)
Some ref that you can take a look.
https://forums.unrealengine.com/t/help-me-make-a-reactive-capsule-pushing-system/495114/35
https://forums.unrealengine.com/t/smoothly-push-player-while-not-moving/150842/27
The physical ball can move in the direction we look at on the server as we wish. However, on the client screen, it moves according to the position it spawned in. In other words, when we look at the ball from the right and press W, the ball moves to the right. How can I fix this?.
https://streamable.com/jl36mp
It can totally be that due to using Physics in a Character, that the CMC is outright not functioning and is never Sending/Receiving the ControlRotation properly.
Is there a way to fix this?
Eh, not sure. One usually doesn't use Physics with a Character/CMC.
Or if possible generally in Multiplayer, unless fully client-authoritative fwiw.
what is CMC?
CharacterMovementComponent
i'm curious.. where exactly is the client's control rotation replicated to the server?
I did it this way.
Via the ServerMove RPC in the CMC (or rather Character, but that's just optimization).
via uint8 ClientRoll and uint32 View params.
uint32 ClientYawPitchINT = 0;
uint8 ClientRollBYTE = 0;
NewMove->GetPackedAngles(ClientYawPitchINT, ClientRollBYTE);
void FSavedMove_Character::GetPackedAngles(uint32& YawAndPitchPack, uint8& RollPack) const
{
// Compress rotation down to 5 bytes
YawAndPitchPack = UCharacterMovementComponent::PackYawAndPitchTo32(SavedControlRotation.Yaw, SavedControlRotation.Pitch);
RollPack = FRotator::CompressAxisToByte(SavedControlRotation.Roll);
}
ohhhh it's in the CMC no wonder I was missing it
Yeah, the world outside ACharacter and UCharacterMovementComponent lacks a lot of Multiplayer stuff :D
Mover and NPP to the rescue. One day. Maybe.
I did replicating using subobject list, still doesn't work for duplicate object, only for NewObject
UStaticMeshComponent* NewWall = DuplicateObject(InitialWallMesh, this, *FString("Wall Mesh").Append(FString::FromInt(Walls.Num())));
//UStaticMeshComponent* NewWall = NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass(), *FString("Wall Mesh").Append(FString::FromInt(Walls.Num())));
NewWall->SetupAttachment(RootComponent);
NewWall->SetWorldLocation(SpawnLocation);
NewWall->SetStaticMesh(InitialWallMesh->GetStaticMesh());
NewWall->SetWorldRotation(SpawnRotation);
NewWall->SetNetAddressable();
NewWall->SetIsReplicated(true);
NewWall->RegisterComponent();
Walls.Add(NewWall);
AddInstanceComponent(NewWall);
// Add new wall as replicating subobject
AddReplicatedSubObject(NewWall, COND_None);
bReplicateUsingRegisteredSubObjectList is set to true
what am i doing wrong?
Hello, is this hierarchy works for replicating? All replicating systems up but doesnt replicating from client to listen server. ๐ค what is the problem here
That sounds like a simple noob idea but it doesn't sound like a simple idea, because when you do a bus ride and sharing items you're describing an MMO or something like GTA in multiplayer, there isn't any way to make this simple. You're fooling yourself then or instead of the bus ride you need to take a long journey of learning to achieve this. It's easy but when you have a big world there's a lot of things to consider. It takes a couple of years to even know if you're doing it right. C++ is worth it if you're deciding to pursue this on the coding side, if you want to be an all rounder I do blender too but haven't had any time to learn blender because of doing hardcore C++ coding. You can't do everything so you have to pick your battles and which skills to upgrade, think of it like a skill tree, do yo uclick unreal or blender and what parts do you upgrade to achieve your game. This would be easier to do if your idea was sane instead of a mini multiplayer GTA thing 'cos you still need every skill that a full GTA game would need to do this on a small level even and the same costs and all those other learnings. Like you can just figure out how to get your idea done if your skills aren't dependent on the idea but the idea is more according to your skills. If you're a good coder and this is your skill then sure, that's what you do which means winging the other stuff. Basically whatever you can showcase the most, if you're good at 2d Art then a simple slideshow story platform without any coding is better off than me.
Also another misconception you mentioned is making it more appealing using multiplayer.. but then you won't have as much gameplay in the game and are riding off the user interactions as multiplayer games are interesting without having to do much, but that's cheating and it takes a certain quantity of players to achieve this.. so most Multiplayer games die before they take off.. So that's a huge misconception, you're basically saying you want to do an elaborate sort of city roaming friends sharing GTA6 game but on a tiny noobish level and to make this interesting you'll make it multiplayer.. You need to rethink this and see what makes games interesting to begin with. A single player game even if only someone's Mom plays it atleast someone did and it's playable forever but for Multiplayer it's obsolete as soon as you decide paying for the server wasn't worth it when everybody thinks the game is dead before it even launches. Considering this, I'm actually in the opposite view like making my Multiplayer game single player for the heck of it just to avoid this because Multiplayer games need numbers to survive.
You're right that learning things can lead to unfinished projects, actually think of this, the peopel making courses do this full time, so like if you're doing courses from multiple people those people are churning them out and Epic is churning out new features daily too and tutorials associated with this. This is called Tutorial Hell. I have almost 100 courses in my Udemy and I hardly get time to do any. I feel like I watch more videos than coding. And its kind of annoying I want to do something quick and end up having to watch a 3 hour stream because that's the only video about that thing but you get used to it like taking minutes to compile to see every change. This is a really long ass process compared to normal coding which is instant, in this you write one line and then boot up the whole engine.. blueprints is more instant and much faster.. C++ is for bigger projects or more technical things or preference if you know it. So the first virtue is patience. My trick is I only do one project so I only have 1 unfinished project but if you want to do a game every 6 months I told you to stick to BP and learn something and see what you can do after this. It's not really logical to plan out your game before learning things because well then you have to learn everything, which means committing several years to one project. The best advice I can give you is look up some of your favorite game developers from seasoned companies on Youtube like Sid Meier etc. and see what makes them and their games tick.
GameSpot @ GDC 2010: Sid Meier delivers the GDC 2010 keynote address, titled "Everything You Know is Wrong". http://gdc.gamespot.com
How do i wait for all characters to be loaded when game starts? I have all controllers, but characters still havent been loaded
Heya guys, quick Q:
When starting playmode using the networked listen server, is this an accurate representation of playing online? (Like what will be replicated and what won't). Atm everything seems to replicate perfectly even though I've done nothing.
Also is there a way to simulate lag?
Okay so I thought about this and if you want to do more than 1 project do not do multiplayer then. Just rule this out as an option for yourself. Otherwise you can't do more than 1 game probably because first of all most developers and companies do one game and a few do more than one game. Even famous companies that are 30 years old have not that many titles. Say a AAA company has 6 titles in 30 years, that's 5 years per title. Then like Epic have Fortnite but they didn't bother to do a game every 3 months or something like this. If your multiplayer game succeeds then you have a lot of work maintaining this and keeping it alive with new skins and battlepasses those goodies or it will become boring and die so then you're stuck even if you win. So depends on what you want to do.. but if it's more than one game then single player maybe better, 'cos you can start on the next game after releasing instead of getting stuck on one game.
That's not really a multiplayer issue. I do not know any elegant way of doing this.
well its like when all characters possessed by player controllers, sounds like a multipalyer thing to me but idk
It's not innaccurate as the guy hosting the game but if you do play as client that's more like someone playing your game on a dedicated server or connected to the host of the listen server, in listen server one player is the server and this one also has to be a client so the listen server mode shows you both client and server as its doing both for the guy who hosts the listen server match.
For simulating the lag its in the play settings in the editor settings I think or somewhere there you can set maximum and minimum. Look around you'll find it eventually.
You want to wait till all characters are possessed or what? I do not think you can. Well maybe in playerstate I guess. or you have waited for this but they're not loaded.. well they get possessed first. I do nto think this is a multiplayer issue.. it will load the character later also in single player you'd be asking this..
You're probably doing what you're doing in the wrong place.. you do not want to wait for them, you just want to do that in beginplay maybe 'cos you know they'll be loaded and possessed then. For a loading screen or something that's different you can look that up but for starting thigns that's what beginplay etc. are for.
well i want to start the game on the server basically, apply some logic, send events to characters etc
Also by the time you're done you'll be waiting much longer thant his so it's not really practical 'cos what if you need to do loading and other things.
I think you need to do things where they're meant to be, otherwise you have to sort of do a loading system and wait till everything has loaded or fire events as things start up like a pawn starts and it's beginplay does something, even if it htis is a central sort of system you want to do things the pawn can tell this sytem taht its spawned so that system then adds it to the queue or whatever 'cos it will need to know all the pawns then too so you're doing that anwyays then and will need some queue or getallactors etc. so make that a queue instead btu that's not really very clean is it.
is it possible to disable collisions for one client only server side?
for example to enter a barrier only a specific client can enter
if somebody can help with this [Link : https://forums.unrealengine.com/t/duplicated-ustaticmeshcomponent-doesnt-replicate-to-clients/1992660 ], it would be very useful
I have a function in my actor that dynamically creates new static mesh component (a Wall Mesh) next to my InitialWallMesh. Function i use is this: void ABuildableWall::AppendWall(int32 WallIndex, ERelativeDirection RelativeDirection) { // Make sure we are on server if(!HasAuthority()) { UE_LOG(LogSecurity, Warning, TEXT("Can't append wall ...
@grave notch If you only need to know on the Server, then shouldn't basically already have all the info for that cause the Server spawns them?
Or do you want to wait till the Clients are done too?
Only on the server, in game mode, I found an event for that now, logic used to be in init new player, where pawns not spawned yet
Hi guys, I have a question. Using an Unreal dedicated server (using OpenLevel and passing the IP where the server is hosted), how many people would this server support? Assuming that it is super optimized and that it is a game that does not require much performance. Also, to host more than 1000 people, is it necessary to use OWL?
Probably at max around 100
Possibly less.
Is that because your architecture is monolithic? If you used distributed architecture, could you increase capacity? I was looking at AWS's game services.
The theoretical maximum amount of clients a single server could host is 65535 but you'd never be able to reach this if there is any other network connections that server would need to make (which it certainly would). The complexity of the game and what kinds of optimizations you make for your game, as well as server hardware and network bandwidth availability can all contribute to how many players a server can support while still maintaining your intentioned gameplay.
ok great, thanks a lot. so it basically depends on the server hardware and code optimization? i was reading and in a monolithic way it is impossible to reach a high number of players on the server thinking of an mmorpg game. i saw the amazon game lift services to use a distributed architecture so that several servers are in charge of handling the requests and everything that an authoritative server entails. am i right?
That's basically how it would need to work if your intention is to have lots of players all "connect to the same server". Most server systems have a single entry point and that entry point then directs the clients to the appropriate server to connect to and disconnects from the original. Unreal's built in networking system isn't really set up for MMO-style networking, and so, realistically, you could probably only reach about 100 players - most quote this number as it was what Epic was able to achieve with Fortnite.
If you're trying to make an MMO with Unreal here's two example ways to do it :
-
Use Unreal's networking system but utilize instanced "zones" which you allow a certain number of players connect to that represent areas in your game. This would mean having loading screens between different zones and multiple copies of that area of the world running as a client would have to "Open Level" into a new server for each zone. You would also need some other server system that manages what zones are running, can spool up and shut down servers as needed based on number of players in a zone so that there's always available room for a player to move into the desired zone, but could end up in a zone that is devoid of players too. You also need additional servers for game-wide communication, like chat
-
Not use Unreal's networking at all and use some other server system that you'd connect to, probably through sockets, that can manage all the communication that is required from server to clients and just have the client represent the world based on the data received from the server. You could allow a player to travel seamlessly across a vast universe in this scenario as they don't need to "Open Level" to a new server at any point in time, which means no loading screens. The bad part here is that you also can't use any of Unreal's built-in multiplayer features or any third party multiplayer plugins that rely on Unreal's networking since you wouldn't be using it.
So I have an animation which is CanoePaddle, this animation is called on the server, then mutlicasts the animation. However, within the animation there is an on paddle anim notifiers that gives thrust. The idea being that I could apply a bit of thrust throughout the paddle, vs one big thrust upon the start of the animation, this gave me much smoother paddling and control of the canoe.
The issue is that when the host paddles the paddle only does its command once, but when the joining player paddles the paddling happens on the server and on the client thus giving me 2x the thrust I want. Now I know this is happening because of the multicast, but I am wondering how I can separate out the thrust over the animation from the multicast. I would need the thrust to be cancelled if the animation is cancelled or overwritten by a new one.
I took the multicasted animation out of the thrust server call and that solves the duplication issue, but now I have one single thrust on command and the animation plays out until overwritten which is intended.
Any ideas how I can sync up the animation to multiple thrusts without duplication? I also want it cancelled if another animation is started.
Hey @cobalt notch thanks for the insight, I guess I'll go without multiplayer, I'm gonna focus more on the gameplay + BP only, what you said make sense. I'm creating a new project after (almost) every new idea, and I just leave them parked on the hard drive, just for fun ๐ thanks also for the video looks interesting, I'm gonna watch it!
Using Seamless travel ?
If so then I got the same problem and submitted a ticket on UDN about it. It seems to be related to their GameplayDebugger having a (now) invalid ReplicatorActor and derefencing it before validating it (well technically they are validating it but after using it ๐คฆโโ๏ธ )
Try setting bUseGameplayDebugger and bUseGameplayDebuggerCore to false in your Target.cs and see if it works (assuming you are not using precompiled binaries and have your own engine version)
Hey all! Nooby here, I have an event which is running on server, and wanted another event inside it to only be fired in clients, as it is updating the UI for them. I tried to create a custom event to run that on client but it crashed my engine D:
Then, tried to just swap that event to a client-only event in the WBP_UI, but still no results apart from saving the crash haha, how should I handle that? Pic 2 is the event in WBP_UI
I also maybe used the wrong word for the comment on DrainDashBars event, but basically that's where the event should go to the client
In your BP_PlayerMater, create an new event called Client_DashBegin make sure it is replicated and run on Owning Client, Call the new Client_DashBegin from your current DashBegin (which is running on the server)
Client_DashBegin will be the one to execute code on the widget
Ideally you shouldn't invoke UI code from gameplay directly like that and instead have the UI bind to events and respond accordingly, but that's another discussion altogether
I see! I'm not too sure on how to bind those as I'm creating them dynamically based on character's stats with a ForEachLoop, is there a way to do that? I'm running events because I'm not aware of other methods
MVVM is one way to solve that, but it can be a bit cumbersome. For my part, I didn't wanna go through that so I injected the context (a.k.a the possessed pawn of the local player controller) to the HUD widget and and of its children recursively when the widget is created inside my HUD BP.
This allows my to easily bind to events on my character (e.g. HP changed, anim state changed) inside widgets easily.
alright, so the suggestion would be to just avoid bindings but rather use event dispatchers?
and what is MVVM?
You want your UI to bind to events from gameplay, but never really want the gameplay to grab a piece of UI and call functions on it directly (from let's say your character BP or anything similar)
what do you mean with binding since there are bindings directly in the widget and event dispatchers?
Code Inside Third_PersonCharacter Blueprint causes this https://streamable.com/gn0vw2
Does anyone have any idea how I can fix this?
Edit: Fixed - Disconnect the custom event and in the details panel click replicate on server, then re connect
15 years later
Yeah if you get a lot of ideas it's probably better to avoid Multiplayer and stick to single player, then you can do 3 to 6 month projects for publishing each idea and move on within a month if you want to abandon something. Also this gives you a chance to practice other skills. My plan is to make a framework this year and then I'll probably just focus on blender again after this. I started with the naive open world assumption most noobs do and stuck to it so if I'm ever done I'll only do this one game and so I do not have much of an idea either, just pirates in ships 'cos you can't really do that much innovation in multiplayer but every genre is open to single player. In hindsight I would just do 6 month games in bp and blender but I've gone too far this time. Also the annual Megajam and gamejams are good for forcing yourself to finish because otherwise it's hard to find the confidence until you force yourself to complete a fullish game. Jams usually have to be in bp 'cos of time constraints and it gives you the confidence. Before Megajam I didn't think I could finish a full game but after that I thought it was fairly easy to do.
How do I do client travel and server travel with bluprints?
Check the pins, Cedric has both c++ and BP examples of different framework functions/variables
Is one of them a listen server, you probably need to make those server executed calls
Are FGameplayAbilityTargetData more efficient than FGameplayEventData for the bandwidth? I see that TargetData has a NetSerialize et GameplayEvent don't, so I assume that event payload are heavier to send via RPC?
Basically my combat is in WoW style: I target an actor then execute my ability. So at the time of activation I already know the target, and I'm wondering if it's best to activate the ability with an event payload or to send the target data to server from within the ability (in the latter case I would batch the ability activation RPC with send target data)
the simple thing is to just profile some simple rpcs and onrep spamming for them with insights
FGameplayAbilityTargetData is basically an interface in practice
from what I can tell
it all depends on which targeting structs you are passing around
Well the simplest one, I just need an actor pointer basically
Can insights be used to profile bandwidth as well?
yes, but it won't show it with oodle compression afaik https://dev.epicgames.com/documentation/en-us/unreal-engine/networking-insights-in-unreal-engine
-NetTrace=1 -tracehost=localhost -trace=net etc
at first glance FGameplayAbilityTargetData looks like you could make a child of it that is just the data you want and get away with less bits but I have no idea what the rpcs look like
Thanks, I'll take a look
Never used insight yet, but gotta start someday !
I find networking insights to be a bit fickle
it does work but in editor it might be a crapshoot
could be me missing something obvious, and frankly testing with true game processes is probably a more fair test of networking as they won't all be in one process (by default)
Can someone help me with this problem, i have a ingame button you press in the lobby to get teleported to the first level, if you interact it returns true so it seems to be working but nothing is happening? am i missing something
also made a variable in the custom event wich is now not connected but same result if someone is wondering why its not attached
Is transition level guaranteed to be loaded with seamless travel? I have a route like seamless travel from menu to game map and hard travel from game map back to main menu. Could I imply that if transition level is loaded (FWorldDelegates::OnPostWorldInitialization), player is changing level to game map? Or should I create my own logic to keep track of it?
Any tutorial or documentation on replication of landscape displacement? (No nanites)
Hi @thin stratus , may i ask for some more help from you?
edit: fixed it thanks to your comments from last week! thank you!!!!!!!!!
I have set up Head Rotation inside of the Animation BP for Manny and I have no idea how you are suppose to replicate it.
For your head rotation, you can replicate the rotation
So I would replicate the Rotation variable then and I do this in the anim bp?
Anim bp just read data from the owner locally
you can have the rotation variable in the owner
make it replicated
Ighty will do that, thanks for the info.
Just to make sure I am on the right track before I get started when you say in the owner, I assume you mean the character bp?
if that;'s the owner of the abp
owner being who ever owns the anim blueprint
@burnt coral sometime you don't need to replicate the variable though, so it really depend on what you are doing
for example the NPC will just look at the closest player for my case
so I will not be replicating anything at all, I just let every machine run it's own code for the NPC to look at the closest player
__
If the head rotation is driven by player input or view however, then you do need to replicate it because you need to tell the server the rotation of the head, which the server then replicate to all other machines
from networking perspective, what is the difference between running client in editor, connecting to remote server versus running client in packaged build
The packaged verison is completely independent and the editor cannot be helping at all. Rather its running like a background server or latency issues would be my assumption. So maybe a more accurate representation of how a server and client would run.
But I am not entirely sure, so don't quote me on it.
Also, thanks for the help and its through the players view. I got it working ๐
Version: 2.1.7
Last Login: <t:1721354786> โข <t:1721354786:R>
Heartbeat: 74ms
Memory Usage: 69.71 MB
โ
Source Code โข Report a Bug โข Contribute
Hello, anyone know how to set a custom name to the session?
Hello everyone. Iโm getting a strange (intermittent) error when connecting to my multiplayer game. On some occasions, as the player is traveling using seamless travel, I get stuck in the transition level, and am not able to possess my character. Here is what I noticed in the server logs. When the following statements in the logs are called in ...
someone here mentions "It seems that the issue was related to joining too early on the client side. Needed to wait until server was ready (especially since I had a large map). "
What does that look like in practice?
hey guys, I'm trying to fire the bottom event in a widget, but keep getting a non valid result as the otuput get of the array.
I'm handling creation of widget in clients directly, but the event commented in azure is part of an event that runs on server. How would you suggest me to handle that? I thought about putting it there because it's supposed to happen in that precise moment of the action, but not sure on why I keep getting null references or how to make that event run on client. I was susggested to change the original one into a client event but still it didn't change things... lmk wha you think :D
guys when I am copying functions like this to another blueprint how to get rid of this error? i dont want manually always create same functions lol I just wanted copy them
If you're doing that a lot , shared parent or component might make more sense for it
Hi. Im trying to build a login system but i'm having some problems interfacing with the dedicated server.
Here is what i have for now:
- login page with an api call, it gets an answer with a token if its ok
- i try to pass that token when i open the connection to the server and try to check it in prelogin.
Here is where my problems start. Prelogin finishes before my api has a chance to verify the token, if i deny the connection i dont really understand how to have it retry (hoping the check is done). I tried allowing it and then disconnecting after if its wrong but i dont like it because the player will spawn for a fraction of a second.
Any advice is welcome. Thanks
anyways to destroy an actor by sending a message from the server side?
I tested with it, in listen server it did destroy
but not at client side
Replicated Actors, destroyed by the Server, will destroy on Clients.
If I have and array of values marked replicated, even if someone changes them on the client getting the value will still be whatever is in on the server right?
nope I can change them no the client.
How would you make an array that can't be changed locally? Do you have to do a Server call to set it locally every time?
Hey guys, am I correct in thinking that when PreReplication is called on an actor it doesn't necessarily mean that the actor will replicate this frame? It looks like PreReplication is just called on all actors being considered for replication, but that list is then sorted and not all of the actors in it are necessarily replicated right away.
And if that's true, is there another function I can use for "this actor is definitely about to replicate RIGHT NOW?"
You cannot. You do not have control of client computer hardware. Any point that you "set" a value, someone could manipulate their computer's RAM so that value cannot be changed or changed to whatever they want. The best you can do is replicate data to them, and if they are requesting the server to do something, you should scrutinize the request and any of the data that they send back to the server.
The server is the "true" state of the game. Just because a client changes the value on their end doesn't mean everyone else sees that value.
yes, I was coming to the same conclusions. What I will do is just do an empty server call just to have the validate functionality and compare the values being passed back when all the selections are finished. Afaik you can't just call a server validate by itself (meaning without an attached _implementation call)
Ideally you wouldn't need to pass the data back and forth. You'd use the server's copy of the data assuming it has the appropriate data that should be used.
ah ok, so instead of passing anything just check the HasAuthority version against the non authority one in an rpc call?
basically they are just strings in arrays and when the player locks in these choices the server sends them to playfab
oh wait, yeah it's even simpler hehe. Just use the sever version regardless so even if the client one is fudged with it wont really impact anything
Exactly ๐
Only allow the client to tell the server the minimal amount of data required. The server should typically already know the state of anything gameplay important itself and would only replicate that information to the client so they can display it on their end.
using FastArrays, can you get the old value before a change ?
yeah i was pretty sure that was the answer
Hello! I'm trying to implement a dash using root motion sources, but I'm not sure I'm doing it correctly. I'm not using GAS so I'm basically manually creating a FRootMotionSource_ConstantForce and then applying it manually via ApplyRootMotionSource.
This generally works, except I can see a tiny bit of rubberbanding on remote players at the very end of the dash. It seems like the ending positions between client/server are slightly off, and so it gets corrected at the very end of the dash, which looks like the player is being snapped backwards a few units.
I wanted to double check if I am applying this RMS correctly. Right now we basically have a replicated Actor that calls Dash() on both server and client. The client is called first predictively, so it'll call ApplyRootMotionSource() a little before server. There's no RPC from client to server; the function is just called on both instances in parallel with the same parameters.
Is this the correct way to be doing this?
how is the function being called on the server? like how are you triggering the dash on the server?
Reason I ask is that in my limited experience with root motion sources, the best way I found to sync them was to make sure the server was triggering the root motion based on something in the networking data, so either a compressed flag or some other variable passed via move data
We have a replicated Ability class which has an Activate function. Dash is being called from there. Activate is called via client input. On the client, it will execute Activate immediately (for prediction) and then RPC to the server and call Activate on the server. Once the server receives the RPC and calls its Activate, then it will also call Dash.
Oh interesting, but if the server itself is triggering it, will you be able to have it immediately execute on the client for responsiveness reasons?
i usually client predict ability activation, and then the server activation is just validating/cancelling the root motion if needed. I wrote a whole bunch of nonsense code to handle a potential race condition, since the CMC data isn't reliable so the ordering isn't guaranteed, but I'm not really sure it was necessary.
hi this iss going to sound dumb but im using an onrep function and when i try to read a variables value on rep using 3 clients on editor only client 2 responds back?
something like a projectile explosion / hit VFX would be multicast and not repnotify right ?
Ah okay that sounds similar to what we're doing as well I think. So something like, client predictively activates -> client calls ApplyRootMotionSource -> this sets some flag in networking data which the server receives as part of regular movement data via CMC -> server validates -> server also calls ApplyRootMotionSource?
im a noob, but typically animations are multicasted. but the hit would be server i believe.
yea i shoul dhave specificed that it's spceically for VFX
Most likely you only set the variable locally
something weird is happening
shooting targets with 100 hp
the server PIE can make the actors destroy (coded after hp becomes 0)
while the client could not destroy them
and at both sides the hp are calculated seperately?
If you don't inform of the server of the change using server rpc, then the change will only happend to that machine.
@cold cipher destroy the actor on server, if it's replicated actor. The client copy will be destroyed too
yes it did destroy on client this time
If it doesn't then check how you are spawning the actor.
For replicated actor, only have the server spawn and destroy (in general)
You set the rules 
There is pros and cons in all method
It's about what you are willing to sacrifice when it comes to mp, I guess
Personally for fire and forget stuff like sfx, you can just use multicast when it really doesn't matter if some player end up not seeing the sfx.
For anything that needs to be in sync, eg special effects on the Wolf in sheep clothing, you don't want to use multicast.
If you are using GAS, just use gameplay effect and let it do its thing.
yeah I changed it so only in server it spawned
looking on rpc now
Is it somewhat of an antipattern if player spawning in a multiplayer game is handled by the Game State? I figured this would be something managed by the Game Mode, but then there are certain facts that the game state is tracking, such as whether the game or the round is over, which only live in the game state.
So in the codebase I'm looking at, the spawning is ultimately deferred to the game state, on the server. My impression however was that game state was perhaps more about bookkeeping and less about altering the state of the game itself, more of a read-only data source for something else to tap into.
Fair to say that's not the correct interpretation and it's totally fine to let the game state handle that?
From the official docs:
The Game State is responsible for enabling the clients to monitor the state of the game. Conceptually, the Game State should manage information that is meant to be known to all connected clients and is specific to the Game Mode but is not specific to any individual player. It can keep track of game-wide properties such as the list of connected players, team score in Capture The Flag, missions that have been completed in an open world game, and so on.
Makes me think that maybe the Game Mode should be checking with Game State about the state of the game, but then itself take care of modifying the game?
yea dope, makes sense
Hey! If it's not too much trouble, I'm trying to create a simple, replicated countdown timer, but I can't get the replicated variable to work.
I've tried following the instructions here: https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-variables-in-blueprints?application_version=4.27 but once i try replicating the variable, it does not replicate to the client
Guide to using Replicated and RepNotify Variables in Blueprints.
What type of variable is it that you're replicating (int? float? timer handle?) and in what class are you replicating it in?
Replicating an int in the default BP_ThirdPersonCharacter class that the base blueprint spawns in
Replicates is set to on in the class settings
Are you setting a timer on begin play or something?
Yes!
Timer calls a custom function which just decrements the int every second
This reflects on the server but not the client
Correct
ok, how are you checking the value of the int on the client?
Print statement debug
On what event?
1 key pressed
Can you show some screenshots of your events?
Yeah, give me a bit. Ty
So here's a basic screenie of the listen server vs client
Pressing 1 displays 10
Quick picture of my code
You don't want the "Update Timer" event as an RPC. I'd also avoid using Set Timer By Function Name - just use Set Timer By Event and you can connect the event you want to use to the orange delegate pin it provides.
Gotcha!
I'll try fixing it and lyk, I appreciate the help
Otherwise, if the Has Authority is connected to begin play the timer you have there should be working correctly.
Does it matter that I'm running it on the listen server/client setting rather than standalone?
Quick question I managed to create my own encoding and decoding for simple float to serialize for the network. I was wondering if the engine has quantization for float packing into a smaller type?
The only thing i've found is quantization of FVectors, I think they just send raw floats over the wire asfaik
there's probably some utility function hiding somewhere. Iris has all the functions in BitPacking.h, I don't know that the same exists for FArchive-based netserializers.
Out of curiosity, for float values over the network what is the best practice for sending floats over the network? I assume for raw input values you can just send the entire thing and for some other calculations maybe 2-3 decimal places?
Hello! Need some help with replication
UPROPERTY(ReplicatedUsing = OnRep_Position)
FVector ReplicatedLocation;
UPROPERTY(ReplicatedUsing = OnRep_Rotation)
FRotator ReplicatedRotation;
UFUNCTION()
void OnRep_Position();
UFUNCTION()
void OnRep_Rotation();```
these are the replicated variables and their OnRep methods. I change these variables here
```c
void APawnAgent::MoveAgent(float deltaTime)
{
m_newVelocity = FVector(0.0f);
FRotator DesiredRot = m_moveInputXYZ.Rotation();
if (!m_moveInputXYZ.IsZero())
{
SetActorRelativeRotation(FMath::RInterpTo(GetActorRotation(), DesiredRot, deltaTime, 10.0f));
m_newVelocity = m_moveInputXYZ;
m_newVelocity.Normalize();
m_newVelocity *= MovementSpeed;
FVector newPos = GetActorLocation() + m_newVelocity * deltaTime;
SetActorLocation(newPos);
FRotator worldRot = GetActorRotation();
m_direction = worldRot.Vector();
m_direction.Normalize();
ReplicatedLocation = newPos;
ReplicatedRotation = worldRot;
}
m_moveInputXYZ = FVector(0.0f);
}```
```c
void APawnAgent::OnRep_Position()
{
SetActorLocation(ReplicatedLocation);
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::Printf(TEXT("rep Pos called")));
}
}
void APawnAgent::OnRep_Rotation()
{
SetActorRotation(ReplicatedRotation);
}```
this doesn't work. What am I missing?
i have already done ```c
void APawnAgent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(APawnAgent, ReplicatedLocation);
DOREPLIFETIME(APawnAgent, ReplicatedRotation);
}```
so you mean I should have changed those variables in one of those ServerMoveSomething_Implementation?
as that code is run by the server. I am trying to build up my fundamentals for it. Please ignore if it gets annoying
uhm, I was doing it through multicast but felt replication would be a better way to handle it
uhm! so you are implying I should rather go with RPCs instead of replicating variables on different clients.
Is there a reason for it? to avoid latency or something?
I see!
in this case - In the non-ideal case, such as the player making an invalid movement
Server sends player the "rolled back" state that they should be in since the correction was received - is the client trying to predict the next frames of the other clients?
I think I need to understand more fundamentals of it - apart from Multiplayer in Unreal
I get your point
let me see what it says!
btw I am not using any CMC in my game. My movements are fairly simple and didn't feel like I need it
yeah that file is just huge
my class extends the pawn class, not character
I deliberately did not extend it with character to avoid any bloating. The pawn's movement is very simple and my plan is to do the multiplayer part on my own
people suggest me to use CMC but I feel i should manually handle it. The movements are not complex and can be handled
uhm, I have heard it but in future I would need to handle more things in game apart from movements. I will need my knowledge there
Then people would suggest me to use GAS
So you are implying I should not know whatโs going on and get it done with Unrealโs tool! If something goes wrong in future then it will be extremely hard for me to know whatโs wrong
Have you ever went down the path of writing your own client server code?
yeah but knowing what's going on would at least help to trim down what could be wrong
uhmmm, 6 months to understand what's going on behind to understand things deeply
you are right. I don't even have that kind of bandwidth
bleehhhhhhhh
I will then go with CMC and GAS after watching the videos you referred to me. In case - I accept they are really tough to handle on my own
because I can't make my own engine. Even with networking I want to use unreal's core networking but not use CMC or GAS as I think they can be handled.
It's like having a layer on top of a layer
you are right!
I thought if I could make it work without using CMC then it wouldn't be difficult to make things work apart from the movements as well.
This would give me the freedom I need at the same time.
but yeha
i get your point
I'll explore these things and decide what needs to be done
would fixing the chaos vehicle movement component to make it less buggy be a hard task
like is it worth it to try and fix or should I just use some other multiplayer vehicle movement component that's out there on the marketplace
what does buggy mean here?
not much, I'm just going off word of mouth
that chaos vehicles are very jittery in multiplayer
and known to not "be very stable"
also how have you been it's been a while
They're jittery because people don't set them up properly and/or don't understand how the physics replication/interpolation works. With a bit of tuning it's pretty servicable
tuning as in tweaking of the movement component itself, or with physics smoothing from the actual chaos physics engine
I imagine if you didn't need cheat prevention etc you could have the person driving sim it locally
The physics can be setup however you want, but the physics replication settings need to be set loose enough that your local sim can move ahead of the Server without being consistently snapped backwards.
ah okay gotcha
but in this senario I would imagine you would still need to do a lot of smoothing for the non simmers
Not at all, you just replicate the inputs to them. Physics is "free" smoothing, they are simulating every frame regardless
but how would replicating the inputs be helpful if the simulation is not deterministic
The engine isn't deterministic, so even if physics was, it wouldn't matter.
The physics replication works by applying forces to make sure the sims converge to the "correct" server state over time, but it's heuristic in nature. Determinism is a wasted venture in UE land
oh ok I don't know anything about physics replication
that makes sense
and this heuristic will kick in for anyone who is not an authoritative physics mover I assume
and if you don't replicate input, that heuristic is gonna have to go work really hard or something
full bitwise style yes, but honestly it's pretty okay-ish in deterministic mode in my dumb tests
with async fixed mode of course
of course that's toast the second user input comes in and things get moved on the main thread randomly 
Yeah, if you run async fixed it pretty much is deterministic, so long as you insert bodies into chaos in the same order (which in replication land is baasssicaly impossible)
You'd just get lots of snapping because the clients aren't running their local sim with the most recent data, so they will frequently diverge from where they should really be going.
And yeah by default, everybody tries to blend to the server state (even the autonomous proxy). You can disable this by unchecking bReplicatePhysicsToAutonomousProxy on the simulated primitive (as long as it's the root component) - but IIRC you need to make sure the server just "accepts" the controlling clients data if you do that
Which is basically client-auth at that point
yeah... I am trying my hand at this with Jolt and it's rapidly spiraling out of control in complexity for what I want without just delaying player input by 5 frames
The only massive problem with the engines current physics replication is you are limited to global settings for every physics sim, which is dumb. Should really be able to have different groups of settings
I am hoping to get away with a "I don't need bitwise but I am going to get damn close" setup
yeah, honestly that's been fine for me in all the stuff I've done
never going back to kinematic vehicles 
also with true rollback you basically say "time to resimulate this" and have to rerun the tick 10 times
this is not so nice in a complex 3d game
Epic are putting a loooot of work into their physics networking tbh, I think they really want viable physics-based characters
But it's all heuristic in nature
I think with some fanagling you could get there (I run my entire game tick on tasks and I could interleave them) but... it's super doomed if a client can't keep up with that
yeah
I respect the effort but I also feel like it would just be easier to make a true fully fledged fixed ticking setup than just having "okay I sure hope physics works" and leaving the rest unchanged
of course this is no joke to just slap in but interpolating things generically is already in the engine...
yeah, well that's how the async stuff does it IIRC, you have the physics running at fixed step and GT data is interpolated
I suppose if they buffer literally any change to physics state then it's probably all gucci
yeah
problem is games are not all physics and you need to run some game rules on the fixed tick if you want to do more than watch blocks collapse
I'm sure it can't be worse than the existing "cowabunga" physics replication setup where things jitter by default
you could sacrifice some immediacy to get smooth interpolation I suppose (buffer known good states)
of course you would occasionally get wacky "wiggling" on things but it would beat the flickering around
Is it possible to let players stay in their current level in standalone when connection is lost?
I did some digging for you and found this snippet in OnlineSessionClient.cpp
void UOnlineSessionClient::OnDestroyForMainMenuComplete(FName SessionName, bool bWasSuccessful)
{
UE_LOG_ONLINE(Verbose, TEXT("OnDestroyForMainMenuComplete %s bSuccess: %d"), *SessionName.ToString(), bWasSuccessful);
IOnlineSessionPtr SessionInt = GetSessionInt();
if (SessionInt.IsValid())
{
SessionInt->ClearOnDestroySessionCompleteDelegate_Handle(OnDestroyForMainMenuCompleteDelegateHandle);
}
UWorld* World = GetWorld();
UNetDriver* NetDriver = World ? World->GetNetDriver() : nullptr;
// Call disconnect to force us back to the menu level
GEngine->HandleDisconnect(World, NetDriver);
bHandlingDisconnect = false;
}
* Transition from destroying a session to returning to the main menu
*
* @param SessionName name of session recently destroyed
* @param bWasSuccessful was the destroy attempt successful
*/
void OnDestroyForMainMenuComplete(FName SessionName, bool bWasSuccessful);```
I'm not a multiplayer expert, but it does look like this is the code that is calling that transfer to the main menu? So i'd say a good starting point is removing this function from the delegate, or something like that
You'll at least need to Use your own implemenation of UOnlineSessionClient
If I have X Components on the same Actor, which all need the same Integer to be replicated alongside their data, is there any other option than pushing the Integer into each set of Data?
The Integer exists "globally", and I currently have to pass it along each Components Serialized Data, to ensure that I have it available on the Client then when processing the Data.
But it feels shite that I have to spend bits on X - 1 copies of Data being sent.
what about replicating it in the game state class or something and having the component grab it from there when its created? not too sure if that would be any better.. i suppose it depends on how many actors use that component
The Integer changes constantly alongside the Data of the Components.
Moving it out of the Actor itself is probably worse.
It's the current FixedTickFrame basically.
The Data gets mapped to the Frame.
But given how Replication works, I have to tell each Component the same Frame.
What is the best of benchmarking dedicated server? what is the best way of running super lightweight clients?
Do i need a lot of rendering clients to benchmark a server?
You can connect Unreal Insights to dedicated server like any other unreal app for profiling.
Re: clients you can run non rendering with the parameter -nullrhi
Bear in mind that things like CMC will be cheaper if the clients are not moving so you might want some test mode logic that moves them randomly for better perf test (same for any in-game actions they might perform).
Do unreal insights create clients? like many at same time?
No, Unreal Insights is the profiling tool. You would start by launching dedi server and profiling that without any clients.
Then I launch/connect a client via a batch file that I can run as many times as I want
This is not what i need, and i want to "benchmark" it at release
without a profiling tool
I can already check bandwidth/cpu usage on my server but i can`t really connect a lot of clients on it
Because each client is expensive to render
so use -nullrhi when launching a client so it's free to render
Is it expensive to process?
depends on your code ๐
Is it realistic to run 100 under a single machine
you'll probably need to get some more machines then
for me running one nullrhi client uses about 10% CPU
maybe you could throttle the update rate to improve that?
Yes, looks good
I have 32 cores here, maybe i can run 100
ryzen 7950x
maybe ๐
depends on your game really
It is a mmorpg
I mean depends on what is happening in your game. Running lots of clientside logic/etc.
If you've never done it, I would recommend profiling your server in detail with just a few clients. You can capture with 1 client, then capture with 2 and see what is scaling up linearly.
I found lots of low hanging fruit for server optimization when I did that.
I have tried already 20 real players but not 100
What have u found?
I mean using Unreal Insights to capture accurate timing for all parts of the game.
Honestly I can't really remember it was many months ago. Let me think...
things like: Turning off overlap events, bEnableUpdateRateOptimizations, OnlyTickMontagesWhenNotRendered, tick rate of logged out players, lowering NetUpdateFrequency, many things!
You never know what you're going to find when you profile which is why I strongly recommend it even with just 1 or 2 clients
RN i just want to know how many it can handle but you are right about finding what is the bottleneck
Fair enough, bear in mind that the Unreal server is very good at hiding when it is overloaded, it just starts throttling updates etc. And it's probably 90% busy on a single core so if you are checking VM stats on a multicore machine it might look underutilised but one of the cores could be 100%.
I know, it is most single threaded but throttling updates is a problem actually
Can i configure min updates/second?
What do you recommend?
You can't configure a minimum because it depends how long the server frame takes.
I recommend optimizing as much as possible to keep your tick time below a threshold.
Would make sense to configure the Max tick as low as possible for your style of game too so it has a consistent rate. For FPS you might want the server to run at 60, but for MMO maybe 10 or 20 Hz is ok.
configure via NetServerMaxTickRate in DefaultEngine.ini
should OnRep functions be marked as UFUNCTION?
I'm gonna say yes
Guys, how do I prevent player controller from getting destroyed after player leaves? I have tried to add this and it still does not work:
Just to be sure: Does that code also call?
And on top of that, is the Pawn referenced anywhere else? Otherwise it will be removed by the GC at some point.
Renaming the project can f'ck up the references
Make sure the Controller, GameMode, etc. is all still spawning properly in your Outliner.
i will try to create this class again
Do you think 200 players on same server is realistic? for example Mortal Online has 500
By realistic i mean using CMC but state of art code, viable
I don't know tbh. Maybe with a low tick rate and lots and lots of optimization.
Relatively sure Unreal's Servers, as of right now, won't support that.
Most games, even with heavy optimization, have 100 as a limit, before they need to use custom Servers.
Not Mortal Online
They probably have their own server infrastructure
I don`t think Mortal Online has custom server because it is a indie mmorpg with precise collision
It is not tab target, imagine doing all this collision check on a custom server
As long as you can't share something from them proving that they use native servers, I would say they aren't doing that.
Rust which is on Unity have 1000 player servers
Yeah but that's not Unreal Engine, so why does that matter
Ok I had a quick look and looks like they have a somewhat custom architecture.
ClusterNode runs part of the world and they have multiple ones of these, with an overall server managing players between these instances. It's likely each node is more limited re: players.
Chances are higher that they use a custom server setup that they integrated on C++ level. UE has all options open for that if the programmer is capable of doing so
Where?
There are also a bunch of networking solutions that allow for more players.
UE's Servers come from a time where Online Games were mostly Arena Shooters (Unreal Tournament says hello)
Which often were having around 32 to 64 players, depending on the Game.
100 Players was only pushed via RepGraph implementation a few years ago via PUBG and Fortnite
It's unrealistic to assume that the native replication model can handle much more than that.
Iris is rep graph on steroids
It quantize the data a single time instead of one per viewer and also has repgraph grid partitioning
I don't think anyone knows for sure if it's possible, you'd have to try it.
It's just unproven,
Instead of betting on Iris, I would bet on whatever Epic announced for LARGE Server setups.
What do you mean? is it a new thing?
I don`t know what large server setups is, a new netcode or what?
I would need to look it up. Nothing that is released.
Just a question i am using object reference for my inventory system should I switch to class reference
iirc they are working on something to support their deal with Disney or whatever it was.
Depends on if you need either. Can't really answer that.
Do you have a link for that?
I have written a mmo server in unity that can handle 10k players but it is custom UDP and also dots is cache efficient/multithreaded
It is like using mass entity for all your code
Tried to look for it, but couldn't find it so quickly.
If only unreal had an easy way to disconnect from one server and connect to another without a loading screen could solve 90% of scaling problems
{
TArray<AItem*> MatchingItems;
// Iterate over the inventory and find items that match the given icon
for (const TPair<AItem*, int32>& ItemPair : InventoryMap)
{
if (ItemPair.Key && ItemPair.Key->Icon == Icon)
{
MatchingItems.Add(ItemPair.Key);
// If we've reached the requested number of items, break out of the loop
if (MatchingItems.Num() >= NumberOfItems)
{
break;
}
}
}
return MatchingItems;
}
``` for context
I mean, that's Actors and not Objects
Also, first time I ever see someone querying an item by a Texture.
Ha ha lol
Just thought could be used in widget
Why not by name? by id?
Already have that
Name tag category image weight space
hey i have this update gravity event that multicasts, but my server doesn't like it. my client sees my server smoothly. why might they be out of sync? network emulation is disabled.
in my experience anything movement component related cannot be multicasted without there being some qualms. movement related things need to be done in cpp as far as i know
you could try to do it locally and on the server and see if that helps tho, i have some quick movement things that i do locally first then and then server, but these are short bursts and when testing w network emulation there are some sync errors at 100+ ms ping
Any good Iris cheat sheets and tutorials out there? Specifically interested in spatial filters right now
thank you both @sweet sage . long road ahead
embrace the journey
Have u tried changing it on client side only?
Maybe it works
that's what i was thinking, cuase if you change it locally, technically the movement should be replicated to the server by defualt as you are the one controling the movement and maybe then just doing the same function/logic on the server just to ensure server is aware that you did that change. definitley not the best appraoch but could work
Yeah, GravityDirection is replicated on SavedMode
Actually i will strip this saved mode down unless i use mover 2
It has a lot of data
Also, anyone who has knowledge on the reason why Iris exists, and why you'd use it over the Replication Graph would be super helpful.
Are they working towards deprecating the Rep Graph?
I will try when I get home. But I donโt have separate BPs for client and server (am noob) so I might just scrap this and start over with a template I have that has special movement replicated and try to iterate off that.
I thought multicast changed it on both client and server
I'm trying to add to the Player State's built in Score member, but when I try to seamlessly travel to the next map the score is reset
bool URewardObject_Score::CommitReward_Implementation(UObject* RewardTarget)
{
const bool& bResult = Super::CommitReward_Implementation(RewardTarget);
if(bResult && RewardTarget->Implements<UQuestComponentInterface>())
{
UE_LOG(LogTemp, Warning, TEXT("URewardObject_Score::CommitReward_Implementation"));
// Give score to player
APlayerState* PlayerState = IQuestComponentInterface::Execute_GetPlayerState(RewardTarget);
if(IsValid(PlayerState))
{
UE_LOG(LogTemp, Warning, TEXT("URewardObject_Score::CommitReward_Implementation IsValid([%s] - [%s])"), *GetNameSafe(PlayerState), *PlayerState->GetPlayerName());
PlayerState->SetScore(PlayerState->GetScore() + ScoreToReward);
UE_LOG(LogTemp, Warning, TEXT("URewardObject_Score::CommitReward_Implementation PlayerState->GetScore(): [%f]"), PlayerState->GetScore());
return true;
}
It's a valid player state, and it gives the correct score at the end, but it seems to reset after this point
Is there an established pattern for configuring a multiplayer match before loading the level?
E.g.
When going from lobby to in-world match, pass some data that was queried from a web service, so that when the level is loaded, the data can be used to change materials on BeginPlay?
strangely enough, client doesn't move on either client nor server when i enable it to client side only
as you can see, mvoement on the server comes back to the client though.
i might just be smooth brained here... forgive me if this is an obvious question... but do i need to run the event locally, unreplicated, and then simultaneously (or as close to it as possible) on the server, on a second event?
haha, wow, i think that's all it was
yea, tht's what i have done for small short movement changes
yeah at least on a local server without emulation it's totally smooth. predictive stuff to smooth it during bad ping is something else but at least the data is correctly sending now
I feel like I'm blind because I'm looking for what I imagine is a relatively common problem
I want to lock the FPS of the listen server so if the player alt tabs, it doesn't drop to 4fps. how in the world do I do that in UE5?
was simple in UE4.
Making some progress with Iris, but one thing that's unclear to me is how to do ordering, if possible.
For example, I'd like to "send" the PlayerController over before other actors. Pre-Iris we were accessing the GetFirstPlayerController() in BeginPlay() on some actors. Somehow, in PIE that was actually working on actors that already existed in the map.
With Iris, its not available yet ๐ค
I think I've found the source of my problem
void APlayerController::SeamlessTravelFrom(APlayerController* OldPC)
{
// copy PlayerState data
if (OldPC->PlayerState)
{
OldPC->PlayerState->Reset();
OldPC->PlayerState->SeamlessTravelTo(PlayerState);
//@fixme: need a way to replace PlayerStates that doesn't cause incorrect "player left the game"/"player entered the game" messages
OldPC->PlayerState->Destroy();
OldPC->PlayerState = NULL;
}
That reset is setting the Score to 0
Why is it there? Why would you want to reset the values before a seamless travel?
I already have the chat developed and working, I did it with node js. Thank you very much, it is partly what I had in mind to do, unfortunately I do not have much knowledge but luckily what you told me is very similar to what I had in mind, I made myself a "manager" that according to the capacity of the server it triggers a request through an api informing if it is full or about to be completed and that manager is in charge of opening other servers in the instance where it is hosted. and at the same time it adds to a database the IP where the new server is created and the clients before connecting to the server (with open world) through another query obtain the server to which they can connect. Thank you very much. Sorry for the delay in answering
not super substantive but this dropped today @thin stratus https://www.youtube.com/watch?v=P4IKS5k47Wg
i have a widget that shows the connected players with their hp bar and icon that are in the same team, the players don't join the session at the same time and player team could change at anytime, this also applies to ai characters that has the same team as the player, my question is what is the best approach to update the UI with the new members and remove the old ones ? i thought of making it as periodic check to see the changes through getting all actors that has the team interface but i don't really think this is a good approach, also when is the best time for a client player character to broadcast that the player is in and has his character ready ?
It's weird. but if you haven't found a work around, you can store the data needed in the game instance, or a save to be loaded when the level load is finished, it will carry over and repopulate through either of those I believe
I'm running the source code, so I was able to switch them and it now works ๐
I was surprised to learn we were accessing it in BeginPlay() right off a PIE boot. It made me think maybe there's something special going on with the PC specifically as part of the initial handshake.
I tested it under really shitty connections and couldnt break it
either way, its a bit weird expecting anything to be ready like that so I've already started on the fix
I cannot for the life of me figure out why the host character is lagging behind and moving through the canoe when paddling. This is only happening on the joining players screen. On the host screen everything works, on the joining it is the host that is desynced. Host on right, joining client on left.
Where do developers typically keep the "rules" of the game when it comes to multiplayer games? E.g. say you're implementing an PvE extraction shooter, where do you keep logic like "has the whole team died? Ok we got to restart the round", or "the team ran out of time, let's restart" or "they reached the objective, let's finish the game".
Is that typically handled by game mode? Or do people perhaps spawn some kind of a "rules manager" actor that takes care of this? Or the game state? Curious if there are best practices here.
Game Mode defines rules that are governed by the authority instance, game state represents the state of the match, still authority ruled but this is replicated to all clients unlike the game mode, so you have different states you can be in, for example you can be in the RestartingMatch state, unreal has basic state stuff in its AGameMode and AGameState (not their base ones, but the class just after that) but I had to basically just re write my own state and game mode system ontop of the base classes just using AGameMode and AGameState as a reference to see what I should be doing
Sounds like game mode can own everything as long as the clients don't need access to some shared data across players, and as soon as that's the case, you want to start moving information into game state?
Either way it sounds like the game mode is the thing doing the starting, resetting, and overall judging of a "match"?
Technically I think its the AGameSettings or whatever that dispatches the beginplay/restart stuff to all actors in the world, if you had the game mode do it, idk if it would replicate properly, you would have the game mode change the game state and the game state would then replicate to all, from there its all on you to respond to new "Match States", for example I have this concept called a ClientBeginplay, which is an extra level I have between beginplay in the world and actually playing the game, it allows me to do some init and RPC setup stuff with clients before the start playing, then I change the match state to ClientBeginplay which replicates and when the clients get that event I fade in the camera and give input back. Unless you want a literal hard like level opening restart, you would need to implement what it means to "restart" the match within your own game
I have a 3D widget component that has "Recieve Hardware Input" enabled. I am able to click/hover over it successfully as the server, but clients don't seem to affect it at all. I'm doing an RTS style top down camera, so I'm trying to use the mouse instead of a pawn with a widget interaction component. Am I doing something horribly wrong?
You snap to the boat, so in the right is the correct state when you attach to actor using snap.
Yeah I clicked through it a bit yesterday. People already shared most of it with me during the actual event.
so the initial attachment works perfectly, but I have done some testing. I sped up the animation by 5x and the thingsseemingly works now. or at least much better, but the animations are so fast I cant really see them that well. However, I have started looking into root motion animations and the issues they can cause. This is why ignore client error correction fixed the joining player desync.
disable root motion notify fixed it, wow this took me like 2-3 days
sometimes the a bullet seems to deal multiple damage at once (I checked only server can spawn so there should be only 1 target) unless the bullet is shot at point blank
and client can deal damage to them, but only the owner can kill them
That's because it appears you're spawning the bullet on both the client and server likely because you're multicasting the spawning of the bullet rather than just spawning a replicated bullet from the server.
If not, then it's likely because you're detecting the hit on both the client and the server and doing something then on both.
can a UserWidget execute a function on server to run a multicast on all client ?
thank for helps
short answer: no
(not without somehow making it a replicated subobject but that would be very, very weird and I don't think any project I have worked on does this)
put the data that needs to replicate in an actual actor/actor component/replicated subobject
Hi. does anyone know why I can't find/see/join sessions in packed build? I tried the same PC, 2 different in the same network, online, Lan. It works fine in editor
Is there any way to check if AActor is replicating to any connection on Iris?
I am having an elevator in my game that takes players to a different floor with each floor having an own mode. Previous floors are not accessible anymore after they have entered the elevator. There should not be a loading screen or a freeze between levels and players should be able to move freely inside the elevator while they wait to reach another floor. I am thinking about an approach on how to handle this and thought about this:
- level stream the different floors and unload them again once finished
- Put the elevator into the persistant level
The problem I am having though is that sometimes there happens a little freeze and also most importantly, I have different game modes and game states for each mode on the floor and don't know really how to run those once the elevator reaches the corresponding floor. Furthermore, maybe the elevator could be static and not move really but once the players are inside of it, it's surroundings change. Finally, this should work for a multiplayer environment.
If I have a physics ball that needs to be updated all the time, is there a better way to do this than event tick? on my local server with latency emulation, it works pretty well, but everyone always says event tick bad
like if i need the exact world location sync'd, why shouldn't the server update the location of the ball for all clients, all the time?
If you have to do something every tick, use tick.
The question you have to ask is not "is tick bad?" but "why do I need to do this every tick?"
If you use tick for something that doesn't need tick, that's where you get problems.
ok, makes sense, thanks
anyone have any idea why animation blueprint do not replicate ?
player basically press button to use flashlight , so character plays the animation , so it jumps to the "holding flash light "idle animation , everything works fine for the client and the host's pov , but the host cant see the client in that state and vice versa
Multicast RPCs are sent immediately compared to setting a replicated variable and not knowing which next frame they will be replicated right? I want my variable to be replicated with onrep function since it's a state, rather then sending it with a MC RPC, but would prefer it to be replicated immediately/faster than normal replicated variables. Is it possible to trigger replication of a variable as soon as the it's set like it's an RPC?
Oh or am I wrong? UE2 documentation states that replication is done at the end of the tick, if that's the case that's good enough for me
I thought variable replication were done every few ticks or time according to net update frequency
Ue2.......?
But to answer I don't believe any replication Is instantaneous.
Which is why client prediction/server rollback is so important for competitive multiplayer.
The way replication works in general is that the client receives the input/command for an action.
The client has to send that to the server for validation and to run whatever code/set whatever. Then depending on that, the server can send that information back out to that player and or all players.
Depending on location, connection speeds, etc determine how long it takes for these signals to be sent/received. Which is your latency or ping. (How long it takes to send and receive data to and from the server)
Tldr;
Your connection/programming is what really controls the speed of replication but it won't ever truly be instantaneous.
There shouldn't be any real difference in replication method unless you're coding it to have delays or something.
ABP is not replicated. You need to replicate state via Pawn, for example. So Client would get keypress and call a Server RPC to say she wants to turn flashlight on. The server sets the replicated bool to true. Then server and all clients can see when the bool becomes true and switch to the holding flash light anim.
may I ask what trees you are using for that project?
that whole level is the lookout_level that came free from unreal maybe 1-2 months ago
Does anyone have any good source of information on Iris, I have enabled it and tested it - and it works. But I assume it's not that easy to migrate by just enabling it? Had some small error where I didn't add a component to the replicatedSubObjects but that was it ๐ค . If anyone can point me to some good documentation I would be forever thankful
Ah I see, thank you
Is this a scene from brokeback island?
(Sorry not helpful)
Not too sure where to begin fixing this but something, whether necessary player "state" or location is not properly replicating.
Possibly a rep notify somewhere might help?
haha, it was root motion not being disabled. i fixed it.
Ohhh! Glad you were able to figure it out! Will keep that Possibility in mind from now on.
i tried setting up listen server replication, but for some reason it only works one way. its mini golf, and both players bp spawns an actor, the ball, and on the clients, i can see my server/host movements on the client, but the hosting player/listen server isnt receiving anything from the client. anyone have any idea whats wrong? ive tried to research this for a whole day. i have tried every single combination of the replication settings in the actor.
replication is one way
from server to clients
if clients want to tell the server anything it must be a client->server RPC
usually prefixed as "ServerDoThing" in C++ as it runs the _Implementation on the server
for example, character movement is a bunch of server rpcs received from the controllering client that tell the server where you say you want to move
im doing it in blueprint currently as i dont need anything advanced and i just started using c++ in UE (been learning it outside of it slowly for some months)
and ALL i need is to update the locations of the balls and display them
but so, do i need to do it manually by calling an event to update the position? i thought it could be just handled by the replication settings in the actor because its working the other way, like i can see the movements of the hosting player on the clients
If you want a client to tell the server something so it can replicate to everyone else then you must send it through an RPC on a replicated actor or actor component that was spawned by the server that the client owns or if it was spawned on the client, that a copy was spawned on both the client and server and has been set up to be net addressable. The common actors that are always owned by a client are their controlled pawn, their player controller or their playerstate.
This can mean that you don't necessarily want the movement to happen on the client either, you may want the client to be able to tell the server, "Hey I'm hitting the ball now" and then the server can interpret that request based on the current direction and calculated power of the swing and simulate and move the replicted actor itself.
If you're trying to move the ball first on the client, and then have it sent out to everyone else, that's possible too, but it's generally easier just allowing the server to perform the movement.
@crisp copper ^
oh okay. damn multiplayer is harder than i thought, like i knew it was hard but yeah.
thanks
but are the physics 100% deterministic? like if i shoot the ball on the client, and then its shot with the same parameters on the server and replicated for other players, will the swing performed on the server be 100% the same? as in the end location
https://youtube.com/@brynertoma?si=V7E2LBiTdO8irXkj
This guy has one of the best replication series I've seen. Imo.
thank you
No. There could be things that are in different positions on the client than what the server has currently and there will always be some small offset due to latency. That's generally why it's better to have the server replicate the movement for you rather than moving it on the client as then anything that is moving with server's authority it should line up correctly on the client too, assuming everything is correctly synchronized.
So if you were trying to "time" a shot through a windmill hole, but were relying on the client to move it and allow it to replicate to everyone else, then on other people's screens it could look like the ball passes through windmill blade, but meanwhile on the client that hit the ball locally it would look correct. If it was server authoritative movement, then it would appear the same for everyone, assuming that the spinning of the windmill blades is synchronized correctly on all client machines.
Excuse me, you dropped this ๐ on accident
i feel like thats way too advanced for me. ive watched many hours of videos explaining replication, as well as some tutorials, and read alot of stuff, and i cant make heads or tails of it. like i can understand the underlying principles, but not how to actually implement it.
also if its server authoritative, wouldnt that mean that the player would have insane input latency as after you do an action, it would send it to the server, do it there, and then send it back to the client?
Cant say it will be the same for you for sure, but the series I just posted for you was like the 4th or 5th series I watched.
It's what got me to understand replication
and doing it in a way that doesnt have latency (predictive and then possible correction) would be extremely difficult and require extensive usage of c++
this is primarily a practise project, but i will be playing it with some friends who live far away, ping would easily be over 200ms
In a golf game, it likely wouldn't matter. I don't think players of a minigolf game would be upset unless you have some kind of crazy skill shot things that would require sub-300ms ping.
There is always way you can try and compensate to make it feel better, like you can actually make it -start- to move on the client, but then replace it with the server's position once it knows its in flight.
but for an example like the example you provided, the windmill, you need to time it, so 0.3 seconds might make you hit the blade
But that's the thing.... Which copy of the blade then are you going to rely on? The server's copy or the clients?
if you rely on the server, then it wouldnt work because when you shoot, when the server receives it, the blades will be in a different position
or am i missing something?
i dont mind if other players see it going through stuff, so would it work if i just manually call and event every frame to update the other players positions?
That's correct, but then that means your timed obstacles like the windmill blades can't check their collisions on the server for that client.
yeah thats fine, they can just check it on the clients
No, they can't check on other clients.
It can only be checked by the client making the ball move.
One thing you could do is have a shared "accurate" time where the person shooting sends you the offset of overall time when they hit the ball to move things to that time in the timeline
but there might be multiple people shooting at the same time. also that seems way too complicated for me. ive been learning replication for only 2 days, and would have to do everything with blueprints as i dont have enough knowledge of c++, especially in UE
BP doesn't really limit you here, it's all just floats and timelines ultimately
with C++ you get more control over the extra unique ways to control replication conditions/raw serialization but I don't see how BP restricts this
assuming the bandwidth cost with the naive approach isn't high enough to matter
okay, but still its too complicated for me. i would have zero clue where to start or what to actually do.
Fair enough... making multiplayer is always complicated inherently so don't feel discouraged I guess
proud of you guys, just figuring out basic blue prints so keep up the good work lol its rough
I just found a nasty oversight and I am not sure how to address it. Would appreciate some high-level guidance.
My server has resources (trees & rocks), these are all ISM using PCG.
When the player whacks a resource, I spawn an actor (BP_ResourceTarget) at that location. That actor manages state/hp for the mesh and when hp = 0, the mesh Multi-Casts a destruction animation and moves the ISM -5000 under the map.
BP_ResourceTarget then destroys itself - otherwise I found my server performance takes a dive after 200+ trees are whacked.
I am only now realizing that the Multi-Cast won't work for late joiners. The tree meshes remain on client, but not on server. The player will not collide with the meshes and can walk through the trees.
I think OnRep is the answer, but I am concerned with 300+ OnRep tree vectors.
Any suggestions?
Are the ISM instances statically generated in the Editor? Or are they randomly generated at runtime?
In-editor. I could potentially change that to runtime but I imagine that would increase load time.
No, dont do that, its actually better for you for it to be static
So
Instances within an ISM have an ID
Its just an Integer
For Instances that get "wacked"
Aye, that's how I move them under the map.
You can replicate the InstanceID
Oh, smart.
So when a Client joins later, you can use the ID to remove the ISM instances that were "wacked"
Thus keeping them correctly in sync
How would I store all the IDs, would that just be an replicated array of ints?
Yeah
You might want to consider removing the RPCs
And just use the Array of IDs to identify which Instances need to play animations
The Local Client can probably predict the removal
Remotes would wait for the Array to change
To know which ones to destroy/remove
Its also better to play a Particle effect instead of animate the ISM instance
The instance just gets hidden or removed immediately
Then the FX is played ontop of it
Much more performant
You will want to also look into using a FastArray
It will make your life easier
Okay, noted. I don't know much about FX or prediction, but this is good homework.
If you are clever enough, you can probably make this a generic enough system to apply to all your resource types, not just trees
But yeah, there is a lot in what I just outlined.
So good luck.
Its very doable.
Thank you Matt!
๐
any idea why my cast fails? can i not cast to a blueprint from the server, thats on the client?
For one, there is no reason to pass "self" into the RPC on the left if you call that RPC on "self". You can just get the Scene property directly.
And then the Tick is probably calling right from the start, where the Ball is not valid yet.
And last, the Ball variable isn't replicated, so the Client will always have it invalid in tick.
its not using the self as a reference for the RPC, its an input i added to it so the client can send it to the bottom left (server/host player) and cast to player so i can access an actor object reference variable and set it to the actor (ball) the server spawns.
self is redundant here
You are in "self"
but it doesnt cast to the same blueprint. its the same name. this is the very reason we need object references in casts, cause there can be multiple instances. in this case, one on the host, one of the client
self is a pointer to the instance that calls the code. this in in C++.
If you have two Actors in your Scene, of the same (BP) Class, and you call your code in Actor_1, then self is that Actor_1 Instance.
Calling a ServerRPC in Actor_1 on Client-side will move to the Actor_1 Instance on Server-side. There is no need for passing self.
and i need a reference to the client BP_Player
That's not how that works
When you pass self there, it will send a NetGUID to the Server that is resolved tot he Instance on the Server-side
it's impossible to get access to the actual Instance of the Client.
That sits on the Client's PC in the RAM.
Whenever you pass any kind of replicated Actor reference via replicated Variable or RPC, you only send an ID that Server and Client agreed on to identify the Actor
That ThePlayerBall variable has to be marked as Replicated.
EventTick calls on everyone (that has an Instance of the Actor), but your Spawn code is triggered only on the Server (which is correct). You have to mark the Variable as Replicated, otherwise it will be null on the Client.
The Cast in your Tick will not work on the Client due to that.
but then it will be the same variable for everyone, right? that wouldnt work because it needs to be a reference to different instances of the BP_Ball that im spawning
No?
You have a bigger misunderstanding of how that all seems to work and align.
BP_Player is a PlayerController I assume?
Or a Character/Pawn?
a pawn
Okay, and BP_Ball is the GolfBall.?
yes, an actor
I assume both are set to Replicate in their Settings.
Okay, so let's say you have 2 Players, and for simplicity, let's say you use a DedicatedServer, and not a ListenServer.
on the host, i can only see myself, on client i can see host ball as well as ofcourse the clients ball, and their movements
The Server will spawn 2 BP_Player, one for Client_1 and one for Client_2.
Due to the replication part, Client_1 will get an Instance locally spawned (due to replication) of their own BP_Player, let's call it BP_Player_1, and it will receive a version of Client_2's BP_Player, let's call it BP_Player_2.
The same goes for Client_2. The result are the following instances on the given Targets/PCs/Players:
Server: BP_Player_1 (Client_1), BP_Player_2 (Client_2)
Client_1: BP_Player_1 (Owner/AutonomousProxy), BP_Player_2 (Client_2/SimulatedProxy)
Client_2: BP_Player_1 (Client_1/SimulatedProxy), BP_Player_2 (Owner/AutonomousProxy)
Client_1 can only call Server_RPCs on Actors they own, so BP_Player_1 in this case.
When calling a ServerRPC on BP_Player_1, it moves the call, over the Internet or LAN, to Server, and that resolves the NetGUID and calls the function in its own version of BP_Player_1.
If the Server now spawns BP_Ball_1 for Client_1 in BP_Player_1, it will again also replicated to everyone else, due to Server spawning a Replicated Actor.
If the Server, after spawning BP_Ball_1, inside BP_Player_1, sets the ThePlayerBall variable, it will be set on the Server version of BP_Player_1 to the BP_Ball_1 instance.
If you mark the variable as replicated, it will (if both Actors are replicated, which they are), replicate the pointer to BP_Ball_1 down to the two versions of BP_Player_1 on Client_1 and Client_2.
BP_Player_2 will not have that variable point to BP_Ball_1. That will get its own BP_Ball_2.
And as previously set, any kind of Replicated Reference to an Actor gets turned into a NetGUID that will be resolved on the other side. So BP_Ball_1 will ultimately be spawned locally on the Clients too, and will be connected through an agreed on NetGUID. When setting ThePlayerBall in BP_Player_1 to BP_Ball_1, it will replicate the NetGUID, which will resolve on the other end to a pointer to BP_Ball_1 in the player's PC Memory (RAM).
This might be a bit tricky to wrap your head around at the start, but it's somewhat crucial that you understand that.
ohh okay. thank you very much for the comprehensive answer. i feel like i understand the process slightly better now.
For a ListenServer, this works similar, but there the first list would look like this:
ListenServer: BP_Player_1 (Owner), BP_Player_2 (Client_1)
Client_1: BP_Player_1 (ListenServer/SimulatedProxy), BP_Player_2 (Owner/AutonomousProxy)
would you say its easier to setup a dedicated server? i do have one extra pc laying around. its quite bad but could probably handle 2 players
That has nothing to do with Easier or not.
The Code is somewhat similar, maybe easier, but you should only use DedicatedServers if you really need them.
Someone/something has to host those.
And it's more annoying to develop with them if you are a beginner due to requiring to download the Source of the Engine.
oh okay. and just to confirm, if a client spawns an actor (which is set to replicate), it wont replicate to the host right?
If you can use ListenServers, do so.
If a Client spawns an Actor, replicated or not, it will only exist locally.
That's the concept of Authority. Client's need to ask the Server to do things that are visible to everyone. And that's usually done through a ServerRPC.
That said, 90% of ServerRPC uses usually fall into telling the Server to do something based on a KeyPress or UI Interaction.
okay, cause that was my previous attempt, which would have made things easier if it worked, but i figured it probably doesnt which is why i switched my tactic to spawn on the server, but wanted to check
One should never use a ServerRPC to tell the Server to, e.g., apply damage to an enemy.
The ServerRPC should be the Key Press that fires the current weapon.
After which the Server can fire the weapon if allowed and damage the enemy.
And then we get into prediction to make the delay not feel that bad for the Client that pressed the key (cause the RPC to the Server and the result of the damageb ack to the client is of course delayed by Ping)
But that's a story for another day.
You code at the top of the screenshot for example looks like it is probably wrong :D
yeah, i know about prediction, but wont be touching that for a long time. luckily for mini golf delay isnt as important
-
BeginPlay should not be used to add MappingContexts for Input. BeginPlay calls on every Instance of the Actor, similar to Tick, and on BeginPlay, the Client most likely doesn't know yet if the Actor is locally controlled by itself to ensure the IMC is only added on its own end.
-
Since BeginPlay calls on every instance, and you only want to spawn the Ball on the Server, you don't need that RPC at all, just the Authority part that already spawns the Ball.
For the IMC, you should use the OnControlledChangedEvent or whatever it is called. It's a function/event if Pawn that you can override. It calls on Server and Owning Client (not on other Clients) and gives you the new Controller, which you can then cast to PlayerController and use IsLocalPlayerController to filter only applying the IMC to the local instance.
And for 2. you just cut the RPC
but all the balls need to be spawned on the server right? if i remove the rpc, how will the client be able to spawn its ball on the server?
yes, once, for the player hosting
This is indentical to the ServerRPC. The Server will spawn teh ball twice.
That's not what SwitchHasAuthority does
Is it possible to "ensure" the locally controlled check can work on BeginPlay by giving owner on spawn params or spawning deferred and setting the owner before finishing spawn? Or is it undefined whatever the case is?
If you have two Players, one ListenServer, one Client, you have BP_Player_ListenServer and BP_Player_Client_1, based on previous explanation, right?
yes
ListenServer and Client_1 both have an instance of each of them, right?
Which means BeginPlay, inside BP_Player, will call 4 times (if you'd print a String in it).
Twice on the ListenServer, once for BP_Player_LIstenServer and once for BP_Player_Client_1
wait what? im so confused : D
And twice on the Client_1, once for the replicated BP_Player_ListenServer and once for the replicated BP_Player_Client_1
Yeah I know what part you are struggling with, but that's not so straight forward to explain.
Put a PrintString on the BeginPlay node, right at the Start. And print the DisplayName of self.
And see what it prints for you.
Maybe that helps.
You can't ensure it. Replication of the PlayerController and the Controller variable are not a given on BeginPlay of the Pawn.
You should always use Functions and Variables that have that "ensured guarantee" build in.
ill try that in a bit, im not home at this moment, but thank you, while im still confused, i do have alot clearer understanding of the system now.
I need to head out and walk the dog and then have an appointment. Will be back later.
It's not locally controlled initially so this doesn't work on beginplay.
The easy way is the controller when it possesses it then this gets set so save it then. I do not think this is a replication or multiplayer issue. It's just not possessed on beginplay even in single player.
Oh if it's the missing controller that causes the check to fail, I want to ask if it would work during gameplay, when controller already exists
Or is the actor's replicated spawn on client and it's net update are different stuff which causes it?
Yeah initially it's maybe not possessed on beginplay then it gets possessed. You can put a print statement for the controller it will have an AI controller on beginplay, not local player.
Yes but all possess does that makes a pawn "locally controlled" is to set the owner as itself (controller). So giving the controller as the owner during spawn wouldn't solve it?
I'm not talking about default pawn spawn with game mode, I'm doing it custom by myself since I let players choose which character they want to play with
No 'cos you can't just give it a controller, you'd have to possess it which again is what its doing anyways.
Just check this once you know its possessed.
What do you mean by you can't give it a controller?
Oh I misunderstood what you said.. It doesn't have a local controller, AI controller is not locally controlled.. that's what youre saying to check so that won't work.
It's not giving an AI controller either, my auto possess is disabled
Yeah so it doesn't have any controller than GetController should be nullptr
if it has a playercontrolller than islocallycontrolled will be working.
Ahh okay I think I'm mixing IsLocallyControlled with HasLocalNetOwner
IsLocallyControlled just means that you're controlling this with inputs using a playercontroller, that its possessed.
Well apparently HasLocalNetOwner also relies on APawn::IsLocallyControlled so yeah I guess that's still a hard no to my question
Wait, actually no, it's relaying on IsLocallyControlled, if the owner is a Pawn, which in case of Pawn is wrong, since I'm asking setting the owner as the controller on spawn
Yeah HasLocalNetOwner wont' work either.. OnRep_Owner is probably where you want to do this.
Maybe if you're using playerstart to spawn the pawn it should already be possessed by the playercontroller but I think its always unavailable on beginplay regardless. You may have to doublecheck this.
Specifically when does an actor begin replicating? On its first tick or before? I want to use some InitialOnly replication and have some initial setup during spawning before it's ready to replicate
At the end of the game frame
Whatever you do in the spawn frame will be picked up at the end of the frame
Tick will be too late potentially, depending on when it is spawned.
Hi, if level has some actors that are not set to replicate. And new player joins game. will it spawn new actor for him or copy its values and then spawn?
I want to create quest manager for each player and do not replicate its values
Hard to understand the question. If the LEVEL has actors and they DO NOT replicate, why would they do anything but simply load with the map when that client joins? I'm not seeing how this connects with quests?
So you mean they basically start empty and trigger begin play like normal actor spawn?
I would rephrase question but I am also not surewhat im asking hah
For starts, this is an actor placed inside the map, right?
in level yes
Then it will simply load up on that client with whatever values it has from the map.
Ok, that also explains my second question ;d
hello please i am having a hard time understanding that RPC table on the unrel documentation
any easier break down? the table is kinda confusing me for real
I doubt you'll get an easier breakdown of it. It's pretty straight forward. What are you not understanding about it in general?
the table .....RPC invoked fromserver are RPCS sent from client to be executed on server right?
๐จโ๐ซ My Patreon link:
https://www.patreon.com/kekdot
Download Project Files | Premium Tutorials | Courses
๐น๏ธ Get our Game on Steam | The Anomaly Project:
https://store.steampowered.com/app/2960770/The_Anomaly_Project/
๐ง๐ปโ๐Get the project files here on Patreon: https://www.patreon.com/posts/66842088
In this video we take a look at the basi...
- A client will make a Server RPC from an actor that the client owns that will run on the server IF the client owns the actor.
- A server will make a Client RPC that will run on the owning client's machine of that actor.
alright thanks
ill check the video
thats is just what Authaer said. But maybe better explained.
Also multicast can be done only from server
ohh ok thanks chief
Multicasts are also better avoided for the most part until you fully learn Replication.
ok heard it updates only twice right?
Not sure where the twice comes from.
go watch the vid, it will clear things for u
Multicasts run once for each machine the actor is relevant for.
Consider changing your armor color. If you multicast this. It will change for the current players in the game if they're close enough. If for any reason someone wasn't close enough and then they become close enough, they will not have the updated color. Similarly if a new player joins the game, they will also not have the color because neither of these received the RPC.
Replication on the other hand will always send most recent values when things change and when they become relevant so you replicate thus both players who did not initially receive the color will get the color at some point.
Multicasts are only really good for non state things. Like say you want to play a three second emote which you don't care if people out of relevancy see even if they get closer.
For this general reasoning, for a vast majority of gameplay systems, multicasts are largely useless over replication.
is there any written document for this ? more than unreal docs?
๐คทโโ๏ธ Probably somewhere in the depths of someone's blog.
ill search thanks
probably at WizardCell's blog
he has a multiplayer tip and tricks article
How can I get pawn of current player / client locally, without replication ?
is that good?
can't get player controller, thats what I need ๐ค
on what
on client side
so I get do stuff for each player independetly ๐
I get owner of local player state, and cast it to player controller. Now Im waiting for game to load up and stupid shaders ;d
actor blueprint
spawned on level, not owned by player
like what else do you wan?T
name? Its RingManager
?
wouldnt get player controller work? on client it should only include local controllers afaik
I though someone would help me :d but I found this node
Can anyone point me to resources on properly doing line traces in multiplayer
I understand backwards reconciliation but i dont know if its possible in bp
Like handling a synced clock, and storing positions at the same rate
And how cmc players interp will affect the accuracy
Vorixo wrote about that
Hello! I am trying to disable replication on actors from certain clients, so I came across SetNetDormancy(DORM_DormantPartial). The problem is that my actor never goes dormant (even when setting to All). It gets marked as bPendingDormancy but ReadyForDormancy is always returning false because the actor constantly has replication changes. Has anyone else dealt with this? Are there any other ways I could achieve a similar thing?
// We need to keep replicating the Actor and its subobjects until none of them have
// changes, and would otherwise go Dormant normally.
if (!bIsInDormancyHysteresis)
{
for (auto MapIt = ReplicationMap.CreateIterator(); MapIt; ++MapIt)
{
if (!MapIt.Value()->ReadyForDormancy(suppressLogs))
{
return false;
}
}
}
Hi guys, I'm having a desync issue when calling through an anim notify. It's only intermittent. It only happens with the client, never the server. The server (screen on the right) always switches hands correctly, despite one of the clients seeing it incorrectly in this video. One vid is with break point on the AN to show it taking the wrong route. This method of syncing in the pic has worked for every other function so far so I don't know why this one is different. Please share any wisdom, I've been on this for like 6 hours today
furthermore once the error happens with my client, it breaks the animation graph and they're effective stuck in place
Can someone help me with this problem:
When one of the players enter a collision a sound plays, to turn it off you interact and the sound turns off. This all works but when either the server or client interacts the sound only turns off in server side not client, i use a multicast to turn it off, but same result with a rep notify
Am I correctly understanding that if I call a server RPC from the server, it intelligently resolves it to a local function call instead of actually making a networked call? I'm trying to interpret this response from the forums: https://forums.unrealengine.com/t/rpc-from-server-to-server/450525/2
Nothing that would cause a performance drop. The generated code (from the macros) makes sure you are calling the function where it belongs. So its just an aditional check. Obviously the easiest way is simply call a regular function if you are sure you are in the server and thats it, as long as you are sure the function will never be called from...
so this is an issue i face in/on client side where i set a reference to my anim bp by casting on begin play locally, however i dont know how/why it flushes out the variale completely, basically i check if this variable is valid on tick and it always returns invalid whenever i stay idle, it weird- ive checked the references all around and i cant figure out whats invalidating the variable, any ideas?
What could cause SpawnedVehicle to return None on all clients, but not server ( dedicated? )
The server is spawning an actor, stores it as a RepNotify variable, RepNotify calls a multicast RPC, but the replicated variable is None only on clients.
If the multicast is called immediately after spawning the actor, then the actor reference may not be on the clients before the multicast is received. You also shouldn't be multicasting the set of the owner, it only needs to run on the server.
Clients also cannot call a multicast, so the OnRep doesn't actually call the multicast on the clients but it will fire on the server when you set the Spawned Vehicle value. Since the OnRep will fire on the server which calls the multicast immediately, the clients are receiving the multicast which is likely happening before the clients receive the actor reference.
okay so i believe ive figured it out and its dumb, i never looked into this since i coded this part like 2 years ago or smth but i shouldve sent the reference to the server from outside, however for now ive realised that i didnt need to really replicate this anyway so i set it to not replicated which kinda fixed it
Just to add to your discovery, Animation Blueprints don't replicate, so setting a replicated reference to one won't replicate it to anyone else.
Animation blueprints are meant to run locally on each machine and instead can pull replicated information from their owning actor to then use to handle your animations.
yeah like i said i coded this 2 years ago and i was new to networking in general, now i understand it a bit better i believe, also dont animations themselves replicate either way?
this kinda makes me ask, do the animation bps work like widget classes where they work in respective to their own pawns?
Animation blueprints run locally and there is no replication in them. If you request to execute a montage it'll only execute locally. I believe these are the two types of things that are normally referenced as animations, and neither of them replicate themselves. In the example projects, any animations that appear replicated is actually happening because the animation details are replicated through the Character, and the animation blueprint usually pulls from that Character the details it needs to be able to run the animation locally, so really, there's no additional replication happening, it's just using replicated data to present what you want it to.
Widgets are similar in that there is no replication happening with them. They are created only locally, so if you wanted to have the widget contact the server in some way or have it use replicated data, it can't itself so you'd need to execute an RPC in a replicated actor to send the server information or read from a replicated actor the replicated data you want it to display.
right so it sounds exactly like a widget, you replicate the data and dont bother dealing with the animation part- all clients have their own sorta local copies of characters with their own anim bps on their local machines just pulling data for them from the server
if i got that right
The animation blueprints and widgets don't pull the data from the server. They use whatever local data is available that you're telling them to use, which could be replicated.
BP_ThirdPersonCharacter - This code only works for the "Server" and none of the "Clients" Does anyone know how to fix it?
Picture show no context at all. If the render target created only in the server then you only run that function in the server machine.
Yeah I'm just now learning that you basically have to have two sets of code to run things
Depend on the context in multiplayer
It's not really two sets of code either
You decide what to run on what machine
In essence we all running our own instance of the game. The programmer job is to establish communication between each player instance to somewhat "sync" them to give illusion that we shared the same world.
You will end up with double component on the server
thats the problem im working on now
And try to avoid multicast for anything that should be in sync
In general don't use multicast until you know the basics imo
It's a common trap for people that just start
how do i get it to show up on all* 3 clients i have? (2 clients) + (1 server/client)
You can look at how to replicate variables via on rep
In general, you just set the variable in server, if marked as replicated, the server will update the client's value
If you are client, the only way to communicate to server is via server rpc
So if you want a client to change a variable, it needs to inform the server via server rpc, then the server will replicate it
Not doing so will only reflect the change locally
Read the pinned section on this channel
You will need to learn how to use switch had authority , is locally controlled, rpcs, rep notify, replicated variable and so on
rpc = ?
still looking for the others you mentioned so i can read up
Other ways for Replication are so-called โRPCโs. Short form for โRemote Procedure Callโ.
Just now seeing pinned section , I read what you typed a few times
I would assumed you have read them before using it here.
If you are looking at tutorials from youtube modt of them are bad or just plain wrong. Your best source of help is the pinned material, it will take time to click so take your time.
The first pinned message is a broken link
#multiplayer message
#multiplayer message
And wizard multiplayer tips and trick
Thank you! for all of this 1000% going to do a bunch of research
Once you finished that, practice with syncing something basic
Like a text variable on top of the player head
Their name or w.e
Then maybe opening/ closing door? For the next challenge
Will do, was just trying to do the basics with the static mesh that i showed too, but it was printing like 4 times XD. Again, thank you!
Why is that inside my onRep function of the "PistolHeld", only the authority role is being called? Should the onRep function be called to all the roles?
What is BP_BaseAgent?
thanks my chief
Anyone knows what entries similar to
LogPhysics: Warning: [Remote.Input] in fault. Reusing Inputcmd. (Client) Input: 37819. (Server) Local Frame: 90500
...```
in logs mean?
Starts happening only on host when client joins and stops when client disconnects. Game seems to work normally, but this warning floods my logs now... unfortunately, I am not sure when this thing started happening. Uncle Google says nothing about it.
Looks like it has something to do with the experimental physics prediction plug-in
Hmmm... it is true I turned it on some time ago in vain hope ragdolls would appear same for all players (it did not). Will try to turn it off, thanks!
Confirmed, that option in project settings was reason. Thanks!
?
I am still trying to wrap my head around RPCs can someone tell me if this is correct? (Works in Game) Just trying to make sure I understand it
If I was to get player uuid on server with no authentication method can it be spoofed or change at random? Or consistent throughout?
Just looking to get someone on an external website to verify a uuid or something to prove itโs them as my normal sso wonโt work anymore
Just seen a very strange thing -
I was able to replicate a value in Character class without any server rpc but I can't do the same in Pawn class. Why?
what value?
show your code
The game mode actor does not exist on clients
get game mode literally returns nothing
When you join into a game as a client, the Game Mode only exists on the server.
With Mover, is it easy to modify the historical states? Let's say a client performs an action that affects location. It sends a timestamp to the server. The server wants to then effect that action in the past. Is it a simple task to update the historical values for Mover and resim?
That's in fact not a Mover question
But an NPP one
And no, I don't think so. NPP handles corrections on client side. Server doesn't even know what a correction is
I see.
NPP has circular buffers of frames for all Models, at least in fixed tick. While you can potentially modify them, I don't think you can easily get the data to the client, especially not if it already reached it before, cause the client assumes all older packages were valid at that point
That's a serious issue I feel
Idk what you are trying to do but we have yet to encounter a need for that
Basically we have a resource, energy, which is tied to movement. But it's also usable by other things. So we wanted to handle energy consumption via mover/npp. But we also want to be able to accurately resim when those other things get used.
But it's not a problem if we can't resim, we will just delay I suppose.
As in, do it in the moment, not lag compensated.
Everything you want to Sim / Resim has to live in NPP land fwiw
Yeah.
We already have the movement effects itself on NPP.
But not the resources (which isn't yet implemented).
Using Energy from outside NPP/Mover is probably not gonna work well
That is my feeling.
I can guarantee you that it's not :P
But we'll make it work.
NPP doesn't solve the problem that CMC + GAS gave
Movers latest commit have MovementModifiers built into Mover
Even a second simulation, like an NPP GAS, is gonna be shitty experience
So do listen servers have corrections at all? do they accept input and shift things over?
ListenServer run other Services
Forgive me, I'm not aware of what Services are in this context
Thanks for the feedback, Cedric!
I see IFixedInterpolateService etc
NPP is basically just a big Manager that has a multitude of Services, which are just some Class that have functions called on Tick.
And Models, e.g. Mover, register their instances based on the NetRole of the player, to those services
And those services are then allowed to access NPPs storage of frame data
That's kinda all it is
You can code whatever service you want
There are smoothing ones, tick ones, reconciling ones for corrections, etc.
You need to alter NPP for it though cause you gotta call the service functions in the NetworkPredictionWorldManager at whatever point makes sense for the service
Existing services can be overridden though by specifying the duplicated version of it with the specific model as templates parameter
Reflection magic
Each service basically has an array of registered instances which it loops over to call the functions then
AutonomousProxy uses a service that grabs input data and puts it into the frame data. ServerRPC service sends the data to the server.
LocalTick calls the predicted sim tick function on the driver (e.g. MoverComponent)
RemoteTick is the server version that ticks the client based on received input
Client locally is also in the reconcile service to check for differences and roll back
Ultimately NPP is simple af
At least structure wise
The code itself is a bit more complex due to tons and tons of templating
In my custom rollback setup I just do everything in a bunch of ECS for loops
The hard part for me was figuring out that you need to actually immediately store the rollbacked frame results
It's becoming a bit of a hairball as I have rendering data tied up in the rollback state (very silly)
Looks like its an NPP party in here
Interpolation is quite simple but having a stable alpha per frame was fairly tedious to measure
It does all this stuff for you thankfully...
I now run my entire game in a custom fixed tick
It has its downsides (technically input is delayed on non-simulating frames) but it's overall nice to know each tick is one unit (16.6ms in my case)
I mean NPP fixed tick is just a counter in the tick function that calls SimTick when the Ms are reached
The current fixed tick is broken. It binds to the PostWorldTick Delegate and passes the FixedFrameRate value set in the engine ini even if its off
the math is quite simple but how you deal with it is another matter
its annoying
you need to not accept insanely large frames, decide when to slow down the sim
I doubt Epic has avoided dealing with that stuff I guess but it's just my take on making it from scratch
The GafferOnGames article is my main reference point
Probably also the only one properly explaining stuff
My main problem with NPP atm is the communication between NPP and non NPP, as well as one model with another, or even 2 instances of one model
Even in fixed tick it's flawed sadly
Cause Instances tick after another. They can't alter each other in the same frame. When one is done, it's output state is sort of sealed off
Suggestion would be to split the logic into SimTick and GatherOutputState, with maybe a Interpolate step in between
But I'm not in the mood to even further alter this damn plugin
You're team is using it right? obvs a modified version of it
NPP 2.0 ๐ฅฒ
But yes, we are. But we had to alter it a lot to get it crash and bug free. Including Mover
also learning alot about client prediction from it in the process
It's ultimately just re-doing things across the network
Learning from it is probably fine
the hard part is how to handle the many wacky situations
I am making a little game project from it to learn
It's hard to find an implementation that is focused on just the generic prediction stuff
So in that regard it's a holy grail
At least the previous one had a generic ability that would make you dash
and stamina
which was a useful example I think
The problem overall, objectively, is that it and Mover are simply not done. They are lacking features, are untested, crashing, bugging, memory leaking etc.
I do have one question about it
its more networking related
and game engine related in a sense
So I am just sorta mapping out the simulation steps between client and server with NPP. For the case of independent ticking, NetworkPredictionManager gets delta time from the engine frame. If I learned correctly when client or server runs seperate frame rates the tricky part is syncing their states. How are GFrames tagged across both server and client. I suspect that for uncapped simulation the Delta Time is accumulated and passed also to the server. The server just uses this to match what frame it has with what the client sent?
Just ping me on it, I'll check tomorrow. I'm falling asleep with my phone in my hand. It's past midnight in Germany

I'm going to assume GFrames are not fixed tick frames
The engine static globals for ticks are more for the main thread
but I have no idea so don't take my word for it, I just made my own...
(which sucks and barely works lol)
So when I looked at the Insights for Fixed Rate it was easier to see it. But for Independent You have Server GFrame and Client then under that is sliced up. For example when I was messing around with insights I noticed that at 120 fps I had 3 world ticks for one frame and then carry over to another frame.
This is where if I understand correctly is the Accumulated Delta time
now it gets interesting how to match what the Network Prediction ticked inside that GFrame and match it with the server that may run the simulation at a different speed
The multiple ticks could not just be the "stable fixed tick" but actually rollback re-simulations
kinda trying to wrap my head around the ticking
For example in the worst case I need to re-do the frame like 10 times
Taking a step back, in general for game engine ticking especially for uncapped stuff is there some frame budget behind the scenes that is defined to know when to carry over accumlated delta time?
or for uncapped its just simply accumlated over frames and subracted from over time
It depends? Some things will warn when they get extreme second+ deltas
With uncapped it just... goes?
yea it would just go and always accumulate delta time
meaning it just gets added to and subtracted to over frames
With fixed ticking the idea is you add the real-time taken and "consume" the time when it accumulates enough
even multiple times if you need to do multiple frames in one go
sub stepping
the accumluated stuff
i assume
so whats left is substepped
that frame
It's kind of like substepping for sure, where the amount of time is built up over time
And once you don't have enough time to eat to do one 16.6ms frame you go back to ticking as normal
and then eventually you have enough time built up to do another fixed tick
Making this 100% super stable is a bit of a doozy as in reality measuring time accurately with delta time is a bit wacky
You could for example actually use the CPU clock timer instead of the world delta time
yeah
So for fixed ticking GFrame ticks at some uncapped frame rate say 120, the network simulation code runs at 30 hz so we would run sims every 4 frame after a X amount of sims we package that shit up and send it to the server
server gets the data with the GFrame It got and delta times and compares with its own Simulation
not every 4 frames, every amount of frames that it takes to built up enough time
but effectively... sometimes yes
The idea with this stuff in the RTS-style ideal case (lockstep rollback) is to only send the player inputs at X frame
but I don't know what NPP sends
When one side gets a new input that is different from their assumed input that frame you must go back in time and redo everything in that sort of parallel reality
One interesting property is that DELAYING the state locally (input delayed, show a technically older frame visually)
lets you get away with less mispredictions
so most fighting games will start with 2-3 frames of input delay baked in because it allows them to have a larger buffer of ~33ms where they can wait for both player's inputs to arrive
which means less need to rollback!
Which is not just for visual smoothness, but also because rollbacks can cause violent jittering between states that are hard to react to
Like "oh actually I was punching 3 frames ago... try to block now"
But once again this is all in the theoretical sense... the NPP could work differently entirely for all I know
so you mentioned not every 4 frames but you mean when there is enough delta time left over
yes, it's not counting up frames it's counting up time elapsed
or built up?
very cool
So I did read that bad boy a long time ago
I remember that after reading that, Unreal CMC was using a clamp type
where like
if you had say 60 hz and your running at anything higher it would just treat stuff as 60 hz anything below would be substepped
Unreal CMC substeps
This is with 0 input delay and 120ms ping (my custom setup)
Because it takes 120ms for the input to reach the server (network emulation)... you are perpetually quite behind
each time they jitter forwards is the entire game redoing 8 frames and showing the result inside of one frame
This is somewhat similar to how CMC jitter looks unsmoothed
but it's far worse because we force the state to be "show me what actually happened on frame 123424" and we don't just show delayed results
so basically if your shit takes to long to get to the server and the server is ahead
you're f'd
so you get corrected?
so when you get some acknowledgement from the server I guess based on your ping you can sorta know how many simulation steps to need to be ahead for the next round trip
or something
nobody gets corrected but the people whos IDEA OF WHICH BUTTONS WERE PUSHED WHEN changes the result of what happened
there is no correction, there is just where people end up after we rollback
ah
I currently force clients to catch up a bit with the server but the exact frame timing is probably a bit iffy :/
thanks!
is there some kind of documentation for knowing which functions automatically replicate to all clients when run on the server ( like SpawnActorFromClass ? ) there is nothing on the node indicating that it does so.
Spawn actor from class doesn't replicate anything. You define on the actor whether it replicates or not and if you spawn an actor marked as replicated, then it would get replicated out to clients.
There is no documentation that would list all functions that provide some kind of replication as the functions themselves don't really replicate - it's typically a variable being set that ends up replicated.
gottchhaa. makes sense. thanks again!
Hello, all! I'm working in UE multiplayer for the first time, though I have experience in other engines and non-game network design experience. I've got a sandbox scene that's basically working, except for two things:
-
I can't figure out how to inform each PlayerController of their own player index in the overall world. I just want to assign a default player name for testing, and I thought it would be trivial to just get their network session index and call them Player 0, Player 1, and so on. The engine clearly has this data, because it titles the player viewports when I run PIE.
-
My pawns both move locally in response to input driven from the PlayerController (I'm using DefaultPawn and not Character because I don't need or want a skeletal mesh). But neither player's camera is seeing movement of the other pawn's visual mesh. Obviously the pawns are replicated, their movement is replicated, and I enabled component replication on the visual mesh. I could use replicated events or RPCs or something along those lines, but is that the most efficient way to do this?
Thanks, and sorry these are n00b questions. I'm not new to network programming, just new to doing this in Unreal. ๐
Config info for the preceding questions: My GameMode is a child class of GameMode, my Pawn is a subclass of DefaultPawn, my PlayerState is a subclass of PlayerState, and my PlayerController is a subclass of PlayerController. I don't have a Level Blueprint here.
Don't bother with trying to reference players by any kind of index. It makes it extremely difficult to manage.
Player Controllers are spawned when a player joins a game. The PlayerController has a reference to the PlayerState and their Controlled Pawn/Character. The Pawn/Character has a reference to the PlayerState on all machines, and to its controller on the owning client and the server. The PlayerState has a reference to the PlayerController it belongs to and can get a reference to the pawn the player is controlling as well, but isn't always valid on all clients unlike the playerstate which is.
Through any of these common classes you should be able to reference which particular player you care about.
The GameState also has an array of all the PlayerStates in the game, so if you ever need to do something with all the players currently in the game, that's how you can get some reference to all of them.
Replicating movement is more complex than just ticking replicate movement and then moving them on the client. Unless you have a custom movement component that RPCs some details about the pawn moving, any movement you may be doing on the client would not occur on the server to then replicate to everyone else.
The character movement component normally does most of this for you whne you're using a "Character" as you'd "Add Movement Input" and that is what ends up triggering an RPC to the server to handle the replication of the movement.
Thanks. That confirms what I had concluded from RTFMing, but I also saw remarks that one should minimize the number of replicated functions/event and RPCs. I'll either go ahead and create some RPCs or maybe -- since it's a sandbox anyway -- I might take a quick run at getting the new Mover component to work, just for fun.
Understood. For one thing, the exact order when they join is unpredictable, and if a low-numbered player loses their network and has to reconnect, the indices become broken unless I'm really careful to resync...et cetera. ๐ I'm not planning to use this method for real development -- I just thought it would be an easy way to tell which client was which for early prototyping. Maybe the right answer is to just let the server-side PlayerController generate a random hexadecimal string. I don't care what the names are, just that they're different in the logs. ๐
The application here isn't a "game" in the sense of any kind of match or level. I'm building a mixed reality app for a non-game engineering situation, and there is really only one "player" who will have the handheld or HMD mixed reality. The "server" (which will be a ListenServer even for actual usage) exists as an extension of the mobile device. (Ideally, the mobile would actually be the ListenServer, but that just doesn't seem smart in terms of performance.) The bad news is that I have to replicate a lot of data, but the good news is it's guaranteed to all be on a private LAN at gigabit speed.
I am managing "sitting" as a state, which is an enum on the player unit.
- Player unit runs over to camp fire and sits down, state is set to "sitting"
- Montage plays for observers (multi-cast?)
- Intended: Late joiner enters relevancy and observes player unit sitting (looping last frame of montage)
I am stuck on the last item. How do I tell late joiner to pick it up from the last frame of the montage? If I use OnRep then the whole montage will play, but if I MC then late joiner will see player unit as standing by the fire.
I've got GAS, should I instead look at gameplay cues?
Thanks for this tip. I'm revising my approach to use the GameState as the registry.
is there a way to do a multicast but exclude a specific player or set of players? i want to make it so when i shoot a weapon the shooter will play their own sound and animations and the server will multicast the event to play the sound and effects
If you're using something that you can use to find out the ownership of the weapon back to the controller during the multicast, you can check if the controller is locally controlled, and if so, don't play the sound.