#multiplayer
1 messages · Page 132 of 1
Is Locally Controlled
same name in c++
i think should be the same
not 100% sure
That's for pawn
oh so u want for anything
Yes, for the case that I don't know what the Actor actually is
If I understand the net roles correctly, GetLocalRole() on an actor owned by the local player controller should be NM_Authority (If it's something spawned on the client) or NM_AutonomousProxy (Replicated from the server but they control)
ive never done that but i think ive seen people ask about that before in here, i think what u want to do is go through the ownership chain and then check the last one?
Well for sanity check, I'm doing this for some interactable objects in the world to give them "Possess" like logic to set the owner to interacting player, so their local inputs can call server RPC
i dont think theres anything built in for that
In case this is a bad approach I can change the design as well
I'm calling EnableInput/DisableInput on ownership changes to not call RPC that would be dropped
It's a bad idea. You need to still RPC to the server in order to set ownership of the actor in order to RPC to the server through them, so it's somewhat pointless. I retract this... There can be times where you may want to set the owner of an actor in order to RPC through them, but usually it's not a great idea if it's something that multiple people could interact with.
i think the way to do this is to send the RPC through the PlayerControler of the pawn that u are controlling and not through the actors
ive never done stuff like that but thats what ive gathered from conversations here
I wanted to go this way to not fill the controller with RPC for interaction with different objects, so each object can be modular and keep their logic within themselves without requiring the controller to be specialized for them
You probably want something like an interface
That would be implemented from controller?
ur interactable actors would use the interface with a method like "interact"
and then u can override that per specific actor class
but then again
ive never done it
but i think theres something like that in the documentation
Oh no no, I'm not questioning the interaction logic, I've already handled that, through a component that resides in pawn so it can handle server RPCs. Interacted object's owner is set as the interactor on server, so they can call server RPC
I wanted to add Enable/Disable Input to not call RPC's if the actor is not owned and doing that on OnRep_Owner
So I was checking if previous owner is locally controlled
Which is why I wanted to see if the previous owner can be checked to see if locally controlled, in case it's not a pawn
im gonna take a wild guess here but i dont think ownership should be used like that
theres probably a better way to do what u want, im just not aware of it
if ur actor is not owned the RPC's shouldnt go through by default i think
since they need an owning connection to go through
It won't, but I think he's trying to circumvent the warning messages.
i have warnings in my project and they havent bothered me yet lol
Technically you can, but... It's better if you're not trying to enable/disable inputs on random actors as it becomes a nightmare to manage.
I would like it to be clean so if there is an actual error when I try to send RPCs where I shouldn't I can be aware of that
but why would u want to call the RPC's through the actor?
why not just go through the PC?
I don't like coupling either
Why would I get my PC dirty when the actor in question can handle everything within itself?
I think thats just the way that unreal does things, i agree with you that calling it from the actor would feel cleaner but i think ur gonna run into trouble later on, altough im not speaking from experience
Is there like more than one actor that you're in control of at a time? Where multiple actors would need to respond to a single input?
i actually managed to implement a dash in the CMC, thanks to every one that gave a hand
spoke too soon lol, client is not working
Hey, is the host considered client after packaging? In listen server. Cause im confused about how to program the logic for host(server). Is he a player or what? Can you explain simply plz
you are both the server and a client
ur gonna have to be a bit more specific in ur question
I mean after publishing the game. Does it work like coop games where the host is the server and the client? Cause i dont know how to put the logic for the host, because i want to make a game like secret neighbour for my friends
And i get a lil confused about it
ur probably gonan need to look at some tutorials first before coming here
also multiplayer is not a good place to start
im sorry to interrupt your chat but is someone experienced in dedicated servers?
I have packaged a working Server and Client Game in UE5.2 with shipping, which works on my localhost. I now want to move it to my external dedicated server where i already did port forwarding etc. The problem is that i can’t see a join message in the server logs when joining. On my local machine i could see them.
The server uses port 7777
“LogNet: Created socket for bind address: 0.0.0.0:7777”
The port 7777 is forwarded on my dedicated server. To connect i enter following command in order to join it:
HauntedRealmsTwoClient.exe <IP>:7777 -WINDOWED -ResX=800 -ResY=450
its a real dedicated physical server in Frankfurt am Main in Germany
ive used a back end service before that required some aditional setup with ports
if its running on a virtual machine ur probably gonna need to connect through a diferent port
you mean i need to change the port the server is currently running on or find out the real port?
find the real port
i used playfab before and the port was something like 16xxx
it wasnt the default one
try shooting them an e-mail
to see if the servers are virtual machines
im running a nodejs website on a specific port and can connect to it, can it still be a virtual machine then?
What can we infer from a log where GetLocalRole() returns ROLE_None and GetRemoteRole() returns ROLE_Authority?
Im not just starting, thats why im asking. Thats the only part where im confused
have u taken a look at the documentation and the oficial utube vids?
those are the best way to start if u have very broad questions like that
also, exi's network compendium
@limber gyro thanks for the ideas, ill check that
I have seen those
So I'm having an issue where if I run the editor as multiplayer it crashes the editor with this code and I'm not sure why, My guess would be it has something to do with replication? It works fine in Standalone 🤔
I posted in CPP before but realized maybe it was a multiplayer issue instead.
did anyone expirience problems with clothing through the client? my model's clothing is seen all buggen from the client, but fine from the server
My only thought is the player controller hasn't been replicated to clients yet. If a client needs to access their player controller you can't run that code off of BeginPlay, instead you should probably run that on possession.
I have in my game in my packaged version of my game where I am using steam advanced sessions to host a server the server loads perfectly but as soon as the client joins the server crashes but I tried doing this again but with unreal engines base character and it works so it has to be something with my character but I disconnected all of my code I could think of event begin play event tick ect and it still wont work? 🙂
I"m going crazy lol I have been trying to fix this for days can someone please help!!!!!!!!!!!! Like I dont know what to do anymore
Cheers, will give that a shot in abit 😄
Hey guys quick question how do you send a reference to a player in a multicast function since you can't replicate pointers ?
hey guys, I m quite sure the question I have to ask is maybe simple replication but I nowhere found any tutorial on that. I have an playercontroller in an 2 player coop game. I use listen server via steam an everything works quite well. The only thing I don´t really know how i can change the playercontroller mesh so both look different to each other. My thought to this was that not the player can choose but always the client on the listen server should be mesh 1 and the other client should be mesh 2.
But I somehow don´t know how to attempt this goal via blueprint?
Hey Folks, hope you are all doing well. I wanted a little help to understand what happens under the hood.
The character is being moved by calling Character->AddMovementInput( Direction,ScaledMovement );
and gravity scale of the character is 1
There are 2 players in the game, P1 and P2
**Scenario 1 **
While P2 is moving(applying inputs), P2 disconnects but for P1 the simulated proxy of P2 continues to move. But as soon as P2 reconnects the simulated proxy is corrected and directed back to the point P2 disconnected. So this clearly tells me that the server had the correct position but didnt update the simulated proxy of P2 in P1 client instance of the game .
**Scenario 2 **
P2 is falling from a great height, P2 disconnects. P1 sees P2 falling and which then continues to move forward indefinitely until P2 reconnects then the simulated proxy is teleported back to the location where P2 disconnected and the fall happens again.
I have used a listen server to see what exactly happens in both cases on the server the P2 ROLE_Authority proxy is stationary in air until the player reconnects
Can anyone tell me why the simulated proxy continues to move and not synced with the state of the server.
THANKS IN ADVANCE
Any idea or good tutorials on how to implement VOIP (opt. with online subsystems)
Anyone point me in the right direction for going from a player spectating to possesing a player pawn? I seamless travel from a lobby (where the players are set as spectator) and the new map opens fine but they are still in spectate mode, cant seem to see the correct way to 'unspectate' them and assingn the default player pawn. I've checked 'handle starting new player' which is returning the spectator controller
For multiplayer, using UObject as an object for Item using OOP.
Possible or too much headache (Using struct would be the only option)?
Lyra does this
“LogOutputDevice: Warning: Script Stack (1 frames): GameModeBase.HandleStartingNewPlayer”
“LogWindows: Windows GetLastError: The operation completed successfully. (0)”
“Log file closed, 11/02/21 15:56:41”
How do i replicate TArray of UObject?
through an actor with its subobject list
What if this TArray is inside another UObject?
that is inside an AActor
i have PlayerController -> PlayerData(UObject) -> TArray<UItem> (UItem is UObject)
i can`t put inside player controller itself because it is a mmorpg and playerdata need to survive even when playercontroller is disconnected
(And it changes owner, when new playercontroller possesses same character)
Is there any way to do that? UObject don`t have replicated subobjects
All replication must go through an actor as some point.
So the uobject has to belong to an actor or to another object which belongs to an actor.
It belongs to another UObject that belongs to PlayerController
Can i have array of UObject inside another object?
A good question.
anyone got an idea why my packaged client can connect in test mode but not in shipping?
did u investigate the virtual machine possibility?
yea, just route them through the actor
Any examples on forwarding inputs from player controller to controlled vehicles? I don't want to own, I just want to control.
How do i change bUseControllerDesiredRotation on multiplayer game without stuttering?
const FRotator DeltaRotator = UKismetMathLibrary::NormalizedDeltaRotator(GetControlRotation(), GetActorRotation());
const float Delta = DeltaRotator.Yaw;
const float AbsoluteDelta = UKismetMathLibrary::Abs(Delta);
const float Speed = GetVelocity().SizeSquared();
if (AbsoluteDelta > 90.0f || Speed > (25.0f * 25.0f))
{
GetCharacterMovement()->bUseControllerDesiredRotation = true;
}
else
{
const float ClampValue = FMath::Clamp(5.0f, 1.0f, 90.0f);
const float Min = ClampValue / -1.0f;
const float Max = ClampValue / 1.0f;
const bool bInRange = UKismetMathLibrary::InRange_FloatFloat(Delta, Min, Max, true, true);
if (bInRange)
{
GetCharacterMovement()->bUseControllerDesiredRotation = false;
}
}
This is my code but it breaks at high ping
I need advice on how to network a material instance. Can anyone help?
hey folks, any help here #multiplayer message
i tried to figure that out until i got the idea to check the server availability with the client development version which worked, so i just needed to figure out how to get a version working for others too. I cooked and packaged the test configuration which works for everyone. now ive come to some questions. is it best practice to take the test config for release? are there any performance or quality issues or can i use this workaround? what is the benefit of using the shipped version instead of test?
You don't. You'd create the material instance on both sides the same way, ie. replicating variables about that instance and creating an instance locally with those same values.
If in the client side GetLocalRole() returns ROLE_Authority and GetRemoteRole() returns ROLE_SimulatedProxy, what does it mean?
i dont know but have you already tried asking gpt?
For this question, not yet.
GetLocalRole() returning ROLE_Authority means that the actor is authoritative on the local machine. This typically means that the actor exists on the server and is responsible for replicating its state to the clients.
GetRemoteRole() returning ROLE_SimulatedProxy means that on the remote machine (client), the actor is acting as a simulated proxy. In networked games, this often means that the client is simulating the behavior of the actor based on the information received from the authoritative server.
i know that shipping removes debuging messages, it probably optimizes space aswell but im just guessing, im sure there is some beenfit
if u get authority then u are most likely calling that from the server
If GetLocalRole() returns ROLE_Authority in the client side, it means the actor is spawned on the client. But I don't understand why the GetRemoteRole() returns ROLE_SimulatedProxy when the replication does not exist on the server side (because client actor will not be replicated to the server).
GetRemoteRole() on the client should return ROLE_None, right?
ChatGPT is not helpful for this question.
The second row.
The role you're checking is based on what the current machine thinks the remote role would be of the actor, it doesn't care about if it is actually a server or not, or if the spawned actor actually gets replicated.
A non-possessed actor marked as replicated spawned by the client or server gets a remoterole of Simulated Proxy on the machine that spawned it.
If the actor is marked as non-replicated, then the remote role is none on the machine that spawned it.
If there is an actor A on the level actor L, which one is created first?
I found the actor A is created first.
"Created" would technically have to be the level as you wouldn't know the actor exists if the level isn't loaded first. Begin Play triggering on the actor first doesn't signify that it existed before the level did.https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Framework/GameFlow/
@solid river ☝️
Consider the second row. What does it mean?
You probably tried to reference a non-replicated actor on a client where that actor doesn't exist. This isn't right.
I have bRepicates=false actor.
This actor is dragged into the level with log on the 2nd row.
This actor is also spawned in level 's BeginPlay() with log on the 1st row.
It seems to me the roles also depend on whether or not the actors are dragged into the level.
Placed non-replicated actor in the level. Net Load on Client = true.
Setting to false prevents the actor from spawning on the client at all.
So it's like the server enforcing the actor to spawn on the client, but that actor has no network connection.
The bReplicates=true for the level.
I will show the screen shot for the complete log including the level one in red.
I don't think the level replicating matters for this. The actor itself is what determines whether or not it replicates.
hey guys, i have this problem where i setup a very simple scene and try to replicate the first person character provided by UE5. The problem is, when i print the name of the remotes, it says "client 0" for both clients... why is it doing this ? (there are only two clients)
player controllers only exist on the server and the owning client
if there weren't two player controllers you wouldn't even get as far as spawning in
How to use this node?
I cannot retrieve the Net Load On Client property of the actor.
Wouldn't both clients be client0 from their own context? Pretty sure the 0 is for split screen
I'm hoping this is the correct channel. I'm brand new to ue5.
So I'm doing a player info card on the lobby menu of my game. Everything is showing up and working when the second player joins, but it remains blank when it's just the host alone in the lobby.
show me the code for when someone joins the lobby
I'm guessing you're only calling the Create Connected Player Widget node here ?
sorry, I am new, and following a tutorial. I've spent like 5 hours going back and forth through the video to figure out where i went wrong.
I think this might be closer to what you are looking for? Its the update when someone connects?
don't worry lol I've been in your situation before + debugging in unreal engine with the almost inexistant documentation is awful
lol son of a gun i figured it out. Pretty obvious when looking at it
Welp. Connect your nodes kids.
is your class supposed to be called 0 Base 😆
Yeah lol, Im only focusing on multiplayer functionality right now. Theres literally nothing else to the game. So I just downloaded some random skeleton
the guy that made the template sure had an interesting naming convention lol
Widgets don't replicate. RPCs do not function in them.
Game Mode also does not replicate and only exists on the host, there is no point in calling any RPCs in it.
You'd need to feed in a reference to a "NavSystemConfigOverride" object which isn't the "Net Load On Client" variable you see on blueprints. "Net Load on Client" of the Actor class is only exposed to have its value edited in the details panel, and not viewed or changed in blueprint graphs.
Is it possible to make actors that are placed on the level at design time get spawned only on the client machine?
i would say no, but im not 100% sure
Hello! I have a small question about a server RPC, I created a new project with the first person template in a C++ project, and decided to Implement a Server RPC to the fire function in the weapon. This is the code I'm using to call the fire function on the server from the client, but the code never gets to the ServerFire function when I try firing it from the client, is there something that I'm missing in order for it to work? I am also calling SetIsReplicatedByDefault(true) on the Weapon Component constructor.
The function is also marked with UFUNCTION(Server, Reliable)
have u tried calling that function outside the authority check?
it might be since thats running on an authonomous proxy that u actually have authority this is wrong
is that function being called by a character?
No, the function is being called on this component, which is on the gun that is a child of the Character BP
so i would suspect that you dont have an owning connection
RPC's need an owning connection to go through
I also tried calling it like this, the Owner of the gun is the Character
Does this mean I need to call it directly from the character?
i think there is a way that you can call it from other actors, there was some one here earlier that did that but RPC's are usualy called through the character or playerController
in theory if the owner of the gun is the character it should work but im not sure what exactly ur doing
have u checked the owning connection in code?
did u set the owner when u spawned the gun?
Yes, this code is in the Character script
the class that spawns it is a child of ACharacter
are those params replicating? im taking a wild guess here cause im not sure
but if ur spawning on the server and the weapon is not set to replicate, the client might not know the owner
anyhow, you should try calling that on the character just to make sure the function actully does what u expect it to
and if it does, try and move it to the weapon
Hmm I think this could be the issue let me check
Yes, this fixed it! Thank you!
I just set the gun replicates to true, and spawned the weapon only if it was the server
ur welcome, im actually surprise that i knwe the answer haha
According to ChatGPT, we should not use GetNetMode(), GetLocalRole() and GetRemoteRole() in actor's constructor
because the actor has not been fully constructed so networking might NOT exist.
Is it good idea to do the following instead to make actors that are placed on the level at design time get spawned only on the client?
AMyActor::BeginPlay()
{
//...
if(GetNetMode()!=ENetMode::NM_Client)
{
Destroy();
}
}
There's no might about it. Don't do anything in na actor's constructor except set default values.
if u destroy replicated actors on the server they are gonna be destroyed on the clients too
ur gonna have to make sure they are not set to replicate
The actors are not replicated (bReplicates=false;).
in theory what u have should work i think, u might wanna try to do that on "postInitialize" function, might work the same way and be a bit better for loading performance, not sure tho, just guessing here
But I am not sure networking is ready to use before BeginPlay(). 🙂
overriding NeedsLoadForServer probably works too
you could put a kind of spawner class instead of directly the actor and tell it to spawn the actor if the code is being executed on the client
void AEnemySpawnerButton::RPC_Server_SpawnEnemy_Implementation()
{
const auto dir = AUndeadDirector::GetInstance();
dir->RPC_Server_SpawnEnemy(GetActorLocation(), GetActorRotation(), mTeam);
}
Anyone have idea on why the second RPC_Server_SpawnEnemy function is called but not executed ?
UFUNCTION(Reliable, Server, WithValidation)
void RPC_Server_SpawnEnemy(FVector pos, FRotator rot, ETeam Team = ETeam::AI);
This is the function's declaration
both classes have bSetReplicates to true
{
ASPlayerState* AttackerPlayerState = AttackerController ? Cast<ASPlayerState>(AttackerController->PlayerState) : nullptr;
ASPlayerState* VictimPlayerState = VictimController ? Cast<ASPlayerState>(VictimController->PlayerState) : nullptr;
if (AttackerPlayerState && AttackerPlayerState != VictimPlayerState)
{
AttackerPlayerState->AddToScore(100.f);
FString VictimSteamName = VictimController->PlayerState ? VictimController->PlayerState->GetPlayerName() : FString();
AttackerController->ClientSetHUDEliminated(VictimSteamName);
}
if (ElimmedCharacter)
{
ElimmedCharacter->Elim();
}
}
void ASPlayerController::ClientSetHUDEliminated_Implementation(const FString& VictimName)
{
SHUD = SHUD == nullptr ? Cast<ASHUD>(GetHUD()) : SHUD;
if (SHUD && SHUD->CharacterOverlay && SHUD->CharacterOverlay->Eliminated)
{
EliminatedTimerHandle.Invalidate();
UHorizontalBox* Box = Cast<UHorizontalBox>(SHUD->CharacterOverlay->Eliminated->GetChildAt(0));
if (Box)
{
UTextBlock* VictimNameText = Cast<UTextBlock>(Box->GetChildAt(2));
if (VictimNameText)
{
VictimNameText->SetText(FText::FromString(VictimName));
}
}
SHUD->CharacterOverlay->Eliminated->SetVisibility(ESlateVisibility::Visible);
GetWorldTimerManager().SetTimer(EliminatedTimerHandle, [this]() {
//Set visibility to hidden after 3 second
if (SHUD && SHUD->CharacterOverlay && SHUD->CharacterOverlay->Eliminated)
{
SHUD->CharacterOverlay->Eliminated->SetVisibility(ESlateVisibility::Hidden);
}
}, 3.f, false);
}
}
The visibility of my HUD element is correctly being set to visible when a player is killed. I am invalidating the timer before setting it to visible so that if several players are killed in a short succession, it shows for 3 seconds before disappearing after the last kill is made.
Unfortunately this does not work, the timer never seems to be invalidated and the HUD element is only visible for 3 seconds starting from the first kill. Any ideas?
how come one shot calls (like launch character) in both the server and client work perfectly in high latency but continuos stuff like dashing doesnt?
why is this spawning the player underneath the map at 0,0,0
it only occasionally works
You should only spawn stuff on the server side. Actors that are spawned on client side will only exist for that particular client
Oh wow, thanks
I mean that doesn't solve the problem at hand.
but spawning stuff with multicast RPC... I haven't done MP stuff but it sounded very wrong
You only want to spawn stuff on client side when it comes to cosmetic stuff or a proxy bullet
it actually did
beyond all posibility it did
Kinda did tbf
just asking but why do you need to ever invalidate the timer?
Run the timer, not looping. Make the time 3 seconds
calling it again should reset the timer
so whenever another player died just call the timer again I think
Yee I tried this but it didn’t work, I thought invalidating it would clear it :/
hey guys, I want to spawn an actor on every client and on the server. I do this in an event in the "game mode" object but it doesn't work (also the event is set to "multicast") i guess it's not the right way so where should i put it ? and should the even be "on server" "mulitcast" or "not replicated" or "owning client" ?
You don't need RPC to spawn replicated actor.
- Make sure the actor you spawn is set to Replicate
- Have the Server Spawn the actor
Game mode only exist on server, just call the spawn function there
thx a lot !
In editor, can we start a client later so we can test RepNotify stuff? (if server open a door, check the door is open is client connect after)
Yes u can
i will try to find the video

@grave lynx https://youtu.be/UstLLZbkmOQ?t=3210
For #NotGDC 2022 I gave an informal presentation for people interested in multiplayer programming in Unreal Engine. This is a recording of our discord hangout.
We go over tools UE5 has for multiplayer development, good ways to use them, things to watch out for, and have a live coding session with examples.
00:00 - Intro
05:15 - Networ...
Time stamped
54:12 to be exact actually
😎
Any other possible solutions?🤔
I haven't done any mp stuff apart from small test.
What I would probably do is to keep the function and timer internally in the widget.
When you send Client Rpc , Get Hud -> Get Widget -> DisplayEliminatedEnemy
Something like that maybe 🤷♂️
i'm still stuck at movement and customization for my mp project
hey sorry to bother again, but now the only problem i have is that : (see image) The construction script can't find the data table because the "spawning" event is only called on server side so the "client" side item doesn't have a "item data table" variable set to something...
You should probably replicate this as an OnRep variable. The OnRep function can then call the same functionality as the construction script, so when that item data replicates, the client will construct the item the same way.
I am setting an On Rep notify variable inside a run on server event right now in which I attach an actor to a different actor. Both actors (Interacting Player and Self) are valid for both the client and the server but still this attachment is not visible on the client. What could be the issue?
On rep only runs on client. Try attach actor to other actor on server
Also make sure your actors are set to replicate
Fyi, actor attachment is replicated by default if the actor itself is replicated
If done on the server of course
the on rep is in a run on server event, yes
and it works on the server
but from the clients eprspective it's not really working
everything besides that in the on rep replicates just fine
perfectly
for both
My point is you don't need to replicate that attaching by hand
Is the actor replicated?
yes
Yea but i mean i have to put the node somewhere and if it wouldn't break it by replicating I guess it would be nice but idk
So the character bp calls the interface
and the interface calls the onRep
the interface event is inside the vehicle bp
both actors are replicated
that's what it looks like. It's not so much code
tried it with event interact directly connected to set interacting player and it does the same, I just didn't change it back yet
that's all code basically.
regarding that functionality at least
couldn't find a solution for 1 month now lol 💀
Is the player the owner of the vehicle when they are interacting?
what do you mean by owner
their player controller possesses it
so yes, basically
When in an actor I am trying to use the "Event ActorOnClicked". Is it possible to check if the button pressed key structure is equal to an "EnhancedInputAction" in some way?
Do they possess it before you're calling the RPC to interact with it? You can't call RPCs on actors that aren't possessed/owned by a player.
So if you're calling this interface without already running on the server, it won't work unless the vehicle is already owned/possessed.
The event that calls the interface runs on the server, yes
These 3 images show everything mate
im setting UStaticMeshComponent::SetCollisionProfileName on the server but the clients arent receiving this. is there a good way to network this call? or do i just make a replicated property and call this in the notify?
What happens when you set UPROPERTY(Replicated, VisibleAnywhere,...)UStaticMeshComponent* Mesh;? Is it properly replicated?
its already replicated
i managed to solve it by scrapping this piece of code all together lmao
Is your idea roughly like this?
UPROPERTY(VisibleAnywhere) UStaticMeshComponent* Mesh;
UPROPERTY(ReplicatedUsing=OnRep_ProfileName)
FString ProfileName;
UFUNCTION()
void OnRep_ProfileNameChanged();
void AMyActor::DoSomethingOnServer()
{
if(HasAuthority())
{
this->ProfileName="Pawn";
OnRep_ProfileNameChanged();
}
}
void AMyActor::OnRep_ProfileNameChanged()
{
Mesh->SetCollisionProfileName(ProfileName);
}
ye basically
i tried doing this but im guessing there was some race condition with the OnRep vs setting the mesh. its something specific to my setup but i ended up trashing it like it said. i appreciate you helping me out though
Version 2:
UPROPERTY(VisibleAnywhere, ReplicatedUsing=OnRep_ProfileNameChanged) UStaticMeshComponent* Mesh;
UFUNCTION()
void OnRep_ProfileNameChanged();
void AMyActor::DoSomethingOnServer()
{
if(HasAuthority())
{
OnRep_ProfileNameChanged();
}
}
void AMyActor::OnRep_ProfileNameChanged()
{
Mesh->SetCollisionProfileName(ProfileName);
}
I don't know whether replicating static mesh component is cheap or not. 🙂
does any one know why the function launch character works perfectly even with latency?
i just call it on the client and on the server with an RPC
ye, thats what i figured, that it was an already built in thing
is there like a list of those movement functions that are alaredy built in?
i know that teleport is
but it would be nice to know what else is there
is it safe to assume that any function that is from the CMC that tries to move the character like "addForce" for example works the same way as "launchCharacter"?
Afaik those only work automatically if you ensure it's called in same timestamp.
E.g. if you call LaunchCharacter when stepping on a jump pad, you don't need to replicate it
Cause server and client step on the launch pad in the same movement timestamp
If you call it outside if movement, so by e.g. pressing a key, then it might be that the CMC does something to not have you correct
by "those" u mean all the movement functions in the CMC?
can someone help, the client and server info about the player-character location is unsynched
it's just the forward vector of the actor, the regular world-location of the actor seems to be fine
i think theres suposed to be a bit of a gap in that info
theres also a var in the player character that u can change to improve precision
i cant remeber the name tho
in my search to understand the CMC i found to way to pass data to it, one is illustrated in this doc:
https://docs.google.com/document/d/1UO6Ww6Lfpti3YElVdo9uioTUtQJQ9CoSLvd9kF8hvJo/edit#heading=h.irlzv6ukhpxb
And the other one is just with a simple server RPC like this:
Custom CMC Network Data Discord Permalink This document will cover how to use and send custom network data between the server and client through the Character Movement Component, beyond just custom flags. This could include sending additional compressed flags, additional input vectors, etc. No...
so which one is the right method? what are the merits and downsides of each one, besides the obvious increase in lines of code
can some one shed some light on this for me?
Server RPC is probably wrong
You want to send the data via the already existing server rpc
so i am assuming that the document that i put above is the correct way to do it, isnt there a less verbose way to do it?
Is Steam Sockets the correct way to do Steam networking these days? Since it seems the default (non Steam Sockets) way shares IP addresses with other clients and is considered to be the legacy option (please correct me if I'm misunderstanding)
Hi I have a postprocess component that i want to apply only on a client. I need to do it on OnRep, because I use replay system. I just have a server function that I call that sets boolean that launches OnRep - ActivatePostProcess. Currently it works, but instead just applying it to client, it applies postprocess for the server also. The component is replicated as propably i cant use OnRep, if its not. Am I doing something wrong as I don't really understand why it happens on the server also
In this case of playing the sound, only the client should ever play the sound
It won't get called on the server unless manually calling the OnRep func there too
If you are testing in editor try checking the "Use Separate Process" checkbox when running multiplayer games
As it may be techically changing the post process component on the server since it's in the same world as the client and it's unbound
It also enables the post process and plays the sound on only on client. But the post process gets applied on server also. Even though i dont call the Onrep on server-function so thats why I'm confused
Use Separate Process, i could test that one
It's likely that as the non separate process PIE thing is sharing one world with the client
Ah okay, Where do you find this "Use Separate Process", i dont seem to see it?
ah because its prolly “Run under one process”
hello, I'm kinda new to multiplayer game development, I have this specific situation where I may not understand how does the replication works. I have a dialogue component that I add to my NPC. Whenever someone steps into sphere collision, the dialogue is started. Now let's assume that Client 1 is stepping into this sphere collision. The widget is put on his screen with the dialogue text. Now I want to do something where if for example Client 2 or Server comes close to the location of the NPC (NPC is spawned from spawner, spawning is replicated on the server, NPC has checked Replicated checkbox) the message is also displayed to them. I don't have system based around to check whether you're being close to the NPC, for now I'm trying to make it so that the message when started by client 1, will be also replicated on the server and multicast to everyone else. I have 4 functions withing the dialogue component. Can any of you explain to me what I'm trying to do and how to do it? Thanks in advance guys
as far as i am aware they are 2 completely separated things
if u wanna run ur server on steam u do it throught the steam net driver, ip net driver is just the default net driver that comes with the engine
which u can also use for direct connections
I don't think this is the case. From what I understand, Steam Sockets is the replacement to the legacy steam net driver that shared IP and had less protections. Steam Sockets run through relay servers to mask IP along with other benefits
But from testing it, it does seem to increase latency quite a bit on average and doesn't have a 100% consistent connection rate which is why I'm curious if people are using it over the legacy one still
yeah thats it, did it work?
sorry, i miss read ur question, i am not sure if is ºthe default way, all i know is that the new stuff is safer
nvm, this was some small mistake
I've checked in branch on interaction with NPC if player was equal to get pawn (0), when obviously the only pawn with id (0) is the one that has created session, so server host, that's why only he could display the message
Naah it still sets it on server also, weird
how can i server travel inside the gamemode using steamcore-pro plugin?
It does seem to increase ping but for me I noticed players still had around 60 which is still very playable.
I was trying to server travel with the steam core pro plugin too but was getting a fatal error saying something about NumDormantObjects. Are you getting errors too
I dont even know how to server travel with that plugin😂
i bought it today so im still pretty new with it
What blueprint would i use to server travel? i could tell you if i got any errors.
I just use execute console command servertravel [map directory]
oh i tried that but nothing happend when i executed it
yeah mine would just fatal error which is supposedly fixed in 5.4 but idk if i need to do something prior to travelling because i am switching modes i think
I know there is other plugins that works great and i used it before but switched to steamcore hopping it would be better but it seems that was a mistake
Yeah im using steamcore because steam functionality is broken until 5.4 so they say
hope it gets fixed
let me know if u figure out servertravel ill do the same, we should friend eachother perhaps?
Yeah that would be great!
I'm trying to get an "OwnedTiles" value to update for either of two players whenever they click on a tile. The value is stored in the Player Pawn. When the player clicks, if they clicked a tile, then I replicate to the server that a tile changed owner. The tile then updates a color enum that is passed to it. This change replicates and is seen by both players. Next, the tile tries to increment the number of owned tiles by 1 no matter what (I plan to add conditions after this step is working) by calling my "Update Owned Tiles" method implemented by the Player Interface. This isn't updating the value for the players. I think I'm not getting the player from my Game State correctly. Below pics are in order: Calling ChangeOwner from the BasePlayer, then the ChangeOwner section in the Tile.
Your cast only happens correctly on the true path, so if it's false, it won't correctly retrieve the game mode. You're probably getting an error in your log about this.
To fix this, move your cast before the branch, then it should be ok.
“LogOutputDevice: Warning: Script Stack (1 frames): GameModeBase.HandleStartingNewPlayer”
“LogWindows: Windows GetLastError: The operation completed successfully. (0)”
“Log file closed, 11/02/21 15:56:41”
I have in my game in my packaged version of my game where I am using steam advanced sessions to host a server the server loads perfectly but as soon as the client joins the server crashes but I tried doing this again but with unreal engines base character and it works so it has to be something with my character but I disconnected all of my code I could think of event begin play event tick ect and it still wont work? 🙂
PLease someone help me!!!!!!!!! 🙂 God bless you all jesus loves you!!!!!!!!! 🙂
@sinful tree Thanks a bunch, that fixed it!
Can anyone look at that and help me out? Been stuck with it for one month now
Apart from what Cedric said before, namely you don't need to replicate the attachment how you are and should be able to do it solely on the server, the other thing that I can see is that you're trying to do the attachment in the OnRep of Collision Enabled but it also utilizes additional variables like the "Interacting Player" but there's no guarantee by the time that Collision Enabled's OnRep fires that the "Interacting Player" has replicated too.
Hi, does anyone has a knowledge of dedicated server CPU usage by tasks in general? Lets say for a game like Fornite with 100 players? How much of the CPU time spend on collisions, relevancy checks, tickflush, gameplay logic, movement etc?
I will try to test this myself with some simulated connections, just looking for a starting point.
This is almost impossible to answer. No one other than the guys at Epic who profile Fortnite would know that.
Your game will have different numbers
Entirely different
Because its a different game.
YOU need to profile your game.
Hey Folks, I wanted to get some clarity on why the simulated proxy behaves as it does. Explained the scenarios here.
#multiplayer message
Does using IsServer do the same thing as using Run On Server with a custom event?
i doubt there is any one that went that deep as to know the exact answer for that question, but i would advise you to take a look at the characterMovementComponent code, you will probably find your answers there.
if ur running that check on an actor that exists in both the server and the client i belive so
not 100% sure there might be some details that i dont know
it will probably depend on what u call on the RPC, there is some info that is only available to the client like button presses for example, so if u were to use a "isServer" in a button press function it wouldt be the same
some one correct me if i am wrong
Yes, thats what I am doing right now. I was hoping somebody might have looked into it before. Thought it could save me sometime. Thanks for the response
Right now I don't see PostNetInit function being called for the Actor's server copy or for standalone net mode for PIE. Can I safely assume this only does work on client copies of a replicated actor?
I noticed that attaching component to component does indeed work. Just not actor to actor, what could be the issue?
I don't want to manually attach each component
{
//removed unrelated code for clarity
//////
if (bIsSprinting && !MoveComp->IsFalling())
{
StaminaCurrent -= StaminaConsumed;
}
else
{
StaminaCurrent += StaminaRegen;
}
}``` so I have this little check from CharacterMovementComponent, refered as MoveComp. Whenever I use any variable in multiplayer from CMC, the editor crashes. I'm quite confused as to why this happen. SprintChecks() gets called on Tick if user is client atm.
can it be because I need to check for ControlledPawn first?
It was me not initializing CMC properly 😁 fixed it
How would I send arbitrary payloads from client to server? For Instance, I want to create a USTRUCT, FPayload, and create children that would be replicated with a method like this.
UFUNCTION(Server, Reliable)
void Server_SendPayload(FPayload& Payload);
Where Payload is some child of FPayload
Digging through Reddit. If using client side hosting. No dedicated servers. Is it really that bad to make a multiplayer game? Any good resources?
You need to still do session nodes on server travel for the player information to transit - look up steam server browser widget setup and you'll probably run into the nodes you are missing
Depends™ but I heard 8 players in non dedicated server is kinda pushing it
Probably doing 4 max I would guess. Keep it simpler lol
That is very dependent on the host
dedicated servers are good for serialization of data and persistency, as for the rest of the multiplayer aspects, not much changes, and honestly 16 player p2p isn't bad, but depends on what you create as well obviously
ie - a driving game, perhaps not 16 users
It's always a bit nerve racking. I know games need to be built from the start with the multiplayer scope in mind.
host need stonks cpu 😆
So I've spent some time into trying to open my router's port to test-play some prototype with a friend online, doesnt seem like my ISP allows me to, but also I would like to be able to simulate a listen-server and client playing on my same PC as if the client is playing online, I think a VPN could allow me to do this, is that correct?.
I'd say don't let it get to you, focus on core replication framework, it will transfer to dedicated server builds as well as p2p for the most part(DS having more variables to work on/with)
You should check:
A) Firewalls
B) Ports for UE
C) Adv Internet settings for allowances
D) (If you decide to host on a DS) server management console for setting up allowances and opening the chosen game port
I checked with nmap and telnet to confirm my port is not open
and I've read in some forums my ISP doesnt allow me to open it
so Im looking for alternatives, someone mentioned Hamachi here I think
change the default port
Damn Hamachi
what do you mean
I thought portforward is a thing you do in your own modem
you should be able to brute force the port on a packaged game during authentication portion of your code
Im not coding it right now, also I wouldnt know how to do that
I'll prob do it for my next project. Ty ty
I'm doing muzzle vfx on a weapon for the owning client to see for instant response but also want to show the muzzle vfx to other players. How would I go about it doing a server to multicast and not make the owning client do the vfx a second time ?
bool for is playercharacter > false > display?
I guess so 🙂 I'll give a whirl.
er
possibly also isvalid node instead before bool then the bool logic
and for the playerchar ref - you need the controller for that character as the primary character to bool against
Yeah I was gonna say. If I do Get Player Controller index 0. All clients know themselves as 0. So it would just stop them all
I gotta be specific with what one
this is multiplayer - if you aren't on a DS I assume you are using sessions?
where ever you do your account / player auth attach an identifier variable and call from that player controller reference
Multiplayer is fun right? 😄
For sure 😛
If you are doing it with RepNotify you can change the Condition to SkipOwner
or if you are doing it with RPC,
Play the Sfx locally right away -> tell server to multicast it.
Exclude the player that plays the sfx. You may be able to use the Is Locally Controlled bool for that.
For reference, I haven't done much MP so take it with grain of salt
There is no use case for GetPlayerController node with index in Multiplayer context. It will just break your game.
See Multiplayer compedium pinned in this channel for useful infos and common trap
do custom PhysMovements have prediction and corrections? since u do send the new mode to the server with a byte i am assuming its gonna sync somehow?
also, when am i suposed to used bit flags, custom mov modes or the more complex way to pass custom data to the CMC? why cant i just use custom mov modes for everything?
Should, yeah
Depends on what movement you create. The bit flags are mostly for input pressed vs released
im still a bit confused, so i should only use physFunctions in movements that are changed directly in the game code for example siming or skydiving? all custom movements that are started by a key press say dashing or wallrunning for example should use flags? this taking into consideration that we only have 4 flags? is this correct or am i missing something here?
You don't need custom MovementModes for everything
Dashing can totally be handled in PhysWalking or PhysFalling
Oder just via different CalcVelocity values
The Flags are limited to 4, that's true, but I think if you really can come up with more than 4 more flags, then you can use the MoveData Container to send additional data I guess
but wouldnt it make more sense since we have a whole byte for custom movement modes to just implement everything in movement modes? would it be wrong to just use movement modes for everything? i know about the data container, some one told me that it was available from .27 onwards and im on .26 so i dont think thats an option but that aside im just trying to understand what was intended for the "end programmer" to do when the CMC was created
for example in a game like overwatch, you ahve like 10 or so movement abilities that are all triggered by key presses, what would be the correct/optimal way to do that sort of thing in unreal?
has anyone tried this udemy multiplayer course? I have been primarly using blueprints, but I am not opposed to using C++, I have experience developing.. just not much in C++ (javascript, react, sql, some C#,etc). https://www.udemy.com/course/unreal-engine-5-cpp-multiplayer-shooter/
can use FInstancedStruct
or copy its net serialization log
sup, I managed to play my game with a friend online, listen-server, now to not bother him all the time I would like to recreate this locally, is running through a VPN the client a good idea or is it a better way?
Oh yeah wtf i thought i was in cpp sorry
It's a fantastic course!
His GAS course is really good too
Good to hear. I went with a different one due to some of the review. Looked like the C++ portion was a bit rough around the edges, but I was also probably being super nit picky lol. https://www.udemy.com/course/unreal-engine-5-multiplayer/
I just grabbed a couple of these today on sale !
I did, it's good for me
FActorSpawnParameters HandSpawnParams;
HandSpawnParams.Owner = this;
HandSpawnParams.Instigator = this;
HandSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
LeftHand = GetWorld()->SpawnActor<AHand>(HandClass, HandSpawnParams);
LeftHand->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale);
//returns false
LeftHand->IsSupportedForNetworking();
Why is spawning an actor this way result in it not being supported for networking?
I'm checking for authority before and the spawned actor is set to replicate
I'm curious about an idea here and how hard it might be to implement, currently the game we are making will not be co-op however, if we did, how hard would it be to add in a "voice filter" into the game so that when speaking through in game chat dependent on your character a filter would be applied?
Depends on your Voice chat integration I guess.
But it wouldnt be difficult.
Are you sure its returning false?
I was worried it would be extremely complex or something, I'm gonna talk to the rest of my group about it, and the many other changes we might do if we go with co-op, thank you!
AActor::IsSuportedForNetworking returns true literally
Im not familiar with the intricacies of it, but I couldnt imagine it being to difficult given that you should be able to modify the sound source after its transmitted.
that makes sense, I've never even touched voice in unreal yet, but this sounds like fun
Hey fellas, I'm starting a project in Unreal and am looking for someone who is proficient in net code for games, I'm coming from a web background and have never really had to deal with the intricacies of network code for games and have a bunch of questions id like to ask, would anyone be so kind as to be able to spare me some time for a small brain picking session?
If you are looking to hire someone please use the Job Board (#instructions).
Otherwise just ask your questions here and whoever has the time and knowledge to answer them will do so.
Don't ask to ask.
Just ask.
please read the entire message before you assume i'm looking to hire, and i have a few questions and felt it more appropriate for a more one on one kind of thing, if noone takes me up on it thats fine, if this isnt the place to ask if someones willing to spare me 10 mins of their time thats also fine, ill be on my way then.
🤦♂️
hey all, doing splitscreen local multiplayer, the user interface widget isnt showing up for the player 1
Is there anyone here who uses AWS GameLift?
EC2 instance not activating after upgrading from GameLift Server SDK version 4.0.2 to 5.1.0?
I did run it locally using GameLiftAnywhere and it worked fine
@regal solar Does the Logs mention anything?
[2023.11.28-04.36.05:079][ 0]LogTemp: Running on port 7777
[2023.11.28-04.36.05:079][ 0]LogTemp: PID: 865
[2023.11.28-04.36.05:079][ 0]LogTemp: Initializing the GameLift Server
these are the last lines
I mean in the Gamelift backend
wdym GameLift backend?
I accessed EC2 instance and viewed MyGame.log
it seems my dedicated server can't read env variable of AL2 instance, it tried to write all env variables of instance but there is nothing about websocket, hostid, fleetid etc
if ur gonna use a paid service you might wanna look into PlayFab, their setup is way easier than AWS, at least the last time i checked
You're right, copied the wrong function IsFullNameStableForNetworking returns false
hence I cannot replicate a UObject that this actor owns
Maybe Im misunderstanding their use but can gameplay tags be an easy way to identify who is on what team in an rts?
UObjects are not replicated by default
A GameplayTag is just a fancy FName. It can be used to identify whatever you like.
So the short answer is yes.
Yes, I'm trying to implement this but it failes because the object is not assigned a netGUID https://www.thegames.dev/?p=45
The UObject effectively needs to piggy back off of an existing ActorChannel. Meaning that for it to replicate an existing replicated Actor needs to add it to their replication list.
There are other resources that explain how to manage this
Its hard for me to link to on my phone
But they arent difficult to find.
Search for “how to replicate uobjects” or something.
There also maybe something in the Pinned Messages in this channel.
thanks a lot for providing an anchor point, I will look more into it
and your intuition wa right pinned messages had the anwser, gotta love this server 😄
Hi folks, I'd like to ask you something. What "should" happen when client would call RPC function on actor A, while that client is outside of relevancy distance of actor A?
The first time that function is being called, nothing happens, however it seem like it changes actor relevancy, since from the first call that client is able to call another RPCs that are being executed, even though client is nowhere close to A relevancy area.
Why wont my client enter the server map when joining the server session, it just stays in the main menu and says that the client joined the session.
could this be related to why i cant servertravel with execute console command too?
One question, the previous one in PlayerState works well, but the latter one in GameState doesn't seem to work.
Hi there, I'd like to inquire what tools you use for collecting metrics from your dedicated servers? By metrics, I mean technical ones (machine resources/traffic/average ping/etc.) and the information for game designers (retention/DAUs/etc).
I’m using Prometheus + Grafana for both, but interested in worthy alternatives and real experience with them.
p.s. Here's my guide about Prometheus+Grafana+UE, perhaps, someone might find it useful.
https://corgineering.notion.site/Prometheus-Grafana-for-UE-c2ce18cb1e3c4308a557f26d26bef7fb
so in a multiplayer game , im trying to keep score for each player across a series of levels , i read that the best way to do it is through game instance , but thats going to load the same score for every level , so question is how do i save the score for each player and load the correct score for each playerindividualy ?
I have a replicated array where item type is derived from FFastArraySerializerItem (and the array itself is a FFastArraySerializer struct). How do I handle new item replicated to client? I mean I know there are 3 methods: "PreReplicatedRemove", "PostReplicatedAdd" and "PostReplicatedChange", but how do I access the actor that contains the replicated array from there? 🤔
I have a couple of actors that are placed in the map but I do not want them to be spawned/loaded at all on the server, client only, is there something to specify that or do I just do BeginPlay check if server and destroy ?
They're going to be loaded/spawned into the level. The easiest thing to do is then destroy them on the server like you said. However, if these actors are holding hard references to assets that you don't want loaded on the server, you'll need to change those to weak references that you explicitly load on clients after the actor spawns/when you need them.
what about this function ? its Editor only so I think it means this will exclude it from being cooked on the server entirely ?
CAN SOMEONE PLEASE HELP ME! 🙂
“LogOutputDevice: Warning: Script Stack (1 frames): GameModeBase.HandleStartingNewPlayer”
“LogWindows: Windows GetLastError: The operation completed successfully. (0)”
“Log file closed, 11/02/21 15:56:41”
I have in my game in my packaged version of my game where I am using steam advanced sessions to host a server the server loads perfectly but as soon as the client joins the server crashes but I tried doing this again but with unreal engines base character and it works so it has to be something with my character but I disconnected all of my code I could think of event begin play event tick ect and it still wont work? 🙂
PLease someone help me!!!!!!!!! 🙂 God bless you all jesus loves you!!!!!!!!! 🙂
Can someone please help me with this 2 weeks And I still cant fix it 🙂
no one can debug that without more logs, crash dump
I'm making a game that moves with physics but there is lag, could it have something to do with the code or do I need to change something from the character?
capsule simulate physics on
I move it by applying impulse
Physics simulation that runs on server and replicates the client is not always efficient nor straightforward to implement, I'd say start with making a good clock synchronization and go from there
IMHO: multiplayer physics is one of the dark souls games in game development terms
something like delay?
will doing this solve the problem
there's just a slight lag in the turns
What is the maximum reccomended size of the array(Lets assume of int32) to be sent via RPC? I remember that when i wanted to send a really big arrays, like e.g. 2000 items(but these were structures, that hold e.g. transforms), it threw an error/warning? I know its byte dependent, not size dependent
byte is a size. Its code. length dependency wouldnt make much sense
Is there a way to dynamically mark something as "should not be replicated"? I'm trying to implement the concept of public and private information. Private information should not even be sent to clients that dont own the information.
Is something like this a built in feature I can leverage?
Importantly, the same data member can change between private and public information
From what I understand, if a client doesn't have an actor relevant, then the client wouldn't have a valid reference to that actor as it wouldn't exist on the client's end and because of this, there'd be no way to actually call an RPC on that actor from the client that does not have it relevant.
I'm fairly certain it's 65535 bytes is the max size of an array which also happens to be the max that can be replicated at once.
For an int32 array, that would mean a max of 16380 int32 values in one array.
For variables, you can mark them as COND_OwnerOnly so it only replicates to the owner of the actor or component. If you're talking about making actors replicate only to certain clients, you can override their IsNetRelevantFor() function and make it so they would only replicate to say their owner, a certain team, or whatever other conditions you want.
I have an ability that will essentially lerp a post process effect and make other players visible through walls. My main concern right now is how do I replicate the parameter collection? An alternative solution I've come to as well is to use a dynamic material instance with post process effect and replicate that instead
Since it would be very disruptive if players could somehow cheat and become client side authoratitive with this, I need some advice with this 🙂
Really the only thing I need to replicate is the lerp value, but I was wondering if there was anything else I would need to consider
It won't matter. If you're sending the location information of players all the time, then someone will likely come up with some way to see through walls anyway.
The only true way around this is to have something that ensures that only actors that should be on screen for a client are actually being replicated to that client. Adding something that allows players to see through walls would likely mean needing to include any actors that are within the camera fustrum up to a certain range away to that list of actors as well during the duration of that ability.
Then it wouldn't matter if a client changes the value client side as they wouldn't be able to see other players that aren't being replicated to them.
The way I'm doing it by gameplay cue, essentially an actor that gets spawned in when the ability starts and ends with the gameplay effect. It is not persistant and that is what is being used to draw to the custom depth
I was asking more about how to replicate this effectively and without losing security
Or authority over the ability
As I'm saying, you're losing authority from the get go as Unreal normally just replicates any actors within relevancy range. This means anyone could piece together a way to know the location of anyone client side anyway, regardless of your ability.
The only secure way is to not replicate all actors all the time and only replicate actors within the frustum that they can actually see (ie their mesh is visible on screen) up to a certain distance away. Your ability would then add all actors to be replicated that are within the camera frustum up to a certain distance away, regardless if they are visible to the player or not. So even if someone does change the value client side, they wouldn't see anything additional beyond what they already can see. There's the authority of it.
Just messing around in a tutorial. When using Printf(TEXT("Client %d: OnRep_ReplicatedVar"), GPlayInEditorID)); I am only getting "Client 0: ...." showing. It is not showing the Client ID number. Am I missing something? Sorry newb here lol
It is obviously working, but just not getting the ID sent across 😦
Try PlayerController()->GetLocalPlayer()->GetControllerId()
Has anyone integrated bullet for deterministic networked physics? How tough was it?
Just saw this. I will tomorrow when back at it. Ty
Hi guys, the previous repNotify works really well in PlayerState but I couldn't figure it out how to do it in GameState in the latter. Can someone help me?
There is no good means to get the local player controller from the gamestate.
Perhaps work it the other way by having an event dispatcher in the Game State that you call in the OnRep on the gamestate.
Your UI then would just need to bind to the event dispatcher and do whatever is needed when the OnRep has occured.
Thanks Datura! I'll try.
Is it like this?
Yeah that should work. It's not great to have the cast value being pulled across to the other event, but it should still work ok in this situation.
So what is the best practice in this situation? Can you enlight me T_T
Promote the gamestate cast to GS_TestOne to a variable and access that variable in the new event, or, get the gamestate and cast again in the new event.
Hmmm this seems to add the DisplayBoard twice. Any idea why?
Should I DM you to explain thoroughly?
It's likely because you're doing it on begin play of player controller and I'm guessing you're doing listen server?
I'm playing as a client.
Actually, none of what you have here really relates to displaying the board twice. No nodes dealing with visibility or constructing the widget and adding to viewport.
There should only be two of these.
All that is happening based on what I see is that when the OnRep gets triggered, it'll call the event, loop through your DisplayBoard array, and call that interface for each item in your array.
This seems to update twice, while I only call in once here.
Still not clear. The OnRep should only get fired once if you've set the variable once, which would only trigger the event dispatcher once for each client, which should technically only trigger the event dispatcher bind on each client once.
Additionally since you're doing this bind on begin play of the controller, you may want to gate the bind behind a "IsLocallyControlled" check to ensure that you're only attempting to update UI on the client that owns the player controller and not the server. You're probably getting a few errors in your log right now that pop up every time the OnRep is triggered.
@hard violet ☝️
I'll try to figure it out later. One question, if I want to add a timer for each player's turn, where should I make that event? on GameState and call it later in GameMode or just in GameMode?
Hey,
I try to trag a ragdoll body in multiplayer. However it crashes after a while with the following log.
Any ideas why?
anyone knows why Pitch Control Rotation Isn't replicated by default while the Yaw is, I don't see my character looking up or down from the other player window
Probably because there isnt an easy way to generalize that.
Pitch can be different depending on the type of game you are making.
First Person vs Third Person.
For example.
where Is it disabled, or should I make It's own Replication code?
You are likely overflowing the reliable buffer or something. Seeing as you are calling a Reliable Multicast RPC on Tick. Do not do that.
Its not "disabled" it just doesnt exist.
You need to replicate it yourself.
ok thanks man
Though it could exist in UE5. I dont use UE5.
@silver pendant Actually looking at it now
There is RemoteViewPitch in APawn
Its replicated
If you call GetBaseAimRotation it will return it for you
So it does exist.
Just in a confusing spot.
yeah I thought It's a check box or something I can just trigger
I wanted it in blueprint
but it's ok
I found that
but not the other one
What other one?
removeviwepitch
GetBaseAimRotation is that
It contains the Pitch Yaw and Roll of the ControlRotation from the Server
It's just a get function
🤦♂️
When clients download UWorld from server, does it mean that all assets used on the level are also downloaded from the server?
a client doesn't download the UWorld though?
I think clients load the UWorld from server.
well that's a completely incorrect assumption
there is no transfer of the map itself
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
this is explaining netmodes and does not say anything close to what you're saying
actors replicate through actor channels whether they're level placed or spawned at runtime
if a server somehow had a newer version of a map, the client wouldn't know of it.
Quoted from the video above from 2:02:
... As we saw in a previous video, when you start up your game, you get a
UGameInstanceobject that is tied to the lifetime of the process, and then the game browses to a URL - either a server address or a map name. That causes the game to LOAD a map, which gives it a World, and the World's net mode will differ depending on how your game instance has started up. ...
From where does the client load the map?
The disk local to you
For a standalone game, the game certainly loads the map locally via a map name.
But for multiplayer games, do they also load the map locally? If yes, what is the purpose of browsing to a server address?
Maps are cooked into the game build
The purpose of browsing to an IP is to actually make the connection. The server then tells you to travel to the map, which is loaded off the local disk
OK. Thank you. Back to my question several days ago.
A non-replicated actor is placed on the level at design time. In the client machine I get the following logs:
Network Mode: Client
Local Role : ROLE_None
Remote Role : ROLE_Authority
Replicates: False
A non-replicated actor is spawned at runtime. In the client machine I get the following logs:
Network Mode: Client
Local Role : ROLE_Authority
Remote Role : ROLE_None
Replicates: False
If we compare it with the previous result (the case in which the actor placed on the level at design time), the roles are just swapped.
From these results I made a hypothesis that the map was probably downloaded from the server as the authority refers to the remote machine.
Authority doesn't refer to the "remote machine"... Remote role refers to the remote machine
That was a bit of a stretch from roles and net modes. Clientside spawned actors at runtime does result in the local role being ROLE_Authority
Network Mode: Client
Local Role : ROLE_None
Remote Role : ROLE_Authority ===> This authority refers to the remote machine.
Replicates: False
That is probably just trying to imply that the client doesn't own the actor.
Unlike a hud actor, which is entirely client owned.
Even if it's not replicated, that actor from the map still exists on the server and the client and the client has no "authority" over it.
OK. But when the non-replicated actor placed on the level at design time why the roles must be swapped?
Local role none seems a bit off, though.
That was just explained to you
The actors exists on both server and clients and clients has no "authority" over it. Why does server has authority over it? This convention seems to be counter-intuitive as the map is also loaded locally. 🙂
I am trying to log it from the server machine. What will be the result.
Because it's the server and unreal is a server authoritative engine?
...So many corrections...
Log from server side:
Network Mode: Listen Server or Dedicated Server
Local Role : ROLE_Authority
Remote Role : ROLE_None
Replicates: False
As expected.
Hello, is it possible to get world opening arguments from BPs? If I do open MapName?something other arguments, I'd like to retrieve the whole string
Sorry to tag onto the message chain from earlier, is there a way for a server to load in a map that is a variant to the cooked map? I would love to be able to provide a level editor of sorts with my game but if everything will need to be a replicated actor in order for it to actually work then it might not be feasible
Where is the toggle to simulate a dedicated server in PIE?
whats the proper way to set values for abilities along with cmc movement, say for example im ultimating and my ultimate moves me with my custom cmc movement but i also wanna set a bool that says "isUltimating", do i just send an RPC for that variable or can i just set that value to true trough the cmc like "getChar()->isUltimating=true" and it will set it in the server because the cmc exists in both places?
Where it says Net Mode in the drop down for PIE settings, select Play As Client
Are you using GAS?
nop
is there a good way to replicate data in a struct? i understand i cant replicate a struct but i dont want to make a new uobject and try to replicate that because it sounds like a bad time. this is what i have so far.
the answer is remove Replicated from the uproperties and it works fine
is it normal when trying to read a property of an object that exists in my level to not get it
Im trying to read the playerStart rotation using get all actors from class, but rotation comes back as 0
I do get the actor, the position is there, but the rotation is reset somehow.
Is this not a perfect time to be using FFastArraySerializer, it's great for inventories with replicated UObjects, Lyra has an example of this exact use case.
ill look into this thanks
There's some nice functions it includes for client side events (PreReplicatedRemove, PostReplicatedAdd and PostReplicatedChanged) when items are added, removed or changed too
On a coop game would you make a replicated client side inventory or host controlled inventory?
i have a replicated var that belongs to a character that i set to true and false in the CMC but for some reason the value is not replicating?
The way unreal works and the way you should design your multiplayer code is that the server is the authority. The client can request for things to happen (like removing an item from the inventory or interacting with stuff in the world) but the server should make sure that the player can perform these actions. The common saying is "don't trust the client"
Yes of course, that I understand. It was more an architecture matter, I open my inventory on a client should the client has his own representation of his inventory or ask the host for what inventory he has. More stress on the server for sure
Hi, quick question.. when doing checks to see if an action can/should be completed, should I do the checks when the player is pressing the input key itself or let the input call the event and have the event do the checks? or does it not matter either way as long as the checks are done before the action is executed?
Hello, can someone confirm whether the behavior I get is correct. So, I have a player state BP that has a bool bIsReady with RepNotify which replication condition is set to None, and anytime I change its value from client the OnRep function is called only there, i.e. not server-side. Since PS are owned by the clients, I would expect any modification of a RepNotify property to fire OnRep function on every machine. Are my expectations wrong? If so, how should I modify the value client-side, through a server RPC perhaps?
Your expectations are as wrong as they can be
Replication will only, ever work Server to Client
The only thing Client to Server are ServerRPCs
And those have to be called inside Client-owned Actors, such as a the PlayerState
Oh, thank you, alright, I'll use a server RPC then 😄
The OnRep only calls cause OnReps in BPs are smokes and mirrors
They are actually OnPropertyChanged callbacks
In C++ you wouldn't have that
Also, I have another problem, unrelated to the previous one. I need to know whether clients are travelling to some new map, or being disconnected from the server because it destroyed the world without any seamless travel. Do you know how I can detect the last case?
I need to know that client-side obviously
GameModes Logout function for example?
Ah
EndPlay of their PlayerController?
GameInstance also has callbacks for NetworkFailure and TravelFailure iirc
Oh, yeah, I remember seeing some function that returned an enum with all these things, but forgot which one. Thank you again 😄
Would it be the RemovedFromWorld case?
For example yeah
Alright, thanks
hey , i have this problem that i havent found much info about it , how do i keep score through a series of levels in a multiplayer game ? (using blueprints)
-(i read that using Save To slot isnt good implementation because players can easily cheat )
goal is to have players collect credit in the side levels , and get the total credit back to the main level
Dont worry soo much about cheating imo, if they want to cheat in your game they can do it anyway. Just do server validation for important things like checking if the score gain is abmormal.
okay so , i dont have to worry about the score loading up the same for everyone else ?
or this happens just because im using same pc and same saved file ?
I dont know the context
If every machine gonna have their own .sav then test it outside pie imo
Could do something with seamless travelling, have a component on the game mode or player controller that keeps track of each score and copy over the value every time you transition to a new map?
You'll be quite limited in what you can do with BP and multiplayer btw, a lot of the more useful functionality is exclusively in C++
Would doing this to replicate camera rotation cause lag for the owning client?
You could instead set a replicated camera rotator variable and have the client set their camera to that value in a rep notify
If it is being called every frame, then it will most definitely will cause lag or some other issue. If it is reliable then it will likely cause lag, if it is unreliable then it might cause jumping between different rotations
You send a value to the server, then it goes back right at you.
Translate thst to movement is like u are moving in one direction. This frame at 0,1 and u send thst to server. Nexts frame u will be at 0,2, and then the next frame the server comes back to you with your replicated variable so u are rubber banded to 0,1
How can I let the client keep their own control rotation value so they don't need to rely on the server, but still replicate for other clients so they can see the camera movement?
Keep the actual control rotation client side and just send it to the Server to replicate to all clients
camera rotation isn't something that really needs authority so keep the logic to control the camera client side
and then periodically (figure the best interval) send that value to server and distribute it to all clients
Hey guys, I've got a really weird issue with my character Aim Replication. All the details are within the video. Any help would be appreciated. Please and thank you
Question about seamless travel. If want to keep my pawn, I added him the getseamlesstravel actor list, correct?
Hey folks.
I have a simple component inheriting from USceneComponent and to implement position replication smoothed on the client.
But the default replication of USceneComponent fights mine. Default replication of USceneComponent is really jittery.
Is there any way I can disable it, without changing the USceneComponent source?
I searched in the server and I didnt find a solution, although @chrome bay posted this:
"You really should avoid replicating USceneComponent derivatives if you can"
Why is that? If so, where would I put my component replication code? In the actor?
Thanks in advance!
Yes, what are you trying to do?
i want to replicate the camera pitch to every client but the owner of that camera
already done for you
BaseAimRotation in pawn
Read on conditional property replication. You use a mixture of PreReplication and DOREPLIFETIME_ACTIVE_OVERRIDE to do that.
That will do its best to keep a reference to the pawn, but if the engine destroys it somewhere else, which it does when for example the PlayerController gets destroyed, then you want to care of that as well. So for example, you override a function called Destroyed that refers to the PlayerController and choose not to despawn the pawn
hey, so I read the documentation page and I dont see how that will help me.
In my derived component, I dont have visibility of the replicated properties of the base type USceneComponent, they are private.
If I did had visibility, I guess I could just DISABLE_REPLICATED_PROPERTY.
I tried not calling Super::GetLifetimeReplicatedProps(OutLifetimeProps) from my component, but in that case my own replicated properties wont replicate.
Although, is it a root component?
no
Disabling the default replication on RelativeLocation, RelativeRotation, etc, is your best bet
though any changes to the replicated position takes effect in USceneComponent::PostRepNotifies(), which is virtual
so you could completely change that behaviour
OnRep_Transform sets bNetUpdateTransform to true
ok, with that I think I can "hide" the behavior, but network data is still being sent from server to client if I am not mistaken. So I am wasting bandwidth.
ya, I am losing hope there is a nice way to solve this.
might as well just move all the code to the Actor, disable replication in the child USceneComponents, and control them from the actor.
I would just hook in and override the bit that does the actual moving of the thing
you still want to replicate movement, just smooth it out
you can do that there
This is nullptr for client, how do I make it not
is this in the playercontroller?
probably calling it too early
yeah it's in begin play
I put it in OnPossess and still doesn't seem to exist, maybe I set it in the character class?
Called when the Pawn is being restarted (usually by being possessed by a Controller).
I think in PlayerController the function you want to override is AcknowledgePossession() for clients.
My aim replication isnt working, one player can control both head rotations on their respective windows. I followed a tutorial and everything. How would I fix this?
Is it dumb to only replicate an inventory content to the owner since other clients can't do anything with the inventory data ?
That'd be the smart thing to do.
Ok thank you !
show code
heres the system in the character bp. then the called variable in the anim bp.
all rotation variables are replicated as well
show more of the left one
show how you're getting the character
@dark edge
the character blueprint calls it from the look input, the anim bp calls it from the event update anim
and the last shows the transform plug in
heres a print string showing the pitch values for both players
Hey yall
im new to networking and trying to understand communication between server and clients
trying to use Rep Notify and running into an issue , hopefully someone could shed some light on it
When Box collision overlap occurs , It calls the event "Player Claimed Zone" successfully , which then sets the Bool "Zone Claimed" to true , This then calls the OnRep function "OnRep_ZoneClaimed" for that bool On both the servers and client successfully.
The Issue im running into is that i want to call the function "Player Claimed Zone" via a key input instead of overlap . When i call that function via an Input Key , it no longer successfully gets called on the client and server , it only gets called on the client
why is this happening? Why is the function working perfectly fine when triggered via overlap but does not called when triggered via key input?
.
(Ovelap Event) 👇
(Rep Notify Funtion called "OnRep_ZoneClaimed) 👇
(Calling the function via a key input) 👇
Overlaps can be detected on clients and on the server, so that means each client as well as the server is going to detect the overlap, and attempt to loop through all the players and do the rest of what you have there. Assuming this isn't an actor that a player would possess or own, you shouldn't be sending a server RPC here either as it's something that can be done on just the server.
First, have the overlap use a "Has Authority" node before everything. This will ensure that the code is only being executed on the server.
Second, you shouldn't need to loop through all the players and checking if the actor is the one overlapping. All that is required is to check if the overlapping actor is of the class of the player - assuming you have a specific class you use for players and players alone, you could cast "other actor" on the overlap to your player character's class, if the cast succeeds, then you can set the values as you desire.
Third, again, remove the server RPC. Just set the bool after this point as you're already running on the authority.
Awesome , ty! . trying this now .
i knew the loop iwas doing was weird , i was just trying to figure out a way to find the player without casting . But i guess thats not needed
Hello, sometimes when I travel (using UEngine::Browse) to the destination map I get a connection Timeout and return to the default map during multiplayer session. How to solve this is or there any solution related to this?
Thanks for the response! , Ive changed to what i believe is what you had noted.
And to confirm what you had said , this code is being written on an actor not owned by the player
The actor in question is set to replicate within class defaults
But the issue is not resolved
When pressing the key 1 and setting the Rep Notify variable "Zone Claimed" on the server , it executes the OnRep function on both server and client
But When pressing the key 1 on the Client , it now executes OnRep function on neither , Where as before it executed on only the client
wait i think im just casting wrong , looking into how to just cast to a class rather than a specific instance of one
Should be like this.
The enable input won't work correctly as enabling input is only for the local client (or the listen server host)
This is going to change the Bool on overlap tho right?
I need to change that rep notify bool via an input
Well you can't do it through this actor. Inputs are local only and you can't RPC through unowned actors.
Additionally replicated variables are only set by the server, not clients.
Clients can change the value, but only locally.
Thank you so much!! , going to read over what you said do some more research and keep working on this . ( This is my 1st online project )
Pointing out that inputs are local only , is def helping me get pointed in right direction
This helped as well , i was casting to a specific instance of the playerBP instead of grabbing the instance that was just overlapped
Hey quick question. Is there a name for transferring in and out of game levels on a multiplayer session?
what is it known as ^
Travelling?
There are 2 types of travelling in UE.
Hard Travel
Seamless Travel
Hard Travel is when you connect to a Server for the first time.
Seamless Travel is when you transition from one level to the next on the same Server.
ok perfect is one better than the other when it comes to multiplayer level transitions?
They have different purposes
Its not so much about which is "better"
Are there any good resources on the Replication graph, for UE 4.26? The UE doc seems insufficient: https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/ReplicationGraph/
I am watching this live stream: https://www.youtube.com/watch?v=CDnNAAzgltw but an article to read would be great.
Working on a multiplayer game? Are there many players in-game together? On this livestream, our networking team will demonstrate 4.20's new Replication Graph Plugin and the server optimizations that were implemented for Fortnite Battle Royale.
NEWS
Unreal Engine Drives Monster Puppet for The Mill and Monster.com
https://www.unrealengine.com/...
hello good morning guys
scripted an ai bot for a multiplayer client side bot works fine but for server bot doesnt aim an shoots itself please help
Been reading around on networking stuff as I have the vanilla build from the EG launcher. So as I've understood this, even if you only want people to create sessions and not have dedicated servers for your online game, you still need to build the engine from source, am I correct? Vanilla build is technically strictly for SP games?
Ohhh, I see! That will save me further headache I suppose 😁 so is there a limit as to how many clients you can have connected to a session? Or does it just depend on the hosts connection?
Ah yea ofc, cheers!
Hello !
As part of setting up an experience on Unreal 5,
I would like to implement integrated screen sharing in the world in non-local multiplayer.
I found a few plugins that allow screen sharing but none are replicated.
Does anyone know of a solution in blueprint or with a plugin?
Or should I look into C++ and if so, what would be the best way to do it?
How to have a begin play on playerstate only fire on one client "the real owner" if I may say?
I would think from the playercontroller since it own the client
Yes yes but my problem is the spawning Order GM -> PC > Playerstate ... so what I do a delay inside the PC ? I hate that 😢
You should avoid delay, it doesn't solve, in fact, its quite the opposite 😬
MMh, perhaps, you can try with GetOwner or PawnPrivate in playerState
except If I do a full "Loading player into world...getting his inventory...async loading shit then saying ... small delay then "Hey I Just connected bros"
what I know Is that OnPostLogin should not be used (well only to store PCs ref)
Hey Guys
I was working with FFastArraySerializer for replicating AddInstance on ISMComponent and it does work. Client can see Instanced Static mesh component.
However, I have another value TArray <FTileStruct> GridTiles; in my FFastArraySerializer struct which seems not being replicated for some reason..
void FPTGridSerializer::PostReplicatedAdd(const FPTGridArraySerializer& InArraySerializer)
{
GridTiles.Add(Tile);
ISMComponent->AddInstance(Tile.TileWorldLocation, true);
}
Below is a function from a AClass
//Some stuff before
InstancedTiles.GridTiles.Add(InstancedTiles.Tile);
ISMComponent->AddInstance(InstancedTiles.Tile.TileWorldLocation, true);
ReplicatedInstancedTiles.MarkItemDirty(ReplicatedInstancedTiles.Items.Add_GetRef(InstancedTiles));
My ISMComponent is correctly replicated but not my GridTiles array.
I tried to fill and replicated an array from my AClass, it is correctly replicated but I would like to keep it with FFastArraySerializer because I can have a lot of values
Do you know if FFastArraySerializer work with Array? Is there a step missing? I have no idea where to look
How do meshes get replicated, through path?
In my FFastArraySerializer struct, I have an ISMComponent
TObjectPtr<UInstancedStaticMeshComponent> ISMComponent;```
Then in my function from my AClass which has an ISMComponent set, I pass like this:
`InstancedTiles.ISMComponent = ISMComponent;`
And it does the work
so you have a struct that has your component and an array of tiles?
exact!
struct FPTGridSerializer : public FFastArraySerializerItem
{
GENERATED_USTRUCT_BODY()
public:
// ISM Component for the grid
UPROPERTY()
TObjectPtr<UInstancedStaticMeshComponent> ISMComponent;
//Tile
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
FTileStruct Tile;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
TArray <FTileStruct> GridTiles;
so why do you call GridTiles.Add in post replicate? wouldn't you add your entry on the server and then just mark the item dirty?
When I set a breakpoint there, it pass there for each generated instanced static mesh
I though it would replicated the array for client there, like it did for the ISMComponent
in theory it should.
How ever, if it doesn't, my solution would be to wrap the array with a struct and write a simple net serialize function for it
👌
Okay, by wrapping, if I understand correctly, I should create another FStruct and move my TArray <FTileStruct> GridTiles inside?
exactly
A simple struct, not with FFastArray stuff ?
not sure if nested fast array works^^' / it worth it
I'd start with just normal struct serialization without delta, just to check if this is the issue
got it, thank you! I'll dig in now 😄
Thanks, I didn't know, I will update!
For folks familiar with Unreal Tournament's implementation of Projectile Prediction and forward-ticking the projectile on the server: I'm having trouble understanding why the server forward-ticks the replicated projectile by 1/2 * ping when its spawned, instead of the full ping value.
I'm drawing it out in a table where I'm matching server states to client states ovewr the time interval, and in this scenario, it seems like the fake client projectile has to sync "backwards" (or at least, there exists 1 replication update where the projectile hovers in place and doesn't move forward) once it receives the replicated one to replace it
ahhhhhh i think I see in BeginPlay() that the projectile that's spawned on client (from replication?) is invoking CatchupTick for another 1/2 * ping, so that might be the missing 1/2 i was thinking of...
if my understanding of this is totally off though please correct me 😅
Are there any disadvantages to depending on TArray replication? I am assuming order is maintained. I can't see the array getting bigger than, say, 500 members or so.
does a moba / rts use net-relevancy for sparsely spread units?
- assume no fog of war.
- assume a player can instantly move their camera to a location on a minimap and expect to see the actors there instantly
because ping is the trip time in both directions
I have a actor in my level that when interacted with should send an integer to the server via a bpi, how could I do that since my client isnt the owning actor and thus can "tell" the server to change a var
- Interacting actor calls a server RPC with the thing it wants to interact with
- Server validates that it is legal and then does the logic
Pretty much how any interaction type thing works honestly.
Soooo I cast to the actor that called the interact event and then send the rpc?
No?
@sweet marten
The actor that is doing the interaction (which is going to be the player, because they are the only external thing to be able to influence things) will just call a server RPC on themselves
2nd pic is from the object u r interacting
That way also works
alr imma try and see how to make it work
- Player calls server interact
- Server Interact method is a server RPC that just calls "Interact" on the object that was passed through the server interact event.
That's it
Replace the method names with w/e fits your game
What's the equivalent to server_validate in bp? Is there even such thing
Not that I'm aware of
And people have largely moved away from the _validate method from what I've heard
0o I c
I cant seem to do it this way, since the RPC is not in my character bp but rather in the gamestate
You want to run rpc on things you own. Your character or your controller
@sweet marten send to server via your character or controller. Then server can change the value in game state. If the value changed is set to replicate, the client will eventually be updated
First screenshot is my BaseCharacter, after that is my gamestate and then finally the actor which is getting interacted with
What am I doing wrong here?
Don't touch Ur game state like that
Have a server rpc in your character. Call it serversettheint. Have a parametre of int, that you want to send. Here you can get a ref to your game state and set the replicated in in game state ( at this point its the server anyway )
When Ur actor in the level is interacted, switch has authority. If remote, get interacting character, call the serversenttheint
Tldr only let your server change the value in gamestate. Client can use server rpc on what they own, which then tell the server to set a value in the game state
That's all I can say, can't hand hold you no more than this.
so basically like this?
No
I just checked and it works (not for the server rn obv) but client works
Anyway what did I do wrong?
Hard to say, what's doing what. But you probably set the value locally as the client instead telling the server to set the new replicated value
Heres where that actors bpi goes to if that helps in any way
Hey guys,
I have an architecture question.
Calling a DropItem function (for example) on the server will help to reduce cheating when on a dedicated server.
But is it the same case on a Listen Server?
Because on a Listen Server the "Server" is like a single player - player.
So he can still cheat basically.
As I understand it, creating an Inventory on the owning client would have no difference between create it using the client/server RPCs because they both could cheat that way or another (as long it's not a dedicated server).
A server RPC call is only good when you want to replicate something to other players in that case.
Am I right? 🤔
trying to spawn a projectile in multiplayer game, client and server both see server projectiles but server doesn't see clients, clients call spawning the projectile on a server rpc though
@brisk swift show code
This is in a gameplay ability class https://pastebin.com/HhJp1N3Q
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Right, but in the clients case, by the time they've received the replicated projectile, ping amount of time has passed due to a complete round-trip. So the server projectiles we're receiving has only traveled approx half the distance of the fake client projectile so far?
And furthermore, when the server receives the projectile request and handles prediction forward-ticking, it's been ping amount of time since the server was in the same world state that the instigating client was in
no
it has traveled the full distance
that the client has
msot likely
since we cant prove it
due to relativity smthn smthn
client sends message, by the time server receives message it has traveled the same amount of time as half ping
so server forward ticks
thats it
same reason we cant prove light moves same speed in all directions
Sorry im still a bit hazy - when the server sends back the real projectile, the client has traveled another half ping of distance tho right? So now it's ahead
u cant rly do that unless ur going to forward tick the projectile on the client
Unless this is resolved by the additional forward tick in BeginPlay that gets invoked on client receiving a rep projectile
whcih at that point seems kinda pointless
so u just keep the fake
since it should be fairly deterministic
But then in this case since the fake projectile is synced to rep proj, it moves backwards for one tick?
u shouldnt need to move it backwards at all?
So if proj is moving at 1000 units/sec and ping is 100ms:
- Client shoots at t=0
- Server receives at t=0.05
- Server forward ticks at t=0.05 to 50units
- Client fake proj is at 50units at t=0.05
- Client receives rep proj at t=0.1
- Client fake proj is now at 100units, but the authority proj it's receiving from server is at 50
- And fake proj is synced to rep one, so it moves 50 back?
What am I misunderstanding here
You want to see your projectile rubber banded?
The only thing I can think of is that the Client also forward-ticks the received rep projectile by another 1/2 ping after receiving from server, which I thiiiiink is happening in BeginPlay
No just trying to understand how it doesn't rubberband in UT
Even if the tick group is set up to before physics I think it's still mismatched in the above example
u dont need to move the clients projectile at all
I don't have all the exact reasonings. But from what I've seen people say is because it kicks people if it returns false. And sometimes it may not necessarily be an "accurate" reason to return false.
So it's been getting handled manually.
Yeah but dont u want to kick ppl when they r being naughty?
If damage is over 99999 gtfo
its not alwayts they are being naughty
Mayhaps. But it's the second part that is the real takeaway
I see
it would be better if it would just refject the rpc
Why not?
cause the whole point of the forward ticking is to compensate for the clients time to send the rpc, if its fairly deterministic they should be in the same state
@eternal canyon AFAIK Validate is run prior to the Implementation, so you dont necessarily need to return false if you find that validation is incorrect.
bonk
I might be wrong but I don't believe that to be the case on their implementation, they're forcefully moving the client projectile to be in sync with the replicated one once it arrives as a one-time operation
yea tho it would be cleaner to have it where u can return false without kicking the player lol and maybe have a separate out param for kicking
tho that would require a lot of changes i would think lol in their code
Or an enum that defines the behavior
yep
It would actually be nice if validate also passed through the inputs as reference so they can be modified before being passed through to the implementation
So you can correct them to some degree
since im pretty sure in fortnite i would think they still ahve remnants from when validate was required
It does. It just interpolated, so you don't see it. And under normal condtions (10-40ms) ping the difference is not that much
I haven't done it but I think the ideal projectile is probably something that's fairly deterministic everywhere and uses clientside hit reg with serverside sanity checks
it entirely depends on how fast projectile is moving, if it is physics sim, and how much do you care about server protections
Isn't the point of the forward-ticking on the server to prevent this?
u shouldnt need client side hit reg
AFAIK once you've forward-ticked the replicated projectile and synced the client one to it there's no need for clientside hit reg
for that as once server syncs it should just have the determinism take hold
well yeah but you have weird velocity behaveior
yea tho rly it shouldnt matter
if ur projectiles are just a straight line
What im talking about is the projectile flies the exact same everywhere
just at different times
What's the function that is essentially "IsLocallyOwned" ie. It's a replicated actor and I'm the owner
there's is locally controlled but that's slightly different
you can just get owner on the thing
yea once you've got deterministic projectile + server is in sync w/ the dummy proj then there's no need for client to own any logic (maybe just cosmetic stuff for responsiveness)
specifically this right here wouldn't rubberband it backwards? https://github.com/EpicGames/UnrealTournament/blob/clean-master/UnrealTournament/Source/UnrealTournament/Private/UTProjectile.cpp#L390-L394
side-note: if possible, i'd love to chat w/ folks that are familiar with the UT implementation in VC today evening and walk through the code flow
instead of rubberbanding backwards you can just lerp the blend
so it just goes forward less fast
during the lerp
So I guess my original question is why do that instead of forward ticking the received replicated projectile on client to account for rep time (which might actually be what happens in BeginPlay)
(which is equivalent to a total forward ticked time of ping for the instance of rep proj on that instigator client, but may vary on other clients based on their ping and is only half that value on server)
forward tick over time or instantly?
instantly
At any given moment, do you want the client to see the projectile in the place it expects it to be, the place the server has it, or the place the server had it ping/2 ago?
well potentially with the atomic forward-tick on server and then per-client forward-tick on receiving the replicated projectile, those should all converge
err, the first 2 should converge
the clients character is ahead of the server by ping/2, do you want their bullets to also be ahead (locally simulated), be in line with the server (server simulated + some adjustment), or be behind the server (just naive replication)
someone somewhere has to see a projectile diverge from its usual local flight
for them to line up at any given moment in time
or not, and just let the client say "I hit this guy" and the server say "yeah it looks like you could have"
in line with server is what im trying to accomplish, but by having the server catch-up (so the client's locally simulated projectile should be truth and server aligns with it, assuming we're within some ping threshold thats not too crazy)
I'd have to think about how that'd interact with moving pawns
End of the day, I think a client hitting another on their screen should be a hit, as it feels way worse to hit but not actuallt then to be hit but not actually from your point of view
with predicted movement there's always going to be 3 views of the world at any given time so everyone can't be correct
yea where it gets funky is that the world state itself fundamentally differs from when the client fires vs when the server receives the request, and im trying to avoid a solution involving rewinding
agreed
I'm glad my project is just saying no prediction lol
server simulates, you see it ping/2 time later, end of story
It's a combat vehicle building game though so not super twitchy
would never work for Counter Strike
honestly i dont need this granularity of prediction and physics simulation but im trying to properly grapple with it conceptually
I wonder what most shooters use nowadays
I think it's some variant of clientside hit reg with serverside sanity chekcs but I'm not sure
if you have the compute to afford rewind and replaying the physics sim, thats probably most effective
Since every client is in the future vs other clients on their own screen you can probably just record state and do your rewind that way.
the movement a shooter saw in the pawn they hit actually happened, just not at the same time as the shot
so i think the solution i proposed somewhere earlier should solve this, barring any issues im totally overlooking:
(all this assumes within some ping threshold)
- client shoots, fake projectile spawned
- server receives request
- server spawns a projectile, forward-ticks by 1/2 ping, replicates it out to everyone
- this is where its kinda murky because someone who was in the path of projectile on client may have already moved out of the way on server, and server won't know this if its less than the distance traveled by that 1/2 ping forward tick
- that's the only case for clientside reporting here i can think of, but we'd have to reconcile on server with target's cached movement history
- this is where its kinda murky because someone who was in the path of projectile on client may have already moved out of the way on server, and server won't know this if its less than the distance traveled by that 1/2 ping forward tick
- original client receives the replicated projectile, and forward-ticks that one by 1/2 ping to account for replication time
- this should line up with their fake projectile at this point -- so we can disable the fake projectile and let the replicated one take over, no blending required
- a different client that receives the replicated projectile would forward-tick it by 1/2 their own ping, not the instigator's ping to account for their own unique replication time
and honestly can prob do a hitscan linetrace rewind for that 1/2 ping server forward-tick prior to spawning rep projectile
Here's mine:
- Shooter shoots, RPCing the relevent data to server, begins simulating projectile locally
- Server shoots, RPCing the relevent data to clients besides owner, begins simulating projectile locally
- Other clients shoot, simulating projectile locally just for cosmetics. Projectile is flying locally on all relevent machines
LATER - Shooter hits, RPCing the data to server and doing predicted hit effect stuff
- Server gets hit data, sanity checks it and notifies if it wants to override it (rare)
What are you doing for your sanity checks?
Basically check that the hit was along the path of the projecile and close enough to the hit pawn or where it was in the past
Anyone know if it is possible to display wireframe views on PIE client windows?
one of the fucntion keys
forget which
does a moba / rts use net-relevancy for sparsely spread units ( or just bAlwaysRelevant = true;)?
- assume no fog of war.
- assume a player can instantly move their camera to a location on a minimap and expect to see the actors there instantly
Depends on the networking type
wym?
Is there any non-trivial example in which spawning replicated actors on the client is mandatory?
If there is no such example, why didn't EPIC make replicated actors always get spawned only on server and never on client? In this way we no longer need to do net role check if(HasAuthority()) everytime we spawn replicated actors on the server.
Any idea?
Hey quick question: Is it possible to have multiple players on one server but on different game levels? thanks in advance if you know the answer
Yeah it is possible all you have to do is have multiple game sessions
Ah i see is it more ideal to have all the different levels, on one level and just have the player teleport to different areas? (Example: out side dungeon - then goes into dungeon (but really the player is just teleported to another section of the map)
Hey guys - im trying to mod the MenuSystemPro, and cant figure out how to get a level name from session data. Any ideas?
You cant break the data struct, and session info isnt level name specific
Is there a c++ fix? If so, i can certainly do something with that
very usefull info, used google, searched on unreal documentation, nothing, only here I was able to find that info
yeah lol
that was the most recent thing that popped out
If we place a replicated actor on the level, why is there only one actor on each client rather than 2 actors (one is replicated from server and the other one is spawned locally by the client)?
It depends on what "we place" mean
Drag the replicated actors onto the level at design time.
In this case the replicated actors are not conditionally spawned with if(HasAuthority()) check.
The design time is prior to play time, right?
Yes.
Well, the clients are essentially getting a copy of the server world, which has only one actor. If you would spawn the thing on play time, and the code would be executed both server and client sides, you would get two actors client side, and only one server-side
But map is loaded locally by each client rather than downloaded from the server, right?
Yeah, but I think things that are marked as replicated are not spawned client-side, but replicated rather, unlike things that are not usually marked as replicated -- walls, floor, lights
It looks like as if there is if(HasAuthority() executed in the level script running on each machine.
does any one know whats the proper way to do security checks with the CMC, for example, i want to spawn something in the server, so i do a server RPC and in that RPC i can check if my cooldown or my resources or whatever has a valid value in the server, but in the CMC ur just setting the bit flag and its being sent, theres no RPC, so how would i check if my cooldown has a proper value in the server?
Was wondering if anyone here had any insight regarding a replication problem I'm facing. Basically I am making a multiplayer inventory system and am running into the problem of the server not replicating the item array to clients.
I have the inventory as an actor comp, set to replicate of course, with the replicated props code to go along with it. My items are a custom C++ struct (don't know if this can cause replication problems).
Users should modify the inventory via the UI by drag and dropping. When this happens, a Server RPC gets called which modifies the inventory array but that is where it all goes wrong. The modification is good on the server and it shows the correct array information, but on clients it is as if the drag never happened + the UI never updates so it appears as if the slots are empty. To update the UI I am using a multicast delegate broadcast.
This is the replication code I have, variables are set to 'Replicated' of course.
I have this gimmic code in place which could easily be the problem. This is the code I have in the slot widgets OnDrop function:
I cannot call a Server RPC on an actor which isn't controlled by a player so this way I am trying to call the method from the Player actor. The functionality is still the same as before, just a wierd way I found to go around the issue.
So yea that is it, sorry for the long read, hopefully someone sees something here that I am missing, if you need more pictures do tell me
but from what u put there i cant see a problem ur probably gonna have to show more, also keep in mind that UMG doesnt replicate, ur gonna need to pass that RPC through a replicated actor
I have a question about child actor component, Im using it for guns in game, and I attach it to GripPoint socket on the player, and while testing in the standalone/listen server everything works fine but when I tested with client the gun has a large offset (as shown on image) is there any solution to it or what I might miss? Thanks
I am trying to call that rpc on the component owned by a player rather than something else. Im aware that UI doesn't replicate.
I am not using any Player controller though, it is just a default class for me so that might be my issue
if u have a player it must have a PC so it shouldnt be an issue eve nif it is the default class
ive seen people have problems with replicating arrays in here so ur issue is not unusual and i think that if u search enough u will find an answer
some days ago some one had marked the properties inside the struct to replicate and it wasnt replicating because of that
turned out he only need to to mark for replication the array itself
im sorry i cant help more i havent done replicated inventories yet
@severe quiver Are you sure the items aren't updated? Where is the Multicast?
Can you show how you try to update the UI?
what Reliable does?
https://docs.unrealengine.com/5.0/en-US/networking-overview-for-unreal-engine/
Near end, there's Reliability section
In a multiplayer context for let's say an interaction system, would you do traces On both server and client or only client?
I would just let the client trace and report to server with little checks
Client will be ahead of the server anyway. If you have a one second delay, when you trace. What you hit may not be what the server hit
I think this is the same with any other predicted action
If you care about cheating, do it on the server.
If you care about cheating, but want a bit more responsiveness for the client, do it on the client and double check with limits on the server.
You can, e.g., send the Location the Player traced from and then check if that is in a limit of distance between current location and what the client said.
If you don't care about cheating, do it on the client.
it's mostly coop
Then maybe for most of RPC, you can just let client send and tell server to "trust me bro"
Basically this function
This is a multicast delegate of course
I've debugged it and it does fire when it needs to, just the clients have wrong info (the not updated items) and that is why it shows wrongly. All in all the entire problem is that clients don't recieve the correct info about the items array
You do know that you can't expect a Multicast and a replicated Property to replicate together, right?
The Multicast can come in earlier
If you need a callback for Data being replicated you need to use an OnRep
And for Arrays of inventory items you then usually use the FastArraySerializer stuff
The OnRep method saved me now actually, now it works finally
Basically I am still using the server method to do the updates and then in the OnRep I've put my update delegates and it does show correctly
Thanks everyone for pushing me in the correct direction 😄
I want to find a widget in my game world and execute a function in that widget when a session invite is received.
How can I get world from a game instance class?
Apparently I can just call this function without a reference to the world
In what class?
game instance
Yeah that's strange. If it was an actor at least it'd be able to infer the world.
Does it work?
I wonder how tf it picks the world but if it works it works
Hi, when I kill an enemy the client and they drop their weapon the client sees one weapon dropped and another floating in place. ```void ABaseCharacter::Die()
{
EquippedWeapon1->DetachFromActor(FDetachmentTransformRules(EDetachmentRule::KeepWorld, true));
MulticastHandleDeath();
}
void ABaseCharacter::MulticastHandleDeath_Implementation()
{
EquippedWeapon1->WeaponMesh->SetSimulatePhysics(true);
EquippedWeapon1->WeaponMesh->SetEnableGravity(true);
EquippedWeapon1->WeaponMesh->SetCollisionEnabled(ECollisionEnabled::PhysicsOnly);
EquippedWeapon1->WeaponMesh->SetCollisionResponseToChannel(ECC_Pawn, ECR_Ignore);
EquippedWeapon1->WeaponMesh->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Block);
}```