#multiplayer
1 messages · Page 252 of 1
it should be pretty much the same on server and clients at all times
minus lag etc
there should be no way that the server sees 1 and client sees 0
assuming that's correct, then your problem is in the usage of the parameter, nothing to do with networking
ok so that's fine then, does that mean the alpha needs to be connected to the param in some way?
as in this wont work because the alpha isn't involved?
yeah probably, do you want the outline glow color to be red no matter what or do you want it to depend on the alpha?
What's the rule here, the glow color is red when ____________?
I'm thinking it should be transparent when alpha is 0 and red when alpha is 1 but idk your design
ideally depend on the alpha, but I don't know how to lerp a linear colour. Do i have to break and make it into floats and finterp each channel?
in this case it should lerp from black to a "Chosen Colour" Variable
there's a color lerp
there it is
my problem was I was looking for an finterp equivalent
unfortunately that hasn't fixed the replication problem
which is?
you are welcome to give up on me any time
if you do:
BeginPlay -> short delay -> timeline -> call that function
does it work correctly everywhere?
same results as my previous examples. everything before the Outliune works
so this is the only node that's not doing anything?
I set the online platform (ie the susbsytem in the config) to null, to test in editor. Its janky but atleast there isnt the unique_net_id mismatch trouble that using steam will get in editor
with that connected, I get the unsynced results. With it disconnected everything is in sync
delay the DMI creation?
no
first check if that material is valid everywhere
this is the only param referencing the post process material, everything else is a material on a mesh
test the delay, if it fixes it then it's a race condition
is first person camera a component on this actor?
yes
does the delay fix it?
delaying after begin play?
sorry for the naivety, where should i be delaying?
test this
oh, yeah that didn't fix it
nor did this
then start debugging to figure out what's broken
did you enable replication on anything that wasn't by default? Also who's machine doesn't do the post process, the host or client?
oh u know what
only for troubleshooting, but put everything back to none
might be a locally controlled thing
since post process is GLOBAL
What's the idea here, an outline is on what pawn on what machine in what state?
do pawns with an alpha of 1 have an outline, and pawns without have no outline? Is that the rule?
should YOUR pawn on MY machine have an outline when YOUR pawn is vanished?
you, a ghost, trigger the vanish ability, and it changes your colour, transparency, and the colour of the outline/cellshading. Everyone should see me the same way i see myself
but it doesn't change how others look
yup
ok, so how does the post process know the difference between your pawn and my pawn on my screen
I guess that's pretty much my initial question, is there a way to do that or will I need to find a non ppm method? I also tried using a post process component attached to the player BP
I think the post process should ALWAYS be there, and you should draw to a stencil when vanished
the PPM doesn't fade in and out, your pawn draws to a stencil or not based on vanished state
ahk, so the issue isn't so much a problem with my replication setup, but more the method of the outline itself
will try the stencil method tomorrow. Thanks for bearing through this with me
First time delving outside of single player
Welcome to #multiplayer , it's 5x the work
I went through so many tutorials thinking "surely there's a more streamlined way to do this by now"
ye MP is pain. I would try writing down the work flow on paper to see if you can figure it out a bit better. Like
Client clicks button on UI -> Server Calls X Function -> Etc,.
A server vs client timeline can help too.
Make sure that all calls between lines are diagonals.
That's a good way to visualise it, thanks guys
What am I missing here, why is a func trigged from an OnRep called twice?
Have you restarted the editor and it still happens?
Yeah, that was a definite oddity. When wierd unexpected things happen, restart is definitely best bet XD
Hi folks. I have an issue with replicating a dynamic skeletalmeshcomp. I have a server rpc in c++ that calls a BlueprintImplementableEvent(https://blueprintue.com/blueprint/0wh-4bk5/) which attaches the dynamic component to the player skeletal mesh. The serverRPC also sets a repnotify value that calls the event as well. This is working fine on the client hosting the server(listen server) but the meshcomp doesn't seem to be replicated on the other connected client even though it is visible on the server. I think My understanding of replication might be a bit flawed here. Since the serverRPC changes the repnotify value shouldn't it replicate to other clients as well? I would appreciate some help thanks. Below is the serverRPC and rep_notify:
{
PlayerWeaponState = EPlayerWeaponState::Equipped;
OnPickUp();
GetCurrentPickupActor()->Destroy();
}
void AhordeGameCharacter::OnRep_PlayerWeaponState()
{
OnPickUp();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, TEXT("Working onpickup for client"));
}```
i have 2 teams, and each team can only control their owned units. when a client makes a request to move units, how can i ensure that they only move units on their side. Would sending their PlayerController through the RPC for a team check work since the client only has access to their own PlayerController?
Have the server assign a "team" to any units and also assign a "team" to each player's playerstate. The client can send the requested move to the server through an RPC, but the server should only proceed if the team on the unit == the team of the player.
we have something like that (rts game) and I'm currently rewriting similar logic to make it more flexible. But in general each PlayerController owns it's own units and when we given an order to an entity, we check if the owner equals the order instigator
how can i get the playerstate of the sending client? Would sending it be risky since Playerstates are replicated to all clients?
if you're sending an RPC to the server, presumably you're sending it on an actor that would inevitably be owned by the player contorller, such as the player controller itself, their playerstate or their controlled pawn, or a replicated component of one of these actors.
Player Controllers and Pawns have a reference to their playerstate. Playerstate has a reference to their controller and their pawn. The Pawn has a reference to the controller and the playerstate.
I see. so sending PlayerController is what i want. thank you!
or getting the playercontroller on the actor im calling it on
You shouldn't need to send the player controller at all.
is there a fast method to change the character anim class at runtime?
calling this on a multicast is very slow
GetMesh()->SetAnimInstanceClass(PlayerAnimObject->GetAnimBlueprintGeneratedClass());
server method which is calling the multicast is derived from c++ animnotify which is called in editor montage
why is that slow
the montage finished and after .5sec delay the new animation class assigned
I am calling it on notify end
I want it to be changed straight forward when the method is called
according to my guess it is slow because:
the current animation instance needs to be destroyed and a new one to be instantiated from the reflection system since i am calling GetAnimBlueprintGeneratedClass()
I would first profile and debug that this suspicion is correct. A 0.5second delay is really high. Might be due to something else
If it's indeed slow due to that function this is not the right channel to ask btw
tested with empty animation class and it sets quickly
Also, why is that a Multicast? I would argue that's State, so it should be replicated via an OnRep.
Also SetAnimInstanceClass most likely has to fully initialize the AnimGraph and all the AnimNodes, cache bones and what not.
can't do it using on rep in my system.
I will post now a bunch of code which will show the system in a minute
That can indeed be a bit expensive. .5 seconds is absolutely wild for a single call though.
If it costs a few ms then we would already say it's expensive
500ms is way too much
and its 500ms in my local system where i am playing as 2 clients
not sure in a real network environment how it will behave
i mean to open world clients
You need to profile it though.
void AArmaCharacterBase::EquipNotifyHandleFinished(class USkeletalMeshComponent* MeshPlayingMontage)
{
MultiSetWeaponAnimClass(EquippedWeapon);
}
void AArmaCharacterBase::MultiSetWeaponAnimClass_Implementation(class AWeapon* AttachedWeapon)
{
if (IsValid(AttachedWeapon))
{
if(!IsValid(AttachedWeapon->PlayerAnimObject)) { return; }
GetMesh()->SetAnimInstanceClass(AttachedWeapon->PlayerAnimObject->GetAnimBlueprintGeneratedClass());
if (UArmaWAnimInstanceBase* WeaponAnimInstance = Cast<UArmaWAnimInstanceBase>(GetMesh()->GetAnimInstance()))
{
WeaponAnimInstance->UpdateCurrentWeaponRef(AttachedWeapon);
}
}
}
void AArmaCharacterBase::UnEquipNotifyHandleFinished(class USkeletalMeshComponent* MeshPlayingMontage)
{
if (HasAuthority())
{
MultiResetMainAnimClass();
}
}
void AArmaCharacterBase::MultiResetMainAnimClass_Implementation()
{
if (!IsValid(PlayerAnimObject) || !IsValid(PlayerAnimObject->GetAnimBlueprintGeneratedClass())) {
return;
}
GetMesh()->SetAnimInstanceClass(PlayerAnimObject->GetAnimBlueprintGeneratedClass());
}
I thought I am just doing it bad practice, that's why didn't thinked to profile it
I mean, you shouldn't need to get the AnimBPGeneratedClss.
You usually just pass the UAnimInstance class into it.
trying UAnimInstance again, few days ago i tried it and there was some issues with it not remember now
it should be tsubclass and i just need to set in editor, right?
UPROPERTY(EditDefaultsOnly)
TSubclassOf <class UAnimInstance> PlayerAnimObject;
Yeah and you should be able to pass that into the SetAnimIsntanceClass
Thanks so much, I really hope it will solve that issue
*bump🙏🏿
it works without needing the bp generated class, and little improved, now its like .06sec delay before setting new class
I think i can solve it now by calling the end notify little early before the notify actually end's
"Dynamic Mesh" is what exactly?
Are you actively creating that component runtime?
I'm somewhat sure that doesn't replicated.
yes It's created at runtime
One usually has to create the Component on both sides.
And ensure it's stably named so it can actually "connect".
I think only Actors will be spawned upon replication.
With my current set up wouldn't the component also be created on the client since my repnotify function is also requesting it to be created? Is there perhaps something I need to include within the repnotify?
Ah you are replicating the equip state. Does the OnRep call properly?
If your current pickup actor is replicated, then it could be that it gets destroyed before the OnRep calls.
Cause you destroy it directly afterwards
interesting... let me try it without destroying the actor.
You can try to either delay the destroy by setting the lifespan, or you can try to call TearOff on it, which cuts the replication ties. But then the client needs to clean it up for itself
Which in theory is fine cause I assume the client can just destroy it locally after equipping
I removed the destruction of the pickup actor but the behavior is the same. maybe it might have something to do with the blueprints? I feel like the implementableevent for some reason isn't called in the rep notify.
PrintStrings to debug (:
Ah I think I see the error of my ways. I assumed that because it was spawned on the server and was marked as replicate that it would automatically do that in the client as well. I ended up spawning the component as an actor instead and then I enclosed the spawning and calling the blueprint event into one function that I call in both the server rpc and the repnotify. The BP event remains the same. It looks something like this now:
{
if (TObjectPtr<UWorld>World = GetWorld())
{
const FVector location = GetActorLocation();
const FRotator rotation = GetActorRotation();
FActorSpawnParameters spawnParameters;
spawnParameters.Owner = this;
WeaponMeshActor = World->SpawnActor<AWeaponMeshActor>(location, rotation, spawnParameters);
OnPickUp();
}
}
void AhordeGameCharacter::Server_HandlePickup_Implementation()
{
PlayerWeaponState = EPlayerWeaponState::Equipped;
SpawnAndAttachWeapon();
GetCurrentPickupActor()->SetLifeSpan(1.5f);
}
void AhordeGameCharacter::OnRep_PlayerWeaponState()
{
SpawnAndAttachWeapon();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, TEXT("Working onpickup for client"));
}```
Thanks for the rubber duck session! 😃 it's working now
i'm confused about the intended way to do replicated movement with the built in CharacterMovement component - it seems like for other things, setting up an explicit server RPC to trigger them is the way to go (like firing an attack), but the CharacterMovement component has built-in server side movement validation? so I can call the movement functions on the client and as long as replication is enabled the server will still be validating the movement even if I don't explicitly do it through an RPC to the server?
The CMC has Client Side predicted movement. The Client performs a move locally, then sends that move to the Server, the Server validates that move. If the Server disagrees with the move, iit will correct the Client.
This ensures that the Client has instant feedback on its movements locally (a smooth experience for the player), while allowing the Server to maintain Authority over the Client (to limit their ability to cheat, like teleport or speed hack etc etc).
so it sounds like using the component implies server authority as long as replicates = True, and I can manipulate it directly on the client with the replication/validation all getting taken care of. just wanted to double check my understanding
As long as you are "manipulating" it through its supported functions, sure.
Generally you will provide the CMC with Inputs
Like Jump, Crouch, Move Forward etc etc
It translates those inputs into "moves"
Which it then uses to sync with the server.
Biggest point is that you usually don't need or should use an additional RPC for movement related stuff. It all has to go through the existing RPC in C++, where you can pass additional information (usually only info the server doesn't know about, aka input) via a container.
That's also why proper predicted custom movement is not a thing in Blueprints
is anyone familiar with this connection error for connecting to a dedicated server?
"PacketHandler parsing packet with zero's in last byte"
If you want to manipulate something on the client locally that is driven by replication you absolutely can... you should just not change what gets replicated down
for example you can override the onrep for actor movement replication and forward it to something else and apply it later as you please
but changing the ACTUAL replicated property locally is a bit nasty as some things may assume you aren't doing that
that's mostly for simple simulated proxy stuff
the CMC server simulated move playback is basically a tiny rollback sim, on sim proxies it's just a position + velocity mostly with some metadata for timing and if they are crouching etc
making stuff work correctly in the CMC requires actually extending the simulation steps IN the cmc itself
you can't just apply stuff in the regular game tick as the CMC has its own inner loop that both sides work together to maintain a similar "good enough" result (considering the saved moves afaik)
clients spam rpcs at the server with where they THINK they are in which way they want to go
the server tries it and sends back the result, if it's too far you get bonked to where the server says you are
So when you've got a timer on a server doing something, like crafting or farm growth, and you want clients to be able to use the time elapsed to show progress bars, what's the best way to do that?
My initial hot take is that you should not need to send constant timer updates if it's known when it started and how long it will take
then you can just compare with the local time on the client or with a roughly accurate server time (made with some math, there is an example I can show)
it depends on accuracy needs though and how bad it is to predict too early or too late
the more stuff you can send in the initial packet that describes the state for a while without needing to constantly rely on a stream of new data the better imo
So it would be some sort of "start server time", from getservertime?
Just a float? And another replicated float for the length?
this is just my rough idea of how I would do it, I think there are plenty of other ways that might make more sense
a float is okay here but risky if the game server is around for days at a time
as it might start to lose accuracy at higher counts
We're talking processing time in minutes
but that's unlikely to be an issue here yeah lol
the offset time is one thing but there would be an absolute time here
I am being a bit overkill trying to make this more quantized here... you can probably get away with sending a lot of these
I would say it's worth considering if you have a LOT of these that get sent at once to try to make them sort of derive the value from other offsets or to be able to send the timer for multiple at a time
but thats something you can make better later I think
for example a single actor rep movement + transform is like ~12 floats or something worth of data
depending on settings
for now I would say just try to make it resilient to people showing up later at the very least (use onreps etc) instead of rpc based
is there a way to have the standalone client and dedicated server launch different maps on startup when running through PIE? im testing out a flow of launch standalone at menu -> click button to connect to server, and have only gotten it to work when starting the dedicated server in a separate process
it's a pain though because then i have to wait a lot longer for the dedicated server process to go through the full startup each time
When you've got a variable that's replicated, if a client changes it and they don't have authority, then it doesn't change, but what's happening in the back end? Is it sending the variable up over the network to check for changing it, or is it doing checks locally in the engine code to decide if to even both sending up?
Does it matter if MARK_PROPERTY_DIRTY_FROM_NAME is called before or after the property change? I thought it had to be called after, but in Lyra it's always called before.
MARK_PROPERTY_DIRTY_FROM_NAME(ThisClass, PawnData, this);
PawnData = InPawnData;
only server has authority to change replicated variables, if client tried it it will be changing for just the client locally and will not replicated anything
I don't think it matters, Afaik MARK_PROPERTY_DIRTY_FROM_NAME just marks the property dirty so it's processed next net update
A further one on this. Replicated timers don't activate on clients, but the structure is set to be "valid" and so can be used for replicated checks that a timer is running on the server?
why using MARK_PROPERTY_DIRTY_FROM_NAME tho ?
editing the prop on server should trigger the collection of it anyway ?
It will skip the property if you're using push model
i heard of push model but not much
is it a alternate networking system where instead of pooling the objects you have to manual trigger ?
im not finding much on the push model system
Throw some brainstorms how I can manage my anim BP for different character classes like for different abilities. Say like Marvel Rivals. My mind boggling
When you register your property for replication in GetLifeTimeProps or something you can set it to be Push based, you just set a bool to true
When you do, the engine will not diff the property unless you mark it dirty with MARK_PROPERTY_DIRTY_FROM_NAME afaik
okay so this have perf gains in some cases
I believe so, but I heard some people saying it doesn't help
Hey everyone, does anyone know of a nice way to get the functionnality of a tmap in a replicatable way (TMaps don't support replication ☹️ )
one way to do it is separate the keys and values into 2 arrays when you need to replicate it and rebuild the tmap on the receiver side
Yeah, I'm watching a youtube video that does something similar : when the map is modified it gets converted to an array of tpairs that is replicated and gets reconverted to a map on the client side.
I think I'll try that.
Yeah, I'm trying to do method 2 right now. Thanks for the link.
I create a custom uobject from an actor component, and replicate it via calling AddReplicatedSubObject
I try to use the object as a parameter in RPC
if I call a multicast RPC just after creation and AddReplicatedSubObject() call, the client does not get a valid ptr (it is nullptr)
If I add a short delay before the RPC call the client gets it properly
is there a way to force init stuff so the object can immediately be used as parameter in RPC-s or is there a way to check if it is ready or not? what exactly do I need to wait for here?
Did anyone managed to make custom movement like climbing the ladders work in multiplayer?
No. You cannot guarantee that the object would start existing before the multicast is received - this happens with every type of replicated object in the engine.
From what I understand, since UObjects are they very base thing that exists in the engine, they don't have anything that can help facilitate knowing when they start existing.
The "easy" way to know when an object exists on a client is to set its reference within an OnRep property somewhere so that when the value of that OnRep is set and the OnRep function triggers you can try to access it and do something with it, but this still pales in comparison to how "Begin Play" works for actors. I'm sure one could duplicate how an AActor ends up calling BeginPlay but it seems rather convoluted, at least to me, as to how one actually gets from the point of constructing the AActor due to replication to the point where Begin Play is called.
something like PreNetReceive of the created object would work as well then, right? instead of the OnRep function
as we are on the client anyway
(the created object has replicated properties too)
I don't want to go the OnRep way because I create multiple instances from the object dynamically
Technical multiplayer question.
suppose i have 100 weapons and each weapon has unique set of animations/offsets/locomotions for character.
so which option is best to implementing them?
1: in a single character animation blueprint class
2: let every weapon has its own animation class for character and when equipped, set the animation class to the owner character
currently i'm doing option 2, which works perfectly but have 0.06sec delay when switching animation class
That's probably a hitch on loading the class. The solution is to async load the classes you may need to use.
Thank You I will look Into it
Ha! so to develop in the editor as dedi then you need to have the following set:
Run Under One Process = FALSE
Play Net Mode = Play As Client
Other wise it probably wont work as you expect 🙂
I did some boiler plate test code, and this would fire on all clients:
Controllers[Choice]->Client_OnScanComplete();
This was related to Run Under One Process being true.
The idea is a message is GEngine Logged on a random connected client. So not supposed to fire on all clients.
I got a feeling that allot of the questions here may be related to this configuration requirement.
Hi ! I'm trying to make this door blueprint work in multiplayer, but I can't figure it out.
I'm learning as I go so this blueprint might be all wrong already but the door does work as I want it to.
Can't make it replicate tho, I've been told to use repnotify to achieve it but don't know how/where to set it up.
Any guidance would be welcome. 🙂
event interact is called by server?
Well, that even I'm not sure. How would I know ? This event is set in my thirdpersoncharacter bp and is a bit of a spaghetti itself.
As I said, learning this stuff, sorry.
call node if switch has authority print string
it will print the role to know what calls it
while running on server, it prints "server", while on client it returns "client"
Is that what you were asking ?
Looks like you are calling this interface function locally on input
If you want it to be replicated, a good solution is to have the server calling "open door" and "close door" (server RPC). Those functions changes the value of a replicated bool "IsOpen".
Inside the OnRep_IsOpen you call your timeline code
Thanks for the insight, will check this out in the morning
So repnotify isn't the way to go ? Or is it working alongside rpc ?
save the output of your timeline alpha * angle to a replicated float with repnotify
in the repnotify, set the relative rotation
then everyone should see the door angle the same as the server
Getting out of bed to see if it can really be that simple lol
Ooof yeah ok that does work !
I'm really confuse with the RPC process, why is that I can only see the pickup in the server side? I already did an RPC call to pickup a ball when entered the character trigger area:
@dark edge Got carried à away and forgot to thank you. Thanks 🙂
why are you doing all that
delete all those RPCs
use a replicated variable to represent state and use repnotify to do things on clients when the state changes. Set that vairable ont the HasAuthority path of that overlap chain and you're done
Like this @dark edge ?
you can lose that server rpc too
overlaps happen on server as well
don't let the client say "I'm holding the ball now" unless you're ok with cheating
What might be better though, is for a replicated ball to have a replicated reference Who'sHoldingMe
Instead of 10 players saying if they hold the ball or not, you have 1 ball saying WHO is holding it
yeah good point
so I should transfer that variable to my actorBall, then do the onRep there?
does anyone have experience adding grpc to the build system? not super familiar with the build setup and trying to add grpc/protobuf to it in one of the template projects, was wondering if theres a recommended resource or way to do this
To the build system? What does that have to do with #multiplayer ?
oops, not exactly sure where the question should go, maybe cpp?
I managed to sync load the animation class and then set it, but it still have a small glitch when transitioning from previous to new animation
if (!IsValid(Owner) || !ThisEquippedBy(Owner) || !Owner->IsHolding(this))
return;
FStreamableManager& Streamable = UAssetManager::GetStreamableManager();
FSoftObjectPath AnimPathToLoad(TEXT("/Game/Animations/abp_AKM.abp_AKM_C"));
Streamable.RequestAsyncLoad(AnimPathToLoad, FStreamableDelegate::CreateLambda([this, AnimPathToLoad]()
{
UObject* LoadedObj = AnimPathToLoad.TryLoad();
UClass* LoadedAnimClass = Cast<UClass>(LoadedObj ? LoadedObj : AnimPathToLoad.ResolveObject());
if (LoadedAnimClass)
Owner->GetMesh()->SetAnimInstanceClass(LoadedAnimClass);
}));
I'm running into an issue where I'm generating splines at runtime and the colliders aren't working on the dedicated server. I've verified I'm replicating the the points with rep-notify, I'm doing a build of the mesh on all pieces individually for replication speed. Clients and servers use the same function to generate everything, including collision. I've added ``` PublicDependencyModuleNames.AddRange(new string[] {
"Core",
"CoreUObject",
"Engine",
"InputCore",
"OnlineSubsystem",
"OnlineSubsystemUtils",
"Chaos",
"ChaosSolverEngine"
});
// Required for splines to generate collision in dedicated server builds
PublicDefinitions.Add("WITH_RUNTIME_PHYSICS_COOKING=1");``` to my build files to try and get the server to use this, but it doesn't seem to work right, I don't have any other build files and it works in the PIE with dedicated server running all players as connected clients, so it seems to be a build issue specifically, but the wizardry is failing to find a reason it's being stripped out
can someone please explain to me what things need to be ran on the server and what things need to be ran on all clients?
@cerulean barn here's a great helper set of info
thank you
there is not a clear and cut answer, you need to understand networking and the specifics of each system.
But as a rule of thumb, the more that you can get away with server-only the better. It's more safe against hacks and simpler to code
If something is only relevant to the player, such as some UI displaying damage dealt, then client only
and usually client+server is in prediction scenarios and can get tricky because if client and server disagree you need to somehow resolve it
hi lol
im stuck at door replication, most likely said, the door doesnt open at all
how do games such as ark:se/ark:a handle the based movement on things like dinos or the ship/skiff without the jitter it causes given player 1 controls the thing you are standing on thus it always throws off player 2's prediction
in cmc the client auth movement is allowed i guess, else server will correct the client location which can feel jitter because of network latency
I was thinking about that, but It would be too easy to cheat
and even though ark is pretty bug ridden it never had any similiar glich/exploit
this is why in pubg so many speed hackers
else nobody will play pubg with jitters
is there no way to smooth out these jitters? Like make them take longer or something
you can for now allow it, and in future disable it when there will be 6g net in every home
client side prediction
or make the server correct the location every 15sec example
instead of on every frame
yeah but client side prediction is the cause of the jitter as it predicts a different velocity even with built in systems in engine like acceleration or braking force
seemingly prediction even ignores those as well even though they are in the same component as the prediction, the CMC
on github some open source projects can help you to do client prediction correctly
I will look into it thank you
Anyone have any idea why I cant rotate a player thats possessed?
Having issues rn, I have tried absolutly everything and cant seem to get it to work
SetActorRotation, SetControlRotation (Server and Client)
If that player is possessing a character, it's likely that the CMC is overriding location and rotation values. I don't know how it should be done but most likely it requires using the CMC itself to set the rotation.
If anyone has an idea it would help a ton!
Been struggling with this for a hour now
ahaha
What's the world's GameMode & GameState class?
wym? They are custom ones, and parents are the base ones
Make sure if your GameState is inherited from AGameState then your GameMode should be AGameMode and not AGameModeBase, I had a experience where the character froze if I don't do that
My issue isn't the character freezing, I am trying to rotate the player in a direction when the player sits down. Right now the player dosen't rotate, so trying to figure out how to do that
print string to verify if the function you want to use to rotate the character is called on first place
Okay, I tested it myself, you cant set the character's rotation / control rotation on the server if the character is possessed. So my quick solution is to try running SetControlRotation() on the player client that is sitting.
I tired that and was having issues
If you can't do that, then you need to make that player unpossess the character temporarily and then you can do SetActorRotation() on the server
would that have any visual glitch when unpossessing?
yes, but you have to test it yourself
Out of curiosity, any tips on how to store player stats/data? I heard some use PlayFab Azure but wanted to see what everyone else uses
It's the only method you should usually use, yes.
I mean, you can always create some other form of connection and send data that way, as long as you know how to do that.
But you won't find any "new" method. RPCs aren't doing anything different than leading to bytes being sent across the net.
Hey guys, trying to do a physics handle pickup
already got the interaction and execution of it down, it just looks super jittery.
if the server has it, it appears super jittery on the client side.. vice versa
tried this rpc but still have the same result? replicated movement and replicates are on all of the actors.
Tick is already running on every instance. Sending the RPC is somewhat redundant. Also you should probably just let this run on authority and replicate the location to everyone. With physics you can more or less forget about prediction anyway.
And what you are mainly lacking is interpolation. Even if you limit the SetLocation call to authority, the replicated location will never be smoothed on its own
Also there is a good chance that the first person camera isn't rotated correctly on the server. You should probably fall back to using control rotation.
Hello,
While testing networking on Unreal Engine server-side as a listen server (with an average ping between 10 and 50), everything looks perfectly smooth on the clients. However, on the server side — specifically for the host (me) — characters appear to stutter heavily.
How can I fix this issue or at least minimize it? I would really appreciate help from someone who truly understands this. Please, I've been dealing with this for months, and it's been frustrating trying to figure it out with almost no resources or proper documentation on Unreal's networking. If there's someone experienced out there, I’d be grateful if you could get in touch.
Also, kindly, I’d prefer not to receive speculative comments from people who’ve only been experimenting with networking for a couple of days.
Hey all quick question, I've got a chat system set up and I'm trying to make the owner's name a different color than all of the other current connected players. I've tried setting it on a condition is local player controller which only sets the host's name to that color. what would be the proper way of going about achieving this?
Did the check for is local player controller not work? Or what do you mean by owner if not the local player?
yeah, I'm using the check is local player controller as the condition. However it's just setting the host's name to the color (green) in this case and the clients to (blue) what I am trying to achieve is the local player only sees their name as green and everyone else in chat as blue.
Then you're making the check on the wrong machine.
Should I be running it as a client event?
You have a chat system. It sends a message. Hopefully carrying with it the sender. This should likely be their PlayerState. You should be checking if that playerstate's controller is valid and is a local controller on the machine displaying the widget.
ah okay, I'll give that a go
ListenServer seeing clients stutter is because the Pose is ticked via the Server RPC for movement. If the Client has a lower update rate/FPS than the server or generally it will tick less often. On top of that, if the client goes past 60 fps, it will start combining moves and only send every second move.
Given how many games uses moving platforms driven by other player does the CMC support smooth based movement on platforms that are have unpredictable movement, such as ones whose movement can change any time based on input on a remote player?
Like you can run around on dinos, rafts, skiffs in ark without jitter, same for Atlas, Sea of Thieves etc
I've been messing with replicated ships which move buttery smooth on controller player(driver) as they of course predict it for themselves, they move smoothly on observing players who don't stand on them, but if a non driver is standing on deck it causes vicious jitter as it tries to predict it constantly, giving new movement input, causes a huge jitter as expected, and even built in braking and acceleration set in the CMC causes micro jitters
I assume its doable given how many UE games do it, I'm just unsure if I'm overlooking some setting in the CMC or do I need to go deeper into its C++ and add customization there
The Platform and the players are both currently controlled/moved by their own CMCs and not physics as my project wouldn't work well with physics
the answer is based movement
it just sends the relative position
if that doesn't work you can just attach directly I guess
something like a ship should probably just have the player attach themselves to it imo
I'm currently using based movement afaik, but it still jitters when the boat has a speed change or controller turns the boat/movement direction
I'm trying to do it like Sea of thieves where you can run around the ship and do stuff while your coop partner drives
I tested it and according to the cmc it recognises the boat's mesh as a valid base
yet for the client standing on deck(not the driver) it boat seems to wildly jitter on turn and acceleration, while for the bystander client who just looks at the ship the opposite happens, the deck client is the one jittering while the boat is smooth, Same goes for the driver, they see the boat moving smoothly given they predicting the movement themselves and only see the passenger(deck) client's pawn jitter
Hey guys, I have transform bone nodes in my animation blueprint, are these something that can be replicated? everyone in my google searches seems to still have issues.
So say I'm modifying a bone with my control rotation so my head tilts back when I look up. I'm controlling this in my character blueprint and casting from that in my ABP. With this method I can get the server to work, and all clients see the servers bones transforming, but clients can only see their own bones transforming. Is it possible to get everone to see everyones bones transforming or should I give up on this?
Here's an example showing their heads tilting down
- Clients see their own bones and servers bones transform
- Server only sees their own
Pretty sure the problem is that the boat is predicted on one client
There is nothing inherently different for getting this to work vs other stuff.
If clients need to see something, then the server has to replicate it. You can't replicate stuff in the AnimationBP, but you can in the character. ControlRotation doesn't exist on other clients, but you can use GetBaseAimRotation, which uses a replicated pitch value.
If you need more custom stuff then you need to replicate it properly through the character
So this is my current setup going from the character blueprint to the ABP. Should I be doing any logic in the OnRep functions? If so, I'm having trouble wrapping my head around what would actually go in it.
This setup is based on this thread: https://forums.unrealengine.com/t/replicating-bone-rotation-modify-transform/374171
I'm new to replication so feel free to talk to me like I'm stupid because in terms of this stuff I kinda am
forgot to include what's in the ControlProperties function:
oh shit, figured it out. This method works if I swap out get rotation with the base aim node, thanks so much @thin stratus
You don't need to multicast etc that
All you need to do is use GetBaseAimRotation in your AnimBP
Instead of the replicated ControlRotation
And replicting ActorRotation is just a waste of bits
ok yeah this is falling into place, thanks again
basically this is what's happening, I removed all the parts until I was left with only a cube, that I now scaled to be long as I though it might be sme issue with the it slipping out from under the base finder linetrace
but as you can see the issue persisty, the passenger sees the platform(base) jitter the driver of the platform and the observer pawn sees the passenger itself jitter and according to both server and client it recognises the long strip as a valid base so it should use relative location yet it jitters
I understand what you're saying, and it actually makes sense when I think about it. So, what can I do to minimize it?
So I can't even say anything
I went into the settings and turned on "Base on Attachment Root"
it started working smoothly but to be sure it was the thing that fixed it I turned it off again
and it still works
this is the only change I did and then promptly reverted it and it started working
Only took 2 days and doing absolutely nothing in the end to fix it
Does the ship move from ticking? based movement assumes it can change ticking prerequisites
it is moved as a character but it now works perfectly
even though as I said all I did was enabling the "Base on Attachment Root" compile-> save then disable "Base on Attachment Root" compile-> save
before that it jittered after that it fixed so I guess it would've flushed something
I would suggest figuring out which one is ticking before the other
Could be that it totally breaks again if you switch who controls whom in the middle.
Do you know exaclty what the solution is ?
@odd gulch p.NetEnableListenServerSmoothing
make sure that is on at least
I would suggest making sure SmoothClientPosition_UpdateVisuals is doing... something on the listen server
make sure NetworkSmoothingMode is on something not none too
p.NetVisualizeSimulatedCorrections at 4 or so should show a complex debug draw... not very useful as its a bit difficult to tell what it's supposed to be doing but I would compare that with the typical client smoothed result
I will check and get back to you, thanks in advance.
ship's movement is based on the input event
This is a somewhat basic question, but am I right to think that when replicating any kind of value that’s changing with a velocity I need to also send a timestamp to compensate on client?
So like, in an isolated example if you move at a speed of 5cm a frame at 60fps simulation speed and want to replicate to clients, you send current position, speed, direction and a timestamp so clients can compare the latter to determine their latency and compensate by direction* speed* time latency
I did what you said, but nothing changed.

depends how fancy you want to get, but yes you might send acceleration and velocity etc and apply the values in different ways
I would start simple and get into complicated stuff if it's needed
Yeah I should probably just see how it goes with just replication lol, though I suspect it's going to jitter a bit with medium-high latency
Wonder how those games that rely on sync and simulate everything else independently do that
im having an issue with redpoint eos and common plugins where when i create session it auto opens the same level im on, before using common plugins i would call create session then open level with ?listen and that worked fine... how did you solve your issue?
I have thought this over and I do wonder if it is possible to delay the up stream. So that the client is waiting.
To counteract, all/anything that could be auctioned between that await time would need to be re-validated.
Or held off to be validated when the response is made. is tricky.
in cmc there is a variable to allow client auth movement and this solves the jitter but security risk
only custom cmc is usefull and will need alot of work to handle that security risk of hacks
yeah if the client can move the Character Movement Component (think that is what CMC is) then that can cause complication.
Without the server snapping it back then everything would be out of sync. but the problem I have possibly noted (not tested) is that the client can delay the response then teleport to another players location (if the client has it) kill them and return. The only way to detect that is by validating/re-validating the shots, damage health. But it would probably be all out of sync any way. A simple solution would be to watch the time stamps and flag any strange patterns.
I got a shooter game demo project from someone claiming was working at aaa company , and that project has something similiar to check player patterns for movement and predicting where should be the player at this time according to the movement input, if there is a big difference it detect it as a speed hack
currently breaking my head with this project to learn how this all stuff working, there are no comments for stuff to explain 😄
Um, is something I forgot in that message above. That may help the next chunk of text make scene.
Event though the server is awaiting a response from the client that is doing some network trickery, it has communication with the other client that got killed. The problem is the server can not validate if the other client that got killed is reporting/relaying the the truth. So how to solve this. next chunk of text on he way.
if the client got killed, he can still remain possessed by temporary AI for validation
The first and most simple way I would do it is to have server based triggers that the players have to pass to be in a location (the player instance on the server passes them). This can be a good way I guess to invalidate the damage. Another way is to calculate distance traveled of each player, not so simple but they wouldn't match.
I'm validating hits on server, so basically a client can see the other client taking damage but if server not validate it the damage will not be dealed
so shooter only see visual effects
doing the whole gameplay on server is a good idea but the game will be lagging if there is not a stable connection
actually yes that is correct now you put it like that the server would not apply the damage as the client is not responding. Hmmm.
If the code is solid 😛
yes server logics are always simple and solid, it not need fancy things
I can see how it is possible tho.
this works the way like clients copies on server deal damage and the result is replicated to local client
Ray cast hit would result in small amounts of damage. A knife attack maybe allot and the really tricky one damage radius.
Throw a grenade reconnect, boom.
I mean if the grande trajectory code is not simulated on the server. And it can be.
@nocturne quail I think server based logic for almost everything is heavy.
And that is one limitation. But I am starting to wonder if the server logic only can be tricked.
I guess it adds more wight to the servers processing demand to counteract some of the more extensive validation checks.
and that result in $$$$$
validating simple code stuff is not heavy unless it involves large heavy ticks
basically a proper design will not effect server performance
for damage system i use linetrace for all hits
and so far it has no performance hits
for grenades do a linetrace from the center point like shown in image on all directions
I know the UE engine is a beast, like the more I understand it, it shocks me.
but one can never trust a client.
And every possibility needs to be defended.
well depending on if it is a cash grab or not I guess.
The problem with the grande is the throw it has to be simulated to know for sure it is at that location.
Basically the radius is defined by its landing location.
the ray casts both gun knife have origin locations so as long as that is tracked then that is fine.
grenade should have time like 5sec, it will explode after 5sec no matter thrown or not and do line trace from the explosion point
put a socket somewhere in weapons to do a linetrace on forward vector of that socket
for a pistol it should be the muzzle point example
if the scope is attached, do line trace from the attached scope
it will again need the bullet socket on the reticle point in scope
trace on all directions example
#blueprint message
Actually that would work, if the distance between the grenade landing and the grande spawn point is validated.
if server did that trace, no need for validation
The server would receive the data from the client.
just delayed.
yeah lots of scenarios in that case
Yeah but i think what you said is a solution that has me a little confused.
just don't delay user inputs to server, developed a best design with a perfect movement prediction and lag compensation it will solve lots of issues with server latency
replicate custom data as less as you can
Yeah but I have seen player teleport and do strange things in games built with UE, it has to be down to the code of that game.
like if a client is not in range, we don't want to replicate stuff to them for no reason and replicate to them when they comes in range
it has nothing to do with engine, it all depends on the developer how they do stuff
This is another thing that has been on my mind.
As soon as the client has the data, can it simply render a overlay as the data is in memory.
client can't dictate server, server dictate client this is what unreal network model is popular for
Any way, that one is the one I want to experiment with.
I think what I have seen with the teleport is just bad code.
if client change something in their local memory it can't effect the server copy memory running somewhere else
right
You nailed it with the distance.
What happens is that the sever receives the call to instance and throw a grenade on a delayed response.
Without knowing its spawn origin or simulating the landing position. it could register and apply damage.
because of the packet upstream delay the server has no idea about the manipulated data by the client.
server is not interested in the client data, server has its own copy of the client which will take damage and it will replicate to the local instance which will get killed
It is not that simple
if the local client changed and tricked that data, server will know that client should be killed , why its moving around, kick him
when you connect to a server, other client sees your copy on server which is owned by server
nobody can manipulate that copy
the only thing impossible to detect or very hard is aim bot
can even compile the code out.
what?
with a dedicated build the client can have the server logic compiled out , I know as I have done it.
but the issue I can see is the RPC call is fired by the client, and because of that it is actually
possible to trick the server if one has made a mistake in the servers logic.
yes and we can't blame the engine for this, again bad developer or for a reason allowing cheats 😄
Hell no I don't blame the engine for that at all. UE is a beast on all levels.
um sorry for the wall of text .. I best ff now.
no issues, you increased my knowledge as well discussing this stuff on multiplayer
does anyone know if there's a nice way to run multiple dedicated servers locally when running the PIE stuff in-editor? i'm setting up a system where the player gets moved from one server to another as they change instances and was looking for a way to configure this in the editor or elsewhere
You can start servers via a bat file
Just need to reference the editor exe and u project file and plug -server and -log behind it
Sorry to revive an old thread, but how & when does Lobby Kit facilitate connecting clients? You said clients need to establish their player count before connection, so how does that work with PIE?
What part of all of this do you mean?
Cause I posted pictures of everything.
So I assume you don't mean the info I already shared
Woah woah woah - why ask that? Instead ask if he would share Salty Panda's Lobby Kit 🙏
It's Blueprints. Why would you want that :D
Because it is less work for me. Work is bad.
You can ask again once I turned it into a plugin
UE6 will release before then 😭
Probably
I do need to brush up the lobby kit eventually. But the marketplace/fab is too saturated anyway to invest time into it
I'm just confused about the order of operations
In the little experiment I did I allowed adding and removing local players in the main menu, before the player connects to a lobby.
Correct
I don't think you can add after connecting, but not sure.
The whole thing is meant to be LOCAL players being also registered as normal player upon login/connection.
If you are past that point, it would need to magically run through that when the player locally adds a client, which feels like a bad idea (could add 1000 players for fun and see things crash).
And the server adding them would not result in the actual player knowing about them.
Especially if it#s a listenserver, it would just be a second player on their end.
So just based on that I doubt you can spawn them after connecting
Multiple local player controllers persist across server connections and/or listen server restarts, right?
I wouldn't say persist, as the actual PlayerController Actor is most likely recreated in various scenarios.
But there should be ULocalPlayer instances that should survive I guess.
What kind of clock is usually used for client prediction?
When you need to predict future state to compensate for one way delay
I am going to build out allot of my ideas that will be open to test.
I am looking at creating some kind of network logging layer that can be seen side by side the running game.
Also I did not notice the possessing the player with a temporary AI after the player has been killed.
That is interesting. And also yes the mouse-look is an aim-bot magnet as it client side. I have had ideas of other types of
combat systems that are server only to remove the aim-bot effectiveness.
But I haven't built enough experiments of the network code yet to really get a
feel for what is cost effective and not.
Why do you possess a dead pawn with an AI controller? And don't do server auth for player's aiming. There's a reason it's client auth and things like EAC exist.
Sorry last message for a while promise. The other things I was looking at was the line of site server to client stream.
So a client would only know of data that would expose valuable data to a 3rd part tool, if the client can see the other player/players/items.
I will experiment a lot with this concept over time.
On the server. I think the idea would be to keep a replicated instance in place.
I'm not sure what that was a response to?
From data prospective. Say the player is destroyed and re-instanced then any data that the sever may
need to reflect on after the event (death) has passed. If I find a situation where I need to do it I will let you know.
Is many ways to go about dealing with a problem and is always a good idea to experiment with a few.
Or could turn them into zombies ha.
But why an AI controller? The pawn is "dead". Unpossess it, let it visually die off or do whatever it needs to do post death. Then later make a new one for the respawn. What does the AI controller bring?
That doesn't make any sense, aiming is always client side for good reasons. Don't try to reinvent the wheel, if it was viable other games would have made it too
As long as the data can be stored somewhere for reflection.
C++ instance of the class seems like a good idea to me tho.
Yeah I am totaly going to do that.
@kindred widget Ok no more messages after this, but you got me thinking.
I don't know if this is possible in UEs code base, but what I do in other development is serialize a class and store them as data.
Then the class can be re-generated with the exact state of when it was captured. Sort of a like a snapshot of the CMC Class in time.
that's irrelevant, you need to understand latency and why certain things happen on client vs server.
Sorry message wasn't for you.
Hu!
@prisma snow this is about as much the client can do in my case: 'CanIDoThisControllerOfEverything()', notice no arguments.
hook that up to an aim-bot.
It's not worth to sacrifice the player experience of everybody to avoid the potential aimbot cheat. Again, if your procedure was viable all other games would be using it.
If no game is doing what you're doing, you are most likely going down an unreasonable path.
In the Common Session subsystem, in the C++, you will find a binding to when a session is created. You need to comment that binding out. That's why it reloads the current level.
Plugins > CommonUser > CommonSessionSubsystem.cpp
You can validate/check for the aim-bot activity on the server. But not wasting time with that nonsense.
Client data = no data.
Probably unrealistic af to scale tho ha.
I come on here as have a question. Development related:
I moved over to visual studio code from visual studio, and I created some blank class files in IDE.
Do I have to re generate the visual studio project files?
You can't really check that on the server though. Do remember that you have to send all of that data to be verified. And given that most non critical input is not reliable, you'd be doing this passing of data outside of the look events themselves by saving them somewhere on the client and passing them through a reliable RPC later. This can already be tampered with. But even if we pretend it cannot, you've now added an assload of data just for one person's aiming code. Multiplied by intended player count.
And you have to rely on the client passing that data to the server. You cannot rely on the Server's version of what it thinks client is doing because client needs to be able to look around without the contraints of the server. Even if there was zero network lag and you have a client running 120fps and a server running 30, it'll feel bad for your client. Add in latency and unreliability of packets and kaboom. Server does not have an accurate representation of what the client is doing due to so many things being out of sync that it's impossible to manage.
So in the end, this is why local to client anti cheat software like BattleEye and Easy Anti Cheat exist. Cause you just can't do this kind of system on server auth.
Never trust the client.
There's little point to join a community help server if you're going to ignore all advice. We already exposed that what you are doing makes no sense and is unreasonable, Authaer explained it really well. You ultimately decide what to do, and it's not our responsibility to convince you.
I didn't ask for advice.
@kindred widget The mouse look can stay on the client. Is how I am treating it.
Because it is open to manipulation, it can not be used as a valid data source for a game mechanic.
Just never trust the clinet it that simple.
@kindred widget Also BattleEye and Easy Anti Cheat exist don't trust that, the client will always find a way.
@kindred widget the real problem is $$$$$$ and that is what I am experimenting with.
It's not that simple, actually. I outlined that above. You have to trust the client at some point. If you server auth everything it's laggy and feels bad for the player and your game will sell like shit because it feels like shit to play. You have to trust the client at some point. Planetside2, Fortnite, CoD, Overwatch, etc etc. literally any FPS/TPS game with competitive gameplay still has client auth look input for this reason.
I know what you mean. I get it. Server controlling/correcting the client cam rotation is a bad idea.
That is why I say it is nonsense. No point of doing it.
At the same time that means the cam being client driven only not be trusted.
Even with client level cheat prevention installed.
That is a lot of stuff. Not doing any of that. Very interesting tho.
yeah. I think VALVE also had some interesting articles about netcode and prediction
Will be digging into it, thank you for posting.
The player peeks latency is really interesting, I did not know about that.
Is obvious now I think of it.
I've got a question for all the dedicated server pros in here 🙂 The issue i have is the following: I have set up a dedicated server project which is using OnlineSubsystemSteam. When i build the project with my Unreal Engine Source build, the dedicated server works as expected. It shows up in the steam client's server list, under the internet tab just as well as under the lan tab. Since working with my source build takes ages for everything (compiling / packaging / ...) i also have created a binary build (in some cases also called "installed build") from my source build. When compiling and building the very same dedicated server project with the binary build the server also shows up under the lan tab but no longer under the internet tab. To make this clear again: The project is exactly the same. In source build it works, in binary build it doesn't. I made sure that the binary build also contains the Steamworks SDK files. However there seems to be a difference between what is used by a source build and what is used from a binary build regarding Steam. Can anyone tell me, what i have to change to make the project work from the binary build as well? Maybe something i have to add to the build.cs or my target.cs or the DefaultEngine.ini or ...? I am really going nuts here 😦 What i think can be ruled out are any problems related to firewall settings, since - as stated already - the dedicated server runs fine when it has been built with the source build of the engine. Thx for any help with this issue!
Thank you 😁
I'm building an ARPG in Unreal where players start in a solo game (non-networked) after choosing their character. If a player invites a friend via Steam, I want the game to switch to a listen server and allow the friend to join, without (seemingly) restarting the session.
Is it best practice to only create a session/listen server when the invite is triggered, or should the lobby always be a listen server in the background? Also, any tips on cleanly transitioning from a solo setup to a networked session without making it feel janky for the player?
I am leaning towards always listening, but not sure of that is shooting myself in the foot later.
AFAIK it always needs to be a listenserver if you don't want to restart the level.
There may be ways around that with engine modifications though. 🤷♂️
Let me know if that solved your problem. It was killing me with Redpoint as well hahaha.
There is a way to do it without engine modifications. I do it in my zombie game. Works perfectly fine as well. @nocturne iron
I'm about to jump into a meeting, will post the code afterwards.
Has anyone used playfab or gamelift or other dedicated server backend services? what was your experience with it? would you recommend them?
bool UGameplayHelpers::StartListeningForConnectionsInMap(UObject* worldContext, FString levelName)
{
UWorld* currentWorld = GEngine->GetWorldFromContextObject(worldContext, EGetWorldErrorMode::LogAndReturnNull);
FURL newUrl = FURL(*levelName);
return currentWorld->Listen(newUrl);
}
@kindred widget @nocturne iron It's actually pretty simple. I have it in a BPFL so I can do it in BP. But you pretty much just tell the world to start listening. Obviously add any other safeguards that you need or want, but for my purposes, I don't need those.
That's pretty good. Thank you! :)
You'll have to properly shut it down as well by making sure the net drivers are closed out.
Do you have code for that as well? 👀
Nah. I didn't implement it because I didn't need it. Closing the session through the sessions stuff worked well enough for me. I might be doing a hard travel in that case. Haven't really touched this project in like 8-ish months.
Thank you :)
Hi, I am new to unreal, why I don't have "ServerTravel" blueprint?
Server Travel is an Advanced Sessions node. You'll need the Advanced Sessions plugin
All it does is call UWorld::ServerTravel So if you have a cpp project you can create identical functionality by creating a Blueprint Library function, getting the world, and calling World->ServerTravel
That's neat. I'll have to remember that one. Have a use case coming up where that'll be nice. 😄 Thank you.
it fixed it... yeah, thanks again
actually now i do another issue where trying to join that session on the same pc is resulting in an exception... did you have to comment out every binding in that function?
yeah commenting out all the bindings fixed it
Yeah Redpoint needs to handle all that stuff, not Common Session Subsystem
@grand kestrel sorry to bug you again, and of course about rotation smoothing, your example where you said that the listen server is forced to be linear didnt make sense when i look back
Ya I corrected that after I said it
It gets forced to exponential
ah nw, other than that you mentioned the lack of extrapolation for meshes, i was wondering why the built in interpolation itself wasnt working for listen server, even though everything should point to it working,
MoveAutonomous, and TickComponent look like they both do this
and the view from clients does have extrapolation?
just not the view of the listen server?
even with the lack of extrapolation there is actual smoothing still happening somewhat at least, and not none
Yeah but the result is poor
Just have to wait until epic decide to add listen servers for Fornite 
my issue was that there is no smoothing whatsoever at all on the rotation
using epic's "best practice" of setting use control rotation yaw to control rotation with input
cranked up the settings just to ensure they actually work, and i took a clip that the movement smoothing works and not rotation
can see that the mesh does at least have any smoothing on location, just not rotation, that was my original question
other devs have got this working, but for me it doesnt work "out-of-the-box" so theres clearly some secret
im working with ue4 sdk, and for some reason, variable won't replicate, even tho RPC works and its owned by local player 🙄
and actor replicaiton settings
it does not replicate from local to server
[A_SpawnerForEachPlayer_C_0] Client 1: Changed mode to: Destroy
[A_SpawnerForEachPlayer_C_0] Server: Mode is is not destroy
[A_SpawnerForEachPlayer_C_0] Server: mode is: FreeFlight
[A_SpawnerForEachPlayer_C_0] Server: Is Owner same as PC: false
[A_SpawnerForEachPlayer_C_0] Client 1: mode is: Destroy
[A_SpawnerForEachPlayer_C_0] Client 1: Is Owner same as PC: true
[A_SpawnerForEachPlayer_C_0] Client 1: mode is: Destroy
[A_SpawnerForEachPlayer_C_0] Client 1: Is Owner same as PC: true
[A_SpawnerForEachPlayer_C_0] Server: Mode is is not destroy
[A_SpawnerForEachPlayer_C_0] Server: mode is: FreeFlight
variables dont replicate from client to server
If this log is in order, then you set it on the client.
always from server to clients
Replicated variables won't change from Local to Server - Only the server can set variables; Clients are allowed to send "Server" RPCs
lol i have to be explicit 😭
is there some unrela function for variable rpc? or I have to create another event
just make a server RPC called on a owning client connection
ye, but its just teadious to create for every variable
Usually you want to be quite explicit with which variables the client is allowed to modify
at this point, I don't replication(for variable) if im using rpc 🤔 im only sending it up
You set it to replicate -> Send RPC to the server to change the variable -> Server then replicates it to everyone
nah, its only usable by owner, but server has to check stuff
yup, it works, thanks guys
so you don't need the other clients to know about it? You could set the replication condition to Owner Only
yes, but I don't replicate anything from server to client 🤔
ahhh my b
no worries 😄
What is the best advice/resource when it comes to creating a 5v5 third person shooter with a completely self hosted dedicated server(s) ( with or without use of EOS/Steam) ?
can someone explain to me why this doesn't remove the widget from the clients screen? ive tried doing it directly in the button (doesn't work either)
also why does this create the widget twice on the same client?
ive been stuck for two days, any help appreciated
repnotify my guy
just have bIsDead as a bool
set it on server, and in the repnotify, show the UI if locally controlled
pretty much all of your code here can be triggered by the state of bIsDead, right?
You should default to using repnotify as your approach to damn near anything unless there's an obvious reason to use RPCs for the purpose
In your case, just covering the UI stuff, can be like:
OnRep_bIsDead -> if LocallyControlled -> branch on bIsDead -> true -> create DeathHud and add to viewport -> set DeathHudRef
-> false -> is DeathHudRef valid? -> true -> remove it from viewport
that's it, now just set bIsDead true and false on server and all that will take place
getting the same issue with this setup
also still printing creating widget twice on the same client
fixed with this check... is this efficient though?
Why do you still have rpcs
No rpcs involved at all
Onrep fires EVERYWHERE when the variable replicates
shouldnt the server set actors hidden?
not the client?
does onrep run on the server?
or on all clients
so this is the modified version, it's not setting the actor to visible when the player clicked respawn
everything else works tho
why is the onrepIsAlive not being ran on all clients when respawning?
when pressing the respawn button and changing isAlive on the player, it only runs the onRepNotify on that client....
how come?
Because you're only changing it locally.
The server has to change it so it can replicate down to all clients.
So you have to to a server RPC to request that it gets changed.
what happened to this
I don't know what are trying to show me.
does onrep not fire everywhere>
Not when you only change it on the local client
Reread what I said and follow it exactly
whats the point of replicating with notify if its not gonna run on the server/ elsewhere
im confused
This still happens. Replication only happens from Server to Clients. Clients setting values for replicated properties only happens on that client.
If you want to communicate to the server that the client clicked something you need to send an RPC.
imchanging a replicated variable..
LOCALLY
On a client.
The client can only talk to the server through RPCs
so how come when i set it there it runs everywhere
Because you're probably setting the health value on the server, which then triggers the onrep which then is trigger the server to set it.
yes im setting the health on the server
and im also setting isalive on the server as u can see there
This is also kind of bad form - you shouldn't be using OnReps to set replicated values anyway. The server is the only place that replicated properties should be getting set.
OnReps can trigger everywhere, if the server is the one that sets the value in the first place.
look how i had it set up earlier
this other dude told me to convert to on rep notifys
Right, which you've done, but if you need to communicate something to the server, you must send an RPC to the server and have it set the replicated properties.
"OnReps can trigger everywhere, if the server is the one that sets the value in the first place.
"
didnt know this specifically
so i should just make a server rpc set isAlive on respawn button
@quasi tide so is it better like this?
or with on reps
Not to be rude - but I don't have the time to go through and read all of your posts for the situation.
I'm running into a strange issue using the OnlineSubsystemNull with Unreal Engine 5.4.
Here's the setup:
- I have two levels: Lobby and Game.
- The Lobby level is assigned a Lobby_GameMode (derived from GameMode).
- The Game level is assigned a Game_GameMode (also derived from GameMode).
Issue:
Player 1 creates a session and travels successfully from the Lobby level to the Game level. However, when other players try to find the session, nothing shows up.
What’s strange:
If I change the Game level to use a GameMode derived from GameModeBase instead (while keeping the Lobby's GameMode unchanged), the session becomes discoverable by other players.
I've tried various combinations of GameModes, but it seems the key condition is that the Game level must use a GameMode class derived from GameModeBase, not GameMode.
Why is this happening? I'm not sure.
@cerulean barnThis setup will work.
On the SERVER set bIsDead when the thing dies, whatever that means. Runs out of hp, whatever
When it replicates out, the OnRep will run on all machines.
In the Onrep function, do what you want to do that depends on bIsDead (show UI, ragdoll, whatever)
That's it
no rpcs involved, just set bIsDead from the server and you're done, the thing is dead, whatever that means in your context.
Literally this simple
Not sure if this would be related with your session issue but on the situation of ClassName and ClassNameBase, always use the matching ones for GameMode and GameState. Otherwise they might be prone to have issues afaik
yeah, i am using matching gamemode and gamestate
That's strange
But key condition is that the Game level must use a GameMode class derived from GameModeBase, not GameMode is also wrong
it is wrong, but it works....anyways here's my setup , if it helps
Edit : BP_Gamestate is derived from gamestate
What functions would I want to override to fully customize the spawning of my character?
It does like two spawns, 1 is quite quick and it happens during the actual character class loading, then the actual character is spawned. The first doesn’t actually get spawned but it seems to just send me to a random spot then go to the correct location I set or was at previously
Assuming the functions I’m looking for are in game mode ^
hi, i'm implementing ping system for teammates, so i spawned a ping actor from player controller via server RPC, then checking for all player controllers to determine if a teammate exist, then set ping actor visible via client RPC, now the problem is that actor spawned entire the game , Although teammates are detected correctly, ping actor is visible for everyone, what shoud i do?
you're probably better off making the ping actor replicated and change it's relevancy so that's it's only and always relevant for players that are on the same team
if you still want to do the client rpc to change visibility, you'll still have to make the actor only relevant to players on the same team
For a multiplayer game for a stamina system would you guys use a time line or actual math mechanics, honestly timeline seems like the better opetion for optimization.
Hi, I'm running into something strange with mesh replication and was wondering if anyone here knew the root cause. Getting the location of a socket on the player 2 (client) mesh from the server returns the wrong value. However, it only provided the wrong value when player 2 was out of view of player 1 (server)(see video). It seems that the player 2 animation is "stuck" on the server when out of frame. Any insight would be appreciated.
My ProjectileMovement uses HomingTarget to track targets. On the client side, the projectile's flight is very shaky due to acceleration. How to improve the stuttering sensation on the client? Does anyone know about NPP? I tried for a long time but it didn't work
When using ProjectileMovementComponent, you may want to make sure that you have a Collision Component as Root and a Mesh Component as Child of that.
You can then call "SetInterpolatedComponent" on the ProjectileMovementComponent, passing the Mesh Component in.
That should cause it to interpolate it.
If not, then that's at least part of the requirements to make it smoother.
SkeletalMeshComponent VisibleTickOption or whatever it is called.
Drop Down Setting. Change it to always tick pose and update bones or so.
thank you that fixed it!
we were really banging our head against the wall on that one. at first we thought it was some replication issue but it didnt make sense because it was only when the client was out of view and not rendered.
anyone have tips for an inventory system and replicating things? are the items replicated or just the shots itself? or what the character is holding in hand
assign each character an inventory class, and have an array or hashmap of items?
im assuming?
With C++, peeps usually use FastArrays for Inventories.
With replicated UObjects and such
In Blueprints you are kinda bound to using the shittiest setup that somewhat still works :D
Do state trees support multiplayer? I was having trouble calling an RPC from a state tree task
Calling an RPC on what?
And what kind of RPC?
The short answer is "No." But you can still call an RPC on something else from something that isn't networked. EG a widget is not networked, but a button click can still call an RPC on an actor.
Well the task is ai behaviour running on the server afaik
Im calling it from a State Tree Task blueprint
a multicast rpc, since its presumbley on the server (as the task logs print to there)
Yeah that won't work. You'd need to call that on the Pawn or whatever this state tree is affecting for instance.
Ah
The state tree doesn't exist on the clients. As you noted it's running on the server. So there's nothing on the other machines to receive it.
that makes sense
interesting
Luckily its pretty easy to call stuff on the character bp lol
is there any way to make 2 players move around in the same widget, like in a fighting game selector?
im trying to find a tutorial for it but i cant find it anywhere or they dont give me the proper answer
Sure.
Don't think of it as two players moving around in a widget. Think of it as two players changing some data, and that widget displays that data
You're talking about something like super smash Brothers, the widget just has to know which element each player has highlighted, whatever that means.
more like DBZ Fighter Z cause im not using the mouse and keboard for my game
Anyways, yeah it's totally doable.
okay okay ty ty! ^^
Which is ?
Basically a simple array of structs. No FastArray, no UObjects. No per item callbacks or delegates.
an array of structs, what would each struct contain?
At least an identifier to the type. Usually an FName to a datatable row, or a pointer to a data asset.
Plus anything else your item needs to function. Stack size, Durability, etc. Anything that isn't static data which you should be pulling from the before mentioned datatable or datatasset.
so the actual actor is one of the components of the struct im assuming
quantity, name etc
Actor?
Not quite. I mean you could keep a pointer to the runtime object maybe. But I wouldn't make the inventory care about that.
an array of structs, and inside the struct is the actual object right?
What is the minimum amount of data needed to represent stored items?
Could just be an int ItemID and int Amount like Minecraft
It's kind of a disconnected concept that a lot of tutorials confuse. The inventory itself is nothing but data. So is your equipped gear.
Lets say you have a gun for example. In your inventory this is just a struct of data. Ammo count, durability, etc etc. Anything you'd need to create what you'd need if you equipped it.
When you equip it, you just need to place the data into a separate container of equipped items, maybe on the same or separate component meant specially for equipped items.
This is where your inventory handling ends.
When equipped a child class of your basic inventory/equipment should handle spawning said actors, or applying attributes through whatever ability system you use, or granting abilities like shooting and throwing grenades, etc.
This same thing applies with a hotbar system like some games have where you don't "equip" the weapon but select it on the hotbar. It should still be the same idea. Simple data and when "Selected", function identical to if it were equipped. You get to keep clean code, not muddle your data handling with gameplay systems, etc.
i dont really understand what ur saying
shouldnt an inventory just be an array of objects
which you want in ur inventory
or better yet a hashmap
"name" : WeaponClass
So you make a game. You have 10 people running around. They're looting up a storm, each person has 250 things picked up. Your way has 2500 things spawned for no reason just to exist in an inventory.
An inventory being an array of class refs is fine
might get a little silly if you have a ton of them and they're hard refs as you'd have to load all the data but it'd "work"
side note is casting ur character class in a widget poor practice? i feel like im wasting so much memory
Sure, but now we're back to an array of structs, because those class refs need extra data to function.
Why? the character probably already exists as a spawned actor right?
all casting does is make the thing be loaded. Your player's character is probably already loaded I'd think, since you are playing the game.
like this for example
totally fine
Note his key word there. "make the thing be loaded". It doesn't load or waste memory in the slightest.
Casting could cause problems when you have random casts to SPECIFIC classes that aren't necessarily common.
Say your widget had some cast to your final boss and all his minions, they would have to be loaded even at the beginning of the game. But if it's just a cast to YourBaseCharacterType, those are gonna be around anyway so it's fine.
It depends™️
I like structs but some people go gung ho on the object method
What does your inventory system have to support? Stacking? Prices? atomic trades? Complex logic like Factorio?
Or is it just sufficient to store classes and instantiate them when needed (equipping, dropping)
Start with array of BaseWeaponClass
primary and secondary
because my hotbar system is pretty weird rn
i just have 2 slots
primary and secondary
and when i switch i just switch the selected slot
they aren't really connected
okay so attach an array of base weapon class to each character?
I mean if its just 2 slots you can just have 2 class refs Slot1 and Slot2
but more generically yes an array of class refs
i already have it working for the 2 slots
im trying to make a better system though
aren't arrays slow though
if ur dropping the first item in the array you have to shift it all over
so
so thats slow lol
how many items are you talking here
deletion in a hash is o(1)
that's how it SCALES, not how it behaves down at the small end where things are happening
is it easier to code replication in blueprints or in c++
replication stuff like this *
Just do it in BP first
then move to C++ once you're comfy or can't do the thing you're trying to do
because im new to all of this and multiple people have told me to start with bp's even though i feel like i would be better off just coding
some of this stuff is pretty confusing already
Have you written a single line of Unreal C++?
ok then you answered the question for yourself lol
ive coded c++ though
When you want to break into the C++ side of it start out with a BPFunctionLibrary and structs and stuff.
okay so quick question
so i have an array of objects right
for the weapons or whatever i add
array of classes yes
ye
would the functionality of attaching the gun to the hand and third person mesh for others to see be in that weapon class or the inventory?
like scrolling through a hotbar
I mean there's the simple easy way and then on the other extreme there's the crazy scalable way that takes like 5 files to define a weapon
id rather do the simple way
would i have a variable like current slot in the character class and whichever slot it is, it spawns that class then attaches?
yeah
Is there a storage inventory or is it just hotbar + what you have equipped currently?
what is the item state of a character, just:
TArray<ItemBaseClass> Hotbar
int CurrentHotbarSlot
ItemBase* EquippedItem
?
I take it you don't want ping lag between pressing a hotbar button and the item appearing in your hands correct?
right
i haven't actually set it up yet
im just planning
my current system just has an equipped weapon + primary + secondary
and when u switch it changes the equipped
how many entries is a hotbar?
I mean how many will it be
like a cube for example
lets just say 5
but i want a backpack / inventory system down the line for sure
It's probably easiest to have the hotbar items exist as hidden actors, with the active one unhidden
it's a lot easier to predictivly unhide an actor than it is to predictively spawn it
and just toggle the animations when setting them visible?
like holding a pistol vs rifle animation
so backpack = array of classes
hotbar = array of objects (adding to hotbar spawns and hides)
Active entry on hotbar is unhidden and set as CurrentItem, it's the thing your inputs go to
the item can define their animations
like this sounds easier than setting up with blueprints
u really dont think i should try coding instead?
Get it working in BP first, it'd take me 10 minutes
Then once it's working start looking at moving it to C++ side of things
okay this makes sense
you'll need a c++ base item, C++ base character, etc.
I'd probably make an inventorycomponent which represents stored items, you could reuse it for chests and such
but i still get confused with the blueprint side of things, so on event begin play in the character i would initilize an empty array of classes and an empty array of objects, then on each pickup append to hotbar, and once hotbar is full, add to backpack im guessing
however you want to do it
I'd make an inventorycomponent for the backpack / chests etc but just get the thing to work first
your cart is very far away from your horse
yeah i should prob just get started and take each problem at a time
so since they are not specific classes or specific objects
would i just have it a straight up array of classes and objects?
thanks for all ur help btw
You could either make all items have a common base class or just use Actor as your base and have all items have a common interface or component on them
u dont think i should spawn in everything as an object? or just the hotbar items
depends on your design
The only reason you'd want stuff on hotbar to be spawned is so you can instantly switch without waiting on spawning from the server
is that typically how its done for hotbar?
it's a lot easier to predictively switch your active item than it is to predictively spawn one
right
there is no typically
it all depends on if you're making WoW or Fortnite or Rust
and if you have $100M or $0 to work with
my game end goal is gonna be like finals but different game mode
but like similar style fps shooter
yeah you probably don't want ping lag on swapping weaps
maybe just spawn in the weapons only in the hotbar
like weapons or lethals
and everything else is stored as a class
like grenades etc
just go do the thing and your plan will 100% change as you do it
no battle plan survives contact with the enemy
lol
yeah ill try and set that up
and obviously i spawn everything on the server
not the client
spawn on the server -> attach on the client
@dark edge (sorry for tag) so everytime im picking up a new object i have to loop through my whole inventory to check if it's already in there? wouldnt a hash map be better because i can just see if the value already exists for the key?
this doesn't check if the item exists or not
it depends on the type of inventory you want
having a hashmap as an inventory implies that you can't have "inventory slots" and each item type can only be added once
(besides its own properties like stack count)
array.contains
can you have 2 of the same weapon?
or addunique
idk if you can have duplicates though, it's your design
How do you control how a character spawns ? I get default behavior I’d like to override
There's a few functions in the game mode that you can override
Yea I noticed a few but not exactly sure which of them would be the one to use, or if I should be overriding all of them to a degree.
The ones that seem right are:
- ChoosePlayerStart
- FindPlayerStart (this one seems semi irrelevant to me but might still be needed for some cases)*
- HandleStartingNewPlayer
My instinct is to ignore findplayerstart , and override the other two. Main unwanted behavior is, before the character will spawn in to the selected location, it will seemingly spawn into and show what appears to be the center of the map/world and then within a couple of seconds or less will go to the correct spot.
Main unwanted behavior is, before the character will spawn in to the selected location, it will seemingly spawn into and show what appears to be the center of the map/world and then within a couple of seconds or less will go to the correct spot. This is because the PlayerController is the View when there is no Pawn that has a Camera Component possessed by the PC.
Generally speaking you typically end up covering this as part of the Loading Screen.
We have a 3 second grace period after the level loads before the loading screen comes down.
This is helpful for covering up things like texture streaming and other unwanted artifacts.
That makes sense. I have a loading screen and it still bleeds a small second of that into view but a small grace period like you mentioned would probably fix that.
The loading screen takes up majority of loading time except the final second or two , I could manually stop the loading screen later on when character is fully ready but I’m curious to know which of those functions are firing to cause that
But tbh, a 3 sec delay would probably solve it
Its not a specific function causing it, its the very nature of what the PlayerController is and how the renderer deals with the view not having a Camera assigned.
When the PC is spawned, its spawned at world origin. For a few frames there is no Pawn, if there is no Pawn there is no Camera. Therefore the PlayerController is the default view when there is no Camera.
So for a few frames, the PC is providing the view to the renderer.
There is nothing you can do to chaange this
The only thing you can do is cover it up.
Ahh ok good to know so a simple delay -> check is the char is valid yet if so, take loading screen down, if not repeat would be simplest way to alleviate?
If that works for you, sure.
In our case we have a Spawn Screen, so the PC gets a Spectator Pawn until the user selects who to spawn as.
Could do a server rpc from each client to let the server know they're ready and then when the server gets that, it tells all clients to remove the loading screen.
Really depends on what you want your players to experience.
Yeah it all depends on what approach is necessary for your game.
Nice , I’m glad to know why that was happening in the first place. Thanks for the replies
Would that spectator pawn be the one that you can select in the game mode details panel?
Is it possible to have replicate this full chian? ActorComponent->UObject->Struct->UObject
Without holding a replicable reference to the UObject somewhere further up?
and have that secondary UObject replicate? Everything else is succesfully replicating
I'm having some tricky issues where it's not 😐
itll be non trivial
the actor component will have to register both UObjects as subobjects
you could probably get away with an interface on the first uobject that gets all UObjects under it
or just get them manually
does it make sense for the struct's uobject to be replicated through the component? is it owned by it?
if its something like a weakptr and its owned and registered elsewhere, you dont need to register that one as a subobject
its basically
InventoryManager(ActorComponent) -> Inventory(UObject) -> FastArraySerializer -> ItemStruct(FastArrayItem)(Struct) -> ItemInstance (UObject)
But the ItemInstance can hold another Nested Inventory(UObject) and have non restricted nesting depth.
In this case, other than the nesting. then yes the component ultimately is the owner of all the UObjects in it's chain at a given time. Unless it moves to another root ActorComponent/Inventory
I know the alternative method is to have some kind of independent Manager of all the uobjects and just hold a reference but then that makes network relevancy and some other things more difficult.
I suppose I have to register the 'jump' from uobject->Struct->uobject at the top level?
i dont see why Inventory having a reference to ItemInstance would be an issue
it probably makes sense for a manager to be able to query all attached inventories and get all items anyway
thats fair
I was just hoping to not have a secondary array at a higher level and figure out a way entirely thru functions or other tricks
well
you could have a delegate in your ItemStruct or Inventory that gets raised when you add or remove an item that then registers/unregisters the ItemInstance UObject
you dont have to hold an array of ItemInstances in InventoryManager as long as you have some other way of tracking owned objects
hmm.
also nothing wrong IMO with an array of TWeakPtr<UObject> in InventoryManager
A challenge I see with that, is if I move an item into another separate inventory/manager like a top level item, I'd need to walk every chain to update all the potential nested things in that item.
but that's not too big I suppose
when i rolled an inventory system using uobjects, i made a base actor component that manages replicated sub objects
well, are transactions between inventories done with the manager?
yeah
then you should know what item is being moved
and can unregister in old and register in new
oh for sure, its entirely doable.
bool UMyInventoryComponent::ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags){
bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
if (Inventory){ bWroteSomething |= Channel->ReplicateSubobject(Inventory, *Bunch, *RepFlags); }
return bWroteSomething;
}
I'd just need to expand this a bit I suppose to go down into the nested items of the inventory
alternatively, make Inventories an ActorComponent
A backpack holding a gun, holding a handguard holding an adapter holding a grip holding a laser.
I don't want each level of 'inventory' to be an actorcomponent. otherwise it'll starts to feel messy like I suddenly have many dozens of actor components. I'd rather avoid that.
understandable
this is the old way of doing it
it is much easier now
oh?
https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-uobjects-in-unreal-engine
"Registered Subobjects List"
you just Add and Remove them as replicated, basically
always has to be routed through an Actor
ah so I can just do the
Inventory = NewObject<UMyInventory>(this, TEXT("Inventory"), RF_Transient);
AddReplicatedSubObject(Inventory);
hmm
something like that, yeah
ah looks like I need to do this anyway to support iris, other approach doesn't support iris
oh you're using iris?
not yet, but id like to eventually
just got it working with the replicatedsubobject and iris. much thanks! 🎉
Quick Q regarding Replication and Net Update Frequency for certain actors.
Let's say for a Chair, you'd interact with it rarely but requires replication for multiplayer too. If I were to set the Net Update Frequency to 4 means every 0.25sec it will automatically update all clients within the Net radius. But I still feel even updating "AUTOMATICALLY" is overkill for just a chair sit action. Wouldn't you just disable automatic net updates for this by setting the Net Update Frequency to 0 to stop all automatic net updates, and just call Force Net Update on the chair when actions are made by the player at that time? Because other than that, why update it?
Just looking for best practices with certain use cases. Cheers guys.
You can use net dormancy
I think I have read about such cases doing something like that but idk where. Maybe in Cedric's compendium or some of the blogs pinned here
Even then, if I were to use that, automatic updates for one time update seems still unnecessary?
No, that why you need net dornamcy, to turn it off, and only update when you need.
Wait so it handles all that for me?
So when I do the execution of a replicated event once, it will go dormant on it's own basically right away when it realises nothing is updating or?
More information here: https://dev.epicgames.com/documentation/en-us/unreal-engine/actor-network-dormancy-in-unreal-engine
Basically you set your actor to DORM_DormantAll, that will stop actor from update.
When you need to replicate some variable call FlushNetDormancy
All I am basically doing is, is running an Owning Client event on a chair actor to enable and disable input for when getting off the chair. The rest is handled through Server anyway. So really only one replicated call.
Thanks!
How would one check if an actor is dormant. Basically if I call Flush Net Dormancy to do a quick replication event and then that's all it needs and can go dormant again, how do I see it actually happen to confirm it works as I'd expect ?
You can check if OnRep_ is called on client.
Can you not just do this locally when the Owner change replicates? Seems unneccesary to send an RPC for it
How would I do that exactly?
Because upon my Server called Interaction Event executes. I do all the logic for setting the player to the chair and disabling movement etc, and then set owner to be able to just do key inputs on the Chair to allow exiting the chair.
But I need to do the Owning Client call to set Input Enabled after the owner has been set don't I?
@chrome bay
Changing the owner and calling a client RPC at the same time is probably going to fail periodically.
psuedo-code here
void AChair::OnRep_Owner()
{
Super::OnRep_Owner();
if (LastInputOwner && GetOwner() != LastInputOwner)
{
LastInputOwner->RemoveInput();
}
LastInputOwner = Cast<APlayerController>(GetOwner());
if (LastInputOwner)
{
LastInputOwner->AddInput();
}
}```
Im doing this in Blueprint just to let you know 😄
RIP
Not much you can do then really, but tbh, even the ab ove isn't flawless. If it were me, I'd replicate an "Owned Chair" property on the controller and update input as that populates/depopulates. No need to replicate chairs then.
Yeah, keeping it to just the controller / player instead of separating replication across more actors.
Hmmm okay.
For the chair inputs though. I'd think putting it on the character itself is best, not controller?
either one ye
I just realised though. That then means I'd have to start putting in bits of logic about a chair inside of the character. Which then it starts getting a bit messy. Bit annoying but I might have to anyhow.
I have a question about the push model ive seen some tutorials and in C++ we obv need to mark the property dirty after a change so we need to do this in BP or is it automatic.
You don't have to mark things dirty to replicate.
It's automatic if it's marked as a uproperty and replicated or repusing.
Some things do sometimes need to be marked dirty, but that's generally more a rendering thing, not replication. With standard unreal stuffs anyway.
if you are using push model, you do need to mark it dirty
i believe this holds true in BP
but if you are using proper set/mutable gets anyway it should be transparent
I don't think that's true at all
you could add some sort of input listener to your character that listens for an input and then forwards that to the chair on the server
the listener is ideally generic and the character knows nothing about the chair
Hello everyone,
Is it possible to replicate a TMap when it's inside a struct?
Essentially I have a double TMap for each of fetching
TMap<FNameQuestName, TMap <ActionTag, ActionCount>>
hmm I've actually remembered that I used a custom NetSerialize for a TMap<TSubclassOf, Struct(int, int)>
Would doing this for both TMaps be better than just turning the data structure into arrays?
```bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
{
bool Temp;
int Num = 0;
if (Ar.IsSaving())
{
Num = CapacitiesMap.Num();
Ar << Num;
for (auto Itr = CapacitiesMap.CreateIterator(); Itr; ++Itr)
{
Ar << Itr.Key();
Itr.Value().NetSerialize(Ar, Map, Temp);
}
}
else if (Ar.IsLoading())
{
Ar << Num;
for (int i = 0; i < Num; i++)
{
TSubclassOf<class ACraftingItemCPP> Key;
FValuableCapacityEntry Value;
Ar << Key;
Value.NetSerialize(Ar, Map, Temp);
CapacitiesMap.Emplace(Key, Value);
}
}
bOutSuccess = true;
return true;
}```
Actually I probably would be better off using a struct key and int value than this nested maps hell
and then just netserialize the one map
TMap doesn't support replication out of the box
I'm changing it into a single TMap instead of nested ones with a struct for a key and I'll just NetSerialize a struct with the TMap inside
question, if i am working on an inventory system and i have an array of classes, when attempting to add another item to the inventory, do i have to loop through my whole inventory to see if the item already exists? doesn't this seem slow?
There is an "Add Unique" node that you can use with arrays.
what does this do?
oh
but doesn
doesn't it deep down still loop through and check if it exists?
or is it constant
Pretty sure it does loop, but at least the loop is done for you in C++ which will be faster.
And besides which, something as small as an inventory is next to nothing in the grand scheme of things.
if you really want an inventory to be unique and fast, use a set
cant i just use a hashmap
Sets don't replicate. Tmaps don't either.
do hashmaps replicate
a set is just a hashmap where the item is the key
You're trying to optimize something that doesn't need optimization, unless you're planning on having inventories that have hundreds of thousands of items, it's going to be negligible on performance.
you would encounter issues with replicating that much data well before the iteration itself is the issue
is it an issue to replicate inventories?
It can be.
not unless they're massive
okay like 20 items max in my game prob
fast array serialization is great but it's annoying
no issue at all
depends on how you make it and use it. if your inventory stores an array of UObjects, then you'll want to look into the ReplicatedSubObjects system. if you're going to transfer replicated UObjects between inventories, then you have to deal with many more nuances with that system.
if you're just replicating a set of ID's in the inventory, then it's pretty simple to deal with replication
You should probably make an inventory slot Struct that holds data about each slot and have a replicated TArray as your inventory
like InventoryIndex, ItemClass/However you ID Items, Quantity
hotbar question (replicated): #blueprint message
Hello,
I'm using Steam Advanced Sessions in my project so that players can invite their friends from Steam. I've set everything up correctly (at least it works).
Now, I need to have the list of players joining the game (for example, 4 players) and have either their unique ID, their name, or something else that would allow them to be distinguished in a list.
My last test, which I thought would be the most interesting, was to connect the "get stored recent player list" node with the "person invited" node of the "event onsessioninviteaccepted" node, but I can't run a test afterwards to verify that the list isn't empty.
I'm open to any tests or ideas on the subject.
(Im novice on unreal)
Thank you.
Did you call the function prior to get stored recent player list that fetches the list? its something like get and store recent players list. If you didn't, the list will probably be empty.
This is my sessioninvitedaccepted event.
After i have only some print string for test but the array on "results" or "playerlist" is always empty.
Something i dont understand too, its the "getandstoredrecentplayertest" always pass on "on failure" but i dont know why
hmm yeah eh
thats probably the problem, it should succeed, but im not sure why its failing. hm
you said you have it setup so Im assuming you have the net drivers set and the subsystem set in the defaultengine.ini config
yes on the video à watched some month ago, he told to add it on defaultengine.ini:
[OnlineSubsystem]
DefaultPlatformService=Steam
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
; If using Sessions
; bInitServerOnClient=true
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
[/Script/Engine.WorldPartitionSettings]
bNewMapsEnableWorldPartition=True
The only thing I'm not too sure about is that I put this little piece of text in the defaultengine.ini present in the Projectname\config and I don't know if it was somewhere else that it should have been put.
Hello everyone,
I have a basketball game setup using Unreal Engine with two players connected to a dedicated server. The basketball is spawned by the GameMode, so it's owned by the server.
Now, when a player shoots, I need to apply an impulse to the ball. The problem is: in the player character class, I don’t have a reference to the ball since it’s owned and spawned by the server (inside the GameMode).
How can my client-side player character send a request to the server to apply an impulse to the ball?
I’m looking for a clean way to trigger this from the client while keeping server authority and replication intact.
they can still have a ref to the ball
Input -> Run On Server Event
Run on Server Event -> boop the ball
Where should I create this event? In the gamemode class?
To boop the ball, I would need the actor reference of the ball in the character. But, since characters don't have access to objects owned by the server
in the character class
and yes they do
if the server spawns a replicated actor, it'll show up on clients
If you're on client and call GetActorOfClass(Basketball) you'll get it if it's a replicated actor and you can refer to it in rpcs
I see, so I should be doing the GetActorOfClass(Basketball) node in a Run on Server node?
Just somehow end up with a reference to The Basketball when both The Basketball and The Pawns exist
For now you could do this, it'll work:
Pawn:
Input -> Run on Server Event
Run on Server Event -> get actor of class Basketball -> boop it
Question on the performance of this, would it be heavy in the server side to do a get all actors of class node?
No, and I said get actor of class
unless you're gonna have many basketballs around
It's not the ideal setup, but don't worry about ideals right now, get the thing to work at all first
Okay will try this
does anyone know why this doesn't show the gun when switching on the first person mesh? just the third person mesh.. unless i switch guns twice then it shows