#multiplayer
1 messages · Page 147 of 1
APCSPreBuildActor* SnappedPreBuild = CurrentSnapAssistActor->GetGhostBuildingActor()->GetSnappedPreBuild();
if (IsValid(SnappedPreBuild))
{
if (SnappedPreBuild->CanBuild())
{
Server_SpawnFromPreBuild(SnappedPreBuild);
}
}
yes
yes
Is it set to replicate?
APCSPreBuildActor::APCSPreBuildActor()
{
PrimaryActorTick.bCanEverTick = false;
bReplicates = true;
}
yes
If the client is sending a reference to the server and it exists on the server as well, something is wrong in your logic with spawning it
If it can't find the reference, then there is something happening in your setup that isn't working how you think.
What is CurrentSnapAssistActor? Where does that live? What is GhostBuildingActor? Where does that live? What is SnappedPreBuild? Where does that live?
all of them is in client
and in client i choose 1 prebuild\
that live in both server and client
that spawned by server
for build
So the server has an exact replica of what the client is doing with their ghost actor? It is also existing on the server and updating on the server and all that?
no server have no idea about what client do with ghost and snap assitst
That's why you can't send that reference. Because the server knows nothing about it
server know about prebuild
and this prebuilds are spawned by server
client do some stuff(server don't know this) and send choosen prebuild refrence
for complete build
its ok now
thanks
It all of a sudden works?
no my mistake was this
void UPCSPreBuildPComponent::BeginPlay()
{
Super::BeginPlay();
if (!GetOwner()->HasAuthority()) return;
const FTransform& ComponentTransform = GetComponentTransform();
APCSPreBuildActor* NewPreBuild = GetWorld()->SpawnActorDeferred<APCSPreBuildActor>(
PreBuildClass, ComponentTransform);
const IPCSBuildingInterface* OwnerInterface = GetOwner<IPCSBuildingInterface>();
const uint8 Score = OwnerInterface->GetScore() - 1;
const bool bHaveInfiniteScore = OwnerInterface->GetInfinite();
const int CollectionID = OwnerInterface->GetCollectionID();
if (NewPreBuild)
{
NewPreBuild->SetInitData(Score, bGiveInfinite && bHaveInfiniteScore, GetOwner<APCSMasterBuildingActor>(), CollectionID, LineHintAssistLocation);
NewPreBuild->FinishSpawning(ComponentTransform);
}
}
if (!GetOwner()->HasAuthority()) return;
this line
was empty
i add this
to spawn it just in server
hola friends
I have very weird bug:
Client can't walk on spawned actors ONLY IN PACKAGED VERSION
Simple project with network replication and procedural generated dungeon via replicated seed. (Seed generated on server, replicated in game state, map generated on client by seed. Game is listen server, bug not reproducing in any net mode)
During devlopment, all works properly. Same seed, same dungeon on server and client.
WHEN ITS PACKAGED VERSION - same seed and same dungeon on server and client, nothing unusual. BUT WHEN THE CLIENT STEPS ON GENERATED MESH - he will be corrected by server and change move direction, desyncs client movement, until he walks back.
Meshed generated by simple spawn actor node.
Also, if you just jumping - it will not correct client.
And again - that only in packaged version of the project. Any ideas?
if you jump and land into the center of the generated mesh, does it correct you all the way back to standing on the ungenerated mesh?
no, If I land - I will stay where I was lended
so this bugging only when client walks on mesh
yeah thats kinda strange, does it happen in the editor if you uncheck "Run under one process" ?
my best guess would be something weird going on with the normals that would make the CharacterMovementComponent think the floor is not walkable
How I can check / fix it?
p.netShowCorrection tracks corrections in development mode, but character moves correct
you could bind a debug key or action to send a raycast down towards the ground and print out the results of the Is Walkable blueprint node on both server and client and make sure they match
Working on it
Walkable is true : (
On server and on client, hit is correct
What I can do next? Can I draw server collision or smth like that to check correction?
i'd check to see if the ImpactNormal from the raycasts match up on server and client.. and maybe its physical material? if you use one
how I can cast ImpactNormal ? Is this a node?
its in the HitResults struct the raycast returns
i think you can right click it and click "split struct"
and which one i should check?
Default phys material
Both on client and server
I thinks something desyncs client and server, but have no idea what
This is just static mesh, in the same exact position...
you are comparing them in the environment where it doesn't work right? ie a packaged game
yep, in packaged game
Any ideas?(
Any ideas how to prevent basic CheatEngine in online unreal engine game that runs on dedicated server?
Doesn’t Easy Anti Cheat detect cheat engine and others during a game’s startup?
How do I configure Easy Anti cheat?
is it plugin or?
You apply to be protected on their website.
Okay thank you!
Oh wait I think it’s part of EOS now.
So I enable EOS plugin and then configure it somewhere and include packaged game?
Seems about right
You have to interface with eos using c++ or buy one of the blueprint plugins from the marketplace.
Also checkout #epic-online-services for more
Has anyone here shipped a game using the seamless travel method of changing levels? I've got a couple prototypes of it working locally, but I'm noticing there are a lot of complexities that don't seem like they're worth the effort relative to just using a single world with stream levels or world partition with different areas broken up as needed.
OK guys, I am missing something about multiplayer replication and Im' trying to sus what it is. I have an actor (a boat) that has multiple interactable stations that are child actors. One of these is the helm. When I interact with the helm, it sends a server RPC to check if the character is in range and nothing is occupying the helm, if so, it sets the character as "AuthorizedDriver" on the ship actor (just a variable, as I'm not sure what to do with it yet). I also swap control contexts on the player controller to send RPCs to the ship, but the ship ignores them. I'm certain it's an authority issue, but I'm not smart enough to understand what i'm doing wrong. i can't give ownership of the ship to the character, as I want multiple characters to be able to interact with multiple stations at once (helm, sails, etc). Any help on understanding how to set this up would be amazing. Thanks so much in advance for your effort.
Simple project with network replication and procedural generated dungeon via replicated seed. (Seed generated on server, replicated in game state, map generated on client by seed. Game is listen server, bug not reproducing in any net mode) During devlopment, all works properly. Same seed, same dungeon on server and client. WHEN ITS PACKAGED VE...
Assumption would be that the Client and Server aren't in sync on the "Base" of the movement
Being the Mesh
You should see a lot of errors in your logs for that
I think dynamically spawned actors have that issue if they are spawned non replicated on server and client
If you spawn it server side and let the actor replicate it should work
But just a random idea
Just checked that in other blueprints room generation is not replicated, because its too heavy
So instead they replicate only seed, then every client just generate dungeon by this seed
Idk if there is a way to have the Actor "sync up" after being spawned locally first.
They would need to have a matched netGUID I guess
Yeah
Again you should see warnings or errors about the base movement in your logs
those ones?
You right, I can see those errors when client is corrected by server
Found same error on forum year ago https://forums.unrealengine.com/t/how-to-approach-networked-procgend-worlds/121592/4
And thats a necro(((
From what I recall, the actors need to be stably named (ie. you ensure somehow that the actors and their components are named in a deterministic way on both the server and the client) and then you can call SetNetAddressable on anything you want replicated (incl. the actor and any of its components that need to replicate)
On server and client they have different names (f.e. BP_Room_01_4356456 and BP_Room_01_111231324 )
Here's an example function I would call after spawning the actor on both the server and client, and I used an index to keep track while it was generating.
void UMyBlueprintLibrary::RegisterGeneratedActorForReplication(AActor* MyActor, int32 Index)
{
FString displayName = "GeneratedTile_" + FString::FromInt(Index);
MyActor->Rename(*displayName);
MyActor->SetActorLabel(*displayName);
TArray<UActorComponent*> ActorComponents = MyActor->GetComponents().Array();
FString compDisplayName;
for (int32 CompIndex = 0; CompIndex < ActorComponents.Num(); CompIndex++) {
compDisplayName = "GeneratedTile_" + FString::FromInt(Index) + "_" + FString::FromInt(CompIndex);
ActorComponents[CompIndex]->Rename(*compDisplayName);
ActorComponents[CompIndex]->SetNetAddressable();
}
MyActor->SetNetAddressable();
}
I cant do this in blueprints for sure?)
No :P
Also, is this will be optimized for generation dungeon? I working on coop game with listen server system
Hence people often saying that Multiplayer without C++ has its limits.
Shouldn't you use int32? Iirc int isn't always int32 on every platform.
Im fullstack dev for 5 years, so Im not feared by C++ code) Just to make sure that I need C++ in this case
It's old code, but yea, you're right XD
:D the function param too
But that static meshes is already renamed - On server and client they have different names (f.e. BP_Room_01_4356456 and BP_Room_01_111231324 )
This code doing the same thing? Or it adds new prefix?
Yeah you rename them via a similar function that Datura posted after spawnign them
Both locally and on the server
Hi, i'm using custom replicated uobject, i can replicate properties from C++ but if i inherit this class in BP, i can't replicate properties, anything special to do in BP ?
So that is solution for 5.1+ version of UE, or that always works like that?) I see some old guides from 4.2, and they didnt use any solution like this. Very strange
Thanks! Will try. Good reson to touch C++)
but im still confused. Why we need to rename actors, if they named differently on client and server? Or this is a reson, and they must be named the same?
Here's what it says on SetNetAddressable():
Allows this actor to be net-addressable by full path name, even if the actor was spawned after map load. @note The caller is required to ensure that this actor's name is stable between server/client. Must be called before FinishSpawning
Ensuring the name is common between the server and client is what allows it to make the link between them.
damn, thank you! This is very interesting. I will try. God, even if it will not work - thank you! That is first good light in this dark hole of multiplayer development in my journey))
One additional thing. I need to call this func after spawn actor on client, right?
So if server spawns it (or client that own server) we didnt need it
Only after client spawns a room?
Based on what I'm reading, I think you need to use SpawnActorDeferred() as SetNetAddressable() must be called before FinishSpawning()
You'd want to call it after any time you spawn the actor, whether server or client.
So I will put my new func there?
so server too, understood
No, you can't use blueprint to handle the spawning as you'd need to use SpawnActorDeferred().
So you'd have to create a function that handles that which you could expose to blueprint 🙂
THEN you could insert that function where your current spawnactor is.
so I need to replace SpawnActor to new func with spawning actor+ SpawnActorDeferred()+RegisterGeneratedActorForReplication
got it, thanks!
And that will be default spawn actor func in C++, but with SpawnActorDeferred() ?
Im annoyng, Im know)
understood
okay, my first c++ code and custom bp node
void UMyBlueprintLibrary::MyOwnSpawnActor(Class, SpawnLocAndRotation) <--- sorry Im javascript monkey and will add type check later
{
AMyActor* MyActor = World->SpawnActorDeferred<AMyActor>(AMyActor::StaticClass(), SpawnLocAndRotation);
MyActor->RegisterGeneratedActorForReplication(MyActor, int32);
MyActor->FinishSpawning(SpawnLocAndRotation);
}
that will not work and I need to read more manuals
:P C++ doesn't allow leaving types away
I know)
You beat me 😅 no "any" type here lol
I write in typescript usually, but here Im just didn't know correct types))0
Look the type of MyActor->FinishSpawning(SpawnLocAndRotation);
but the idea is correct? World->SpawnActorDeferred , then RegisterGeneratedActorForReplication (new func for rename by Datura) and finally FinishSpawning
what the hell is AMyActor* MyActor, oh crying under the table with JS monkey plush
i have an fps game that i have been working on that uses a complex weapon pickup system, it uses a bunch of variables to find out what weapon the player is holding, im trying to learn how to network replicate and the code is so spaghetti that i dont even know where to begin. is there such thing as code so bad for replication that its easier to completely rewrite it in a way that works better for replication.
Also, what is the easiest way to add cutom bp node to BP-only project?
blueprintcallable
There is no catch all answer to this
Either make a C++ Child of the Class your BP is inheriting from
And plug it in-between
WIth a UFUNCTION(BlueprintCallable) function
Or if not relevant to a specific class, make a BlueprintFunctionLibrary (in C++) and add a UFUNCTION(BlueprintCallable) that is static
Keep in mind that static functions have no direct access to the UWorld
So if you need that you need to pass in a context object
I would suggest you look at existing static functions of Libraries in the engine for that
Does someone know if it's possible to have replicated properties in a blueprint inheriting from a replicated uobject ?
Should be totally fine as long as you still add that UObject to an Actors Subobject list imo?
Mhh, i have replicated properties in my c++ class (inheriting from a uobject), everything is working but in blueprint properties are not replicated (inheriting from the c++ class)
So i guess something is missing
Can I clear intermediate files from online subsystem steam?
They are getting saed as gimp files for some reason and it is confusing the compiler
how do i make an attach actor to component network replicable
You usually don't do Singleplayer first. If you need Multiplayer you directly start coding for it. Otherwise it becomes a mess.
If it's not automatically replicated (which it usually is for Actors), then via some RepNotify/OnRep variable
Depends on context
Your c++ properties are replicating ?
Yep, only the blueprint version is not working
To replicate BP properties you need to grab them and tell the lifetime props to replicate them
Check UGameplayAbility.cpp at its GetlifetimeReplicatedProps
It has some code to grab BP properties
Hm i can't find GetlifetimeReplicatedProps in GameplayAbility.cpp
Hmm sec
Not on pc
{
BPClass->GetLifetimeBlueprintReplicationList(OutLifetimeProps);
}```
So i should just call this from GetLifetimeReplicatedProps in c++ ?
yes
Ok thanks !
im new to replication and i have no idea what im doing here, im trying to replicate an attach actor to component where the target actor is gotten from a BPI Event but whenever the client picks it up i get a message that the server couldent read the target actor. it works fine when the server picks it up though.
You shouldn't use Multicasts for State
Weapon being equipped is a State
And you can't just connect the Weapon pin to something that went to the Server and back
You'd need to pass that through the RPC
In theory you should just call the Server RPC, and cut the Multicast.
And pass the Weapon through the Server RPC fwiw and then set a RepNotify/OnRep variable with that Weapon.
In the OnRep function you can then attach the actor
If you don't know what RepNotify etc. is, re-read the Network Compendium on that topic please.
i know what a rep notify is, but i kept getting an error whenever i picked it up on client, and now that i setup a rep notify to the best of my knowledge it still doesn't work but now im just not getting an error
you should not need to replicate attachments though
attachments are replicated by default
the RepNotify value has to be set by the server for it to work
EquipWeapon is that being called by the Client or Server?
also what's WeaponSet's type? You probably should use an identifier (WeaponID, WeaponClass, etc) for that, not an object reference
i have never needed to replicate the attachment
actor has a ReplicatedAttachment system
i just attach on server, and the weapon is attached on all client
@thin stratus @sinful tree Solution is simple, guys
I just set mobility of all generated meshes to "static" and now it works
oh God, 30 hours of debug
REMEMBER KIDS
IF YOUR STATIC MESH HAS MOVABLE MOBILITY, YOU WILL BE REJECTED BY SERVER IF ITS NOT REPLICATED
Gamechanger for generated dungeon in multiplayer
nach, I downloaded C++ stuff...((99
is that a part of ReplicateMovement?
im trying to learn networking and just read documentation for 3 hours and i still cant get a single variable to replicate, does anyone have any good references for network replication
ive finally got somewhere but now i have an actor that wont destroy if the client runs the event but will if the server runs the event i used an RPC to the server and then a multicast but it still wont delete for when client runs it
RPCs = Send Data / Execute Instructions
Replication = Value is set on server, and is sent to clients. You can change the replication condition of properties so that only certain clients receive the updates or the updates are only sent at certain times.
You can only call a "Run On Server" RPC from a client if the client owns the actor that you're calling it on.
You can only call a "Run on Client" RPC from the server if the actor is owned by a client.
By default, the Player Controller, a player's controlled Pawn and their PlayerState or any replicated components of these actors are things that are "owned" by a client and can appropriately send and receive the server/client RPCs. You can assign ownership of actors at run time, but that requires you to set that ownership on the server and it isn't necessarily what you need to do to interact with objects.
Multicast RPCs can only be called by the server, and can execute for all clients that have the actor relevant regardless of ownership. An example of an actor not being relevant is if it is far out of range of a client, in which case the server may cull the actor from replicating for that particular client. These are typically used for fire and forget events that aren't mandatory for the game to function, for example playing a sound effect or displaying a particle effect.
So if you want a client to be able to call "Destroy Server" the client would first have to own the "BP_WeaponBase" actor.
A way around this would be to do the "Run On Server" event on a client owned actor, like their player controller, playerstate or pawn. Once running on the server, you can then call to destroy the actor - if it is replicated you shouldn't need to multicast it.
Simple question : How do people make their First Person Character have a hand shown on the screen for them to be able to use it. But when they switch their camera to third person or viewing that character from someone else's perspective shows something totaly different, like the full body for instance.
By that I'm referring for example to minecraft, where in FPS mode you see only 1 hand on your screen, but when you're in TPS or seen from someone else's perspective, they see the full body and the arm isn't placed in front of the player like on the FPS POV, as the arms are placed along the body.
I don't know how to do something like that, any guidance please ? 🙂
using "HasAuthority" node ?
Then it will create an issue with the player hosting the game as my game is hosted by a player creating the game. And using "HasAuthority" for him it will return true and will create an issue ?
@vagrant grailcheck OnlyOwnerSee
and OwnerNoSee
two options on primitive components (including meshes)
Thanks 🙏
I am trying to make a respawn system for players, I get everything to work except one thing. On client when he dies second time, he can't respawn because in player blueprint (CMC) playerstate is null.
I have in playerstate variable which tells if player can respawn or no, and after death I have simple timer which sets this variable.
It seems like after deleting the actor and spawning it again it has no reference to player state, what can I do?
strange is that cast is not failing but it is still pointing to null class
I've got two questions:
- For learning multiplayer with blueprints, what tutorials do you recommend?
- I am stuck with an issue. I have a projectile that when it's Box Collision overlaps with another object, it freezes (to simulate a spear getting stuck)
There are two exceptions to this freezing, and it's if it's the player or if it's another spear
The issue I am having right now is that for the Server it looks like the spear freezes, while on the client it travels normally. I believe that this is because on the server the spear is actually hitting the player (ignoring the check). What could I be doing wrong?
you are comparing it to player index 0 which is always the same player, not that one which is throwing it
Aha! What should I check with instead? 😄
what blueprint it is?
I want to make it so that if it hits another player it will trigger, but not if it's you the player.
I know what you want to do, but I am asking what object the code is?
that one on screenshot
so get the "self" reference
I think you should store in projectile a player object which threw it, then compare it to that stored variable
and here set this player
as self
Thoughts on this naming conventions for replicated functions/events in both BP and C++:
If anyone has a resource for an alternative I'm curious to see it. Cant seem to find a standard
How can I get the player object that threw it?
in player blueprint get reference to "self"
On the First Person Blueprint
then you set it from return value -> throwing client
Because your ret value from spawn actor is your projectile which you spawned
I think this is simple to understand
No I got it now! But it still doesn't work hmm
I think your condition with overlapped component is useless
but I might be wrong
I would try to remove it
@prisma belfry i normally have Server_SomeFunction, NetMulticast_SomeFunction, Client_SomeFunction
Still not working hm
I used that before but i would really prefer the alphabetical sorting shows the related functions together
Throwing client make replicated
Anyone experienced that multiplayer works perfectly when running listenserver and client both on your pc but some things dont replicate when its two pcs on the same lan? any usual suspects?
it is already
Throwing Client is a Variable (Actor Object Reference) on the projectile
On FirstPersonCharacter BP, where I spawn the projectile, I set the variable to be (self) so that I can get what player threw the spear
I tried printing it and on the client it can find it correctly, but not on the server
"This is: " is what I print when overlapping
I fixed it!!!
It was so simple
SpawnActor has a field for Owner
I just used that one instead
just fyi if your BP_Spear is set to replicated, you might have issues with the spear spawning twice on listen servers for clients when a client calls the server function to call the multicast
Lol, didn't noticed it, but glad your worked it out. I am also beginner in ue5 also, but I am switching from Unity
Hello. I need data that is not normally replicated (to be specific, ForwardVector of camera). I need to update it every tick (or at least often enough - player will look up or down, even slightly, all the time).
How I can do it without lolmurdering network? I mean, characters walk and change direction in response to player's input all the time. That means variables like character position or rotation are replicated efficiently enough... somehow.
What I was doing before was running code normally (in sense that all instances run it both on client and server), then call client-specific code for local client that gets camera data like ForwardVector, THEN inside I call server code that sets forward vector in replicated variable. I was able to get away with that because it was called only sporadically.
In pseudo-code:
AttackSomethingOrOther() {
// This code runs everywhere on all characters both on client and server
// ...
if (IsLocallyControlled()) { // local player character?
CL_ResolveWherePlayerLooksAt(); // client-side: UFUNCTION(Client, Reliable, ...
}
// ...
}
CL_ResolveWherePlayerLooksAt_Implementation() {
FVector LocForwardVector = GetFirstPersonCamera()->GetForwardVector(); // this var is not replicated
SV_SaveWherePlayerLooksAt(LocForwardVector); // server-side: UFUNCTION(Server, Reliable, ...
}
SV_SaveWherePlayerLooksAt_Implementation(FVector LocForwardVector) {
// to my knowledge, replication of variables works only on server, so you must be ON server to set these vars and see them updated everywhere
ForwardVector = LocForwardVector; // ForwardVector is UPROPERTY(Replicated, ...
}
Is there better way?
You can use the player's control rotation server-side
Most common convention is:
Server_: Server RPC
Multicast_: Multicast RPC
Client_: Client RPC
You can drop the _ if you want as well.
Main thing is to prefix it with the type of RPC it is
might be a silly question but.. for replicating array properties.. is it guaranteed that .. lets say on the server I add 20 elements to an array in one function... Those 20 elements are going to replicate back to the client when the replication happens? Its not going to replicate them one at a time or something. I'm basically hoping RepNotify wouldnt be called 20 times or something.
is BeginPlay() of my ACharacter a safe place to cast to my CMC Subclass in both the client and server? or can it be null/delay to initialize?
like: Cast<UMyMovementComponent>(GetMovementComponent());
Should be fine. BeginPlay runs after the component initialization stuff
I see
anyone here experienced at diagnosing client correction error messages? (stuff that gets printed when p.NetShowCorrections = 1 ), I sometimes have these corrections happen, seemingly at random, but only in a packaged build
my theory at the moment and according to these logs (someone correct me here if I'm wrong) but it seems the client and server are disagreeing on the walk speed (Cmc->MaxWalkSpeed ?) momentarily according to the logs
I say this since the logs show a really big difference in Client vs Server velocity, which I believe is affected by Cmc's MaxWalkSpeed? ( I was just running forward when the issue happened)
how to make this:
When new player joins already active chat, server would send this new client all old chat log to his chat window as well?
Hey guys, if I have two teams that the player selects from the main menu before joining a game on a dedicated server
Then I find a session hosted by a dedicated server and client travel to that server
what would be the best way to go about communicating to the server what team I previously selected in the menu to have the server spawn the correct pawn?
lets say in the menu I select "play as counter terrorist" and then after client travel the server should spawn me the "counter terrorist character" pawn to posses
would it be something in the session interface or should I have a variable in the game instance and after joining send the value to the server via rpc
hey can anyone help me with this :/ ? im guessing its related to multiplayer stuff ?
Hey guys, I face an issue, I use gamemode's restart with seamless travel enabled. Works fine, the only problem that I have is that the WBP UI does not show on the clients after the game restarts, this is the code for it, this runs on a playercontroller. Btw its dedicated server
Your OnRep will be called just once in that case. If you add elements in two different frames, the OnRep might be called one or two times on the client depending on whether the two updates make it to the client separately or not. But any modifications to the array during a single game tick will arrive as one change and one call from the client’s point of view.
I suspected, thanks for confirming!
im trying to make picking up a weapon network replicable, but i have no idea what im doing, i manage to get it to work but i was told that its a bad way of doing it, what would be the good way of doing it?
is the DemoNetDriver on Epic's agenda these days, or is it not updated?
Asking because I'm trying to decide whether or not I should fix a bug I've got in replay playback, or wait for 5.4
check github?
but it's unlikely they're touching it until they fix things up for iris
hey i have an actor with a static mesh thats replicated the actor is replicated also
and im destorying component on player character BP, event on server
but nothing happens ??
I'm actually not sure if Component Destroy is replicated
even if i RPC it dosent get destryed :/
For some reason when trying to run code in server, the game mode isn't recognised?
Very confused, I understand that the game mode can only be referenced by the server as clients cant access it but it should be recognised since its code is run on the server so if anyone could figure out the problem that would be great thanks
you're not running it on the server though
those messages are coming from a client
I don't even see the print string causing those messages in your screenshot
I'm executing the code on the server though
the code you posted maybe
not the code showing messages in your screenshot
nothing you posted contains a print string that prints "cast failed", they all say something else.
thats odd
it's not, the print string is coming from a client from code you haven't posted.
it even says "Client 0"
in all likelihood this code isn't failing the way you think it is, or isn't being hit at all. The failing code is elsewhere.
When adding to the controller array it prints server: 0
which has nothing to do with the code you posted
again, the messages are coming from a client
from a print string node that says "cast failed"
which none of the code you posted has
I can't even read half of that the screenshot is so small
i dont remember changing the print output
anyway, this blueprint is probably something that isn't replicated. Running a server rpc on something that isn't replicated won't run it on the server.
this code is in gameinstance i thought gameinstance is replicated
no, not at all
ah
even if it was this still wouldn't work
player controller is replicated though and so is player state?
only the client that owns an actor can call server RPCs on it
yes
those would work
In my head i tried to put this code on game instance thinking it was replicated so I'd be able to reuse this code in another level
if there is a randomization factor being applied to my output damage, how can i get the client to predict what that value will be? i tried running same functions on client prior, and although, it works fine, the randomization gives slightly different numbers and it effects the way some client side visuals show up vs how they actually are on the server
i could get them after the fact, but this is what im trying to avoid
either don't predict it or it needs to be deterministically random
and being deterministic isn't the only complication (that's the easy part), dealing with mispredictions is going to throw all kinds of wrenches into that
a question you may want to ask yourself is whether you really want to be showing any kind of exact damage values at all if the server hasn't confirmed it anyway
what could cause a client to receive client corrections when both these booleans are set to true?
Is there no persistent between levels replicated object in Unreal?
no
GameState is replicated, but that doesn’t help with trying to send RPCs to the server, only with getting state back out to clients. If it’s something about the world, GameState is a good place for replicated data. If it’s something about one player, PlayerState. If the client needs to tell the server something, PlayerState and PlayerController are the usual places.
dang
yea that's a good point. i have the 'dmg numbers' showing after which works great but im trying to apply a variable change to a sfx that i'd like to have heard on client prior to anything and it would depend on the potential dmg done, but i suppose it could be 1 leg behind as it's only effecting a pitch of a sfx
the health of the enemy basically pitches up a sfx as it gets closer to death, but that first inital hit is going to return "100" everytime because i don't have that dmg calulation until after
DOREPLIFETIME(UAgentAttributeSet, Health);
DOREPLIFETIME_CONDITION_NOTIFY(UAgentAttributeSet, Health, COND_None, REPNOTIFY_Always);
these are identical in function, right? 
Like you'd only use the second if you were adding restrictions, but no condition and always notify means... no restrictions 
To expand on that.
@lucid badger Since the Server doesnt keep track of the value on the Client, if its value changes, it will send it. The Client then has the opportunity to have OnRep called if their local value was different to what the Server sent down.
REPNOTIFY_Always, causes OnRep to be called regardless of that.
Got it, thanks guys
I didn't think about the case where the client is updated with same value
Clients can change their local value at will.
Yeah. I just figured it would always fire even if the value was same
Not by default
Yep understood now 
my assumption is you want GameNetworkManager->ClientAuthorativePosition to be true as well
where do I set this?
or how can I access the "GameNetWorkManager"?
you can set it in code but I think the intention is in a config ini
[/Script/Engine.GameNetworkManager]
ClientAuthorativePosition=true
in your game ini
@clear island
there are other cmc related settings in here
"why are those in here AND the cmc?" arguable some are generic to any movement replication I guess
thanks, going to give it a try
ok just tried this, yet still I'm getting corrections, running out of ideas here lol
where are these corrections coming from
try breakpointing the rpcs that are sent from server-client when the server sets them
anything "correction" should be related
or just raw repmoves
I just set a breakpoint on OnClientCorrectionReceived
thats how I'm noticing those
yea I've been trying to track where that is 😄
but there' stuff in the playercontroller
- CMC
- Character too I think?
its not even minor corrections either, its really noticeable, causing visible rubber banding
but only happens in a packaged build for some reason
is it just me or is this a bit silly how the demo net driver disallows net startup actors from being destroyed during replay checkpoint loading, seemingly regardless of whether or not they were destroyed by the authority in the actual game at that point in time
Without knowing that code too well, no? Seems logical - net startup actors are generally ones in the level, so there's no "create actor" command that comes over the wire (or as part of a demo). So destroying one when rolling back would mean it'd never be recreated, and it sounds like they do have a separate system for that.
My understanding of the replay system is that replicated actors that existed at a specific point in time would have a "create" command stored as part of the checkpoint. Net startup actors probably don't do this since they're already in the level and get matched up based on a stable name instead of created on the spot.
what pains me about it is that a giant part of the set of assumptions that I had about the demo net driver is wrong
my assumption was that replay playback was analogous to a client joining a match, and scrubbing the replay was analogous to a client joining the match in a specific time
when a netstartup actor had been destroyed on the server before the client would join, the client wouldn't load said actor, even if its a netstartup one
because the server would tell him 'whatever used to be here is dead now'
that just doesn't happen with replays
Yeah that's not possible because there's no network message for actor creation that the replay system could capture. The creation of the actor comes with the map load.
So instead it has to deal with netstartup stuff differently.
then i'd expect the checkpoint data to hold a list of GUIDs of dead startup actors or something idk
it does seem to do that though
I mean that there seems to be a bunch of code that does exactly that.
If it doesn't work then it sounds like you're doing something wrong.
Though it's hard to say what, as I said I'm not super familiar with replays aside from the fact that I know they generally work.
wouldnt be the first time it turns out to be on me, but with that I am left clueless
look through the uses of QueueNetStartupActorForRollbackViaDeletion, there's a few things that call it that are in blocks dedicated to handling net startup stuff
and like, it shouldnt get less straightforward than the responsibility of calling Destroy() on the server
i'll do that, thanks 👍
Should VFX for other clients (sim proxy) be rep notify vs multicasts?
I guess it would depends in some cases but if i had to choose between one or the other, which would be best practice?
You generally would want VFX to be generated from an Unreliable Multicast RPC.
Since VFX are typically fire and forget events, tying them to OnReps can have unintended consequences. You have to manage what happens during changing Relevancy for example.
The unreliability of the RPC is that way because most of the time triggering VFX is not gameplay imperative.
Dope so far so good. And yea the fire and forget principle makes sense. Perhaps sometimes there are tails of VFX that could be benefit from a repnotify is someone joins late but I got you
Perhaps, but you would want to ask yourself, is their lifetime enough to warrant that?
Is the Player actually going to see them immediately when they join and for the period they may have left to live.
The answer is typically no.
Yea 100p. Doors and things like that repnotfies but for blast fx , a multicast would be fine
Its better in this case to assume unimportance and introduce importance than the other way around.
A door opening/closing isnt VFX.
Lol I know but I was just giving an example of something that would be used for rep notify that I already use
Sure
I have dedicated server survival game. Server (Game mode) saves all players to array variable of structures. Structure contains health, items, location, etc.. And server checks all controllers every 2 seconds and update variable. Problem is that it have pretty high usage of server and latecy goes way too big when over 60 players same time. What could be alternative way to do it?
Why does this need to be a polling operation?
I would expect that you would only update a Players data in this way, if and when they perform an action that would change it.
But every player usually moves all the time and pickup items, use ammo, etc
What is this data for exactly?
Location vector, integer health, integer level, integer experience, integer array inventory, etc or what did you mean?
When player disconnects adn joins back to server. Server find player data and set back to player.
Ok
or when server crashes. Server saves that variable to file every one hour
So why not just perform the save operation when that Player chooses to disconnect?
Good point. I should use OnLogout?
Ok well, if the Server crashes you are unlikely to be able to retain much of anything that happened recently.
But I could only save every 10 minutes instead of 2 seconds
If its a survival game, why not make it a mechanic? Save when you sleep in a bed or something?
Every 2 seconds is just ludicrous
It is game where you start without items and if you leave server spawns sleeper with you items on server.
What could possibly change within 2 seconds that is that important to retain.
That is true but I thought if you find very rare item and then you disconnect
It is not cool to join back to server and not have that anymore. But I can put that save to OnLogout
Thank you!
Good luck
Besides periodic saves, you could also save when something important happens. Checkpoint reached, boss defeated, quest completed, whatever an “important thing” is in your game.
I will try to put it when client disconnects. And then I could put that save happen every 5 minutes for example just for if server crashes. Putting it to important events is also good idea.
Thank you!
Quick question: When new client join server how to make varible inside server be replicated to this new client?
Any variable that is marked as replicated and part of a replicated actor/component/etc. will replicate to new clients
Like Cedric said ☝️ But I think in this case what you're looking for is "RepNotify" which like "Replicated" does replicate to new clients, but it will also execute a function on the server and on the client to update stuff in it. This is usually used when your variable is used to behave like a "State" of your actor.
For instance, if you have someone has the default white unreal engine skin, and he goes into a box collision which changes his color to Blue. If people join the game later or were not present in the "Relevancy" range of that Player. They will keep seeing him with the white skin because they were not present when the skin change happened. So in that case you need to use "RepNotify" and in the function generated do the Skin change so people joigning later or when they're in the relevancy range of that player, they see him with the right skin color 🙂
Hi,
Has anyone created a two person interactive emote system? Like two person high five or hug?
@thin stratus now the same error occured again and i was doing nothing just walking really
I fear I can't really help more. There is nothing to start on. I, personally, would hook up Visual Studio to it and let it crash then. And then check what is wrong and what actor causes it
ok gotcha, wdym hook up VS to it ?
No but the idea would be that you move the characters both in place slightly, similar to how a one person interaction with stuff would work, and then trigger the montages locally on each
Well if you are using BP only then you'd need to start your game and then attach VS to the game or editor process
If you use c++, then just start with it attached already from vs
can motion warping be used for that?
I assume so, I don't do much anim stuff lately
im using bp only but its converted to a c++ since im using steams subsystem*
wdym attached do i run it from vs the project or ?
Yeah then you can run it via F5 key from vs
Vs will compile and start the editor with it already attached to the new process
ok ill try
ok and once im running it via VS then i just play untill error and it will get printed in a log somewhere or ?
also should i always run the editor/project via VS ? like is there any perks on doing that ? or more costly preformance wise ?
do actor components also need to override GetReplicatedLifetime props and specify each property? If so then on the actor itself do i need to specify the component inside the actors version of that function?
The component needs to override it yeah, but unless you have a replicated reference to that component then no it doesn't need to be in the actor
It's specifically for the replicated UPROPERTY's of that class only
Alright thank you
In what cases would I want a replicated reference to a component on an actor
Just curious
interesting, i never thought about how animation / skin changes should be rep notifys (like equipping an items/armor/etc). is that something you'd mean ? currently am using a multicast for that but given your point i may want to change my equipping to a notify event
Hard to say really, if you spawn it at runtime perhaps, but there are ways around that that void having to store replicated refs.
Check this awesome series, you will understand better than with my explainations (he shows the example with the skin I talked about), it's 4 episodes series. https://youtu.be/TEojA3VBXG8
❗ DISCLAIMER: Re-uploaded due to the original video being somehow magically deleted (I didn't do it..) 😭
👋 Welcome to the Replication Series! This series covers how Unreal Engine handles Replication from the ground up starting with what replication is and how Unreal's Client-Server model works and then moves on into more advanced topics.
📹 ...
Hi guys, i am curious about is there anyway or program can simulate lag/lost to specify process? I want to test how weak net players look like in other players' view.
I have used clumsy, but it seems can only use to all process.
Click on the 3 dots where you can change the amount of players and net mode type, at the bottom click on "Advanced Settings" then scroll down to the "Enable Network Emulation" section, enable it, and play with what's isnide Incoming / Outgoing traffic
Thank you for your reply. But the settings you mentioned will affect on every client I start in my local editor?
Yes, except the server if I'm not mistaking
@thin stratus ok now i got the error while Vs was attached
where should i look :/ M?
In my situation, i am trying to avoid the problem that strong net player will see the weak net players' character rollback or teleport. So i only need one client that has the weak net problem when i test in editor.. 😦
Go here
You'll see the same callstack that you saw in the logging
In there, you would want to go from top to bottom, one by one and check the VARIABLES on the left side
And see if you can find what Character has the issue
fwiw you can post a screenshot of the 2nd callstack entry from the top
As I think that was the PreReplicate one
You call to PreReplication
And then show me the members tab
Eh
Variable tab
It's on the left already open
Think it's called "Autos" in VS
"this" being the object instance this crashed on
oh ok
I just meant the left window
Yes
Can you scroll that a bit
And see ify ou can find the character movement comp
That's all redundant
hm okey
nullptr means it's pointing to nothing
The properties are just garbage then
The main point is that the CMC shouldn't be null
Are you somewhere destroying the component ?
And if not, you might want to redo the Character (BP_Skeleton) as in deletei t and make it again (unless that's a very big code one)
Cause this is usually nothing that should happen
The CMC is a core part of the Character and usually should share the lifetime with it
im destroying it in a RPC*
when a enemy dies
i think that did it
hm okey so its something realated to the NPC wanting to use CMC after its being destroyed i suppose
well super thanks as always so far!
No worries, yeah don't destroy that
And now you also learned a bit about debugging crashes
There is more to it, but this usually at least gives some info
hey, what do people to get Steam names and avatars in C++? I tried using the AdvanceSteamSession plugin, cause it worked well in BP, but I cannot build my game when I try to use it. This is my code:
FBPUniqueNetId SteamID;
EBlueprintAsyncResultSwitch ResultSwitch = EBlueprintAsyncResultSwitch::OnSuccess;
UTexture2D* SteamAvatar = UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(SteamID, ResultSwitch, SteamAvatarSize::SteamAvatar_Medium );
if (SteamAvatar)
{
I_Avatar->SetBrushFromTexture(SteamAvatar);
}
I have added it in the PublicDependencyModuleNames, but it's still not working. Curious what people use to get Steam info? Maybe the actual Steam API?
Good morning everyone. I am having trouble with a race condition and need some assistance. I have a Replicated actor spawned on the server that needs to have its details shown on the HUD. The problem is that the HUD appears to be created before the actor is replicated to all clients. How would I go about ensuring that it is replicated before I create the HUD element for it?
I am confused, I have a actor component that has a variable marked as replicated and a function marked with reliable and server, the client is calling the function and the server is being updated but the client value stays the same, and if I call it from the listen server player then it updates like normal on this listen server but the client is not receiving any updates
This is the component that exists on the character BP
UFUNCTION(BlueprintCallable, Server, Reliable)
void UpdateReplicatedValue();
protected:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Replicated)
float myReplicatedValue = 0.f;
And here is the function
void USG_MyReplicationTestComponent::UpdateReplicatedValue_Implementation()
{
myReplicatedValue = FMath::RandRange(0.f, 100.f);
}
Client and Listen call it but only the listen server is being updated in both cases
Does anyone here have an opinion about the main anti-cheat solutions available on the market? I'm doing some research and considering adding one to the game I'm working on.
don't forget the UAbilitySystemComponent::InitAbilityActorInfo() to initialize the cached data about the owner/avatar. This is generally done server-side with OnPossessed() and client-side with OnRep_PlayerState or anything else
Actually all the replication/prediction is automatically handled in your use case. You just need to have a valid prediction key when committing the ability (i.e restore it via WaitNetSync after the montage being played)
Hmm. This fixed my issue SetIsReplicatedByDefault(true);. I didnt realise components needed this. Are there any other obscurities I should be aware of
Perhaps I missed it but none of the docs I read mentioned it
you also need to override the virtual function GetLifetimeReplicatedProps and register your variables to be replicated with DOREPLIFETIME
Yeah that one is heavily documented, I found that one, its just this one that threw me off. How common is it for a server to enable/disable replication of a component? Also does this mean I can also simply disable actor replication by also flipping its bool from the server
this is madening how is this even possible
i have a "Door BP" with a componenet Lock
everything is replicated on the actor + parent
and this is how im destroying it
only for Testing
but it dosent work ??
on a player character BP its calling it
makes no sense ??
I think its pretty common, components are just set to not replicate by default so people arent causing performance issues by being unaware their component is registered to replicate
I guess that makes sense but what is the cost since at that point the person wouldnt have marked any variables as replicates + added them to the GetReplicatedLifetimeProps thing
Yes, actually on the AttributeSet, you declare the FGameplayAttributeData, which is actually the Attribute itself. And then you decorate it with the attribute macro (for the getters/setters) and you add the UPROPERTY(ReplicatedUsing=...) so you mark it for replication with the OnRep function (for the ones that need to be replicated like the health or the mana). In the OnRep function, you call a macro that has been set for you (that actually retrieve the ASC and call a function from there)
The prediction key is just an int that is incremented when a new action and its side effects is predicted. So the system can ID every actions with its prediction key and know what to do with the static delegates. You can learn more about how they actually work under the hood with the GameplayPrediction.h file
maybe someone here knows the answer? multiplayer related
why is player invalid at line 5
if(!IsValid(Character)){ ScreenLog("Character Null ptr"); return; } else {PlayerDriver = Character;}
bAttachedToVehicle = false;
OnRep_bAttachedToVehicle()
{
if(!IsValid(PlayerDriver)){ ScreenLog("PlayerDriver Null ptr"); return; } //LINE::5 <<<
GetController()->Possess(PlayerDriver);
}
SetOwner(nullptr);
PlayerDriver = nullptr; //commenting this will return in result a valid PlayerDriver ptr, but why this effects in OnRep_bAttachedToVehicle() ?
OnRep_PlayerDriver();
what am I even looking at
Question - If I have a bunch of replicated data on my actor/component, should I instead be using a struct and trying to pack as much things that relate together in order to save on bandwidth and also ensure they all arrive together? Are individual Replicated properties all sent out of order and erratic, I have been looking into the CMC and their way of doing it seems to make alot of sense with FCharacterServerMovePackedBits packed stuff
@lost inlet you know having spaces and tabs makes your code slower right?
and new lines.
fixed it, now it looks like
if(!IsValid(Character)){ ScreenLog("Character Null ptr"); return; } else {PlayerDriver = Character;}
bAttachedToVehicle = false;
OnRep_bAttachedToVehicle()
{
if(!IsValid(PlayerDriver)){ ScreenLog("PlayerDriver Null ptr"); return; }
GetController()->Possess(PlayerDriver);
}
GetWorld()->GetTimerManager().SetTimer(RepNotifyTimerHandle, this, &AArmaChaosVehicleBase::DelayCallRepNotifies, 0.01f, false);
SetOwner(nullptr);
//PlayerDriver = nullptr;
//OnRep_PlayerDriver();
DelayCallRepNotifies()
{
if(HasAuthority()) {PlayerDriver = nullptr; OnRep_PlayerDriver(); }
}
it was needed a small delay between repnotifies
"fixed"
That is a very poor fix - just gonna say that now.
You've got a race condition, fixing it "well" is an essential part of MP programming in UE
I've got a relevancy issue I don't understand while trying to set up a spectator system for players that die in my game. I've never had any other issues with relevancy so I am a bit baffled.
Suppose that there are 3 players, p0, p1, and p2. If p0 dies he starts spectating p1. If p2 was outside of p0's relevancy range when p0 died, and p1 runs over to fight p2, p0, who is spectating p1, will not see p2 on his screen. Everything works fine for both p1 and p2 and p0 can see p1 taking damage.
here p1 is on the left, p0 is in the middle and p2 is on the right. The white cube is a debug cube I put on p0's spectator pawn to make sure its location was moving with p1.
When p0 dies, my code unposses and destroy's their characters pawn, the creates a spectator pawn, then possesses the spectator pawn. Then the spectator pawn is attached to the player we want to spectate (in this case p1) via "AttachActorToActor"
I believe this is related to the issue @fathom aspen talks about here: https://wizardcell.com/unreal/spectating-system/#4-simulated-proxies-invisible-to-spectator-due-to-net-relevancy
I set my child class of the spectator pawn to have replicates = true, and given that P2 can see p0s spectator pawn cube it seems like it is replicated
but I want p0 to use that cubes location for determining what is relevant to him and I can't get that to work
I see that wizard cells guide suggests overriding the "SrcLocation" but I seems like we should be able to get it to work via this check
else if (bNetUseOwnerRelevancy && Owner) { return Owner->IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation); }
if the "Owner" is correctly set (so the "Owner" of the spectator is the player we are spectating)
GMC added support for custom sync types in its latest v2 beta

@fathom aspen I think you'll like that
I was able to easily add FInstancedStruct binding support, now I can pass in arbitrary data into the client's moves
Yeah
Well technically you can implement support for any type, I just did FInstancedStruct because that just means any USTRUCT is supported now
SpectatorPawn doesn't exist on the server from what I remember. It's local only
But yeah I don't quite remember the specifics
hmm, the functions are definitely running on the server in my child class but using the Owner still just doesn't work, debating between your solution and just making a regular pawn that happens to be a spectator lol.
Note: Attaching the SpectatorPawn to the spectated pawn to cure this issue won’t help (unless it’s done to the listen-server player), as the SpectatorPawn exists locally, which is generally client-side. The server should be aware of the changing location of the SpectatorPawn to compute relevancy.
See i even had a note
If u scroll a bit down
I wasn't wrong
yeah, I am on a dedicated server so was hoping it would be different lol
It's worse
this seems like a pretty standard issue that any spectator system would encounter, surprised they don't just handle it in the engine
Since, no player is the server
Well the whole system wasn't being worked on for long
Where is your 40 minute blog post review for GMC?
It was almost out, but @solar stirrup insisted that he writes it
I'm always nervous about using things with many issues lol. Is there a good reason not to just use a regular pawn?
You can do w/e. At the end of the day the core of it, is to setviewtarget etc.
It does its best to mirror the same view, and for the most part it looks fine
Thank you
SpectatorPawn is just a proxy actor to do stuff
Any delegate I can bind to for when an actor's owner changes? Need it for the rep graph
Seems like Iris has a callback for that, which is nice I guess, but I'm still stuck in the past...
One day Iris will get more information on it 🙏
Thank You for correcting me, For now at least this is working, and i'm googling how to fix race conditions
Hey all, is there a way to use preparemapchange and commit map change with servertravel?
Struggling a little bit with getting values from server to client; what is the high-level flow?
Let's say I have a value on the server (cooldownTimeRemaining) - this value is produced in a server function.
Client needs this value.
What does that look like in terms of flow?
Client >> Custom "Run on Server" event >> [server runs func and generates value] -- this is where I am stuck, how do I tell the server to send that value back to the requesting client?
note: in my setup, all actors are simulated proxy
Are there any standard techniques for smoothing regeneration of a resource? Think like a stamina bar. I've tried various update rates, and even with consistent rates on both server and client being predicted, there are pretty frequent corrections that look really jarring.
I'm envisioning some kind of abstraction between the actual health/stamina value and what is shown on the bar, where the bar is lerping to the actual replicated value in a way that hides the slight jerking of the corrections... but that still doesn't sound like it would be quite right
guess I'll try it and mess around with it
The easy way is to not predict on the client but instead interp from the client's current value to the server's. Every time a new value comes in you just set that as a new interp target, which puts what the client shows slightly behind but with a fast enough interp it doesn't really matter.
So lerp without the prediction at all
and that just ends up looking like a smooth consistent fill rate? In my head I'm still imagining that being potentially jerky still but probably it's too tiny to see 
it depends on how fast the interp is and how often changes come in
you can also design around not needing it to be smooth at all - like showing a slightly faded bar of where the servers is and the real bar catches up to it over time.
you can predict but you need more information than the server's current value - you need to know when that value was set at the very least so you know if you've predicted past it.
I would still consider that smooth. By not smooth I mean like WoW classic energy bar--gaining 40% of the bar in instant chunks vs. it slowly filling
You may also need other info like whether the bar should be filling at all.
How many updates per second is reasonable? I've got it down to 4 and it still looks reasonably smooth but I'm guessing with the lerping technique even less works fine 
for prediction If you know for a fact that every second the bar fills 10% then you might not need any info except the server's value, when the server's value was set, and the client's value.
Yeah that makes sense 
you don't really think of this in updates per second
updates may not come in consistently
you can't guarantee that nor should you try
I mean server side
Regen is defined per second but applies X times per second divided by X
that depends on your game
it doesn't even have to be done that way, it could be continuous if you calculate the value at the moment of retrieval
storing a base value and what time that value was set would let you calculate as if it was continuously adding to it
but it really depends on the design of the mechanics you want
there's no right answer
Sure I was just curious for examples cuz I'm not sure what would be considered too much net traffic
again, not something you really need to worry about
Good, that's the answer then 
setting a replicated value multiple times does not necessarily result in multiple updates being sent
Oh right
unless you're forcing net updates an actor will only send updates at a rate defined by a number of settings and also how much other stuff is being sent from elsewhere.
Right right right, that didn't occur to me when thinking about this
Okay excellent I will fiddle with the lerping
thanks
Hey! I am trying to make a client in my game possess another pawn, but I can't seem to make anyone other than the server possess a pawn.
I know the issue has to do with the player controller and that is not replicated but don't know how to get past that.
image for referance
is it possible to return a variables value using an interface?
i am having lets say a component with a variable and a class that uses the boolean variable. i made an interface called GetVar returning boolean. implementing the interface in component snd directly sending the boolean var and using interface message to retrieve it. it always returns false, is it the interface or the variable?
Does anyone know where how to implement multiplayer proximity chat, or where I should start looking?
- the interface must be included in the class settings for the sender and reciever of the event.
- to send a variable, it has to be set in the sender through the interface, then, when the interface function is called in the reciever, it will have an output of the variable. Are you certain you are setting the variable in the sender?
yes, also why would i need to include the interface in the reciever if its just calling a message and using the output of that very message
you call the message in the sender. You run the function in the reciever
@daring gorge
hmm
@daring gorge in the sender:
makes sense now that i think of direct cpp implementation of a basic interface
int the reciever:
so the class that calls the new func
test event
does that class also need to implement the interface
test event is just a custom event that i created to trigger the sending
yeah, lets suppose its in another class
cant i use an object reference and just call the new func directly
yes
so then i dont need to implement the interface in the sender class
I'm not sure what you mean by the player controller not being replicated, because it is, but only to the owning client
also this is ALWAYS wrong in an MP game
if you are using object references, you dont need an interface
it returns false always even if i set the value to true. i guess ill debug it with a bunch of print strings and check again later
you dont need either with an interface
what would I put for the input "target" on the possess node if not the controller?
so if multiple classes implement the interface then wouldnt i need to pass in an object reference for a particular object to call the method
tbh I don't know why you're doing it this way round. you need to own the pawn to call RPCs on it
no
you just pull the function from the interface @daring gorge
on every actor that implements it
so whe the sender updates, it automatically runs the function on everything that has the interface
interfaces are good stuff once you get it
so i think a more viable use case would be lets say using an interface for kill feed or chat system i guess?
something which is more global
I use interfaces all the time for specific use cases
so what method would you say I should to let a client posses another pawn?
its not necessarily for the global stuff but could be good for it as well
would you be able to give me examples
its just a way to abstract blueprint communication.
since i use them to avoid casting
sure
the player controller being responsible for this instead
Ok thank you so much for the help!
OK my turn. Anyone know why a rotational value would desync and finally stop working if my actors are moving through the world too quickly? I have a multiplayer ship with a helm actor with a wheel. the logic of the wheel sets a rotational value that gets sent to the boat, the server sets the rotation for multiplayer and the rotation runs locally for predictive purposes. At low speeds, everything is in sync. at 25% its a bit out of sync and values slide randomly against each other. at 50% and above. only the local rotation changes. the server version of the rotation does nothing.
Hey, could someone tell my why when in multiplayer, my vehicle (custom movement) insanely twitches, lags, etc? its in sync but its very jittery
hey guys I'm trying to blue print multiplayer proximity chat. Wonder why I cant hear myself when I play on a listen server 2 with clients
heres a screen shot of my voip implementation
it has to do with how the movement component is programmed in c++, you need to do some cheeky behind the scenes server stuff for your vehicle class
u mean?
i reccomend watching delgoodies tutorial on the character movement component
the proble mis that the movement component in unreal only have native server integreation for walking, jumping, swimming, and flyings
is this made in blueprints by any chance?
it is
i use easy-fm component
which was written in c++
Anyone know why movement for a pawn would work for Player 1, but player 2 can only rotate the camera? QE should rotate, WASD should move but on P2 it does nothing.
That makes sense. Custom movement in multiplayer is really a C++ only thing
any idea why is it so badly stuttering?
On unreal multiplayer game can i Possess (OnLogin) a character that is already on world instead of spawning another?
Yes, you just have to reference the character that is in world for the possess.
well, I'm guessing you would store a reference to the charcter on the server that was connected to the login account, and that reference would be retrieved on login and used for possess
yeah im trying to sus that out. thinking...
I'm not sure if you can prevent it, however, you can destroy it when you possess the other.
@sweet sage
which is what i would probably do
😄
Not good
@sweet sage you need to do it when the controller is ready for the pawn
there is functions in the gamemode
What is the function name?
RestartPlayer is a good start
comes from HandleStartingNewPlayer
calls RestartPlayerAtPlayerStart
has some stuff here
notabe the bottom chunk here
is when the players pawn will get created
you will need to like override this
and add your custom logic
SpawnDefualtPawn is also overrisable
so you could just override that
and return the pawn you want them to have, instead of spawning a new one
so many options
^^ that guy knows way more. listen to him LUL
I'm still trying to get any clue on why a rotational value would desync worse based on actor speed.
If I set replicated variable on Server RPC Reliable Is it enough to save for all players on server? Even if other players joins to server after it is set?
How do you replicate the actual sprinting animation? Default in CMC the walk animation plays on both client & server. When I flip the cycle state to Sprint its only replicate Server -> Client vice versa.
A replicated variable set on the server will eventually be in sync on clients
First off, do you want to drive the walk -> sprint transition by some state variable or by actual speed?
that's for the max speed, what do you want to do for the actual animation?
Ohhhh
I just want it to go from walking to sprinting
It works just doesnt replicate to anyone else
when the actual speed you're going is high enough, or when the button is pushed?
When the button is pressed
read that Safe_bWantsToSprint in combination with making sure your speed is high enough
What do you mean by that?
If you're standing still but bWantToSprint, you surely don't want to play the sprint animation right?
First off, figure out what boolean, if any, is synced between all machines
This looks goofy, why does Safe_bWantsToSprint depend on IsSprinting?
wanting to sprint and sprinting are different things
It doesn't Im new to c++ so I just be trying stuff lol
yeah it's a mess
I thought you needed a replicated variable to drive a animation across proxys
Why are you doing all that instead of just reading IsSprinting?
what is the purpose of the Safe_bWantsToSprint
Anyway, I'd just use the actual speed to determine which anim to play
Since that should be synced if you've otherwise done everything correctly
it works if I use IsCrouching
Yes because Is Crouching is a built-in variable being kept in sync through the CMC
you need to do the same for your sprinting if you want to do it that way
I'd be very suprised if your sprinting speed change even works right now without rubberbanding, have you tested with lag simulation on?
Yea i was getting confused when doing it I wasnt sure what is and isnt needed, but Ill try again.
It works without rubberbanding with 500 ping
Its not I created that bool myself its not part of original CMC. I removed all the stuff related to it from my code & am gonna try and follow how the cmc does it for IsCrouching
Okay thank you!
I mean assuming your speed change works just use that
If speed < SmallNumber -> Idle
If speed < WalkSpeed -> Walk
else Sprint
What use the speed to drive the animation instead of the bool?
I tried this but didn't work. I mean my only goal at this point is to replicate that bool so ill work on that.
your pawn certainly has a Walk and Sprint speed parameters right?
Just check is CurrentSpeedYouAreGoing > Walk, if so, you're sprinting
and i'm assuming you have a non-sprinting max speed to return to when you stop sprinting right?
Its just overriding the walk movement mode so it just defaults to CMC MaxWalkSpeed when I release shift
but you do have access to those 2 variables on all machines right?
k so in anim check if it's going faster than maxwalkspeed (assuming that doesn't change at runtime) and you're in business
Im pretty sure I just need to replicate IsSprinting variable when I use IsWalking it works too, but defaults to the Run anims
however you want to do it
Well half way there its replicating client -> server
Thanks for your help appreciate it!
Hey devs!!... I am having some trouble with the physics replication on UE... if you see the clip... the movements of the spheres on the client side is very glitchy when the mesh count increases... how can I solve that
also... I have been playing with NetEmulation commands for a while now... and I wanted to ask when applying packet delays in that... is it expected to apply only when the server instance does it... or should it happen from both the ends
G'day all, I'm trying to trigger a WBP (Using Lyra Framework) for a player based on specific conditions within a Game State Component. For example, this should be activated when there is only one player remaining from a particular team, and only activate on that player.
I can get the SinglePlayer version working seamlessly, however i cannot get the content to display in MP unless i call a Multicast RPC function
My thoughts were, this should only be called on the Client using Run on Client RPC?
Does anyone knows where unreal unload current map when changing server?
I want to connect to another server (ipaddress) but keep current server loaded. I will spawn on same position anyway
The two times I've done it they've been physics objects. My suggestion would be spawn them before throwing (and replicate), have the throwing client "launch" it locally, use the engines physics interpolation to blend them together. Fine control of the physics material settings and perhaps some contact modification to tune their trajectories and response to hitting things.
But yeah detonation would be replicated by server, or a gameplay cue, however you prefer
It would, but if you have any gameplay-relevant physics objects you can't NOT simulate them server-side anyway
And by gameplay relevant I mean basically anything that has physics and collision
The biggest area you'll see server load, usually, is by far character movement and replication prioritisation. Physics is a small fish in the pond
10 vehicles is nothing
I'm doing 100 without issue
I mean if you want 60 vehicles, you need to spec server hardware to cope with it. They aren't crazy expensive but obviously aren't cheap either - but if you're making a game with 60 vehicles it's reasonable to spend a lot of the servers time coping with them.
Has anyone tried to implement a head bang kind of thing as a emote thing with the crowd?
The other issue is how you deal with anything that isn't client controlled, what then
Client-owned chaos vehicles are client-authoritative out of the box IIRC
CMC is much more expensive usually yeah. Disabling primitive overlaps also gives a big chunk of performance back usually
The main thing you'll be up against with a high player/bject count is the CPU time the server spends deciding what to replicate. Unfortunately the engine isn't very efficient at that currently. Iris should improve it a fair bit but that comes with a loooot of integration time atm.
The engine is building that currently
Still experimental (and chaos vehicles are due a huge overhaul to come with)
Physics prediction is insanely hard
Not strictly, the server basically accepts whatever inputs the client gives it, and sends that out immediately to other clients. The prediction model adds some latency but allows the server to fully simulate the vehicle first
Server-auth physics is almost always a hueristic of some nature. Perfect is nigh on impossible
I would just heed caution when it comes to saying anything networking + physics is easy 😄
Many have been down this road 😄
I've been in this pit of despair since pre-UE4 days
Any solutions are usually highly game specific
what do you guys use to get Steam avatars and names in C++? The AdvanceSessionsLibrary or?
I have no idea why people choose to use SmoothSync for physics vehicles. This stuff exists in the engine already
all physics objects inclusive of vehicles use physics based interpolation when they are replicated from the server. It's adjustable in project settings.
as long as you have a known pair of states you can interpolate them
the issue is how you make up for not having the pair of states on time or in a constant rate
What is correct way to get controller in RPC? This is in Player controller blueprint. That function is called from pawn when I want to save player for server.
Or should I just use that replicated SteamID in gamemode to loop all controllers (set in OnLogin) to check steamID == SteamID and forget inoutting controller.
I am trying to look for an event that is called when the PlayerState ready on server. Just like this one, but PlayerState.
What if your server has a gpu though?
There's an OnRep_PlayerState somewhere. Probably player controller
I mean I'd hope your players have more money than sense if they need to rent GPU servers
I am confusion about what that means. If my server had a gpu why would players need to rent a server 😐
That's basically the physics replication system that's been in the engine forever
and 50m is nuts
Hey friends. Still banging my head against the wall. Trying to figure out why the rotational value set by input and using repnotify for player sync is desyncing with actor speed... at low speeds, all inputs and values properly replicate. as the speed increases, the desync gets worse until the server stops reporting a value change completely. Im using a server RPC to set the rotational value from input.
this is all local testing so server and client are on the same system
if I am not mistaken, replication priority falls with distance, could that be the issue?
I believe that if the pawns of two clients are close to each other, updates will be provided more frequently compared to two pawns that are further apart
OH yeah ok replication to the player falls with distance between actors
but my character should be colocated with the helm, as well as the ship. there should be no distance change there
hm I dont know enough about your game or specific scenario to provide much feedback, but if you haven't read this you probably should
https://docs.unrealengine.com/5.3/en-US/actor-relevancy-and-priority-in-unreal-engine/
I likely have not. so a-reading I will go. Thanks!
Hello there !
I am a bit confused about the CharacterMovementComponent's prediction architecture in cpp.
I'm developing a system that computes a Location & Rotation each frame for a character to attain a target in a set amount of time (Like a homing dash). I used to add the computed Location & rotation delta each frame to my AActor* but it does not work in an online setup and was very rubberbandish.
I learned recently about FSavedMove and MoveAutonomous and added the computed Location & Rotation to a custom FCharacterNetworkMoveData, for it to be sent to the server. But I don't really know what to do with it once received by the server.
So I'm wondering if Unreal has a built in solution to pass fixed Position and Rotation instead of velocity and acceleration, and if not, where should I look to achieve it ?
Thank you @uneven dock I'll look into it
is there any major performance hits when "replicating" a float variable for example? basic Q, but just curious on how much replicating a simple variable can cause problems?
shouldnt have a problem replicating a float variable, the character movement component is all replicated via floats and work great
the only performance hits i could imagine would be if you were replicating 10000 on tick lmao
lmao, yea it's very minimal as it's only 1 float variable, and tbh im trying to find a way to not even have to do that cause it feels like cheating to just hit replicate on it lol
what is teh purpose of it?
if it is unchanging, you might be able to just drop it into a class and call it a day
alternative, you could just replicate it whenever it updates, depending on how frequently it updates
it's the health of a hit actor, so when attacking/hitting something w health, it gets the health from that actor and uses that variable for effecting the pitch of SFX. so the closer to death of that hit actor it will pitch the SFX up until death
Depends how you do it, but generally I wouldn't worry about replicated properties until they become an issue
Replicate as little as you can but don't go for premature optimization
I'm guessing it's a health variable for actors?
shouldnt be a problem replicating actor health lol, replicate on hit to adjust all clients understanding of that specific actors health
yea exactly
haha yea i figured, but have never really done it like this, usually find another way to get the varaible to replicate
The server doesn't send a replicated property to clients every time it updates
It does so on an interval
Just don't use RPCs for that and you're fine :^)
ahhh interesting, that makes sense as to why sometimes the actual health the health i got back are slightly different sometimes
so i should NOT do this then lmaooo
what are you attempting to accomplish here
lol yea i am changing it, but basically when hitting an actor, i want to get the health of the actor that im hitting so that the SFX that the client hears is based off of that variable
good q, and this is what i went back and forth on, i put it on server, becasue to get the characters health i would need to replicate a struct of the players stats to get it's current health
for the client that is
around? like in the world?
ya
i mean, could be 10, could be 100, probalby not 1000
could be 1
lol
it would depend on the context of what's happening
Any particular reason health isn't just a replicated variable on the things you're hitting?
this works great for everything BUT the character
hence why i did this
the character has a health varaible in a struct
What do you mean by THE character? Are characters the things you're hitting?
i didn't want to replicate the struct
lol yea, they can be
I mean you kinda have to replicate the health if you want access to it clientside. Why don't you want to replicate the struct?
tbh, i just thought it was a bad move, but i also think what i've done in response was also a bad move, so perhaps that is a good play?
i just didn't want it to be something that causes issues
i suppose the struct is all just float variables anyway
Things have health.
You presumably want the current health of thinys to be in sync with the server's version of things.
You want to play a sound based on health when you hit something.
Simplest version is just to do a clientside hit and play the sound, no networking directly involved at all.
Whether or not the hits are predicted or whatever is another matter, but on the client you should have access to some version of the health, use that
yea exactly, the issue is, when i hit on the client side, it isn't predicting the proper dmg amount, so the health is always 1 hit behind the server
it's not predicting or you're just reading health before the damage application? Do you want to drive the sound by the hp before or after the hit?
yea essnetially doing the FX on client prior to the actual server doing dmg
assuming the client has all the info, just do the math and play sound based on post-hit hp value
i'd like that sfx that is effected by the health variable to be in realtime, but i'd have to do damage on that client
You're in the realm of predicting hits and effects at this point
yea i could do that . only other thing is that my current dmg calculation is a bit randomized, so the client will have a slightly different number than the server
sync seeds up or use random from stream or whatever
if you want to predict it correctly it's a lot of work, that's what's ahead of you unless you just want to wait on the round trip to server to play the sound
i'd certiainly like to predict it correctly lol
is there a way to get custom information like a password from a session before joining it? (Without using advanced sessions or another plugin)
also what does this mean?
sync seeds up? or use random from stream? never heard of either
https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/Blueprints/UserGuide/RandomStreams/
Explanation of random streams and how to use them in Blueprints.
that way you can roll the same random number on server and client
I've never used it but something like that is the ticket
this could very well be the ticket, but im also more concerned w your "it's a lot of work" lol i have most of what is happneing on the server being predicted but im curious what you meant by that ?
so what do you do on a mispredict?
touche
i've actually been trying to figure this out lol
for example, when a client hits but server doesnt
i'd like to have a "miss" thing happen
welcome to multiplayer lol
lmfao i love it
Hit...... oh wait nvm MISS
dmg numbers don't show when client misses, but i'd like to go even further by making that number show "0" or "miss" and how would i start to think about doing that?
do you mean a miss as in a predictable miss or one where the server doesn't agree?
like hit chance?
server doesn't agree lmao that is my current hit chance 🤣
\
Then there's nothing to do if you want hits to be predicted
the hit already happened clientside, can't really take it back
ok , well thats good to know then, and makes sense. is there another way of doing it where this can be mediated?
like going back and forth from server to client back to server?
client to server to client to server
I think most systems just favor the shooter in some way if it is a shooter (making mispredictions rare)
some only show hits when validated
by favor the shooter (attacker) you're suggesting that if their client says "hit", the system will ensure the server does the hit? is that what you mean?
kinda seems opposite to what you'd want
Client says hit -> server says "yeah probably hit" -> it's all good
maybe im misinterpreting
server rules out and nullifies obvious misses
but it's a fact of life that if you have predicted movement or predicted anything really, the 3 game worlds (owning client, server, other client) fundamentally do NOT agree
so the choice is between a shooter saying "hey that's bullshit I hit that guy!" or the shootee saying "hey that's bullshit I was around the corner!"
for sure, i like how you put that. it's all an illusion in some ways. just about making the illusion seem very real
haha yea exactly
It feels better to hit when the hit happens on your screen than it feels bad to be hit when it didn't happen on your screen. You pay more attention to your own actions then the actions of others, so your own actions need to be reflected in the game state the most accurately
I'd start with a hit being a hit if the attacking client says so, then incorporate the synced randomness, then the geometric hit validation (did the thing actually hit in 3d space)
yea i'd agree here for sure. especially if im doing hit FX on client prior to server.
im bascially doing the same overlap event (sword swing for example) on client and server, and if the client hits, it runs the same exact fucntions on server, but perhaps i can just send the info im gettting from the client, straight to the server? and then use that info only if the client says hit, then check the server w that info?
cuase im bascially doing 2 seperate overlap events (one on client and one on server) and there are defintley times where client and server are not matched up due to character location/etc just not being fully in sync (testing under latent envorment)
Guys im trying to get working proximity chat in my game, and cant tell if its working. Any suggestions on how to debug?
This is my current blueprint
I have an inventory with arrays. When i drop an item to world, this is removed only vissualy but it's still occupying a space
i have a system where you can pickup and drop weapons but whenever someone picks up a weapon that has been dropped by a player, the pickup target isnt reading for the destroy actor
Unlink destroy actor.. it works?
wdym
and how would that fix the problem of the actor not being destroyed
Why would you multicast the destroy
saw it in a matt aspland video
what would i do instead
A replicated Actor can only be destroyed by the Server and that automatically causes it to destroy locally
Also does your Equip Weapon call ultimately RPC to the Server?
yes
Destroy Actor On Server is also such as strange thing to do
You should RPC when your Press E
And then get the Overlaps on the Server
And then you don't need any other RPC
Also your Pickup param might be null if your weapon isn't actually a replicated Actor
I made the E key call an RPC and it still doesnt work
You'd need to show your code
y'all I implemented AI navigation on a moving mesh for my multiplayer game (I used the sea of thieves method where I have static versions of the ships with AI actors pathfinding on them and then translate that to movement on the moving ship) and now after trying it I'm realizing the movement doesn't add much to the game (takes away from managing the AI characters) and am probably going to scrap it 😂 😭
And alos confirm the weapon is replicated
it is
That's the same stuff you already posted?
what more do you need
