#multiplayer
1 messages · Page 638 of 1
hey - sorry, work got in the way...
I've tried replicated everything already, and still can't get this to work
but don't stress. I'm gonna go watch a few more tutorials and maybe grab a udemy course quick
this guy explains it really well - just used BP mostly, so maybe I can learn something there
I don't know if you have it but when you have a rpc call from client to server in cpp you need to have a validate function matching
forget about it you have no rpc from client to server
does FindSession automatically remove sessions that are full ?
is ATeam an actor ?
does it just track what team a certain player is on ?
^
yes
So GameMode has TArray<ATeam*> Teams; which is a list of all the teams in the game
then why is it an actor
if its just for tracking teams you could just make it an int
then represent that int differently on UI based on the number
or an Enum
i have a TeamActor
please educate me on this madness
holds all team related stuff (like a TeamPlayerState)
its the first im hearing of it
so its like a player state made specifically to hold team stuff ?
correct. The Team Object holds the team name, colour, index, an array for all the players in the team
yeah and its only replicated to the team (no other team)
Yeah, exactly like a PlayerState for Teams. Unreal Tournament has that too
Fortnite probably too :D
Fortnite does
but how do you replicate an object only to specific clients ?
or in this case a player state
I would assume by utilizing IsNetRelevantFor
nightmares
ohh
then in theory all you should have to do is see how APlayerState is replicated then overidde the IsNetRelevantFor for your ATeam object
PlayerState replicates to all
no its for everything that you want persistent and shared with other players even when the player isnt alive per say
like kills
or deaths
or when the main character isnt possessed
and your possessing a spectator
so is my thinking fine on the process?
PlayerController calls GameMode -> GameMode assigns PlayerController to a team. GameMode then tells PlayerController which team he belongs to.
PlayerController then tells PlayerState which team he belongs to.
then there's something wrong with my URPOPERTIES or something
I wouldnt do it like that
I would just have the server set the team var in the player state
probably from the gamemode
cause in BP, if I output PlayerState->Team, it returns null on Clients but Team1 and Team2 on server
but you dont need anything to do with the controller
Well keep in mind that the PlayerController doesn't exist on other clients.
yup
So you can work with Controllers in the TeamObject, but if you need some sort of replicated PlayerList then you will also have to utilize the PlayerState
yup
Yeah, only server have all the copies
so should the PlayerState ask the GM to assign the team, and the GM then update the PlayerState?
The GameMode should process the Team stuff when the Player Joins I assume
At least the initial one
yes
{
Super::InitGame(MapName, Options, ErrorMessage);
if (TeamClass == NULL)
{
TeamClass = ATeam::StaticClass();
}
for (int32 Index = 0; Index < NumberOfTeams; Index++)
{
UE_LOG(LogTemp, Warning, TEXT("Creating Team!"));
ATeam* NewTeam = GetWorld()->SpawnActor<ATeam>(TeamClass);
NewTeam->TeamIndex = Index;
Teams.Add(NewTeam);
}
}```
You should have access to the PlayerState via Login or PostLogin, as wenn as HandleStartingNewPlayer.
ohhhhh
The code looks fine
then this is what I did before with PlayerController
{
Super::BeginPlay();
AGameModeTitan* GM = GetWorld()->GetAuthGameMode<AGameModeTitan>();
if (GM)
{
GM->AddPlayerToTeam(this);
}
}```
That's theoretically also fine. This will only succeed on the Server
then back on the GameMode
{
if (CharacterController)
{
int32 Index = 0;
if (Teams[0]->GetTeamMembers().Num() > Teams[1]->GetTeamMembers().Num())
{
Index = 1;
}
Teams[Index]->AddPlayerToTeam(CharacterController);
CharacterController->SetTeam(Teams[Index]);
}
}```
that tries to keep the teams level
is it possible to just put the teamState in the player state since the teamState is only relevant to specific clients
and that way can be accessed from game state ?
Despite the fact that this ignores all teams with index 2 to NumberOfTeams-1, that's also okay
Right
then back on the controller:
{
ACharacterState* CS = GetPlayerState<ACharacterState>();
if (CS)
{
CS->SetTeam(Team);
}
}```
ATeam is marked as replicate, right?
You also have to keep in mind that it might take some time for the Actor to actually be spawned replicated
If you need to react to that, then you need to utilize OnRep
that is all a little bit fragile though
its more complex then it needs to be
and is ready fairly late (BeginPlay)
Yeah, but it should either way work, at least in theory
As long as the Actor and the Variable in the PlayerState are marked as replicated, the Client should be able to access it once it's replicated.
i'd assign teams prior to Super::HandleStartingNewPlayer
that way they can take advantage of team ID for spawn position
and i wouldn't need another hook
that is true
so on ATeam object I have
{
bReplicates = true;
}```
set in the constructor
And the Team Variable in the PlayerState is replicated?
and on PlayerState I have
ATeam* Team;```
When do you try to access it on the Client?
ignore the fact that its edit and read all over the place - I'm debugging like crazy here
I would try it with ReplicatedUsing=OnRep_Team and check with OnRep_Team() when it's replicated.
If you try to access it too early, it might still not be replicated down to the client
You should also mark the Team as always relevant as long as you don't override the IsNetRelevantFor
Just to make sure it's not out of relevancy range
so...:
ATeam* Team;
UFUNCTION()
void OnRep_Team();```
let me go read up some more on ReplicatedUsing quick
I am having an issue displaying widgets from the client side on the gamestate. So basically I am displaying widgets in between waves of a horde spawning type of game mode. I am using an enum to determine the wave state and then when it is starting the next wave, it should display a widget. I am using a Client RPC on my player controller and if I call it OnPostLogin from the game mode then it works on client and server but if I call it in a custom function on the gamestate then it only works on the server and not the client. It also works on both if I assign it to an action input for testing. Anybody know if I am missing something on the gamestate?
So there's a term for all of this.... : Automagically
It appears to be working
I have NO idea why
lol
Q: What's worse that your code not working and you have no idea why?
A: Your code working, and you have no idea why.
Thanks everyone for your help @thin stratus @winged badger @foggy idol @eternal canyon@pastel marlin
meh, it's semi working
is this right?
.h file
ATeam* Team;
void SetTeam(ATeam* NewTeam);
UFUNCTION()
void OnRep_Team() {}
UFUNCTION(reliable, server, WithValidation)
void Server_SetTeam(ATeam* NewTeam);```
.cpp file
{
Server_SetTeam_Implementation(NewTeam);
}
void ACharacterState::Server_SetTeam_Implementation(ATeam* NewTeam)
{
UE_LOG(LogClass, Warning, TEXT("Setting Team on Server/State! %s, %i"), *GetName(), NewTeam->TeamIndex);
this->Team = NewTeam;
OnRep_Team();
}
bool ACharacterState::Server_SetTeam_Validate(ATeam* NewTeam)
{
return true;
}```
reason I think it's not working is cause when I run it :
that's the TeamIndex var is printing out
yet in the console I see two instances:
going to 0 and 1
@upper lynx You've macroed it in GetLifetimeReplicatedProps?
yip
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ACharacterState, Team);
}
Where is the kismet library print coming from?
the what what now?
The blue prints.
They look like blueprint PrintStrings, or UKismetSystemLibrary::PrintString()
Where is TeamIndex set and coming from?
TeamIndex is a int32 variable in the ATeam object
that gets set by the GM when the game starts
you'll see it there
But it isn't replicated.
You're getting the default property from a replicated object. So even though game mode is setting it on server, clients will always have a default value.
How is it updating clients though?
It won't update on clients if you're just simply setting it on the server in the team object.
once a new player joins the game, the HandleStartingNewPlayer method runs. I then add the controller to the Team
ACharacterState* CS = Cast<ACharacterState>(CharacterController->PlayerState);
if (CS)
{
CS->SetTeam(Teams[Index]);
}```
I then call the PlayerState associated with that controller, and call SetTeam
when it hits SetTeam, this logic is followed
SetTeam calls ServerSetTeam, which sets the Team, and that in turn calls OnRepTeam
I'm most likely wrong with that logic
but I need to know why
Right. But this is all related to the Team object. Your clients will get the object fine. But your TeamIndex integer isn't set to replicate. So unless you're RPCing that data from somewhere else, a client will never get updated about what their TeamIndex is.
wait you're right....
hang ten, testing something quick
as soon as I make TeamIndex replicated, I'm unable to read it from BP
How is your UPROPERTY for it marked?
Should see it fine with a UPROPERTY(BlueprintReadOnly, Replicated)
cool, trying that quick
int32 TeamIndex = -1;```
yeah I don't see it
If I pull off Team, there's no TeamIndex or "Team Index" or even Index for that matter
Your syntax looks fine. You're closing the editor to compile?
Haha. Be careful with hot reloading.
hmmm, Team is still not valid
AInfo (which I know doesn't replicate)
I changed it to AActor now to see if that helps
argh, have to restart editor
so, how's unity (facepalm)
AInfo should replicate fine. That's their whole purpose is to be a replicating object that has an actor channel.
meh - AActor also still returns invalid object
it's fine. I think I'm gonna call it a night
23:20 here
Make sure that you're setting these in your constructor.
SetReplicates(true);
bAlwaysRelevant = true;
yip, doing that too 😉
thanks @kindred widget
appreciate the help
I'll dig around some more tomorrow to see what I'm doing wrong
quick Q, before I go
so replicating the object variable is not enough? you need to replicate the variables within that object too?
ie: not only replicate the Team object on the PlayerState, but also replicate the TeamName and TeamIndex variables within ATeam too?
Hmm. So first you need to make the object itself replicated. This makes it replicate to clients. Then you can make that object replicate it's values that you set to replicate.
But like in the case of your pointer on the playerstate. You're just replicating the pointer, not the object there. The playerstate itself is a replicated object with that replicated pointer that points to a replicated object.
If all set correctly, clients will get a valid object from that pointer too when the object is relevant to the client.
Haha. It gets much easier to wrap your head around with some practice.
You too.
HOLY CRAP!!! ITS WORKING!!!!
WHOOOOOOOOOOOOOOOP
closed the editor a few times and did a few build clicks
now it's working
hooray!!!!
awesome, thanks guys!!
ok, going to bed
g'night
I just randomly got the bug of my textures being all blurry and unloaded on only the Server Host. The client's textures all load in. Tested with multiple people. I only noticed this after adding a plugin called Smooth Sync to my project. Anybody know what is going on or how I can find help?
is anyone using a proxy AIController to posses their player character, in order to skip all the complexity of client-side prediction that comes with the character class and gameplay ability system?
If so, what is the proper way to deal with owner-only variables vs things that are generally safe to replicate to everyone? for example, inventory should be replicated to the owner only.
I was using the OwnerOnly replication condition on my character for this previously. But trying to experiment with moving away from PlayerController directly possessing the character.
Does anyone know if the “Strip Animation Data on Dedicated Server” flag causes you to lose AnimMontage notifies on server?
likely yes, but you'll probably want to cache the timings on save or something
so the dedicated server doesn't need the notifies
@lost inlet I’m debating for my multiplayer project to leverage the PlayMontageAndWaitForEvent nodes with GAS. The idea being some gameplay events would be triggered based on their placement in the anim montage.
However I also want to be optimized and strip anim track data from the server, so I’m unsure if these goals conflict.
I will say however, it appears the only section in code that uses that flag ‘bStripAnimationDataOnDedicatedServer’ is ‘UAnimSequence::Serialize’. ‘UAnimMontage’ inherits from ‘UAnimSequenceBase’, not the child ‘UAnimSequence’. This leads me to think Anim Montages will still serialize everything like normal since there is no inheritance path in an UAnimMontage that causes us to hit that flag. I’m feeling like the assumption that is sensible is that notifies on the anim sequence won’t trigger, but notifies on the montage will.
Any thoughts on that? Like possible I’m missing something.
yeah but tying gameplay to animation is just something I'd advise against anyway, saves having to load them on dedicated
our game just caches a bunch of stuff in PreSave for timing purposes
No I’m with you. Where I come from we decouple animation and gameplay hard in production. Was debating if setting things up this way was like a cool new UE4 feature I should utilize or if sticking to roots is better.
I come from UE3 so there weren’t really gameplay notifies with animation.
this seems a more shouldn't than couldn't
Appreciate the help
@jolly berry exactly right. Use anim notifies for client only FX, but you can rely on AnimMontage triggering notified on server and clients.
I read a post somewhere that this is the behaviour Fortnite rely on too.
@silent valley Good to know, I appreciate the confirmation. I’d be curious to read the post if you had it but figure you prolly don’t have that lying around 😅
I’m still in general agreeance that keeping gameplay events decoupled is ultimately still more sound and scalable, but I’m much happier knowing I have the option to do anim montage notify stuff if I needed.
Yeah it's a convenience feature I guess. It's nice to be able to build the functionality in the Montages.
@silent valley https://answers.unrealengine.com/questions/43365/view.html
You think this was what you read?
No, I think it was on UDN and also regarding Gameplay Ability system.
👍
Is this a good way to get around the (if owning client) thing?
no
unless client owns the VendingMachine
nothing happens
and even if it did, you just called a RPC from an RPC
both of them server
I think you misunderstood it..
It executes the "ServerSpawnItem" on the character wich is owned by the client and the return event is not an rpc just a normal event (to get back on the unowned actor but now on the server)
If I make an HISM component replicated, that would only replicate the actual component right? Not the state of its instances.
Thinking it might still be useful to set it to replicated, as I could then keep a reference to the component and separately replicate their instances and still know which component they belong to
(multiple components on same actor)
hej everyone, i'm trying to fix a problem with doors i'm having replicated in clients and server.
the mesh of the door moves perfectly both in clients and in the listening server.
however, it seems like the actual server is still having some instance of the door in the original location non rotated.
because the interact button works only on the original rotation, not on the newly rotated location UNLESS you are the listening server.
The way i've set it up is the event that gives the rotation values from the mouse is running on the server, and then the door rotation is replicated and being set on the mesh as set relative rotation.
anyone has an idea on what i could be doing wrong?
This should work, but to make it more generic I would probably go with something different.
- Interact with HasAuthority check. If authority call spawnItem method if not call ServerInteract on passed character and also pass self as an argument.
- The ServerInteract method on Character would accept objects implementing Interact interface as argument and inside the method you would just call Interact on that object.
- Now the HasAuthority check in VendingMachine interact will pass and we will spawn the object.
The profit with that approach is that you don't have to add anything new to the character blueprint if you add some new objects implementing Interact interface.
I did something way cooler. I basically remade the physics constraint, copied and pasted the PhysicsConstraintComponent.cpp and h into my own Physics Constraint Component. Next, I replicated the Constraint Instance struct variable. (FConstraintInstance ConstraintInstance). However, the angular force still seems to not be synced across the network. For example, the constraint breaks for the server, but the client still sees it as being intact. Do you have any advice on this?
Anyone used the damage system already available in ue4 ? (applyDamage, applyPointDamage ...)
I use it. It's basically just a nice little interface, nothing fancy
I was pondering to use it but i have a few worry about it so maybe you have the same use case
the first one is how it work out for high frequency damage
not too much net usage ?
net usage is the least of your worries tho
if they can use it in Fortnite (100 player battle royale) i am sure net usage is fine 😄
well in fortnite they use the network graph (i think its called like that)
and that is only for replicated actors
but yeah if you use it at high frequency and it work good enough for me too
not GAS
GAS ?
Gameplay Ability System
visibility channel?
for applyRadialDamage
not sure what trace channel has to do with anything
those functions are kinda garbage tbh
cause they don;'t allow any fine tuning
all my damage functions are custom made, so i have full control over what they do
I made mine to but found out they were pretty similar to the base one for now so was wondering if it was worth to make the switch
anyway thanks for the info i think i will stick to my own function for now so i can more easily modify them if need be
having your own damage system/functions will serve you better
What happens when you use a Server RPC if you are already authority?
Any bandwith usage?
Ah yes! Thanks!
@peak sentinel why would it send the rpc of the network if its local?
It wouldnt, right? Just trying to learn whats happening on the background
it is invoked locally
Clients can't join anymore when a host left a session they were in what's the problem there?
I guess it's a common thing?
Afaik when a host leaves session is closed
And how do you repair it?
If a session is destroyed its normal that they can not join again because session is not valid anymore
Host needs to create another session and invite clients there
Yeah yeah i know, but if there is a new session they can't join that anymore
I remember I had this problem when using Advanced Sessions plugin but dont know any fix, sorry
ok
you probably need to use a dedicated server at that point instead of a listen server
if you want to keep the session running
I think you need to call DestroySession on the client's player controller. I just set a SessionActive boolean on my game instance to true if I start or join a session, and if I'm back to the main menu (because you left the game or got kicked/disconnected) I call DestroySession if SessionActive was true and set it to false again.
I have an issue with passing a struct from game-mode to player controller onPostLogin. It seems to not update when passed.
I tried with a simple string and it got passed to the client just fine. But the struct, no sir. anyone got this?
When I do seamless travel on my dedicated server, it is not calling OnPostLogin or OnSwapPlayerControllers, has anyone had this issue?
hey, i'm desperately trying to replicate an array of UObjects the last couple of days (ultimately array of interface instances but for now I'm trying UObjects). I use this array in an InventoryComponent and found a couple of posts where they managed to get this done. However nothing works for me and I don't know if it is my implementation for the UObject replication or the setup of replicated variables and RPCs (I'm new to UE). I do not want to use Structs (reason Inheritance, Polymorphism) nor do I want to use Actors (reason memory overhead and flexibility). Also for the purpose of understanding how all this replication works behind the curtain I want to get it right with UObjects.
I would appreciate if someone could take a look on the project in a video-call with me.
Is it that common in UE to store the whole Actor if all you need is the data? If you had hundreds of items that would be quite the overhead. Also I read that it is quite inperformant to have all those actors hidden in the world.
If someone has the same issue, OnPostLogin does not get called in seamless travel. And OnSwapPlayerController does not get called if the new playercontroller class is the same as the old one. So use HandleStartingNewPlayer event, it will get called in seamless travel.
Well Fortnite has two invisible actors for each player on the map, to start with, so it can't be that bad
Actors are heavier in memory but memory is usually not a problem
Make that three actors, actually
PlayerController, PlayerState, HUD
Erm, HUD is client side only, nevermind
Yeah I was making the larger point that Fortnite has 200 invisible actors on server
Ok, I guess that isn't an issue then. Unfortunately for my purpose/architecture I still might need the UObject (need to reevaluate). I have an interface ILootable which can be attached to any ItemObject you want. Ultimately the inventory would be array<ILootable>. Do you know if this is possible to replicate for interfaces?
Interfaces are purely virtual objects
They don't actually exist
The actor implementing the interface would be replicating
And if that's what you're asking, the actor would be replicating the interface data
Yes this might work, will try to replace my UObject Items with actors and see if they get replicated. Thanks
But still intrigued to get replication with UObjects working 🙂
Well it's not that hard
You still need an actor though
Implement ReplicateSubobjects and use Channel->ReplicateSubobject
Should be lots of examples in engine code
So, anyone have had problem passing stuff from server to client onPostLogin? Still having this issue.. String works fine tho.
i would not try to pass any object pointers, unless its pointing to an actor thats loaded from the package
those need to replicate on their own, as actors for the passed NetGUID to be resolved (unless loaded - then NetGUID is static and you're fine)
Anyone here using a proxy AIController to control their character instead of possession directly from the PlayerController?
I have seen it in some example projects. The client-side prediction of Character and GAS is pretty complex, this model would simplify it (but you lose client side prediction ofc)
Setup doesn't seem too bad. Was the simplicity worth it when you lose the client side prediction?
as CMC is tightly coupled to Character and PlayerController, and assumes PC is possessing Character directly
I guess it depends on the game
we didn't lose the client side prediction
interesting.
but we did have to override a fair chunk of CMC + APlayerController:TickPlayer and few other things
assign roles manually
The built in Character and GAS stuff seems to change behavior depending on whether you were an autonomous proxy (PC possess) or not (server AIController posses)
and so on
ahhh you really picked it apart
in the end, PathfollowingComponent moving the player ends up in AddMoveInput as well
After reconsideration I will go with actors. But wouldn't it be useful if they would provide a UNetworkObject : UObject which could be used for UObject replication without an actor? Maybe even AActor could inherit from it? I don't see a downside (limited knowledge though 🙂 )
thx @bitter oriole @winged badger @twin juniper
as long as you manage to avoid all the obstacles for it being called
you'll have client side prediction
can a player add movement input to a character they dont possess?
isn't that tightly coupled with ownership?
it needs to RPC
we also needed to replicate the AIController
allow for client side nav mesh generation
I was thinking of a dead simple model of RPCing down commands and letting the server pass those to the AIController controlled char
yeah, i've been in that land. I did figure out client-side pathfinding with a directly possessed character. getting the navmesh on client and following the path on client side with moveinputs.
you're better off uncoupling the CMC from PC/Character combo
This model would be way simpler. Just pass the target location in an RPC and let server handle it.
Doesn't the Character and CMC work fine for fully AIControlled characters tho? It seems to be used widely for bots/NPCs as well. In this model, responding to RPC'd commands and responding to Behavior Tree commands is not much different from the Character class perspective.
prediction won't work out of the box
there are several Casts in the CMC
and it also expects ROLE_AutonomousPRoxy
yeah, thats my big debate. am I willing to gain simplicity and lose prediction capability.
There is a hobby project called League of Legends that has no prediction 😛
so for commercial you don't really have a choice
I think there is some maximum tolerable latency which can turn it into an infrastructure problem
I figured this out. Seems like I cannot pass maps, but arrays are no problemo.
if you're comfortable with c++
its a 4 hours "hack"
to do either option that allows for prediction
you are just talking about movement prediction right?
yes
yeah, for sure
League has an option for that too
it's the GAS ability stuff where I question the value vs complexity
I've implemented a few abilities now with the autonomous proxy model and it's... a lot to reason about correctly.
@dense narwhal just flatten the map for replication, works fine
I see the power but I wonder if it's worth the bugs/complexity/effort...
FMyNormalStruct has a Map and a constructor that takes FMyReplicatedStruct, which has the Map flattened into key and value array for example, and a constructor that takes FMyNormalStruct
for something RPG-ish, anyway
makes for a very simple way of using those interchangeably
I want to use FIND instead of foreachWithBreak when finding stuff tho.
Also, why is actors loading before gamemode * 😂
Hey Zlo, how are you handling the replication of private state if you don't possess it directly anymore? I've been using OwnerOnly replication with the PC possession model, which wouldn't work in that model.
For something like inventory of the character
Are you just putting that into PlayerState?
yes playerstate
player controller just handles inputs, forwards them to the AI controller for the player
we use client side movement of ai, with the cmc so player moves instantly when clicking, without waiting for the server to move them
i did those changes..
yes
no we use our own system
not as powerful as GAS, but kinda
Why are you using an AI component for the player character, just to leverage certain things like the behavior tree? It wouldn't be necessary, right, to do simple click to move MOBA type controls?
pathfinding is an AI feature
actually player controllers can path :
but we relalized this 2 years after we started and meh, no going back
orly. can they move the character autonomously too? 😄
I just got told that networked movement prediction is a thing? I might be kind of stupid here but can anyone point me to some docs or examples about it?
@hoary lark no
well... have you ever noticed in an online game when your character moves instantly when you press W, i.e. you don't have to wait for the signal to go to the server and come back for your character to move? have you ever noticed the server correcting your position?
Does anyone know anything about sessions?
We've got a session going via Oculus but players aren't replicating and only the session creator gets transitioned to the new map with a Server RPC console command for ServerTravel
@hoary lark I did some more digging about it and i realize that was a really bad question.
I guess what i'm really looking for is feedback on my current strategy
Currently what happens is
- Client selects a character and selects a position in the world
- This position gets sent to the server via an rpc call to the actor's "NavToDest" function.
3 Server performs the custom pathfinding i implemented and sets a vector of positions.
3 an RPC Multicast is issued to all clients, these perform the same pathfinding but only uses it to draw some debug info right now. - Server moves the character along path using getaicontroller -> MoveToLocation.
It works great but I've noticed that when i test this with a good amount of ping like 200-300ms it feels sluggish and not at snappy.
What i'm interested in achieving is say something like what you're describing @hoary lark where the moment i click as a laggy client my character starts moving right away. I don't mind a bit of rubber banding or correcting that happens after.
So obviously because in this case no prediction is happening because I'm sending a request to the server and having the server perform the navigation but what if I didn't want to do that? If i wanted to have the client drive the movement? could i just directly use the movement component on the client and would unreal automatically do the appropriate network prediction and rubberbanding? or is there more that I have to do for that?
Your message to the server could be something like "I'm moving here, and my path is this XXXXXX, please update if you know something about the path that I might not"
Then you start moving, and the server might correct the path or whatever. You could presumably even do local pathfinding but with predicted movement, much like how a player would move a character.
I would probably prefer pathfinding to be local but it depends on the game design. All the server would see is "Moving X direction"
Does the client need to share a port in the router later in the packaged game when I use "Listening server"?
@golden fulcrum this is similar to what I was discussing before. When you possess a Character class with the PlayerController, it will do client-side prediction of movement. The only issue is that Character movement is based on input vectors, so you have to do some custom work to make it use pathfinding.
What I did was add a PathFollowingComponent to my Character subclass, and then re-implemented some of what the MoveToLocation was doing.
But the trick is to enable navmesh on clients (a project setting) and then grab the path on the client and follow it using movement vectors. So from the server perspective, it just receives the movment vectors, no different than using a joystick movement (which is what UE4 has clearly been originally made for, FPS game with WASD or joystick movement).
Unfortunately I'm not sure how well that works if you can change your selected character or select multiple characters.
so BlueprintAuthorityOnly doesn't actually seem to do anything, I just got a bug where a static function marked as such was being called on clients as well
or maybe it just doesn't work for static functions?
hey guys could anyone help me with this error please
[2021.05.14-05.28.05:511][ 1]LogOnline: Warning: OSS: Async task 'FOnlineAsyncTaskSteamCreateServer bWasSuccessful: 0' failed in 34.560883 seconds
[2021.05.14-05.28.05:514][ 1]LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 34.52, Realtime: 34.53. SteamNetDriver_2147482479
Do replication conditions make replication itself any more efficient at all or is it just for convenience?
Well if only the owner needs the data, why sending it to everyone? :P
why does replication not work when using the topdown template ?
I even started a new project from blank template and worked towards multiplayer, however player pawn isn't replicated (same as topdown template as shown above)
turns out not a single template supports replication, that's not how the tutorials show it to be
He it's "baguette" 🥐
Need help :
I'm trying to host a dedicated server on AWS EC2 but I can't join the server.
[2021.05.14-09.18.41:733][755]LogOnline: STEAM: Adding P2P connection information with user 765611...77401397 (Name: UNKNOWN [0x143BF77F2E0])
The server disconnect client
[2021.05.14-09.18.56:770][204]LogOnline: STEAM: Removing P2P Session Id: UNKNOWN [0x143BF775E30], Channel: -1, IdleTime: 14.977
[2021.05.14-09.19.11:712][204]LogOnline: STEAM: Closing all communications with user 765611...77401397
[2021.05.14-09.19.11:717][204]LogOnline: STEAM: 765611...77401397 has been removed.
[2021.05.14-09.19.11:727][204]LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 14.95, Realtime: 14.96. SteamNetDriver_2147482144
This dedicated server works when I host it on my computer with distant clients but not on aws
I already tryed to open all UDP / TCP ports "free for all" on AWS firewall and on my EC2 instance firewall
Any idea?
never mind I was playing on standalone 🤦🏼♂️
Linux or Windows?
On Linux you also need the steamclient.so file is inside your Project/Binaries/Linux folder.
ok probably something similar then.
Try installing Steam client on the instance
I've uploaded :
- a server package
- a client package
so you already have Steam installed on the server to download and install the exe?
oh my bad lol
ok thank you I try this
but => instance will need a steam account??
no I don't think so
I'm not sure about this, but I think the instance needs to have some Steam DLLs installed for it to work.
Arf I just realised that I already had steam installed
I try to connect to an account
Ok I just found the solution: I had a bad port config. Ports were opened but not for all ips 😋 it's fine now thank you for your help when you told me to install steam I tryed to connect it to a steam account and realised the firewall where blocking 🙂
I was talking more about the cpu cost, for example does initial only checks less after first bunch or something?
I'm trying to update the steam SDK to the latest (1.51) but ue4 is still trying to find 1.47
i have updated the Steamworks.build.cs
Is it a source engine build ? Pretty sure you need that to use custom SDKs
(updating Steam SDK is not a requirement for nay feature that I know of)
ive just checked the release notes for 4.26 and i dont think they support 1.51 yet, says 1.47 so i guess that might be it
But why do you need 1.51
no particular reason, i was just updating things
the sdk is loading however this is now the issue
Just leave the engine as it is, it comes with a valid Steam SDK that needs no updating at all
Hello 👋
I'm running into one of those nasty situations where I am tempted to add "delay 0.1" to avoid a replication race-condition.
I have a server + n clients relationship. I want the server to wait until the value has been replicated to all clients.
I'm calling like:
child.setFlag() //which is DOREPLIFETIME
do something
I want the do something to wait until the flag is synced up on all clients.
I guess this is what RPCs are for?
what you mean by this 'child.setFlag() //which is DOREPLIFETIME'?
child is replicated ?
I have a parent with children
child contains flag.
From server, I want to set flag for all children (on all clients), before continuing logic.
Bah I think I'm talking nonsense.
The first time I run, the flag isn't set yet. If I run additional times, the flag is set. So I know its just a race-condition.
why don't u set the flag at begin play or something if its known for clients?
while waiting for them to replicate
Flag is dynamic.
But I think an RPC is maybe correct...?
So instead of using DOREPLIFETIME in the child flag, I can set the setFlag to client reliable
It would have to be reliable multicast
To ensure the server gets it as well?
the server will run it anyway
To broadcast the change to all clients
if multicast
And the RPC will delay the thread, right?
i.e., it will prevent continuation of the current function until all clients are syced up?
no
no way
this is not possible out of the box. I think you would need to do server RPC from every client to the server to ack that you already received that flag
and only after that execute whatever you want on the server
Hmm interesting
Seems like such a common use-case, but I know that multiplayer can be complicated.
In this case there is sort of a secondary possibility, which relies on each CLIENT waiting to recieve flag before continuing. I just have to add additional logic so that it can keep retrying until it knows for sure its flag.
maybe onrep flag call a server rpc
if the flag is going to be modified onetime
so it doesn't spam rpc's
Do you really need to wait for the sync on clients?
Yes, I guess so at least.
Its a graph traversal situation.
One graph sets a flag on its edges, so determine flow.
During flow, the edges don't have an updated state yet, so its impossible to continue.
Thats why I wanted "wait for sync up" kind of situation.
The only way clients can report back to the server is via an Actor that they own (e.g. Pawn, PlayerState).
What you're asking is tricky but I managed to make it work for my multiplayer testing framework.
Server creates one actor for each client, owned by that client. This actor is used to implement a WaitForAllClients type scenario.
The client owned actor has a reliable Server RPC that the client calls when it reaches a specific node (or int32 id)
Server associates the node value with that client, and it can then reason about where each client is up to.
Unreal is not really designed to work like this though, so you might be better off redesigning your system if possible.
extra actor seems like overcomplicating the situation
can be as simple as setting a flag in GameState with OnRep
having the clients after receiving it and when ready just RPC via PlayerState and set its Acknovledged flag value
yes that's better if you can intrusively modify Player/Gamestate
then condition to continue is simply !PlayerArray.ContainsByPredicate([this](const APlayerState* PS) { return CurrentState != PS->AcknowledgetState; });
Bah its just annoying, because it makes me so tempted to just add wait 0.5 and hope clients sync up :/
pseudocoded, since i don't bother casting the PS there
its literally 1 OnRep variable in GS, 2 functions in GS/GM, 1 variable in PS and 1 server RPC in PS to make it work
so you have CurrentState with OnRep in GS
OnRep function finds the local PS and sends the ServerAcknowledgeState(State) RPC
the RPC sets the Acknowledged state in PS, and calls TryCompleteState on the GameMode
GS has CanCompleteState function that uses the above condition, to return true
and TryCompleteState just calls GS->CanCompleteState to see if it can exec its logic
it will go through with it only when all clients sent an ACk
if listen server you don't need to treat the host any different from clients here
only if you need your thing decoupled from the main project you might want to spawn separate actor/component to do that as noogs already suggested
That sounds dope in theory but i'm really struggling to find examples of that implemented in unreal engine outside of some asset store plugins. i've implemented something similar in my own game engines in the past but I'd like to see what's the canonical way to do that in unreal engine.
I guess i should just start looking into the source code huh.
Hey guys, im trying to run the function 'Fire' on the server from my main character pawn, but for some reason, whenever i try to do that on the client side it doesnt fire the event, any ideas?
Is your character set to replicated? Also setting that Firing bool won't replicate that to other users. You should set that on the server
im not interested in the firing bool currently, just the event. my character is set to replicated.
nevermind, think i got it, thx!
wait, I think the problem is that im trying to run an event on a class that is not owned by a player controller, although i set it to replicates the event is still only being called when the server is the one calling it, why is that @empty axle
its possible to do client side prediction for patchfinding
either by deriving a custom CMC and uncoupling the Character-PC-CMC triangle and setting the Autonomous_Proxy role manually
or by implementing pathfollowing on the PC
Pathfollowing move also ends up in AddMovementInput call, just like controlling your character with WASD does
Can I somehow delay the clients joining my dedicated server in editor-mode?
What is the right way to solve this example and similar cases?
I have a vending machine actor placed in the world, nobody spawned it and nobody owns it. But on the vending machine there is logic that has to be done on the server. The item that the vending machine drops needs to be spawned on the server. However since nobody will return (is owning client) as true, there seems to be no way to run the logic on the server without doing it on the character or sketchy things like that.
How do y’all professionals handle that?
@scarlet cypress No professionals here but I don't think its possible to send a RPC to the server if you don't own the Acotr, for your use case one solution which was proposed on a similar question was to handle the item transfer from the vendor to the player inventory on the inventory side
Did you set the owner of the weapon to the player character?
No professional here either, but I can hazard a guess. I'd assume there's something like a player interacting with the vending machine for there to even be a need to RPC anything? Then just have the interact action on the player RPC to the server with a reference to the vending machine being interacted with, and have the server function call the method on the vending machine that does all the spawning logic
And if you want more than just vending machines the player can interact with, make an interface with an Interact method which the vending machine class implements, and call the Interact interface method from the serverside method in the player
So I’m having some issues with a character select widget I have created, below I will add screenshots of nodes but for context I’ll type here: controller has the pawn to spawn function inside of it which is then spawned with the gamemode, for the new pawns from character select I’ve set it as a variable inside the game instance, when I load the game the pawn doesn’t spawn from selection and there is no control in game what so ever.
Originally the pawn to spawn variable was set as a perm local variable
Controller before
Controller after
Game instance variable
Widget
GetActorOfClass looks for a spawned actor in the game world, which I'm guessing isn't there at that point
Just use the class directly, if all you're using it for is GetClass?
Hmm let me test that out
So just remove that GetActorOfClass and GetClass node, and set the class in the PawnToSpawn setter to the one you had in GetActorOfClass
Hmm the characters still don’t spawn in
I’m thinking it’s something with the controller logic
There’s still that perm local variable connected and the cast to game instance is connected to game instance which I’m not sure if that’s correct
Hi! I remember that steam multiplayer was working only on the 4.24 version or something like that, is that the case still?
Like can you get steam multiplayer as easily working on the newest version or do I remember something wrong?
Yeah you seem to have a lot of redundant code, so cleaning that up wouldn't hurt either. Refactor early and often. But hard to tell what's wrong from just a few screenshots, you'll just have to start debugging and see at which point something unexpected happens
Haven't had any issues in 4.25 and 4.26 with the steam plugin. Granted, I haven't published anything on steam itself yet, but I doubt that would be a problem
Okay, thanks!! 🙂
Hello does anyone know a tutorial to learn how to save the variables of a character in the dedicated server? for example with playfab?
dedicated servers just run a game instance when instructed to, they don't hold data
for that you need a separate server
Hello .. if i did the replication on dedicated server can i run listen server normallly or i have to change the replication again
Hi guys, I'm finding when my client walks into another character ai it constantly rubber bands backwards. Does anyone know what could cause this? Maybe the client and server have slightly different understandings of where the player and the ai are but I'm using a fairly typical setup so I would have thought this wouldn't be such a big problem
The AI probably doesn't have the same location on server and clients
I'm changing a variable that should have impact on IsNetRelevantFor but it takes too long to take effect. Is there something I can do about it?
p.netshowcorrections 1
This will show the server and client position and can help track the problem down.
@odd iron Dedicated doesn't have anything to do with RPC or replication difference. Literally the only difference between a listenserver and dedicated is that in listenserver, the server also has a HUD, can spawn widgets, and has a player. If you're doing your programming correctly, your game can run on either dedicated or listenserver. Server code will be the same for both, and client code will work the same.
It is except the Wiďget😋
Not sure I follow?
Sorry my replication works super except Screen effects
What kind of screen effects? Usually that kind of stuff gets triggered client side via certain conditional replication, or stuff that happens on the client anyhow.
@kindred widget its Fear or glitch its working on dedicated for each client but it firing for all players on Listen
Sounds like you're setting the value oddly. That sounds like the server should be setting a value on the server version of a player's pawn. That state value gets replicated. Then each client can do with it what they want. Other clients can see that pawn as feared with an effect or something around them, and the owning client can play camera effects and such.
For a MOBA-like game, how would I go about making the server for it? preferably without needing a source code build of ue4
I don't believe you can do a dedicated server without a source build.
How about epic online services?
alright thanks
So if I have a project that relies on an UE version downloaded from the Epic Store, how would I make the switch to a source code build? Since I'm working on a team I don't know what other people would have to do in order to use the same engine version, would they have to download the source code and build it too in order to use it?
no
just one person needs to build the dedicated server
the rest can use the same version but launcher edition
Hi everyone, I'm new to multiplayer and I have a very basic set-up. I have 2 player starts in the scene, and I'm simply trying to get the client and the server to move their player character.
While it works fine with basic templates like the ThirdPerson, it breaks with my own gamemode / pawn. It sometimes works in the client, by as the server, the inputs and the camera rotation seem to be broken.
Any idea how to fix it ?
Did anybody manage to replicate a Physics Constraint Component?
I tried making my own Phsyics Constraint Component by literally copying and pasting everything from the original cpp and h.
Then, I replicated the Constraint Instance which contains all the settings for the constraint. However, the angular force seems to not be in sync between the server and the client.
I still have some things left to try, but I am not being so optimistic about this, if anybody could help, I would highly appreciate it.
If you need to get the local player regardless of if you are a listen server host or a client, will GetWorld()->GetFirstPlayerController() always return the local controller (the current local machine)?
not always
you'd be better off with GetFirstLocalPlayerController
during seamless travel, client controller can end up at [0] on the listen server
Hey guys i just want to make sure i understand this correctly
from the unreal engine docs
Any replicated actor can be replicated as a reference
Does this actually mean that pointers to replicated actors will be properly replicated across the network?
eg If in my game state class if i keep a reference to an array of actors spawned at run time, that array of actors will properly be replicated?
Without taking everything into account, yes
Important things are:
- The Actor Class is marked as "Replicated".
- The Array in the GameState is marked as "Replicated".
- The Actors are relevant for the Player, which by default is distance based.
- The Server spawned those Actors.
Thanks so much I thought i had made a huge mistake when i was replicating pointers across the network at first but was confused at it just sort of magically working.
It works with unique IDs.
given a 3rd person char that wants to interact with a chest to access it's content, by pressing an interact key (E). Would you guys let the char call the chest or let the playercontroller call the chest? (hope the question makes sense?)
If I want to set a variable on each client's GameInstance, what's the best way of doing that? Multicast from GameState?
@empty bluff I've been doing it from the Character which works fine but I'm not sure if it's the correct way. The Character sends a message through a Blueprint Interface to the object
ok, thanks, that's also what i do now... i was just starting to wonder if that was the recommended way of doing it, since i present the content of the chest in a widget which i pass through the playercontroller
Seems fine to me but I'm a bit of an amateur 🙂
I'm not really sure there is a correct way to handle that so much as whatever fits your game style. For instance some people put inventories on their Playerstate. Allows other users to see them and persists death. Some on the controller. Persists death, but other players won't see it. On the character it allows you to leave behind items on death.
Mostly pointing that out, because whatever you have the inventory on should probably be what is initiating the interaction with the other inventory.
yeah, that makes good sense, and i may have been thinking of it the wrong way, since i was assuming it had something todo with wether inventory was stored on the server centrally or on each client.
Inventory should always be stored on the server. Server should have authority over all real data.
yeah, i've heard that... but how about games like Terraria and Valheim? they don't seem to keep player inventory on the server they connect to
For instance, I use a single actor component class for all of mine. The component gets attached to things that can hold items. My character has a function that does the interaction line trace, iterates over the hit actor's components, if they have an inventory component, it calls the local hud, and sends that component through along with the character's own inventory component to populate and open up a transfer widget. Widget uses the component on the character to RPC to the server version of the component to do actual transfer logic.
And I can't speak for those games specifically because they aren't made in Unreal, but if you were going to do that, you'd probably just have client data that gets uploaded to the server when a client connects. Then the server can replicate this back as it changes. On log out, request the actual state and let the client overwrite it locally.
At least as far as Valheim is concerned. Haven't played Terraria.
I was considering the last scenario as a posibility too rather than keeping it on the client entirely... anyway, still learning how to design this multiplayer stuff... so much to learn
While in a game, server should have authority and control of data. It's the simplest way to avoid inconsistent states and odd glitches, or bad bugs where the player expects one thing and another happens.
btw what i do right now when i approach a chest, then i have a Interactorcomponent that has logic for detecting interactables. it has responsibility for highlighting the relevant interactable and also has a server_interact method that i can call with reference to the interactable
is that potentially bad on the client, to fetch the reference to the interactable, then call the server with that reference and do the transfer logic on the server?
once i hit the server, i "lock" it as occupied by playercontroller, and only allow it to be interacted with if it's not "locked"
I designed mine to avoid the locking. But the concept is similar. In mine, I have to send a bit of extra data through the RPC to let server check if the client is moving the correct object, so that two people don't try to move the same thing before server is able to replicate state back. In general, clients should just see what the server's current state is. Then RPC to server to have the server move stuff around.
Hello everyone, I'm very confused. I've created a pawn and added custom movement without the Movement component just with variables, because I have no idea how to make it work with PawnMovement component. I use a third person template and the replication works there, but as soon as I load another map where you fly an airplane, it doesn't replicate.
you probably forgot to replace your default pawn class in the project settings?
(trying again today) Hi everyone, I'm new to multiplayer and I have a very basic set-up. I have 2 player starts in the scene, and I'm simply trying to get the client and the server to possess & move their player character.
While it works fine with basic templates like the ThirdPerson, it breaks with my own gamemode / pawn. It sometimes works in the client, but as the server, the inputs and the camera rotation seem to be broken.
Any idea how to fix it ?
Hi, in which side should i repossess player to different pawn in multiplayer? Is it client or server thing? Can server possess player controller, and will it work if i possess it on client side?
Also, HUD only exists on Client Side, so i think, PlayerController's GetHUD will fail on server side?
Logically yes
hey, is it true that an interface variable cannot be replicated? at least for me it's not working, using object references is fine though
I'm looking for the right method in GameMode to start doing stuff when all the players have joined. BeginPlay() executes before any of the remote clients are in the game (if I start an editor game with 2 players in client mode, GetNumPlayers() is 0 in BeginPlay...) Does GameMode even know how many players it expects to join?
Yeah, now that I think about it, it makes sense... the game mode doesn't know how many players are coming (at least not the number on the slider when you launch from editor), so best it can do is count them on PostLogin
Hey @winged badger @meager spade regarding our convo earlier. How are you guys handling replication of your OwnerOnly type variables when you are possessing the character with an AIController?
Or perhaps for anyone here who is using an AIController proxy to control their characters (rather than possessing the character directly). I'd like to avoid replicating the ASC, inventory, etc to all players for obvious gameplay/cheat related reasons.
we usually don't use those, but skip owner
your game doesn't have any variables you only want to share with the owning player?
I don't think ai controller is replicated to clients.
So as long as you don't save data on the pawn itself and replicate those properties. Basically on controller is pretty safe.
it isn't unless you configure it to replicate
But is there actual reason to replicate AI controller to clients?
I have data on the pawn itself, in the ASC (for Gameplay Ability System).
cooldowns, etc
You can say, separate those, cause really the only things that needs to be done on clients are like effects(particles etc) spawns and movement.
I'm overriding IsNetRelevantFor on an actor, but it takes like 5 seconds for the actor to stop being relevant when IsNetRelevantFor should return false, is there a way I can fix this? I tried using "ForceNetUpdate" but that didn't work.
So local data is garbage if people peeked.
is there any plain english explanation for the replication flow of shooter game weapons? The example project
I keep getting lost in the code and I'm having really hard time figuring it out 😄
which part you get lost? pick up? firing? updating remaining ammos? spawning effects?
basically, replication go from server to clients.
has anyone here tried to do predictive actor spawning? im looking over the code for UTProjectile in unreal tournament
it looks kinda arcane, especially how it matches up the server projectile to the client projectile using
the velocity direction?
very strange
also i dont understand the PlayerController->GetPredictionTime() stuff
Why can my HUD class spawn only on one side?
Joke is that it spawns only on listen server, but not on client
I predictively spawn projectiles, and I hash the launch position and direction as a the key. It works well, you just need to make sure you hash the quantized version if that's what you send via RPC.
would you mind sharing your code?
How can i fix it? Im just complete newbie in networking, so im facing a lot of issues atm
how do you know they dont spawn on clients?
My HUD class is spawning widgets on BeginPlay event
Which code? The projectile mgr I have is 500 lines long 🙂
this is my hash function if that's what you want to see
static int32 HashPosDir(FVector_NetQuantize const& pos, FVector_NetQuantizeNormal const& dir)
{
// hash it!
int32 hash = HashCombine(0x8235626b, GetTypeHash(pos));
hash = HashCombine(hash, GetTypeHash(dir));
return hash;
}
hmmm
i'm curious, what do you do with this hash? (and what happens when two projectiles are shot in the same direction from the same position?)
My guess is that if the hash matches one that's already in the table of spawned projectiles, you just don't spawn, instead interpolate (or whatever your client side prediction/server matching) the current one
yeah it's a way for clients and server to know they are talking about the same projectile.
If player launches from same pos/dir then yes it would be a problem and I've not looked at that yet.
Cause it's extremely unlikely to have same location/rotation
it's almost impossible in real situation
ah I see
If you're new to multiplayer - predictive projectile spawning is probably not a wise first thing to tackle, it can get complex quickly.
yeah lots of edge cases for sure. Like when RPCs arrive in different orders or the hit rpc arrives before the launch rpc 🙃
I agree, also it's not that important factor other than competition arena type of shooting games.
Most player would not play anything above like 100ping already.
Yeah that too, for a simple bow and arrow I wouldn't even bother using a replicated projectile for the local player, just predict the whole thing. It's almost certainly going to be deterministic in nature.
Just replicate the projectile for third-party viewers or even just the start position and direction and have them spawn one locally
Do you guys use projectiles too in automatic rifles or anything that spawn projectiles too frequently?
I see, probably there isnt much way to predict it too since the travel time of the projectile is lesser than RPC travel time
Actually rather than RPC travel time its about timers because you just use one timer RPC to start firing
You only have start/stop trigger
I have projectile based rapid fire plasma gun which is why I use the manager and hash approach, rather than a replicated actor per shot.
Everything in HLL is a projectile but we aren't using actors. Would be bandwidth-suicide.
But also, since bullets are SMOL, it doesn't matter if you don't see all of them so we can replicate them "lazily"
Sci-Fi big-boi plasma guns are probably another ball game
I'm developing a top-down shooter and couldnt find any optimal solutions for projectile-only weapons
if you're doing things like an MG42 you might just do what jambax said... spawn it locally per machine (with pooling of course), no need to replicate the flight path. you can make all the bouncing/penetration randomization the same across all clients, there's just a chance it might hit differently on certain clients so other players might occasionally see a weird hit, this is where "trust the client" and "server shoould sanity-check the client" come into play 😄
It's all very situational which is why it's hard to find solutions that cover all bases, I don't think there are any really
yeah definitely, there's several ways to do things with strengths & weaknesses
Also tbh players will forgive the occasional miss-prediction but they won't like a gun that feels permanently laggy 😄
If it's a spray bullet type game you might be able to do start/stop firing message, but usually you'll need at least 1 RPC per shot.
I guess I'm doing the same, triggering timer locally first, then sending a server rpc to start the timer and do not care about else
I also have another RPC to stop the timer
bonus points if you can build in a bug that games like Rainbow Six Vegas 2 had (sometimes the "stop firing" signal never got broadcast properly, and you would have to spend the rest of the mission listening to the other player's gun firing sound)
Ah I remember that bug 😄 Thanks for pointing out
shouldn't be an issue if you're using reliable RPCs here anyway... I'm sure Ubisoft just pulled an Ubisoft on that job 😄
lol we had that for a while 😄
p.s. in case it wasn't known/clear, you would (could) also include a random stream seed in the start RPC. by sharing that initial random seed you can ensure all machines generate the same random effects/events, assuming you have any
I'm literally enlightened and now understand why @silent valley use hashes , thanks 😄
Guys is there way to edit source code for that execute on client RPC?
I having trouble about Client RPC's are running on server when a player leaves. (characters shouldnt destroy as like MOBA games, so i edited it from playercontroller to block destroying character, and thats work)
but when player leaved, that character owner switches to server as expected. so execute on client RPC's are running on server too.
The way i want to add: **is dedicated server boolean ** at the run on client RPC's. so it wont run on server and wont make lot bugs also cpu resource which is widget things.
where is that run on client RPC at the UE4 source? anyone know?
anyone know why dormant actors (marked dormant all) would still be in the active list and not actually dormant
[2021.05.16-21.15.34:671][471]LogSolsticeCheats: Actor: AmmoExplosivePickup_C_2147430494 (AmmoExplosivePickup_C) - Next Update: 254.564468, LastNetReplicateTime: 64.312965, OptimalNetUpdateDelta: 1.000000, PendingNetupdate? 0, ForceRelevantFrame? 0, Dormant Connections: 0
tho this actor is marked "Dormant all"
if possible, that would be save lot time instead adding is dedicated server branch to all client rpcs.
let me know please
you should definitely not be trying to edit engine source code for this, its a terrible idea
why? just wanna try to add if(isdedicatedserver) on exec output to blueprint 
so it wont fire on server that client rpcs
there lot of client rpc that send attack, animation, KDA or audio etc. also not only on one character, there'll be 30 or more characters for MOBA. that requires lot times to add with branch on BP
if you want to do 30 player game and do your networking in BP
that game will never work
4, maybe 6
no its not player,im talkin about characters
or NetMode
still runs client widget nodes from server. not work
or not even compiling the body of the function for the server target
this a 5v5 MOBA game match, so players choose one of 30 characters and enter the game.
not about 30 players entering this match lol
you know how do you make owner without owner for avoiding run client rpcs on server?
no that actor owner is still on server.
still will run on server
how can i have authority without the game?
if i switch owner to another player then clientrpcs will run on that player and that makes more bugs within double rpc
the way that i want; disabling execute on client rpc event fires on server
this
runs on server after leaved from game
even that says execute on owning client
yeah but i dont want it
character parent(base, main one) not only created from character. its includes towers, minions so i cant add character things even they are not connected each other(like different animation, behaviour etc)
why? let me know then
Scratching my head on this one, trying to get the number of players in the game but it doesnt seem to return the number properly for the player coming in. It only seems to update when someone else joins in
yes its easy without source edits, but requires a lot time to do checking with all of 30 characters per 10 ~ client rpcs
doing this for when the player joins in
and then i have this interface that i setup to a billboard which updates the number of players when the player joins in
it doesnt even fire on the Client 
the server got it but not the client, i add a bit of a delay and it picks it up but ideally i dont want to add a delay
what you would suggest? make all them on one parent?
but minions, towers and characters are too different. minions are not even having client rpcs. and they using AI controller and AI behaviours within same parent.
at the parent there's have some damage calculation, CC(crowd control) coming from player to minion or tower or to enemy character. and some basics that need on everything minions and player characters too.
well not 3 class i guess its just sample
inhibitors, base guardians, mining guardians etc
which is connected each other for damage calculation armor lifesteal etc
nope, it wont fire that rpc event. so i dont need to add branch or bool if i do changes on engine.
like imagine:
executerpcbp(exec,some structs etc);
this is firing the RPC events on blueprint from C++ engine
if i would change like that
if(!isdedicatedserver) executerpcbp(exec,some structs etc);
it wont fire RPC event on blueprint if it is on server. only fires if its client
since i dont know where is this RPC event firing so i gave example with one string
exec is :
so this white thing wont do anything on server within client rpc.
so it affect all client rpcs and i dont need to add brach, bool check etc on all characters bp's
thats because server loading and client loading times are different. the server loads faster than yours. so after server fires it you will miss it since you didnt loaded yet.
you can try onrep replication on that variable. after client get it changes asap then you can fire that node without multicast
hope i explained well 
even why UE developers didnt add that checking, dunno
who need running client rpcs on the server even there is run on server rpc tho
which is why you use composition over inheritance
put a component on them
damn laggy discord
Anyone know the correct way of locally predicting MoveComponentTo?
Anybody use Advanced Sessions and know how to close a game instance to create another game. My problem is I can Host, but I don't know how to properly go back to main menu without using Open Level. When I try to host again or join another session, it fails unless I restart the game.
OOOOOOOOO, that fixed it.
So the Rep Notify is basically a message that gets set to the Clients and its literally like
"Do this when you can?"
Hello, got an Intresting question. I've seen 3 main game hosting servers being used, which are: Gamelift, photon and SpacialOs.
So between these 3 which one do you guys think is the best overall?
No, which suits my needs or anything just your own opinions.
why if this is into my character the print node says server? and the sum value is correct, but if I try to print it it says 0
oh I think I solved but the value is not right
does anyone know why play as client with 1 player spawns two characters
Ah yeah that's true. That makes sense in my situation as well
I've started my Server joining and all that other stuff setup so hopefully I can get this all working. Wish me luck -_-'
Random thing, anyway to test players leaving the server I hit exit and it exits all the windows 
Ah just noticed you can run them as separate processes, instead of sharing the same process.
Is there anything built it into the player state (like the ping) to get if the player is running on a wired or a wireless connection?
I don't think so. if you have something run on player's computer locally, you could try fetch the network connection name through windows API/etc.
Ah fair, do you have any guides or anything in notes, info I could follow with helping me with using stuff like windows API in UE4? I've been searching on this for months but I've met a lot of dead ends from it.
I think the fastest way is just run windows command and then save the output into a text file. Save and parse and save to a config somewhere.
You are essentially relying on people don't manually change their connection names.
Just how complicated would it be to make a simpler version of the CoD game lobby ? Like a base simple version of it
It's difficult to answer because CoD is a giant AAA game and has a different architecture than you probably do. For example, the players likely aren't connected together during the lobby, and each player gets the other player's state from the server that stores which skin you've equipped and so on. Assuming you're not doing a game-as-a-service with extensive always-online services, you probably don't want to do that, so you can simply have people join the game, and then make the lobby a special state of the game with a lobby menus and camera, and then start the game.
Yeah that sounds intresting thanks for your answer. I'll look into it more 😄
Hi guys, quick question, is that possible that ue4 could support 500 characters replication? like 4 players with 500 AI characters.
No
I noticed that there are bandwidth for networking, only 100 characters movement replication works OK, beyond that number, it is extremely lag. Is that possible to do some optimization for 500 characters movement replication?
Did you test for 100 characters in real-world conditions with two machines some hundred of miles apart ?
Yes, its OK. I tried to increase the bandwidth in config file, it could work for 300 characters but its like 200kb/s for client download which is too high
Is there even remote multiplayer games with that large amount of character replication?
CoD Warzone being the largest BR game has 150 simultaneous players, no NPCs.
So you played your game with 300 characters moving seamlessly in real-world conditions - two machines far apart physically ?
Because that's surprising
Yeah. but I changed the config to increase the limit of networking bandwidth
Anyway, assuming you have 4 players, just replicate the player data and have whatever logic drives characters simulated locally
Deterministically, of course
OK, so for replicate 500 character's movement is not possible right?
I don't think it's possible without writing your own netcode with minimal data per character.
I doubt 300 actually works in real world, but you're telling me it does, so...
I was wondering it there anything I could do on it maybe adding some custom networking data sending
Yeah sure: don't use character and roll your own pawn class instead
Yeah, I'm thinking of this, I checked the network profiler, there are lots of waste bits in packet
Theoretically it could be done if all that's going through the netcode is just player input every 1/128 seconds, not accounting for accurate collision detection.
Character is a full-featured AAA player class, it's as heavy as it gets, if you're using it for simple player controlled AI it's pointless. Roll your own class instead - and like I said, it needs no replication at all if players aren't driving it directly. Replicate the actual high level player commands, and ensure your custom pawns react deterministically to these commands. For example you can replicate pathfinding commands.
For reference, Doom's ancient netcode only sends out input data, and people tried to go past 160 simultaneous player with resounding success.
I c thanks guys, I think one way could be making own character class from pawn and custom character movement class from pawn movement. Deal with custom networking would be possible right
There is no need for anything custom, just don't use Character for this
Got it, make sense.
@smoky crag the bandwidth is not your chokepoint, the CPU is
very few people actually had bandwidth issues, before their server CPU died evaluating actors for replication, or just running 300+ CMCs on the GT
and 100 players is not possible, unless you have a very experienced team with you
Yeah. That's why games like Apex and Fornite are the way they are. You might have a ton of players in one server. But the local client performance and server performance are greatly enhanced by the fact that most times people never see all of those other players fully replicated. You see like 20-30 max in most games, and an average of 10. Server still has to consider the replication, but it can be highly optimized via a few factors. Clients aren't constantly simulating a hundred character movements since they only care about the few the server says are important, etc.
Does HUD class spawn automatically for each client?
But for some reason HUD calls BeginPlay event on Listen Server's Client, but not on other clients
I don't know how it all works, just started working with networking
Fixed it
What about RPC functions, i have a Server function, that is being called by my Widget when i press a button. But when i press button on client, it doesn't call a function, it works only with Listen Server
Server Function is located in GameState class, and being called by Widget
GameState is not null, i checked
I guess, maybe i should use something another for this call, actually
AGameState is owned by server i guess?
Oh, i guess it's bad idea to call Server RPC function from Widget
What side owns APlayerState?
copy pasting from #cpp to here:
Is a replicated component based weapon system a stupid idea?
At first I tried to just have a component where the "fire" function checks if the component owner is the authority, calls "server fire" if not authorty, replicates it to server and finally from server back to clients for playing the firing effects and so on.
But then I realized that RPCs are a thing for actor's only, and not actor components? Does that mean it's impossible to encapsulate the replication flow inside the component? Should I instead just do a weapon actor that can do RPCs? I'm kinda lost here 😄
voting for actor based weapon system 😄
technically component based weapon system could work but can be pain in the ass when inheritance / high level scripts / explosed events / data storage / runtime comp creation / subcomp requirements comes in.
actor solves all this issue, makes easy to use, designer friendly etc. also with some "new" systems like replication graph its way cheaper to replicate cuz' you can filter,sort via class or replicate as depedency with the character etc.
Hello, we use Advanced Sessions and I want to Find Sessions Advanced on a dedicated server but it doesn't seem to work without a player controller. Anyway to get around this?
Dunno what the PC is used for, but you can look into the AdvancedSessions source code to understand why
AS is a Blueprint layer on top of the online susbsystem, which doesn't need PCs, so it's probably only used for context
I did read something about it being used for a unique id
Very weird that they would have made the choice to make a player controller mandatory
It's not that weird, really
Advanced sessions is basically "easy matchmaking in Blueprints", so it's not exactly tailored for AAA type games
Take a peek at the source and see if you can get rid of it
For the most part it seems like it's running GetUniqueId on the player state, which may not be needed in a dedi context
But that code is finding sessions, which is just weird for a dedicated server, anyway
You'd expect the server to be joining an explicit session by ID, or be the one creating the session
I need to know how many other dedicated servers are out there and of what type. There is probably a better way to it then 😅
Does anyone had problem with current number of players when u find server and want to join. It correctly show max players but current players is always 1. Idk why
are there any special techniques or something when calling an RPC from a replicated scene component?
except for GetOwnerRole() are there any extra steps
?
GetOwner()->HasAuthority() => Standalone/DedicatedServer/ListenServer
! GetOwner()->HasAuthority() => Client
Actually a client can have authority over something he owns
Well if you really don't need the client to run the code you could check for :
GetNetMode() < NM_Client
or ! IsNetMode(NM_Client)
anyone got any resources for extending the character movement component not really sure I need to do to add a custom movement?
do you want to know how to add a custom movement?
Well I just want to add a networked sprint and in the future want to do some stuff like flying, the best way seems to be changing the movement component
thanks let me have a look
Anyone have experience with this Create Advanced Session?
Create Advanced Session Dedicated works, the standard Create Session also works (albeit with a limitation).
But when we use Create Advanced Session nobody is able to see the session/server.
It also has a lot more options than the Dedicated session, such as the Presence options. What do the Presence options mean?
Yeah, my target is for at most 4 players, and running 500 characters for replication. For only testing 300 characters, the cpu is totally OK as I did a lot of optimization on movement and skeleton and mesh. But the bandwidth is really an issue, as I increase the bandwidth it works great, but nobody wants to have a game with 200 kb/s.
I'm thinking to create my own character class in order to reduce cpu and do a better networking replication.
as Stranger mentioned, doing it with CMC is not feasible
we can only run 200ish, before the average gaming computers have performance problems
YES, the current cmc cost really high cpu, need to have my own one
and we stripped out everything we didn't absolutely need, its still CMC tho
I totally agree, I did the same thing, but 300 character is at most with 30 FPS.
there are methods for smoke&mirrors
any characters you're not actually interacting with can be faked with niagara
I think creating a custom character class with custom CMC and doing the custom networking part for this is the only choice for me.
it will move, and run animations
Yeah, I read through the indro of niagara characters. But for a 500 character battle group, nothing could be ignored as running as niagara, that's my concern
BTW, I saw a game called conqueror's blade, it could support 30 players, and each player could control 40 around soldiers, which really surprised me.
nothing there will work out of the box though
what do you mean about the box? I just wondering if creating a custom character class with custom CMC and doing the custom networking part would be the best way for 500 characters replication.
it wouldn't
the 500 characters is also not a small number
to evaluate and replicate, also CPU cost
you'd be better off splitting them into units
reduce the number of Actors involved
I c, like making 20 characters as a group instead of individual right?
I think this is really what I needs, yeah trying to group up the characters.
Thanks Zlo this really helps me
btw, you can also offset the replication for further away characters so you don't have to update everything in one go. like you stagger the replication if you can. there is a unreal video about handling large crowd
I c thanks, only delay the replication for character that far away of all players right? This won't affect any character behavior like fighting each other right?
yeah, you can delay any that aren't in immediate action area.
(like they can even tick slower for AI, etc, etc)
basically, you hide the fact they have slower update rate with different/staggered actions. as it's so chaotic all around you won't really notice that hey this couple is playing the same animation twice for the past 5 secs
especially if they are like 50 meters away hiding behind foreground characters.
I c, if I don't want them to have different behavior when fighting, only reduce the rendering and networking ticks, also even reduce animation but keep the animation notifies since they are used for fighting.
yeah, doesn't matter how you approach it, the basic idea stays the same. ie. playing the animation is pretty much local, while update the action usually is from server to client.
you can keep the logics to like dead simple value for far away AIs. like just play the fighting animation until the system get to you.
so your anim blueprint needs to be able to handle that instead of returning back to idle once a cycle is done.
also, if possible, you should see ways to interpolate one action to another with an offset per character
say, we go from running to the in place fighting animation
your AI anim blueprint should be able to blend from running into any part of that cycle fighting animation
once you figure that part out it's a lot easier to stagger out animation even if the event/replication happen to tell them to do the same action at the same time. As they are interpolating to different part of the same animation cycle.
@smoky crag see above
Thanks, that's really helpful
Does UE4 only use port 7777? What if I want to host multiple instances of my game on a single server/ip?
I want moving platforms in my multplayer game. I added a box and animated it using the level sequencer. The players glitch through it.
What should I have done instead? 🙂
hmm, maybe I should stop being lazy and just create an actor blueprint. One where I set up replication and then only start the level sequence on the server? Is that how I should have done it?
Moving, player-colliding platforms, in multiplayers, are not easy at all
You need them to be exactly at the same spot everywhere on all clients (so some sort of replication is needed, if only the shared world time)
You also need to be wary of pushing players into eachother or into walls, etc
I think I got it to work, sort of.
How I'm doing it right now, that I have only playtested for a minute or two, is that I created a BP_MovingPlatform where I clicked replicates and replicate movement.
I start the level sequence in the level blueprint if is has authority.
My two clients seems to agree where everything is, and nobody has so far glitched through the platform! Have not tested with walls yet.
The platform feels a little bit choppy though. Guess that's to be expected due to it not being played on the clients...
But if I play it on the clients then they start to glitch through it again. 🙂
Not really a must have feature. I should probably try and concentrate on the rest of the game. 😛
Is your pawn movement base on velocity or acceleration/force?
When you move the players I mean.
Yeah, but I mean your player pawn.
Yes, sorry.
The players is just the standard 3rd person template mannequin
And I don't know what it uses
Hmmm... So probably more velocity based.
My idea is, if the pawn is acceleration/force based. You wont be able to change direction that quickly, but now you are open to ambient velocity.
Like the Albert Einstein relativity, if you are on platform, your ambient velocity just matches the platform.
Compare to say, 0 velocity and want to let friction of collision to make you match platform speed.
Which is where the choppy coming from I think
It is? I thought it was because of the replication, and that it probably would increase if it was played over the internet and not on the same computer?
The platform looked a bit choppy from an observer that was not on the platform. 🙂
but just a tiny bit.
Yeah, that as well since physics are in the server, and you also need some sort of interpolation if too out of sync.
I asked thus question an hour ago with no response, Does UE4 only use port 7777? What if I want to host multiple instances of my game on a single server/ip?
No, it uses 7777 and up
OK but how do I tell the client to open the world on a different port?
How to set up and package a dedicated server for your project.
open ip:port, assuming you are somehow not using any session system
Some posts on the unreal forum said you can't pass the port
This is your chance to try it out and prove them wrong once and for all!
I don't currently have a project setup
This is your chance to whip up a small proof of concept and prove them wrong once and for all!
I'm very busy with exams...
This is your chance to study really hard and learn a lot of stuff and kick ass at the exams and get a good grade or whatever it is kids these days gets except STDs and prove them wrong once and for all! (OK, I will stop now, this is getting silly, it's 11pm, and I have work tomorrow...)
From the engine code, certainly looks like my answer is indeed correct
So I would just type 127.0.0.1:7778 in the level name, and it should work fine?
Wait it says editor play settings, do I have to change something there?
Thats dumb then bc you can't change the port after compiling the game
This is just an excerpt from the source to show you that this syntax is indeed expected to work
If you are not using any modern session system such as Steam, then you would pass the port to specify which server you want
k ty
when do I really want to make a call to StartSession ?, is it when the game really begins or just once joining a lobby ? or depends on my logic?
I'm using steam online subsystem
yes you can, just make the port a variable input
I know there's a way to make only 1 client print out a string instead of all clients but I can't remember the method. Does anyone know how?
anyone familiar with networking?
wondering why my server owner can shoot but my client can not
the simple idea is that it checks whether the weapon fired is hitscan or not and if it is it will do this
using strings to test it gets right up to fire hitscan server and then doesnt procede
for the client
Simple answer is you're using Get Player Character 0.
You shouldn't be using that within multiplayer.
The actual reference to the character you're concerned with.
oh i see yeah, because its a multicast i need to be more specific
i dont know how to get the reference though
In multiplayer, Get Player Character 0 doesn't specifically reference the character that you may want to actually fire the weapon on the client, server and other clients. If your FireHitScan event is on the character, then getting a reference to self would suffice. If the event is on a weapon that is attached to a character, then you can use something like Get Attach Parent Actor.
You also want to avoid having the client tell too much to the server on what to do as this opens up avenues for clients to cheat/exploit. As an example, if I hijacked my client, I could pass invalid information back to the server about my character's location, so then I'm able to shoot people from anywhere I want without even having to move my character at all. In otherwords, you want your clients making requests only to the server and the server checking its values of where the character is, and what the player is aiming at, if the character is "alive" and only when the server has verified everything should it proceed with what the client requested. You can still send data from the client to the server, but generally it should be minimal information, like a reference to a specific character, or an index of something the player is wanting to interact with.
And... If you're not sure about how to get a reference, you may want to start with that before trying to figure out multiplayer as multiplayer makes the concept even harder to follow as you're now dealing with multiple references to the same thing on different computers.
Ive been working on this for a bit, i have animations and weapons being shared accross computers
thank you for the advice
i tried Get Parent Actor but i didnt know about this seperate one
I think @deft oar needs to go through the basics of Content Example->Network_Features first.
no offense, but your question is very typical starter issue. which means you are lacking basic knowledge about networking with UE4.
well their solution didnt work either, getting the attach parent actor and then getting this camera by its class still works only on the listen server owner and not the client
there is even a UE4 networking compendium written by a very nice guy that shares essential info you must digest.
it's in the pin, so please read it.
basically, UE4 gives you a lot of controls over networking, thus you need to know at lease some basic terminology and know that multiplayer is very hard to do well.
not the gush but its mostly an experiment to test with my friends, i was stumped on one thing and decided to ask i dont know why you have to be so pretentious about it
because you are
usually, you can't expect to develop a prototype with everything written without considering multiplayer from the get go and expect to hit a switch on your events then it's multiplayer ready.
you NEED to develop the project with multiplayer in mind from the very beginning.
my entire prototype considers multiplayer
yes, so go read the pin compendium, study the Network_Features case by case.
when you go through those feel free to ask question
use get controlled pawn instead get player character 0 because 0 will be the server and your client will be 1
ive mostly been learning through tutorial and commenting because thats my preffered way of learning i dont think ill be able to wade through all of it
yeah, it doesn't really work that way though with multiplayer. a very simple analogy would be, I want to develop a network chat program but I don't know how to program sockets or understand how the protocol works.
the concept is very simple to send and receive text you typed in a text field
but you can't develop a chat program without the knowledge of how the networking part works.
there is a reason why like 95%+ indie game aren't multiplayer games. if they do they have people that really understand it well to pull it off.
if you are solo dev it's your responsibility to understand how it works, it's rewarding to study that part of UE4 to be honest.
That's why you develop your chat program in JS 🙃 npm i sockets.io-chat
XD
but yeah, seriously, it tooks me like almost 2 weeks? roughly to understand the spawning process for a client join that spawns to a random starting spawn point.
compare to that the fire projectile is so easy once you go through the network_features example map
I did entire project from scratch instead of inheriting the multiplayer shooter one.( using custom movement component helps big time as well as you will be responsible to handle the replication of movements, instead of using the character movement component.)
omg, I can't believe the wiki I wrote still alive here.
Prerequisites : Go through Epic's Blueprint Networking tutorial and have a properly working Multiplayer ready Pawn. Skill Level: Intermediate Engine Version: 4.1.0 Before you start, make sure your ...
version 4.1.0 lol
facepalm on my events all have RELIABLE on. 
Anyone worked with morph targets across a network?
Trying to get Oculus' lip sync tool to work and the only thing the server is getting is Morph Target name and Value but the server won't replicate any face movements at all
the sentence of "server won't replicate any face movements at all" tell me you don't know that replication only goes server to client.
@severe tendon so if you want something that happens on client to happen on server, try search for project that does remote collaboration, or even VR multiplayer setups.
that should get you started on how to efficiently drive replication to "other" clients
Let me rephrase that
The values are being sent from the client to the server, the server then multi-casts it to all other clients in the session minus the owner of the actor
Client Calls Server RPC and hands off Mesh, Name and Float > Server calls Multicast RPC and hands off the same info > Each client updates based on that value
We aren't making a game so cheating isn't an issue
Only problem is no ones updating. But they are for the hand tracking using the same method
cool, let's make it simpler. you can have one actor that are replicated and just keep looping morph target A to B and back
make that work first
Not using a map variable are you?
lol, probably is
No
Oculus Lip-Sync gives us an array so we just check if the values are the same as the ones that have already been sent and if they have we don't send them
Yes?
you mentioned. " hands off Mesh, Name and Float", are you passing the mesh reference?
Yes
so the funny thing is you can't pass reference cause server will have it's own thing
and you can't guarantee that they are the same
say, you have face O shape on server and client
they can be in totally different address space, orders in memory etc
so the only way to tell is that your server pawn and client pawn both owns the same mesh(data wise)
sorry gotta brush my son's teeth, come back later.
imagine this
you have a dedicated server, does it need to load the mesh for each pawn? or does it just need to know which mesh a pawn owns?
dedicated server don't run any skeleton mesh or pretty much any rendering mesh at all.
so that's why passing a reference to a mesh is meaningless.
Strangely it works with the hands
