#multiplayer
1 messages · Page 138 of 1
No, the RPC is on the pawn
It sounds like you're calling an RPC that exists on an actor that isn't client owned, which means the RPC definition isn't on the pawn (which would normally be client owned if they're possessing that pawn)
You spawning it on a server instance and assigning a replicated actor to be its owner - is that correct?
I'm not calling the RPC on the item actor, I'm only doing the RPCs on the player pawn
And this RPC is not even displaying your Print String?
From what I can tell it might be because the item selection validation is failing on the client side
Can you provide a screenshot of your call to the RPC? If the pawn is client owned, the RPC should be working regardless of the item validation and giving you the print string.
This is how I'm doing selecting interactables: https://blueprintue.com/blueprint/6xw99qod/
And here's how it does the interaction with the interactable item, basically: https://blueprintue.com/blueprint/rf19ym4p/
The server take key item event just tells the item to do whatever specific business it's supposed to do before presumably destroying itself, which is currently the only thing it does
But the client never gets that far because the interactable selected fails to validate.
I'd make the tick part only happen on the client. The client itself can determine what it wants to interact with without having to tell the server anything, and show anything that it wants to without involvement from the server. This also saves on 60 RPCs per second since you're no longer calling them on tick.
Then your client would need to RPC to the server with a reference to the actor that they want to interact with when you want to actually interact
The server when it receives the RPC can validate if the actor is valid, is close by enough, etc. and if so, perform the interaction as needed.
Well, the tick also handles setting the physics handle target location for picking up and moving physics objects
That's information you could send through the RPC to the server when you want to begin the interaction.
It's also updated with the camera rotation and the player being able to rotate the object after picking it up, but that's something I can only deal with after getting the client to be able to interact at all
But anyway
This is the log warning I'm getting for setting the server interactable: "LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor Celestial_PC_Character_C_1. Function Server Set Interactable will not be processed."
Is that message spammed in your output log?
or is it only maybe a few times and stops?
It spams, presumably because of the second call that clears the reference if nothing is hit
You have more than 1 character in the scene, right?
Tick fires on clients and server. If you have other clients running this tick, then they too are trying to call that RPC and since they don't own that other actor, it fails.
Basically, you should put your "Is Locally Controlled" check at the start of the tick to ensure that only the client that should be doing the traces is doing it and calling the RPCs.
Okay, did that, and it does seem like the server RPC is calling as it should
But the client is still accessing none when trying to interact with anything
holla, am testing character movement
and well the server character can move around but the clients can not.
looking at the outliner I also see that only one Player controller is created and it is also named PlayerController1 not even PlayerController0
Any solution?
and yes I am using enhanced input and setting it up from Virtual void PossessedBy(AController* NewController)
WELP looks like I needed to set the specific variables to replicated to fix that
PossessedBy is server only, use OnControllerChanged or whatever its called
THANK YOU 
Now I just need to figure out why the object physics pick-up functionality isn't working properly but that can wait until later, I need to go to bed
Does anyone know if the connection travel string is encrypted? Like if I were to do:
UGameplayStatics::OpenLevel(Owner->GetWorld(), LevelName, true, "listen?Password=" + Password)
Would password be encrypted over the network?
Don't think so. If you wanted to encrypt, you'd have to encrypt on the client using a public key and decrypt on the server with the private key.
Got it thank you!
Is there any tech on the horizon (maybe something including AI 🤔 ) that would prevent cheating in FPS multiplayer games or at least prevent it more successfully than what we have right now?
Depends on what you mean by cheating.
Any data that is shared with a client means that data can be accessed at any time - so for example, "wall hacks" that allow players to see the locations of other players is something preventable by not sharing that data, but isn't always easy to implement because at some point you need to share that data when it is appropriate so the client knows the right position of that player so it can be simulated on their side without the other player just popping into existence.
Other cheats like making targets more visible by swapping textures around or adding additional light sources in the map can effectively be impossible to prevent against someone willing to fight against whatever systems you have, as again, you're running software on a client machine and that means you don't have authority of what happens on that computer and someone with knowhow can spoof whateer checks you may have. Some anti-cheats try to detect file manipulation, but if you're relying on that machine to advise whether or not the files have been manipulated, then you're out of luck as the person in control of the machine could spoof the report making it appear as if they have valid files. Even if you were to request the client to send the files to the server so the server can validate them that doesn't mean the client has to provide you with the files they're using, just the ones you're expecting to see.
Another avenue of cheats is having to accept inputs from clients, and that means you need to be strict with what you accept from clients, ensuring that what they're asking of the server is actually ok for them to be requesting which results in more processing time used up on the server validating those inputs.
So out of these, there's only 2 things that you can really control - what happens on the server, and what data you share with clients. You can't really trust clients at all.
If you wanted to completely stamp out cheating, then you'd need to never allow a client to directly control the computer that the client software is running on. Effectively, allowing clients to connect to something that gives them back a video signal and it accepts inputs from them and that's it. They won't render or simulate anything on their end, and all they can do is see what is being fed to them, and no "game data" is shared. Tie this together with strict server authoritative coding for their inputs, and you'll have no means for clients to be able to cheat.
As a general answer no, there is no magical technology on the horizon that would significantly prevent cheating more than current methods. "AI" (really, statistical analysis) methods of anti-cheat have already been in use for years - you can find some vague talks from valve about what they've done in the past. But anti-cheat is always an arms race and there is no solution to it because it is both impossible and yet necessary to trust the client.
yes only god can prevent cheating lol
Many thanks for such an exhausting explanation. I didn't expect it, much appreciated
LOL, PUBG tried every anti-cheat solution out there, but still, there are people cheating.
Even in a game where you do not trust the client for anything - let's say chess, where every move can be perfectly server authoritative - you cannot 100% prove that the person actually inputting moves to the game is human unless you have full control over the hardware. And even then you probably can't prove that the input devices are being used by a human. And even if you can you definitely can't prove that someone didn't wire up some servos to a joystick.
Online chess, incidentally, is generally kept fair through the use of statistical analysis - you can actually find some fun bits of drama in the online chess community with explanations of how that kind of analysis works.
But it's not realistic to make even most of those guarantees. You definitely can't make guarantees about someone's PC (you can try with kernel drivers but they're never perfect). Modern consoles are much harder to do any sort of software-based cheating with, but you can't make any guarantees about the input device. Console manufacturers have at various points thought about (or tried, or will try) only allowing "approved" third party hardware but this becomes an accessibility issue and is frankly an unacceptable compromise as a result.
And for realtime games, where it is effectively impossible to be perfectly server authoritative due to latency and the necessity of client prediction, trusting the base hardware is only half the battle.
And you can still have a robot playing with your mouse and keyboard
Yeah, there’s only so much you can do to stop cheating
Sometimes the best anti-cheat is just designing your game to be difficult to cheat at - there are games where automating stuff will only get you so far before someone with good game sense and knowledge of the mechanics makes an absolute fool of you (eg. Sniper bots in TF2, any fighting game)
Policing inputs is actually only a concern for a few genres, pretty much mostly just shooters off the top of my head though.
Policing input types is primarily an issue for shooters that want to segregate matchmaking population based on input type, but policing inputs in general is in theory something ideally you'd be able to do for any game. It would make sending input from cheating software much harder. It's just basically impossible to do.
Well, I'm talking about detecting aimbots and such, but yeah
It's the same thing.
In the ideal scenario anyway.
But that ideal doesn't exist. Hence relying on either "proving" that other software isn't messing with the game, or using statistical models to try to find inputs that obviously don't come from a real person.
Hey everyone, apologies for asking yet another question.
I have it set up so players can connect to a lobby, which then the host/server can change the settings of it and then start the game (wherein they load into the map and the gameplay loop goes through before after the game ends they all go back to the lobby). My question is how would I communicate variables between levels? Like how could I have the variables set [or rather the game settings set] in the lobby, be carried over to the new level? [And potentially vice versa if I wanted to have certain stats tracked/displayed for fun in the lobby like who died first etc]
(also im using advanced sessions, using steam API for the networking socket, and CommonUI as relevant plugins... just in case lol)
Hi, should CredentialsToken be set when logging into Steam using Online Services?
How is my character being checked as locally controlled on BeginPlay() but not at any other time when I check for IsLocallyControlled?
When is SetHealth being called?
Sethealth is being called on the overlap event with a DamagingSphere I have in the world
Are you testing in Standalone mode?
client on dedicated server (mb)
I think your on overlap event is occurring on the server where your character isn't locally controlled. BeginPlay is called on the server and client.
Where do you bind the event?
that's why. your character isn't locally controlled on server
yep lol. but now you know.
Look into RepNotifies. Your health property should be replicated and set only on the server. RepNotify is called on client's when they receive the changed value of the property from the server. Inside the RepNotify you'd want to add your functionality to update the health bar.
It took me an embarassingly long time to realize this... 😅
Just never had to bother I guess
if i have a multicast event on an actor, is there a way to check if the client executing the multicast event is the owner of the actor?
check if the owner is a player, check if that player is local
im doing this in blueprint at the moment. when i have the actor from GetOwner do i use Get Local Role and switch on that?
no
if the owner is intended to be a player controller then cast to controller and call IsLocalController
if the owner is intended to be a pawn then do the same, the function is IsLocallyControlled
oh sweet thanks heaps
what 😭
usually i can accept that i had a key misunderstanding which was messing everything up but idek what could be hte problem now b
Yeah i was thinking beginplay was too early but wasn't sure, and yes it is a client
i had a similar issue with doing stuff in the constructor which was also too early so might just be another case of that
i really doubt it tho since there's no way it could be too early to set th evariables, unreal engine also had a follow along tutorial covering actor components where the maxHealth was put in the constructor
How can I access the data in another actor class from widget.cpp?
I created a widget with user widget inheritance in C++, then connected it to a widget blueprint. I create this widget from another C++ actor class and make it appear on the screen. Everything works fine so far.But how can I access the value in the actor class in which I created the widget, from widget.cpp?
I simply want to display the value in an actor class via the widget.
yes cpp
why I cant trigger interact
interact message work well and I have implement interface both objects but event interact doesnt trigger
and does implement interface does not see the interface on the door
I made it correct but it doesnt work
i dont think thats the correct way to do a sphere trace
you also want to ignore the player character
you also want to make a seperate trace channel
and i dont think this is multiplayer related #blueprint
print what it's hitting
assuming it's hitting anything
that's a single sphere trace so it'll only return one hit, you'll want to do a multi sphere trace and select what to hit.
Hello,
Has anyone ever encountered an issue where Linetrace by channel doesn't properly hit client side? It a trace used for hover information on objects, it works fine on host but not on client
even though the object has collision enabled and is blocking that channel
Show your code
It's very unlikely that it's not working if everything is up to snuff
is it possible to set variables too early in multiplayer, like in BeginPlay?
BeginPlay typically isn't too early but yes it is possible to set them too early. What are you trying to do?
I had this issue yesterday, it was a client on a dedicated server and it was really late at night so i just decided to sleep and continue today but i still had no idea what could be the issue
could the UPROPERTY macros mess with it?
oh sorry for not explaining, it's just trying to set the health and max health variables
I think i'm just gonna try making a new component and slowly working through that
Start and end can't be the same for the sphere to be drawn. Add a 0, 0, 1 vector to the location before plugging into end
No, as long as the client setting the variable updates on the server e.g.
server_sethealth(maxhealth);
Health = maxhealth;
With the first function being a serve rpc
If you're trying to access this on the server at begin play, yes, too early
This is for sure a noob question but I'm new to replication in unreal, I've tried so many tutorials and I'm clearly just doing something wrong. My end goal is to replicate ui across clients/server and I've been trying to figure out where I can put data/functions before I go too far.
In this example I am trying to generate a random number when someone clicks a button and show the same number to everyone
In my level blueprint I have the following (screenshot #1 of blueprint):
- make widget, add on click event to button
- When button is clicked, generate a random number
I am replicating the variable that stores the random number (screenshot #2 of cpp)
When I have the GenRandomNumber blueprint node set to run on server, it only works when you click the button on the server. If you click on the client nothing happens
If I set it to multicast, when you click on the server the client is generating its own random for a split second before the server's value overrides it. When you click on the client then the client just goes yolo and makes its own number and is now deviated from the server (pic 3)
How am I supposed to do this? Seems like there is no combination of run on server/multicast that lets the client ask the server to generate a new number?
oh it seems like the problem is related to ownership? Moving the function the player controller solved the issue... I guess this is why all demos use the player controller, but none of them talk about ownership
How come I can't replicate Break Constraint? I got Set Constrained to replicate.
Generally, avoid calling RPC functions directly from widgets. For example, you might have RPC function in your controller and you might try to trigger it once you click on the button. Even though that function is in the controller, it will fail to replicate. Instead, call a regular function in controller and from there call RPC function.
Definitely agree that trying to have widgets do replication is a bad idea. Originally I was hoping to make some kind of UI subsystem but I'm not sure how subsystems work with ownership and I could just stick with having a separate menucontroller to at least get some separatation
err, what was said isn't true. The thing calling an RPC is irrelevant.
You can call an RPC from literally any code, the RPC has no way to know what is calling it.
If an RPC fails to execute then it has nothing to do with the fact that a widget (or anything else) called it, it has to do with the fact that the RPC wasn't allowed to be called from that game instance in the first place. Moving the call to the controller (or anything else) would not change that.
The actual answer to your question is that a server RPC can only be executed by a client if that client owns the thing it is calling the RPC on. The issue has nothing to do with a widget calling the RPC and everything to do with the RPC being part of the level blueprint which absolutely is not (and should not be) owned by your client
The things your client owns includes its own player controller, the controlled pawn, their own player state, and whatever other actors you have explicitly designated as owned by that player. Also replicated components (and subobjects) belonging to anything mentioned.
Could I do a ROLE_Authority check in my BeginPlay to set the health and maxhealth values on the server or would that be trying to access it too early?
Anybody know about this? #multiplayer message
Nvm I accidentally set my health values as floats 🫠
just gotta fix the health bar ui being weird
🤔
Solved this by creating a function that would set the variables in component, and called that in my charcacter beginplay :3
kind of ignored what it was saying in my blueprint editor and just went with what the outputs were saying, and realized when i was setting the perent for my healthbar, i did the cast wrong for the float value percent
@dusty void That looks like you are calling that during the Character's Constructor?
Or are you creating the Component on BeginPlay?
Either way a strange setup
When using seamless travel what is the best architecture for getting data to the widgets? Sometimes the game state doesnt exist yet or other components like player controller when their construct is called so i cannot even bind the delegates.
@thin stratus Thanks a lot for your Multiplayer Compendium
What Data to what Widgets?
No worries
Do you know any good tutorials for creating different multiplayer gamemodes like tdm and all
Nope, I generally don't have an overview of tutorials, especially not up to date ones, cause I barely ever look those up.
Different Multiplayer GameModes are usually done through a chain of inheritance
AMyGameMode_Base <- AMyGameMode_MainMenu
<- AMyGameMode_Game <- AMyGameMode_Lobby
<- AMyGameMode_Gameplay <- AMyGameMode_Deathmatch
<- AMyGameMode_CaptureTheFlag
Stuff like that
I would suggest coding your GameModes to have optional Teams from the start.
You can't have multiple parents, and coding a Deathmatch and a TeamdeathMatch mode if you later have other GameModes that also have Team vs none Team versions is a pain.
It's easier to just code a Deathmatch GameMode and having the _Gameplay one already support optional Teams vs FFA.
Or just put everyone on their own team
I think most implementations just have a specific team index for FFA. E.g. 255
I actually need a tutorial to completely understand it.
Maybe I can get it in a course
Then I can't help, sorry!
So I have a map and when you click on different locations it takes you to a different game mode.
When I load into this new map they have a new GameMode class with all new components: GameState, PlayerState, playercontroller, etc
When using seamless the UserWidgets in the HUD construct before the data in the playerstate is made causing them to be empty
I got them working with tick looking for the components (playerstate etc) to be valid. But it’s horrible as you can’t seem to debug tick without freezing.
Single process doesn’t seem to work and crashes when I try to run it on 5.2 for net.AllowPIESingleProcess (spelling may be wrong)
Right, let's not call Actors Components, cause that gets pretty confusing
GameMode, GameState, PlayerState and PlayerController are all Actors
Do you use C++ or BP?
In general, with Multiplayer, you need to rely a lot on OnRep functions and Delegates.
And that can sometimes also become a chain of callbacks.
If you need the PlayerState to be valid in your Widget, then you would theoritically need to listen to OnRep_PlayerState in your PlayerController (for Clients) and callback when that is valid.
And in your Widget check if the PlayerState is valid and otherwise wait for the Callback
Ah I see let me try that out
UE has no simple "Everything is ready." event
The only thing you can somewhat rely on is that if BeginPlay calls in any Actor on the Client, the GameState is valid
But that's the extend of it. Actors otherwise can replicate in any order
Ya I noticed I was even trying to count the number of players and their valid actors and then broadcast a build widgets event
Is begin plays timing the same as on construct in widgets?
No, Construct is tied to you adding the Widget to the Viewport
Or to an existing Widget that is already in the Viewport
Got it so if the HUD fires add to view port early the timing could be wrong
BeginPlay is only tied to the GameState replicating the MatchState variable
I guess? Not sure what "early" here is, but if you PlayerController replicates before the PlayerState (which is likely), then the HUD will also exist before the PlayerState
If you create your Widget in the HUD BeginPlay or similar, then it might call Construct with an invalid PlayerState
Makes sense thank you
I do wish this existed
I wunna look a lil bit into this new iris thing... went over the official docs, any more good info out there?
about to just go over the sourcecode a bit
my game is in normal speed when i play with one game window open but 2 windows makes the game time slow
i tried different characters, levels, gamemodes
i checked every setting possible
(in every play mode - standalone, server, client)
Hi i have a widget blueprint i need it to chance a variable in game state when i change the variable on server it works fine but when i change it in client it wont work is there anyone who can help me?
i really need help
i undid it dw, rn my issue is that even tho it works well with updating the health bar correctly, when i output the health & maxhealth values, it all shows up as 0 and the percent is just a ridiculous number
Pretty sure I did smth wrong when i switched the value types to float cause i went back to when i had integers and it does output proper values at least for my health component 🤔
besides the atrocious amount of output logs
i think when i had all integers the only issue when i was doing integers was the percent value was being all weird but the actual health bar was still behaving like i needed it to
yah everything looks fine until i output what the healthbarwidget gets in values after the float casts but the health bar still behaves properly
That's a lot of mixed up random words
What is your client controlling? A Character or a Pawn? Or just a normal Actor?
If it's a Character, then by default the Client will predict, that's how the CharacterMovementComponent (CMC) works.
You can't really change that unless you actively don't possess that Character. But that might cause other issues in the future.
You might want to explain what the Client is fighting the Server for, why you are getting corrections etc.
Im trying to rotate my character on the yaw axis.
To replicate the rotation i wrote this code:
void AOceanityPlayerController::TurnShip(const FInputActionValue& Value)
{
constexpr float Multiplier = 0.5f;
float InputAxisValue = Value.Get<float>() * GetWorld()->DeltaTimeSeconds * 100.f * Multiplier;
if (AccelerateAxisValue != 0)
{
InputAxisValue *= AccelerateAxisValue;
}
const FRotator ActorRotation(GetPawn()->GetActorRotation());
const FRotator NewRotation(ActorRotation.Pitch, ActorRotation.Yaw + InputAxisValue, ActorRotation.Roll);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Yaw: %f"), InputAxisValue));
ReplicateShipRotation(NewRotation);
}
void AOceanityPlayerController::ReplicateShipRotation(const FRotator& NewRotation)
{
if (GetLocalRole() != ROLE_Authority)
{
Server_ReplicateShipRotation(NewRotation);
}
GetPawn()->SetActorRotation(NewRotation);
}
void AOceanityPlayerController::Server_ReplicateShipRotation_Implementation(const FRotator& NewRotation)
{
ReplicateShipRotation(NewRotation);
}
It works fine except that the Client rotates with half the speed than the Server does.
Can someone help me with that?
How can I make that when the game starts, every players spawns at the same time and not that host spawns first and then each client depending on how fast their computer is
The first and easiest step is to use the GameMode's functions and variables
The GameMode has a boolean called "bDelayedStart" iirc
If you set that to true, you can override the ReadyToStartMatch (or so) function in it, and if that returns true it will start
That starting will spawn the DefaultPawnClass
You could, if you know how many players you expect, simply count the PlayerControllers and compare in that Ready function
alright I didnt know that thank you
How do you replicate break constraint function?
You don't, you replicate some other state or event which breaks the constraint
There's no reason to change possession, you can drive a character with navmesh while still possessed by a player controller.
You will probably want to block client input (both client-side to avoid mispredictions and server-side to block the client from overriding what you're doing) but this doesn't require changing out the controller.
I think Kaos's game did something similar with AI
where they have a dummy controller that just accepts orders directly from players
that's more for multiple units though
(rts style)
You don't even need that for this, you can use a path following component on a player controlled character
The hardest part is blocking client input, and that's not hard - it's just not a simple switch.
I just showed up and didn't read any context so ignore me
That's because you don't have a proper path following component
And are potentially having your server-side inputs to the character stomped by client inputs, which again is fixable.
you may find some better results tweaking a lot of the values for how rubberbanding works either globally or per instance depending on context
for example, how far of a discrepancy you accept etc
that's assuming you keep seeing rubberbanding you can't ignore though
check the pins, they have a great overview of how the game object's net roles work
Remote == Client, right ?
yes, but it gets a bit less clear with certain game objects
and if you need to support listen servers (one player is the host) or dedicates (a server with no player)
I am trying to replicate a static mesh of my character which is a suboject
I can change it using RPC but not normal replication
the position of it or which mesh it is?
The Mesh
@pallid mesa 's article is a great resource for that https://vorixo.github.io/devtricks/stateful-events-multiplayer/
I think you could onrep swap the mesh to the one you want as in this article
I'm repping you here vori lol
void ALearningCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ALearningCharacter, CurrentHealth);
DOREPLIFETIME(ALearningCharacter, HatMesh);
}
void ALearningCharacter::ChangeHatMesh()
{
if (GetLocalRole() == ROLE_Authority)
if (HatMeshTwo)
HatMesh->SetStaticMesh(HatMeshTwo);
}```
UPROPERTY(EditAnywhere, BlueprintReadOnly, ReplicatedUsing = OnRep_HatObject, Category = "Custom Actors", meta = (AllowPrivateAccess = "true"))
TObjectPtr<UStaticMeshComponent> HatMesh;
OnRep_HatObject will fire whenever a client receives a replicated value for that thing
there are some caveats I need to make clear though
they differ in C++ and BP in behaviour
also, your code is replicated to a specific INSTANCE of a static mesh component
so like, which hat mesh INSTANCE is the hat
if you want to swap the TYPE(asset santa hat/elf hat etc) of mesh you may want to send a static mesh asset instead
UStaticMeshComponent's works like this:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=StaticMesh, ReplicatedUsing=OnRep_StaticMesh, meta=(AllowPrivateAccess="true"))
TObjectPtr<class UStaticMesh> StaticMesh;
there's nothing stopping you from just having a replicated soft ptr on your own actor though and just passing the change over to the child component
Its a component though
yeah, but the component can just be a local thing attached to the head and which mesh it uses can be sent over the network
HatMeshTwo is the UStaticMesh that I am trying to switch to
Nope
in that case ignore what I said earlier, I was making an assumption about what you want
so I'm a bit less clear on this part of it but afaik you could do this a number of ways
if the two different actor component ptrs are network addressable (which they are by default iirc? I need to check) sending the ptr to them from the server should make it over?
SavedMoves might be sitting around...
the CMC works with a sort of buffer of input state
I'm not sure how it handles swapping over between owning clients
remember: only the server can change replicated values! if it needs to change from the client you may need an RPC from the playercontroller etc
The Authority is Local
Always printing Local even in a Dedicated server
Is it normal ?
FORCEINLINE_DEBUGGABLE bool AActor::HasAuthority() const
{
return (GetLocalRole() == ROLE_Authority);
}
who takes the input?
does the dedicated server take input from the local player? here I think no
I think it's running the keypress on only the playing client
I actually don't know 100% if the "global" input events like that route to dedicates in PIE but I'm 70% sure no
to be frank, this is going to be a bit of a rabbithole
making the CMC do what you want specifically is quite hard without messing with it... it's the single most complicated game actor by my guessing
I'm hoping you can just temporrally turn off local corrections
if it helps they are replacing it in the coming year(s)
to make it less wacky
"Mover 2.0" on the roadmap
I am trying to replicate this Mesh change from last 3 hrs. Still got no success with using RPC
hmm... I wonder if this bad boy is running when you don't want it to on the server when in-between controllers?
// Perform input-driven move for any locally-controlled character, and also
// allow animation root motion or physics to move characters even if they have no controller
sorry for the big pasta
UCharacterMovementComponent::TickComponent
I highly suggest doing some simple replication overview stuff in the pins etc or on the learning site, there's a lot of terminology
also don't feel bad, this stuff is pretty tough to understand
Hmm. Still trying ....
here's a weird one... try making both of the hat meshes Component->SetNetAddressable();
but this is kind of wacky internal stuff and you are probably better off with your own simple made mapping?
my suggestion: instead of needing to send component addresses over the network
make a simple name or number represent the different hat "slots"
for example: the RPC sends "int32 HatID = 0" and it swaps to the first slot
the local client knows which slot 0 corresponds to and sets the simulated proxy to use that
etc etc
I will try this one
remember that RPCs from the client to the server must be from an actor the client OWNS
your homework is the answer which actor that is for the client 😄
There's one actor on the local machine and a copy of it on the server, right
it is predicted, just not perfectly and doing it "the right way" is extremely annoying
for example, if the client sets maxspeed without it being accounted for in the same savedmove on the server: rubberbanding time
Thats where I learned from
the answer: your custom APlayerController can send the rpc
(to be more accurate, anything your client owns)
a "server" rpc is called on client and does the _Implementation on the server
then you have the server do stuff... and send it back however
(or not at all)
I already succeded in changing that mesh by using RPC
Now, when I am trying to do it without the RPC
I am not able to do so
Btw, I tried the Boolean method
Not working
the client can only send rpcs
clients can not change replicated values and have them propogate
replication is ONLY from server to clients
rpcs can be either way
yeah this is more about the local role
Local Role and Authority are different ?
FORCEINLINE_DEBUGGABLE bool AActor::HasAuthority() const
{
return (GetLocalRole() == ROLE_Authority);
}
``` which might not always be what you expect
no, they are the same
it could be an actor spawned by the client and only on the client
the netdriver's netmode is more specific I guess
what even is remoterole on local spawned things? none?
lol I'm amazed my guess worked
careful though as clearing it out may cause other things ot get out of wack I'm not aware of
one thing that could help is having a really nice visual logger history
where you see what the server and client expected at each point
and where things diverge
LogTemp, Warning TEXT("yo my shit broke")
p.shownetcorrections
but that's not much context
two capsules so not much info, yeah
apologies, it's p.NetShowCorrections
it's very vague on WHY the correction happened though
it's just showing when it does
and where
unless there's some secondary one I dunno
I was able to replicate everything else. But when server or client break free the constraint, the physic asset still stay attached to the player. I replicated SetConstraint using Server->Multicast->SetContraint. I assumed it's same for replicating BreakConstraint.
you might want to check the advanced editor->play settings
you can set if it's just on server or client
or both
and even packet variance
a bit faster than typing it out, it's the same thing though iirc
it's a good idea to check how things feel on "average" connection quality
"bad" is horribly overkill but you can tweak them
it's intended to see if things like break down etc with missing packets etc
@nova wasp Is a server function and an RPC the same ?
I am confused. Because their declaration looks same
I am not seeking anyone's attention. If asking you was a seek of approval in your view. Then I am sorry. I won't ask you anytime again.
It's just that I was not able to understand somethings.
I did took a look on that. I wonder if Server RPC is the only way to change a variable on the server side so it gets replicated to all the clients.
For some reason my variables are not replicating properly but they are only inside the animbp. i'm getting the reference and setting them.
animbps do not replicate
wut
exactly what I said, AnimBPs do not replicate.
how is stuff like this replicating then?
those variables aren't on the animBP
velocity is a member of the "character movement", which I assume is a character movement component
which does replicate
this is not replicating for me
control rotation is not accessible to other clients.
So updates like movement and location use Server RPC ?
got it working. sent it through the character
The only way for client to communicate to server is through server rpc
When a variable is marked as replicate. Server will always try to replicate the value to client.
So if client need to inform others of their change, let's say their character height
Client -> server rpc, set height (setting height in server). The server will then replicate the height variable to all client on next net update
But if you are already the server, no rpc needed. Just change the variable value it will replicate to clients on the next update
deafening sound of 100 anim instances sending 2d sounds to client
PLONKPLONKPLONKPLONKPLONKPLONK
yeah we all start somewhere
I want to dig up my old projects to show them in here lol, I have some funny lines
I struggle with that ideal a lot
"never let anim state influence gameplay state"
okay, animations which create/are hitboxes are animations
the more direct meaning would be "always be able to get a similar animation state with the same input"
and have the game tell animations what to do almost entirely... for anything remotely important
which feels crazy but I'm kind of liking it
I mean even for like locomotion animation here to a certain extent
If you use Get Base Aim Rotation instead of Control Rotation you'll get a similar rotator with replicated pitch that you can use for aim offsets without needlessly replicating the control rotation (again)
@burnt hinge
Its pretty heavily compressed, down to a byte IIRC, I added some interpolation to smooth it out for sim proxy only
Ahh got it. Thanks very much.
It was hard to understand at the beginning.
By the way, I am still confused about ownership.
If I start a dedicated server in my PIE. Who has ownership over my player character, the server or the PIE ?
Server have authority for everything in the world. The only thing it doesn't have authority over is entities that is spawned by the client which in this case won't exist on the server.
Prob should read the compendium, it goes over ownership and rpcs
In general you as a client only own the controller and the pawn. You can set ownership on certain actor to the client (done on server) but use it with caution as it allow cheating
Is there no BLUEPRINT way to show the steamID of a player? Im at the point where it all seems to work...hosting,connecting,steam overlay with Spacewar as game etc. but i cant figure out how to get that ID XD
I did read the compendium. But the ownership and authority part was kinda confusing
Well doubt anyone can explain better than the compendium, perhaps you just need to do the practical part on your end
Have you tried this?
https://docs.unrealengine.com/5.0/en-US/BlueprintAPI/PlayerState/GetUniqueNetId/
That's what I used to get the players steam avatar
Not sure if it's the steam I'd but you can test it
howd u get the avatar after(so i might be able to reconstruct how to get id ^^)? as this is a struct,but i cant "break" it to see its variables?
Using advance session plugin and pulling the get avatar friend node
Then feeding the unique net id
hm, no clue about that, imma investigate and get back to you(might take some time, christmas n stuff lol) but weve talked a lot so were used to it by now i think 😄 merry christmas btw 🙂
What should I do in the practical part in order to better understand this
By applying ownership and doing rpc calls?
Rpc calls by client on actors they don't own will get dropped
So, let's say I am in a dedicated server and I am the client. My character is owner by a player controller which is owned by a connection. So am owning the client or the server ?
Hey, is there any way to call server RPCs from non-player owned objects? like a random replicated ball's script calling a server RPC on itself. (in Blueprints.)
I've just been directing all my server RPCs through the player controller
By making the player own them, so no, either own it, or keep doing what you're doing
yea that works too. i'm already using that for aim offsets. control rotation is just a lot more expensive?
It's not just about cost, but it's not really accessible on simulated proxies, so its irrelevant
if i replicate it it's available for everyone
Sure, but why bother if it's already replicated
doesn't seem like it's exactly the same. the values are completely different and control rotation seems to be more accurate
Makes sense, because the other rotation is quantized/compressed
And if it is, then it is for a reason
i guess ill stick with aim rotation. i just want the characters head movement to be replicated so everyone sees where you are actually looking but it doesn't have to be super accurate
Yeah I remember that it used to not to be accurate on one of the axises, but then living with it as I didn't need it to be super accurate either
yaw seems to act slightly different
Yeah indeed that was it most prolly
Personally I just replicate a single uint8 for proxies up down looking angle, and have the clients smooth it out
You could also pass the object a reference to a net owning object and call that object's RPC. A little bit hacky so tread with caution.
this is similar to what i do, i have a ServerRPCCommunicator component on my player for all my server rpc request needs
I would just make sure you clearly define (in your own mind) what types of behaviour you allow the object to have authority over. There's a reason there's a hierarchy and you can end up with a minefield later down the line if you keep introducing small exception cases.
I've lost a few toes to stray rpc mines myself over the years
oh damn i've never thought about that in the 7 months i've been working on this game
hopefully i don't cross any landmines just yet haha
How can i replicate a child actor component?
So what options do i have? i basically recreated the matrix demo audio logic. It's all on a child actor component. But their system is obv singleplayer
just plop the whole logic on the actor itself or use actor component?
Hi. I have a flying pawn and I'm still trying to figure out what's wrong with my code. The other client is very laggy when it's moving/rotating. I've tried all kind of changes and still the same. I also, left it without any RPC because I though addmovementinput it's already replicated. I do have replicate movement active and everything, but it's still lagging. Does anyone knows what's the problem?
Thank you!
`void ADragon::Move(const FInputActionValue& Value)
{
float const MoveValue = Value.Get<float>();
if(Controller && (MoveValue != 0.0f))
{
FVector const Direction = GetActorForwardVector();
SetMove(Direction, MoveValue);
}
}
void ADragon::SetMove(FVector DirectionF, float MoveValueF)
{
if(GetLocalRole() < ROLE_Authority)
{
S_Move(DirectionF, MoveValueF);
}
AddMovementInput(DirectionF, MoveValueF);
}
void ADragon::S_Move_Implementation(FVector DirectionF, float MoveValueF)
{
SetMove(DirectionF, MoveValueF);
}`
anyone?
(also found out if i open more windows it makes it more slowed down)
Epic has a very good tutorial on replicating sub objects
Have a look
Hey all, I'm wondering if there are any devs out there who have encountered this issue in the past, and might have a solution or better approach? I'm replicating some interpolated character movement currently (see attached video, first play is standalone, second is two clients) and I'm having trouble with managing server events on tick, while cleanly replicating the movement for the client.
I'm pulling animation curve data and determining offset so dodges and foot planting maintain world position regardless of framerate, and then adding a server actor offset, and attempting to duplicate it on the client to maintain a smooth, framerate consistent translation. Only issue is I'm having trouble figuring out how exactly to compensate for latency on the client, because I unfortunately can't just NetMulticast or run the same function on a Client replicated or non-replicated function. Here's a video to help demonstrate some of the visual bugs this is creating:
If anyone wants a couple of code snippets to help clarify my approach, just let me know. Luckily, it's all C++. Thanks to anyone who might be able to help!
hella confusing for blueprint. why do they never show blueprint examples smh
- Enable Actor replication
- Enable your Component replication
- Use Server or Multicast RPC Event for updating your replicated component
basically the same as always then. seems to work but hard to test 2 audios on 1 pc
Maybe use Attention trick ?
not familiar with that
Attenuation= The volume and pitch of audio change according to distance
ah yea, well if i play as client i have audio now. before i didn't so it should be working
Hi, I'm using UE 5.3 and there isn't a Online Subsystem Steam equivalent for Online Services. Will Online Subsystem Steam still work in UE 5.3? The docs say anything past 5.1 to use Online Services.
How about trying it out and letting us know
whats wrong about it
yesterday it was working when I did it, today I tried to close and open the programme because the clients could not open the door and now the server cannot open it either.
and for clients this has also stopped working
I'm about to lose my mind, things I've done are broken for no reason, help me please ;-;
Hi, Can anyone explain to me why when I click in "server" click to move in the top down template controller works as expected (Click somewhere and run there) but in a Client window it does NOT i have to hold the mouse button to move around please?
When the level starts I have this in the Level Blueprint to enable Input Modes again after coming from the menu
I was assuming that Get Player Controller would be the controller assigned to the Client already, so I didnt think I would have to do a check if it,s a local controller or not.
How do I respawn a player properly in multiplayer ?
restart player
assuming respawn means getting a new fresh pawn
what respawning means depends on your game's architecture
what class is this code in?
I just followed Epic's tutorial
It binds event OnDestroy actor -> Spawns it in world and Posesses it
That works properly for Single player
But Not in multiplayer
What would be the equivalent for Multiplayer
the same thing but serverside only
don't do that tho
use the gamemode functions
I tried server doesnt work properly
then you probably aren't possessing it with the right controller
as in multiplayer there are multiple player controllers
Restart Player
anything with get player 0 in multiplayer is smelly
player 0 is the host or first player to join if it's dedicated server
player 1 is the next one
player 2 is the next
How to I get the proper index of the player which died
get that pawns playercontroller
no index involved
When in this chain does the pawn get destroyed?
Not in this chain
The pawn gets destroy with projectile damage
What class is this code in?
and lose your multicasts, you don't need them
In main character BP C++
so then why are you getting player character all over the place, this IS a player's character
You can just do:
Begin Play -> bind event to ondeath (target is self)
etc
but you don't need to bind, just add to the ondeath event
an EXTERNAL class would do binding, that's for if the gamemode wanted to know when someone died (which would be the more correct way to do it)
I would suggest using RestartPlayer though, as that''ll make every spawn the same as the first
Its in the MainGameMenu Mode so Game Mode so this means only the server can access it right?
Not sure why the Client has to double click and hold to move to a location but the server can click once to move to a location still.
Im using the TopDown Player Controller Template in both Client and Server.
get player controller 0 in multiplayer is gross
don't do that
and yes, gamemode is on server only
Ahh ok how would you do this please?
When should a players input mode be game and ui?
I solved the issue, no worries
I wonder if there are any plans for replicating TMaps?
Anyway, why isn't it already a thing?
Pretty sure we had that topic a few times already
You might be able to find that answer with the search
Not sure if they will add replication to it (and other types like TSet), but given it hasn't happened yet, my gut says they won't
Just wondering why. What is preventing them from adding it?
If it was simple and made sense to do, then epic would've likely done it already.
My guess is that there's no accurate way to keep track of what index has what and it becomes inefficient if you were needing to replicate the entire TMap every time there is some change.
You're probably better off using a FFastArraySerializer using an array of a struct that contains your key/value pairs and using it to keep a local TMap updated as you get pre/post change functions.
Yup most of the time falling back to an array is simpler and cheaper
I know that this is not the answer, but it's just a C++ work around
https://www.youtube.com/watch?v=4US1mHsGcs4
TMaps and TSets cannot be replicated uproperties in unreal.
However, they have some convenient methods to convert to an array, which we can use for replication.
That being said, this needs to be used carefully. As frequently converting your set or map data structures to an array could be a performance issue.
An alternative, is if the logic neede...
I know the workaround, just want to feed my curiosity
Thanks anyway
When i join a session, the On Success execution fires, but the client doesn't join the session. Is there a fix to this?\
A Value of a SubObject of my UActorComponent attached to a ACharacter seems that's not replicating properly. Here's the code:
// MyActor.h
UCLASS()
class UMyActorComponent : public UActorComponent
{
// ...
UMyActorComponent();
virtual void BeginPlay() override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(Replicated)
UMySubObject* SubObject;
};
// MyActor.cpp
UMyActorComponent::UMyActorComponent()
{
SetIsReplicated(true);
bReplicateUsingRegisteredSubObjectList = true;
}
UMyActorComponent::BeginPlay()
{
MySubObject = NewObject<UMySubObject>(GetOwner());
GetOwner()->AddReplicatedSubObject(MySubObject);
}
// MySubObject.h
UCLASS()
class UMySubObject : public UObject
{
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual bool IsSupportedForNetworking() const override;
public:
UPROPERTY(Replicated)
float Value = 0;
}
// MySubObject.cpp
UMySubObject::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
DOREPLIFETIME(UMySubObject, Value);
}
bool UMySubObject::IsSupportedForNetworking() const
{
return true;
}
- No crashes, no console errors, etc.
- I am testing with two instances; one (remote) client and one server. Server calls a function that changes
Valueand it sees the changed value on his instance, but when (remote) client calls a function to readValue, it seems unchanged (0).
The above said, what am I missing? 🤔 Pretty much am following the approach proposed by https://docs.unrealengine.com/5.2/en-US/replicated-subobjects-in-unreal-engine/ but can't see what's wrong with the code above.
This only works on the client with authority, but I want it to work for anyone locally (each player sees a different mesh). Any way to stop this from replicating?
Hi everyone. If I'm making a multiplayer game where citizens engage in dialogue, and I want all clients to hear the dialogue, should I execute the dialogue using GAS, playing the voice animation as a montage, or would I bet better with an RPC?
I recently told you to use a player controller for client->server rpcs but that was a bit misleading, technically anything replicated and OWNED by the client can send a client->server rpc to be more clear
edited my comment to make it a bit more specific
Anybody knows how to replicate BreakConstraint function?
you could just make your own rpc that sends over the call to BreakConstraint?
In blueprint, I used Server->Multicast->SetConstraint. That worked but doesnt work for BreakConstraint function.
Can have many reasons. You'll need to check the log files of the client.
Don't you have to use SetIsReplicatedByDefault()? Also, on begin play you create the object on both client and server sides, i.e. the client might simply override the replicated object. Make sure to run the object creation code server-side only
And if it's a uobject it always has, why not a default subobject?
Hey, I'm fairly new with Multiplayer and I don't get my damaging other players straight.
My PrimaryFire method on the Character determines if you hit something, if you do it calls the ServerTakenDamage(Server, Reliable, WithValidation) method:
...
if (IsLocallyControlled())
{
HitCharacter->ServerTakenDamage(10.0f, FDamageEvent(), GetController(), nullptr);
}```
This than calls the overriden TakeDamage function of that player with the provided arguments and returns
In that TakenDamage Method I simply do `CurrentHealth - DamageAmount`, invoke a respawn in the gamemode and set the killfeed in the UI.
My Health is:
```UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health and Stamina", ReplicatedUsing=OnRep_CurrentHealth)
float CurrentHealth;
UFUNCTION()
void OnRep_CurrentHealth();```
And the On_Rep Method just refreshes the UI through the GUI.
My problem now is, when I set my Editor to "Play as Listen Server", the server client can shoot the connected client as expected everything works as intendet, but when I try to shoot as Client to the Server, or play as 2 clients shooting at each other I receive `"No owning connection for actor BP_ThirdPersonNewCharacter_C_1. Function ServerTakenDamage will not be processed`
I guess thats because the HitCharacter is not owned by the client - but I did not found a way to work around that. I tried implementing the DealDamage entirely in the gamemode but with the same result and I guess that might be a massive networked overhead.
did not we have lyria channel?
i want to ask if we can make the game played between me and my friends for free online with out paying for servers and with out installing the engine source code
is this possible?
As per my knowledge you can use EOS (Epic Online Services) and the Lobby System https://dev.epicgames.com/docs/game-services/lobbies
i read in the forums they cant do this unless i have the source
i just want to play with my homies
Hmmm I think and as far as my testing with this goes (only on my local machine though) the EOS Plugin mainly works, when it comes to dedicated servers though you need to have the engine compiled from source (but its free you could do that it just takes a huge amount of storage)
In my test setup (followed from here: https://www.youtube.com/watch?v=bvvzXbgeexQ&list=PLnL7VgJvoJuc6JqDSzua1Tv-iud0_1kUY&ab_channel=Gamewizard) for the Lobbies, Session creation and joining you don't need the compiled unreal engine from source
Guys im trying to get unique ID from every player
void ASentinelPlayerState::Multi_GetUserID_Implementation()
{
const IOnlineSubsystem* OSS = IOnlineSubsystem::Get();
FString UserID = OSS->GetIdentityInterface()->GetUniquePlayerId(0)->ToString();
PlayerSessionID = UserID;
}
in postlogin in lobbygame mode i calling the getuser id where im adding userid to array
SentinelState->GetUserID();
IDLIST.Add(SentinelState->PlayerSessionID);
When i save my game im printing
void UBaseGameInstance::SaveDataToPlayerFolder()
{
ALobbyGameMode* LobbyMode = Cast<ALobbyGameMode>(GetWorld()->GetAuthGameMode());
for (APlayerController* PlayerController : LobbyMode->PlayerControllerList)
{
ASentinelPlayerState* SentinelState = Cast<ASentinelPlayerState>(PlayerController->PlayerState);
UE_LOG(LogTemp, Warning, TEXT("Player Controllers: %i"), LobbyMode->PlayerControllerList.Num());
UE_LOG(LogTemp, Warning, TEXT("Player ID: %s"), *SentinelState->PlayerSessionID);
UE_LOG(LogTemp, Warning, TEXT("Player ID: %i"), PlayerController->GetPlatformUserId());
}
for (FString PlayerID : LobbyMode->IDLIST)
{
UE_LOG(LogTemp, Warning, TEXT("Lobby ID: %s"), *PlayerID);
}
}
But what im getting is only my ID even when another player is connected to session via steam
Anyone can give me an idea how would i even know, If client is connected with Server, I have this case where user can pause the app, and sometimes they get disconnected, I can see it from StatelessConnectHandlerComponent, which checks a handshake.
Is it possible i can access it somehow ?
Hey I have a question. If I want to program Ai behaviror tree, how is it different on multiplayer game from singleplayer?
Guess the NetMode would be Client instead of Standalone?
Not too different. It will only exist on the Server, along with the AIController.
Doesn't Login (not post login) already provide you with the id?
I made a replicated door like this, but the clients still can't open the door. it seems to open on its own, but it can't pass through the door due to colision and remains closed in others.
Also from the PlayerState you'd want the UniqueNetId
But is it going to change the NetMode, because i was connected when i paused the game and server session is destroyed, before this client even knows about the session dying, so who would change the NetMode and Who is handling StatelessConnectHandlerComponent ?
@thin stratus
Every time I close and open the programme, it breaks here, which is a completely unrelated part. When I delete the Open/Closed variable and add it again, it gets better. what is the problem please help.
You will need to Server RPC before interacting
Also the Multicast in the OnRep makes no sense
How to get UniqueNetID?
And I'm not sure if an OnRep function that seemingly looks renamed still works. They usually share the name with the variable
At least in BP
It's just a getter function
GetUniqueNetId
Or something like that
Its provided from player state?
You asked how to know if a client is connected
PlayerState should have the unique net Id yes
I am sorry if i have not explained it properly, issue is Client is connected to server and then Client are pausing the App, now when Client comes back from paused state, Session might be destroyed, so how would client knows if it is still connected with server ?
I dont have anything like GetUniqueNetID only ID
Shouldn't the destroyed Session follow that the Server fully shut down so the Client will probably process the lost connection?
Which usually gets communicated with the GameInstance in BP or similar even Event NetworkFailure
It's GetUniqueId
Without the net apparently
I got it
It is but you need to
GetUniqueId().GetUniqueNetId();
Right, cause it returns the Repl version that can be exposed to BPs
Apparently in at least 5.3 there is a BP version of that function finally
And question is this id always the same ?
or it is changing every time player joins new session
oh yes event Networkfailure will happen when StateLessConnectHandlerComponent will be done with its HandShakeProcess and time limit exceeds, then it sends that event, but i want to detect, even the handshake process is in progress, Maybe i should decrease the time to less than 5 seconds to make it send the event sooner,
My current time for that check is 60 seconds, I had made it so maybe sometimes when you have bad connection it will not get disconnected that much.
If you are using Steam, then that's the SteamID
k
How can I turn it to replicated door pls help me
TSharedPtr<const FUniqueNetId> PlayerNetID = GetUniqueId().GetUniqueNetId();
how to convert it into string
when i do it like that
FString PlayerIdString = PlayerNetID->ToString();
my engine is crashing
Relatively sure you don't need to do GetUniqueNetId on it
The FUniqueNetIdRepl already has a ToString method
Try testing it in standalone when you have steam enabled
I found out that its a problem with the controller
when i iterate thorugh player states it works
Thank you for taking the time, Tony. And you are right, this piece is key: the client might simply override the replicated object. Make sure to run the object creation code server-side only.
Thank you kind sir!
Should I use repnotify for Setactivated and Deactivated actor component
coz deactivated dosent work
Use repnotify for anything stateful. Use RPC/Multicast for transient changes and effects. If a player connects after the RPC changed a variable they won’t have that new value it will still be the default value but if you use repnotify then a player who joins after the variable changes will receive the new updated value as well.
So for a door you can have a repnotify boolean for example bDoorOpen
I am trying to rerspawn my pawn from the gamemode. But its not working
in multiplayer
I followed this tutorial - https://docs.unrealengine.com/5.0/en-US/respawning-a-player-character/
When I build my game and play on my computer it looks fine, but on another computer with almost same stats certain textures are blurry any idea why?
lyra when playing as listen server it does not move the other player
they are not connected, why?
Blurry textures usually means there were more textures waiting to be loaded but the limit was too low and/or the GPU was out of vram. You can solve this by following this guide: https://youtu.be/uk3W8Zhahdg
This time on Unreal Tips & Tricks, we look at how to manage the Texture Streaming Pool size to take advantage of more video memory, or VRAM. By doing this, we can avoid going over our allocated VRAM budget for streamed textures and MIP maps. We'll also take a brief look at how to modify multiple textures at the same time.
For more details, plea...
so i have this car and its fine on the server but on the client its bad
it starts off fine
but after driving for a second it starts freaking out on the other clients
What's the overall structure of your replication setup?
HOW does the car drive on multiple computers?
Probably not very well. They're very bumpy.
I mean technically, how does it work?
You press the go button. How does the car go on other peoples computers?
do RPCs on the gamestate work? afaik no player owns the gamestate so probably not right
Only Multicasts from Server-side
Hello
I would like to know how to handle player disconnection and exactly how to distinguish between player leaving the game by choice or due to network connection lost
Anyone knows how to properly use replicated variable in a material instance via material parameter collection. My skybox actor calculates time of day and replicates it to the clients. I'm seeing the correct value both of the variable and in the MPS where I pass it on all the clients, but it's not affecting the material instance on the clients.
I'm not very familiar with material but can the materials be replicated?
I don't think so, only the variables that you pass into it do
HasAuthority part
Pointer to material can be replicated?
Remote part
Material
Actor is replicated, mesh replicated, variable timeOfDay01 replicated
if it's in property It would seem like it's replicating the property, as far I could think at the moment you may want to add OnRep function and adjust materiel accordingly I think values inside that certain materials would not be replicated so you may want either have certain preset mat or change accorinding to other factors
Note: I'm not familiar with Unreal engine much or materiels
I think yes, but I'm not storying it
Don't even need it
That's what I'm doing, but material won't update on client (the variable does)
U just set the time of day in server , then server will replicate that value to clients
It does replicate it succesfully, but the material won't consider this change
It should , provided that you do the set mpc in client too
I will suggest to do repnotify
And on rep function, set the scalar parametre value of the pmc
that's what's happening
sun moves on the host (left), but stays still on the client (right) at the default value of 0.5
Oh I think I need to set direction light to be replicated as well. Cause I'm seeing skybox colors update correctly but not the sun position
On sec, I test it
Oh, light settings don't have 'replicated' variable, so I just need to update sun position on the clients, I guess
Hey guys, I want to spawn custom player pawn choosen in runtime by players when they join first time. I was wondering which function of gamemode to override where I can get hold of controller and can run possess on it? I can't seem to find any c++ function for it
Thanks guys, I solved the issue but updating the sun rotation on the clients (material was updating correctly, so my bad)
perfecto
advanced session plugin works fine in same pc in 2 instanecs/players but when play between 2 pcs ( in same house same network ) it does not show the servers list
any idea why?
Yes the the car is trying to replicate but it starts vibrating more and more as you drive around
GameInstance has a few methods for that:
/** Opportunity for blueprints to handle network errors. */
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "NetworkError"))
ENGINE_API void HandleNetworkError(ENetworkFailure::Type FailureType, bool bIsServer);
/** Opportunity for blueprints to handle travel errors. */
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "TravelError"))
ENGINE_API void HandleTravelError(ETravelFailure::Type FailureType);
Thank you, You are savior
When you spawn two clients using PIE, what exactly differentiates them? Because when I'm checking player controller it seems that only one exists despite there's two clients/windows. I have a kind of a weird setup where one client is the "server"/viewer, while the other client is the control panel that fires events that executes on the server (entirely local, no actual networking other than local)
They're still operating independently, so there must be some controller or otherwise that identifies which is which
Because when I'm checking player controller it seems that only one
Clients only know about their controller. So if you will have 4 players in your game, each client will only have 1 controller in their world, while the server will have all 4 of them.
To explain a bit further. I have a project where one client is supposed to be the environment that is seen, whereas the other client is a control panel (that moves the camera, fires events on the former). When setup, the main screen is displayed on a separate TV, whereas the control panel (client #2) is moved to another display (all of this on the same computer).
any tips on how it would make most sense to differentiate between these two? to separate what is shown/executed on each. I'm planning to run it similarly to how the PIE 2 clients executes.
(for example, should I perhaps spawn two pawns and use that?)
i have fairly decent experience with UE, but nothing on networking. Just looking for a pointer in the right direction and I'll do the research necessary
If there a multiplayer stealth style game template to help me get started on a new game?
Inventory, equip slots, AI, basic movements... so I can focus on the envirnment and game, story and game play aspects.
You still haven't explained how your system works
How does your input get turned into forces on the car
just because its MS, does not mean it won't go anywhere.....
I'm trying to keep score per hit, but the not owner check keeps failing because owner isn't setting for some reason
To spawn and set owner I'm doing this
{
if (!ensure(ProjectileRoot)) { return; }
// Spawn the projectile at the specified location and rotation
auto Projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileActor, ProjectileRoot->GetSocketLocation(FName("Projectile")), ProjectileRoot->GetSocketRotation(FName("Projectile")));
if (Projectile)
{
// Set the projectile's owner to be this vehicle character
Projectile->SetOwner(this);
And to check the hit wasn't the owner before incrementing the score I'm doing this
{
if (AMyPlayerState* PS = ShootingVehicle->GetPlayerState<AMyPlayerState>())
{
PS->PlayerHit();
if (OtherVehicle)
{
OtherVehicle->Die();
Anyone see what I'm doing wrong?
mb it uses line traces and add force
and a bunch of math
Can anyone help me?
Im trying to destroy an item on pickup from both client and server, but it can only be destroyed if the server picks it up and then it still only gets destroyed on the server
On pickup im calling DestroyActor Server which then should call On Rep Actor To Destroy
I also tried multicasting after running from server but with no luck.
The actor that im trying to destroy + the character im destroying it from both has Replication enabled.
Can anyone see what im doing wrong?
Natively replicated actors must be created and destroyed server-side only since they're replicated, which means that the clients are going to repeat what server did -- create or destroy. You do not need to call any DestroyActor client-side if the actor was replicated back from the server.
Even if i only destroy it from the server it doesnt get destroyed on clients
How do you create the actor?
Could it be because the BP's i wanna destroy gets loaded in from map load? and not spawned from server?
Could it be because the BP's i wanna destroy gets loaded in from map load
What do you mean by that?
and not spawned from server?
It means that you're doing something wrong. If you have a replicated actor, it must be present server-side, otherwise there's no reason to make it replicated.
The BP is just on the map, do i need to spawn it using Spawn Actor from class?
But if i destroy it server side would i need a w/ notify?
You don't. If it's there prior to play time, it will be present both server and client sides
You do not need this RepNotify. Calling DestroyActor server-side only (use HasAuthority node) would be enough to destroy it from every world associated with that server
So just this?
This is a server RPC. It can be called only server-side or owning-client-side. For the latter it's related to things like PlayerController, PlayerState, Character and such, but a regular actor spawned server-side, and replicated back to clients this is not the case, so calling this RPC client-side would do nothing.
If you want to destroy an actor that is owned by the server you need to use a server RPC on an actor that is owned by the client. For instance, you can use a PlayerController.
Also there's no reason to use HasAuthority in a server RPC because nothing but server can execute that
You would need to use PlayerController to call a server RPC with the actor you want to destroy. And yeah, you would need to create that RPC
Yeap
Alright thanks, i'll try that a little later, i'll let you know if i get it to work 🙂
i get this error
Yeah, it is
How did you implement the whole thing?
The issue is where the cast is, as it's saying that it cannot read its result. That's weird though, since only the first exec pin is connected. Can you move the nodes around so that's clear what is connected to what?
But not the BP i want to destroy, it doesnt work with that one
Also you don't need to have a separate event to call a server RPC. You're able to call an RPC using the controller itself
wdym?
This method gets called using left click, when i left click on the BP BP_VicNormalDoor the door gets destroyed, but when i do it to BP_Banana it does nothing
Can you put a breakpoint on the cast, and see whether it works fine when you try to destroy the banana? It should work fine, but the error says otherwise, maybe I'm getting it wrong or something
it works fine
What about the error though? What node does it happen on?
Destroy actor
Yours one?
it must be a setting on the banana right?
wdym?
since it works on the door but not the banana
wouldnt that mean the error is on the banana?
.
no the unreal destroy actor
If it fails server-side, it means that the banana does not exist server side. If so, how do you create it?
i can see the banana from my server client, but its just in the level
yeah
Is it replicated?
If no, server-side and client-side bananas are technically different bananas
i checked the "replicates" checkbox
Just now? So it wasn't before?
no, it was there before
Uh, it should work. Can you double check that you're actually passing a banana to the server? Try to put a breakpoint before the RPC call and inside it, and see whether you pass not a None, and whether it gets the same thing or not
i tried checking "Always relevant" do you think that would do anything?
Looks like it gets passed as None to the server
It won't do anything unless you changed anything relevancy related prior to that
Then the issue is not in the networking code, but in the item scan
Should i try spawning the Banana in when i generate my dungeon instead?
that way it will be generated from the server
I have a UI that's supposed to default to a value of 100 for player and opponent, and increment by 6 every five seconds. It also updates whenever you spend money. This update pulls the player's cash value from their player state. The problems:
- When you spend, it doesn't update your cash value on the opponent's screen until the 5 second update
- Player 1 (Server)'s Opponent value lags behind one tick. It starts at 100, goes to 0, then up to 106 and increases as expected.
- On Client, own cash sometimes visually misses an increment tick, although the cash is spendable.
Is the client passing it as None, or is it just server that gets it like that?
You can see here it recieves None but sends the banana
although it is the Client banana, dont know if that does anything
Yeah, that's weird, especially since the actor is replicated. Again, you spawn it prior to play time that's fine
Wdym by "client banana"?
ignore that, its just the replicated client banana
Again, is it spawned prior to play time? You just placed it into the level manually
yeah i did
How does this specific banana get there?
Is it spawned at runtime or just placed in the level?
They pass it using a server RPC using PC after firing a trace client-side. The banana is spawned prior to play time
And it's marked as replicated
i just placed it in the level
I tried spawning it in runtime and my current implementation works with that
Just not with the banana that is placed in the level pre start
I have no clue why it wouldn't work when it's placed prior to play time. If it's just an actor with the replication enabled it should not be None when passed to the server via a server RPC. If spawning it on runtime works fine for you, I guess do that, but the issue is weird 😔
Try it with just a plain static mesh actor placed in the level
Line trace -> tell server to destroy the actor
Is it actually an error or are you trusting the BP debugger too much
What is the actual data type of the parameter to the run on server event?
just actor reference right?
yeah
It works with other blueprints, just not the Banana
but the other ones i spawn in at runtime
Then your Banana isn't replicated
Make a new actor with just a cube and set replicates and test with that
something's goofy with that actor if the cube actor works
Same error
But i would need to spawn in all the BP's anyway cause it needs to be random so im just gonna do that
yeah somethings fucky with your setup if actors placed in the level aren't replicating
You doing anything weird like level streaming or sublevels etc?
from placed in the level?
yeah, but i found a way to fix it, i basically just place a spawner BP which i replace at runtime, thats what i wanted in the end anyway, so im just doing that now
"fix"
You still haven't told anyone how your button presses get to the server and are reflected in the application of forces on the vehicle server and clientside
Or your physics replication settings if you're using that
oh you wanted to know how the button presses work
I want to know how your system works in general
You press forward button, what happens?
it adds force in the forward direction
Show the code
noooooooooooo don't pass deltatime from server
Do this
Input -> run on server event passing Throttle over
Run on server event -> set ReplicatedThrottle
Tick -> use ReplicatedThrottle in your normal update stuff
then go loosen up your physics replication settings, they are way too strict by default
ok
wdym by loosen up
make the settings less strict
but first check that it works with them as default
it'll drive but be very jittery
its driving
but after doing so turns and stuff the car stats floating
nvm it is jittery
but still floating
whats the correct way of getting the local player controller inside game state? i want this client side so do i just check authority and use Get Player Controller 0?
make SURE it works 100% in single player
it does
then make sure all the control variables (steering, throttle, etc) are replicated like I said
Input -> send to server
Server recieves -> sets replicated variables.
Tick -> use replicated variables to do physcis
There's ways to make it slicker but do that for now
Im new to multiplayer so if the answer is obvious thats probably why
no
Im not sure why this isnt replicated
no multicasts
replicated variables
- Send your input floats to the server (throttle, brake, steer, etc)
- Server sets some replicated variables
- Tick uses those replicated variables to do the physics.
The only RPC should be the client sending the inputs to server
for now
i guess im having a hard time understanding
wait
maybe i get it now
like this for the turning?
I still see zero replicated variables
what do you mean by replicated variables
how do i do that
is the a blueprint im missing
ok
You're missing the entire way the engine multiplayer works
ok i set all of them to replicate
ok i figured it out
Hi, I'm spawning item on the server and trying to pass it to the client, but client gets a null reference. How can I fix this?
actor might not be replicated yet
Are there any ways to check if it is replicated and then call event on client?
The actor will get a beginplay when it becomes available on the client, and any references that are RepNotify will get their notifications too.
I'm trying to use replicated physics in 5.3. But when I get a spam of warnings in the logs like:
LogPlayerController: Warning: ClientInput buffer overflow. MyPlayerController [Player]. RecvFrame: 8291. LastProcessInputFrame: 8275.
Also this one appears some times too:
LogPhysics: Warning: [Remote.Input] in fault. Reusing Inputcmd. (Client) Input: 8619. (Server) Local Frame: 1051
these start printing right when the player joins the game
We are getting reports of some clients speedhacking in our dedicated server game. Does anyone know if there's a known exploit in CMC for this?
I would have hoped the cmc would prevent this...
We control the server so it's definitely a client side hack.
Does anyone know a good resource for common Unreal multiplayer cheats? So I can stop them of course! Not really found anything via search (not surprising I suppose).
Guys i have array of structs
UPROPERTY(Replicated)
TArray<struct FSlotData> SlotArray;
Im calling my add item locally
void UCharacterInventoryComponent::AddItem()
{
if (ItemDataTable)
{
FItemData* InteractData = FindItemByID(CurrentInteractable->ID);
if (InteractData && CurrentInteractable)
{
bool CanStack = InteractData->ItemNumericData.bIsStackable;
int MaxStackSize = InteractData->ItemNumericData.MaxStackSize;
for (int SlotIndex = 0; SlotIndex < SlotArray.Num(); SlotIndex++)
{
if (CanStack && SlotArray[SlotIndex].ID == InteractData->TextData.ItemID)
{
SlotArray[SlotIndex].Quanity += InteractData->ItemNumericData.Quanity;
ItemSlotArray[SlotIndex]->ThisSlotData.Quanity = SlotArray[SlotIndex].Quanity;
ItemSlotArray[SlotIndex]->UpdateWidget();
RefreshInventoryForPlayerState();
return;
}
}
if (MaxSlots >= CountFreeSlots())
{
int FreeSlot = FindFreeSlot();
SlotArray[FreeSlot].ID = InteractData->TextData.ItemID;
SlotArray[FreeSlot].Quanity = InteractData->ItemNumericData.Quanity;
ItemSlotArray[FreeSlot]->ThisSlotData = SlotArray[FreeSlot];
ItemSlotArray[FreeSlot]->UpdateWidget();
RefreshInventoryForPlayerState();
}
}
}
}
What i can do to change this value as well on the server, of course i placed this array in GetLifeTimeReplicatedProps
USTRUCT(BlueprintType)
struct FSlotData
{
GENERATED_BODY()
UPROPERTY()
FName ID = "Empty";
UPROPERTY()
int Quanity = 0;
};
struct look like this
Are you calling it on the server or the client?
On the client I see.
Stuff doesn't replicate from the client to the server.
Yes i want add item locally
If you want to do it "properly", the client asks the server for the change, the server makes the change and updates the client.
You can add whatever prediction you like around that.
And of course if the server rejects teh change, it should inform the client.
So i should call add item from server?
👍
And RPCs are filtered based on owning actor.
Im little confused here so if you have for example Server prefix for UFUNCTION this function will call on server but executes only on client or the both?
You mean the Server specifier? (not a prefix - changing the function name does nothing)
That will make the function execute on the server, if it's called from a client-owned actor.
So what i want to do here then is to add Client in ufunction?
That would cause the server to tell a client to execute a function.
Your problem is the client is already doing it and it doesn't work.
Did you end up figuring it out?
Found this variable AGameNetworkManager::bMovementTimeDiscrepancyDetection - seems to be disabled by default. Going to investigate further.
Iirc the CMC has something against it, which is turned off by default
I heard some regular ( @chrome bay ? ) complain about that several times.
But not sure if it's the boolean you mentioned
It does sound like it could address it though, because the Cheating you encounter is probably caused by then sending updates with faked timestamps or something like that
Yeah it's that bool and the second one (bMovementTimeDiscrepancyDetection and bMovementTimeDiscrepancyResolution) both need to be true, and they default to false.
It does seem to be related to time between updates but I've not really dug into it.
I tested and seems fine with it on and default settings, although with Bad net emulation it does not feel quite as nice as it used to.
Would love to find a whistleblower from the hacking community to hire as a consultant 😄
@silent valley What is your game called?
Outerstellar
i can look into it a little bit when i get home
ok feel free to DM me 👍
but I think the CMC booleans will address the speedhack, just makes the experience worse for high latency/high packetloss players
You can literally just override tick component and give deltatime *= 2 on client to fake a speedhack IIRC - been years since I tested
Didn't test the speedhack detection but I did see it there
Ok thanks I'll give it a test
Hello does anyone know if there's a way to export the map collisions?
No I stopped working on it
So I've been testing to see if I could get Steam sessions working using AdvancedSteamSessions, I can find the sessions on my own PC, I can find it using 2 different machines on 2 different accounts (even with different download regions, country wise), however my 2 friends in the UK can not find any session when they create one and try to join. I suspect I'm still running it via LAN somehow but I'm not sure where or what I could be doing wrong. Using steams test AppID 480.
I am creating a physics based pawn actor and was searching about to handle the replication, client-side prediction and stuff for it, I just found out that unreal has something named NetworkedPrediction plugin which could help out in my case, I'm a bit new to engine right now, so don't really know how to search for eacmple/Documentation for this, Can someone point to some resources
Or if you know a better way to handle physics based networked movement please share
the example content within the plugin tho note
to actually use it
u have to use it for everything
Hey @dark edge sorry for ping but you seem like you've played with the physics replication a bit. are you familiar with this?
That doesn't sound like a physics problem to me
What's your setup, what are you actually doing?
Physics replication isn't hard at all WITHOUT prediction, just mess with the replicated physics settings, they are very strict by default.
Generalized physics movement with prediction is a very hard problem, you probably won't find a turnkey solution for that right now.
Yeah but for a character controller we would need prediction right?
Why aren't you just using the usual Unreal Character?
My character is more of a floating character which can interact with other physics objects (for gameplay purposes), the default controller just doesn't work with that kind of setting
Call it a movement component, controllers are a totally different thing in Unreal
How does it move, really gently or very twitchy?
You could probably get away with not using prediction if it's really floaty anyway.
PlayerState->SetIsSpectator(true);
ChangeState(NAME_Spectating);
bPlayerIsWaiting = true;
ClientGotoState(NAME_Spectating);```
I am using this code by WizardCell to spectate in my game. but for some reason, i cant destroy my player after doing so. or well, i can, but when i do, it works fine on the listen server/client, but not on the client. on the client it removes the player, but then i cant move my spectator pawn anymore. idk why
Completely depends on player input
It feels pretty tight even after being a physics based character
Yeah predicting that will be tough
Predicting it alone isn't the problem, you can do that easily
it's reconciliation, like when 2 characters are both pushing on something, where does it go?
Thats why vehicles in games can feel great, until they collide with another vehicle and then it turns into a jittery mess
Yeah, I honestly don't know how anyone solved it
If everyone is locally predicting, they can't both be right if they disagree on some shared thing like a box they're pushing. That's why I'm totally NOT doing prediction for my game, but it also helps that mine's a vehicle building game so prediction is very hard, and not really necessary. 30ms lag for turning a tank is just fine.
Yeah
I have a net multicast function invoked from a UFUNCTION(Server) that modifies a REPNOTIFY variable, but when it it runs, the REPNOTIFY function for that modified variable does not appear to run. I have called GetLifetimeReplicatedProps() and DOREPLIFETIME for the class/variable (it's a component attached to a blueprint object in the editor). Any advice on debugging this?
OK, I have no idea how REPNOTIFY variables work apparently
i'm coming to the conlusion they just don't work
Can I use playfab within ue4, and if so is there a tutorial or documentation I can follow to learn? Or anybody willing to atleast show me the basics?
Hi, im calling a Server method from my widget but i cant seem to get it to work? how would i go about doing that?
It doesnt execute from either Client or server
im dumb, ignore me
Is the ItemObject an Actor or an Asset?
Just asking cause sending that to the Server might not work
PlayFab should have a plugin and documentation
i fixed the execution being on Cast failed and not succeeded, but that only fixed it server side, it doesnt work from client
But it calls?
its a custom type with parent of Object
RepNotify functions in C++ trigger on the Client if the value replicates (and, by default, changes)
A multicast to change such a variable makes no sense
If it's just a normal object and you aren't replicating that via c++ then that won't work
In BPs you can't replicate plain objects
how would i go about replicating it through BPs? or is it easy to do from c++?
Switch to actor?
You can't replicate it through BPs. You can only send Actors (that are replicated and spawned by the server) or Structs
And since that Payload is probably local only, you would need a struct
Is it easy to make it replicate through c++? or is it easier to switch it to actor?
Yes, I have realized that and changed the code - although modifying the repnotify variable directly on the server function still doesn't seem to cause the repnotify to fire, but something wonky is going on here /shrug
C++ would only allow you to replicate the Object via an existing Actor. Similar to how Components replicate.
I don't think that helps you here.
And an Actor would only work if the server spawns it, so that also doesn't work. You'll need to switch to a Struct
RepNotify doesn't call for servers in c++
In case you were expecting that
It should call on the clients though, correct?
if i just do a run on server from client widget with an Actor instead of object, that would work?
Of the actor the property is in is replicated and the property is set to ReplicatedUsing=..., as well as set up via DOREPLIFTIME and the value is different than the one the client currently has
Isn't RepNotify for a variable being replicated to? A direct change from the server isn't necessarily replication, right?
Only if that actor is replicated and spawned by the server
Which I doubt makes sense for a drag and drop payload
My plan is for the update on the server to be replicated to clients, e.g. if an actor gets hit and takes damage, the server calculates the new hp and then the hp is replicated out to clients
Maybe the actor itself isn't set to replicate, thanks
or, as it turns out, it is. idk, maybe it's something wonky because it's a component
so i should replace the object with a struct?
On the rpc atleast yeah
Oh so the inventory can work the same, but before i send to the server i convert to a structure?
The payload can stay an object but you would need to manually convert its data to a struct or have the struct in then object to begin with
And the struct properties would of course need to not be an object ;)
ofc xD
I'll give that a go, thanks!
Aha, it turns out it isn't finding the component, so the code that I was sure invoking all of this, in fact, is not being invoked at all. I don't know why this one in particular isn't working when the others are, but progress! Thanks for the help
Does anyone have some good resources for prediction in Unreal or are we still in the "engineer it yourself" era? If so, any good nonUnreal resources?
There are lots of non unreal resources that go into network prediction here: https://github.com/rumaniel/Awesome-Game-Networking
Some unreal docs there as well, although nothing for ue5, although it's probably quite similar to ue4
@thin stratus It works, thanks!
is there any way to know when a actor becomes "relevant" again once they enter the AOI? Other than just PostNetInit
BeginPlay doesnt seem to get retriggered
On server or client?
I thought Begin Play got fired
I think only if the actor hasnt been in the AOI already
then it gets triggered
but if a player is infront of you, walks a mile away, and walks back
Doesnt seem to get triggered
Only PostNetInit does
Was hoping there would be a BP solution for this but I can always expose the function in BP I guess
I posted this in #online-subsystems but it might be more relevant for #multiplayer -- not sure what's going wrong
it didn't to me either, until i searched the code base for that log and it brought me to NetworkPhysicsComponent.cpp
i've created a sandbox environement just to test the new physics system ouot. so i literally just have a character blueprint with 1 event. on space bar, add impulse to the root component. thats it.
What do you mean by new physics system, Chaos or something newer?
No I mean the Physics Replication settings. These:
I'm wondering if there's just a setup step that i missed
That's the experimental network prediction plugin, IDK the current state of it or if it works at all right now
there's the old built-in physics replication system that works just fine
oh what is this?
Should be on by default, look at the settings for a physics body
Does unreal engine have built in events or methods to know at which state the client is now after connecting to a server? like ("connecting, connected, failedToConnect")
The stock settings are really strict, you can find them in project settings
okay how would you approach a simple minigolf type of project? i need a decent smooth prediction solution for teh clients.
Why do you need prediction for mini golf?
It'll be a LOT easier without prediction and the gameplay will be the same
for the clients so it's not jittery i mean. If the player shoots the ball locally, and on the server. then wont the other players just have the position of the player who just shot be snapping around?
So I understand on a dedicated server for each player, there are two player controllers: 1 for the server and 1 for the client
Are these treated as separate objects, in the sense that if the server updates a variable on its player controller, the client would not see that variable change in the client's player controller? Or are the two objects synchronized?
Two objects are synchronized
But when the server updates a variable on the player controller it should be an RPC call of course
So either the server runs RPC on client, or set the variable to be synchronized
And there is only one player controller for each player
Why would two player controllers exist?
^
I was trying to better understand "switch has authority" and some of the conversation was suggesting there was a "server version" and a "client version" of the PC. But from what I understand of your answer; there is one PC object but it's shared by the server and the client.
Is that correct?
(and thank you btw)
No. The client and server are (discounting play-in-editor) running in entirely different processes - they cannot physically share any objects. But they each have an instance of each replicated object that is associated with the other side's version.
So conceptually you could say that there's a single player controller, but in actuality there's two that are made equivalent to each other through replication. And you generally know which side you're on based on either HasAuthority or IsLocallyControlled (these are not the same thing, they are used in different situations).
The server has one instance of the player controller, the client has another. The server has authority over all replicated objects.
Whether you want to talk about the conceptually-singular player controller or the two separate-but-associated real objects depends on the context.
Okay, still trying to digest that and I hope you mind won't if I ask a few follow up questions.
For "switch has authority" on the PC, Authority = (server only do this logic) & Remote = (client only do this logic) - is that correct?
In my setup, I am not clear on when I should use switch has auth vs. a "is local player controller" branch.
"local controller" is more about if they are actually being controlled on this machine
player controllers do not exist on other players machines (with the regular setup)
https://cedric-neukirchen.net/docs/multiplayer-compendium/framework-and-network
the actual player's machine in which they are pushing buttons to move stuff around have the "locally controlling" player controller
But authority is literally just one thing: if the local role is ROLE_Authority
Sort of... "authority" means, well, that you have authority over the object. You're allowed to do anything you want with it and everyone has to listen to you about it.
Let's say you have a standalone/offline game: you are always the authority.
Let's say you have a networked game, and you spawn a replicated actor (for example, a player controller): the server always has authority.
Let's say you have a networked game but you spawn an actor on a client (no replication): the client has authority because no one else even knows the actor exists - clients can't replicate things by themselves.
And even for actors that exist in a level for everyone but aren't marked as being replicated - all clients and the server have authority, because the objects aren't replicated at all.
I always favoured checking netmode in c++
The idea of authority is a sort of abstraction away from having to know whether you're the client or server. In most scenarios you don't actually care about client/server, you just want to know whether you have the ability to make certain types of changes that only the thing that spawned the actor would be able to.
I feel like a lot of fog has been lifted with these answers. Thank you all so very much.
It's an important distinction because there are situations where you a player and also a server, like netmode NM_ListenServer
which would arguably be mostly the same role wise as checking on the server, it's kind of case by case
Also Local and Remote role are flipped on client/server and I can't believe I never realized that until just now lol
Checking != NM_Client or < NM_Client is my goto.
yeah, that's by far the most common "is this NOT a server?"
Well, "is this the server?" more like 😛
but the other distinctions matter if you need to distinguish your own player vs other players in the local client world
so it's all case by case etc
definitely also brush up on the rules for who's allowed to RPC to server as well, that was my biggest hangup for a while
Yeah. There's a reason to use all the different tests. Sometimes there are multiple valid ones.
in a nutshell: generally playercontrollers and pawns are OWNED by you (not directly related to NetMode/NetRole)
https://cedric-neukirchen.net/docs/multiplayer-compendium/ownership
Sometimes I wonder how other engines deal with the idea of roles and ownership
I dislike not being able to make RPCs from anywhere at least
but there may be some massive spaghetti problem with that I'm not aware of
It's probably just about the network connection.
Or, rather, network channel.
The server only accepts input from actors owned by the client. So you can only send rpcs from those actors.
I'm sure it'd be perfectly possible for epic to have routed all rpcs through your player controller, but eh.