#multiplayer
1 messages Β· Page 46 of 1
hello everyone, iβm making a multiplayer fps and my camera is attached to characterβs head, and the head isnt alining perfectly with the forward vector, so whenever i start the game the player controller resets the camera rotation to face the forward vector, the problem is the remote characters dont have a character controller so their camera never gets reset, so their aiming endup slightly offseted,
and the aim functionality which is based on the camera totaly breaks, see the pictures
i tried sending the relative rotation at beginplay to the server and set it but didnt work idk why
feel free to seggest anything cause im getting crazy stuck with this for 3 days π₯²
if im not clear enough please let me know, thanks
One usually uses BaseAimRotation for synced rotation for all players
It uses controller pitch for server and autonomous
And a replicated pitch for anyone else
Should be available for pawns and or characters in blueprints
the pitch is allready replicated through the aim blendspace
@dry pebble @digital herald @graceful flame
Some engineer on/from a Client of mine recently looked at GEs for MovementSpeed changes.
The removal of GEs can't be predicted, so that's always a little annoyance. I think they wrote some fancy custom code into the CMC that keeps track of GEs applied via their Prediction keys or so. There was also a small delay between application on server and client when not using the CMC directly (e.g. applying the GE from an Ability).
It all came down to him adding some "threshold" or "slack" where the server waited on the client or so. I sadly can't share the implementation, but it did remove corrections from applying GEs for MovementSpeed changes. Without that we always had corrections at start and especially end of the GE as the client can't predict removal.
(We also went away from using GEs for cooldowns because of that, which is also what Epic did internally)
So you are already using BaseAimRotation?
yeah
i think i fixed it
i wasnt using the camera boom
now that i attached it to the head and the camera as its child it all works fine
thanks mate
Oki glad you solved it
i think some problem don't get fixed until u ask someone
lol
even if he didnt give u the answer
That's more or less the concept of rubberducking
yeah thanks mate, a lot
hey guys its again me π i was sick af but today I tried use my thirdperson character as plane with its(movement) but anything I do I mean any move is not replicated either
I moved with my plane and from second client it has same position, maybe is problem in my controls?
also i am doing flying like this
but CMC should be replicated
I have it inside
set it to flying
did u check the replicates checkbox
on the character movement
and replicate movement on the thirdpersonBP
idk men
ther is another checkbox called replicate movement
i have too
i never used used add actor offset/rotation so idk π
try replicating through events
u mean RPC?
no just replicate the input event
i dont understand how
somthing like this
Hey guys, in today's video, I'm going to be showing you how to replicate sprinting for your online multiplayer game. This will replicate the movement, speed, and animations.
More Replication Videos: https://youtube.com/playlist?list=PLQN3U_-lMANOaPmzSGLDhyWzKzwgKDz9V
#Ue4 #UnrealEngine4 #Ue4Tutorial
____________________________________________...
ah yea do you think its good for replicating movement of my pawn?
do you know why I am getting this error? I am doing this
i dont really know π i don't have that much experience yet
as for the warning im not sure
I am calling it from event tick
This is very simple
you're calling a ServerRPC from a non-owning actor
so your BPDFCPlayer RPC is not being called from the owning client
So in your example you most likely have 2 players, the Tick is being called on each client. And for the non-owning client it'll throw the error
There should be networking basics guides in the pinned messages. Check those out @real ridge
aw i forgot about that
no u shoud only check "is locally controlled" before calling the event fly server
Thanks for sharing. Sounds like custom prediction via the CMC yields the best results.
and how to fix it?
i am testing it in 2 windows
so thats maybe problem
Don't call RPCs on event tick, this ticks every frame
but I have update position on event tick where I am calculating position of my plane and he is moving I need have it there π¦
Use replicated movement from CMC (CharacterMovementComponent)
That's literally what it is there for.
Can anyone please help me out of this!!1
it's not working I have it there but it is not replicating my plane
can u clear this up
Just ago fixed that issue. Thanks for answers.
Is a property limited to the replication condition of the actor/component that holds it, or are they individual for all intents and purposes?
Are replicated variables guaranteed to be in good condition when an actor becomes relevent?
Like say I had a component that gives itself a replicated GUID on spawn.
On BeginPlay, the component registers with a subsystem.
When the actor containing the component becomes relevant, should its GUID be in good shape by the time it registers?
I think there is a better place to do that in the Actor lifecycle - I think PostNetReceive or PostNetInit...something like that anyway
kind of a bump on a question I asked earlier but still;
Anyone know how to turn off certain clients receiving character / CMC location corrections from the server? doesn't matter whether this is done server side, as in simply not sending corrections to that client somehow or client side, just not using the corrected versions that the server gives. Overriding methods like ClientAdjustPosition_Implementation and PostNetReceiveLocationAndRotation to simply just be empty still cause corrections from what I'm experiencing.
also definitely worth mentioning that this ignoring corrections needs happen on clients that don't control the character
Hey guys, I'm working on a listen server game where players can do damage to each other, but there is also environmental damage. When setting the owner of the environmental who do I set as an owner of that damage? How do I separate the listen server player from the environment, which is its own neutral entity?
Thanks for sharing eXi, appreciate it. I'm surprised something as simple as a proper (no net correction) stamina drain while sprinting hasn't been publicly solved yet, seems like a lot of people would use this.
Stamina, outside of GAS, is relatively straight forward
The problem is that the CMC needs a lot of boilerplate code to fully support this
No. Replication to server-state is guaranteed to happen, but eventually.
I see interesting
This sounds weird, you might want to elaborate. It sounds like you don't want those actors to be replicated?
I am completely lost on how to predict GAS stamina now with sprinting speed change. If anyone can point me in some sort of direction in the CMC, I'd really appreciate it. Back to the source code for me lol π
I don't think anyone can point you
Either no one solved this or can share it
This isn't every day code anymore
Stamina without GAS, where the Value lives in the CMC directly and is not replicated and only modified via the Sprint Code, is relatively okay
But if you use GEs to modify the value, then you suffer from the problem that prediction can't remove GEs
You'd need to cut the local player some slack for the duration where the server removed the GE and the Client hasn't yet
Hmm okay perhaps I'll have "Energy" for sprinting and let that live on the CMC seperate from GAS stamina and just manage it differently. Why not replicate this?
There is no need for it
The idea of the CMC is that it does the same on the server as on the client
In the same timestamp at least
If you consume the value during the sprint, it should consume on both ends the same
If you end up having a different value, it will cause a correction, at which point you send the server's value to the client to sync again
The CMC itself isn't even replicated fwiw
Ahh I see, and during a replay should I "Save" the stamina value in the FSavedMove_Character? Just locally for the client
I'm aiming to stop the movement replication for a short amount of time to do a knockback client side to not have to RPC to the server and wait for that. Exactly the same knockback will happen on the server and I'm going to re enable replication after it's finished, and probably smooth the client location to the server one during it
SavedMoves are also used to send stuff to the Server
while you don't send the stamina value to the server, it can still be that the Client chooses to combine two moves
And the client at that point actually performs the original move twice
So it's:
- Perform Move 1
- Choose to not Send Move 1
- Combine Move 1 and Move 2
- Perform Move 1+2 (performing Move 1 twice)
The thing that resolves this is that the SavedMove has a method in which it resets the CMC state back to BEFORE move 1
So you will want to save the Stamina value before you perform the move
So you can later reset it
Otherwise the Client will consume too much Stamina when mvoes are combined
Pretty shitty to find out cause Moves aren't combined that often, unless the client is > 60 FPS
At least with default settings
You could just use RootMotionSources
But they aren't available outside of GameplayAbilities by default
If you execute those on Server and Client together, it will sync up everything automatically in the CMC
Only thing you need to do is flush server moves before executing them
Oh wow I didn't realize it worked like that, that is very insightful, thank you. And yeah that would've been a shock to find out. I hate bugs that happen rarely like that.
And when you say "If you end up having a different value, it will cause a correction, at which point you send the server's value to the client to sync again", is this just automatic because server and client are running the same code or are you saying I need to manually sync this?
We have no corrections on 200+ Ping with that
The CMC has functions to sync, but you need to override it to send your additional values
Nowadays you make a new Container Struct that inherits from the default one
struct FVRTCharacterMoveResponseDataContainer : FCharacterMoveResponseDataContainer
{
typedef FCharacterMoveResponseDataContainer Super;
public:
virtual void ServerFillResponseData(const UCharacterMovementComponent& CharacterMovement, const FClientAdjustment& PendingAdjustment) override;
virtual bool Serialize(UCharacterMovementComponent& CharacterMovement, FArchive& Ar, UPackageMap* PackageMap) override;
float Stamina;
};
Aha I think I remember glancing over something about that in the source and about that struct too, thanks I'll look into it.
UVRTCharacterMovementComponent::UVRTCharacterMovementComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
SetMoveResponseDataContainer(VRTMoveResponseDataContainer);
}
Last line is for setting that
oh that must be it lol!
VRTMoveResponseDataContainer is a member variable
void FVRTCharacterMoveResponseDataContainer::ServerFillResponseData(const UCharacterMovementComponent& CharacterMovement, const FClientAdjustment& PendingAdjustment)
{
Super::ServerFillResponseData(CharacterMovement, PendingAdjustment);
const UVRTCharacterMovementComponent* VRTMoveComp = Cast<UVRTCharacterMovementComponent>(&CharacterMovement);
const AVRTCharacter* VRTCharacter = Cast<AVRTCharacter>(VRTMoveComp->GetCharacterOwner());
Stamina = VRTMoveComp->GetStamina();
}
bool FVRTCharacterMoveResponseDataContainer::Serialize(UCharacterMovementComponent& CharacterMovement, FArchive& Ar, UPackageMap* PackageMap)
{
if (!Super::Serialize(CharacterMovement, Ar, PackageMap))
{
return false;
}
if (IsCorrection())
{
Ar << Stamina;
}
return !Ar.IsError();
}
Something like this
Not sure if the Serialize is needed tbh
Just followed what Epic did iirc
I'll have to write something for that eventually, but i'm busy refactoring something that is quite old into something new and shiny and that comes first
Ohh interesting that is very helpful, now I can start reading about those methods. appreciate the help exi! π
out with the old, in with the new π
Note though that code above is not all you need. Depends on what you actually do
It might also need a bIsSprinting boolean for example
When you handle the MoveResponse you might then need to start or stop sprinting based on that boolean
Ahh okies, I'll keep that in mind when trial and erroring, thanks
ClientHandleMoveResponse is the function that gets your move response container
Something something in there const FVRTCharacterMoveResponseDataContainer& VRTMoveResponse = static_cast<const FVRTCharacterMoveResponseDataContainer&>(MoveResponse);
perfect knowing all those methods really help, so I can try breakpointing through it and see what they originally do. If anything else comes up you think might help, I'll all ears (or eyes lol)
basically @dry pebble same stuff we said yesterday on stream, you can use an attribute for that and handle the base value yourself.. great explanation from exi with practical code
Ah I see, I was able to change the attribute in CMC but not handle it predictively. So like how eXi mentioned using a value stored on the CMC and influenced by sprinting only, this attribute could only be used by sprinting too? E.g currently using "stamina attribute" for dashing ability too, so I assume I cannot combine these for the CMC sprint? Keep it seperate?
Yes you could use your stamina attribute for dashes aswell as long as the dash is also handled in the cmc
the moment you use something that mutates stamina outside the cmc, issues will arise for sure
No, the dash is an ability, but uses root motion sources (which is linked to cmc I believe) and has a GE to reduce stamina. So I assume I have to seperate it then
yes unless you have some delays that prevent you from sprinting right after dashing
but its a mess
in fact I'm suggesting to use an attribute but... you are losing the benefits of using an attribute (mutations and such) so... heh
I could put dash in the CMC later, but for now for practice, I might try a seperate variable. Any benefit to using an attribute and modifying the base value vs just a value on the cmc?
not many without pulling lots of hair
right lol, so I might just try with a value on the cmc
it'd be cool if you can simply apply an instant GE locally which appends tags and such
its possible but you have to modify GAS
which is another deep pit
right yeah, I'd prefer to avoid that for as long as possible lol. I'll try tapping into all those methods eXi mentioned and see what I can make. thanks for the help guys!
sure!
I'm going to read through CharacterMovementReplication.h, are there any other classes relevant that link to CharacterMovementComponent that I should look into?
Anyone remember how to make a client-side-only pawn send its location updates to server for purposes of the net culling of other objects?
I have to ask every 6 months because I forget
The Character is deeply connected
But then again also not
SPEAKING OF CMC, i did some prototyping and research
i'm going to, again, try a more basic implementation of INetworkPrediction interface
but, both the version i just finish and stock CMC didn't really respond well to root motion locomotion
it would be fine in an empty space, but as soon as i had collisions and surface sliding, root motion locomotion got too unpredictable and i would get constant rubberbanding under all my tested network emulation settings for both my own work and stock cmc
i'm going to go back to square one, do another solid and simple movement component, but i need to have root motion be only incidental
it's not that bad, i just have to adjust some locomotion animations that are root motion based and normalize them to work with a static movespeed, but after my tests today with stock Character and CMC, i'm pretty sure it's just root motion in networking that is too unpredictable when used for locomotion
again, kind of a "duh of course" moment, but hey i LEARNED something which is always nice
did you try turning on client authoritative during root motion?
oh i was thinking about this, or adding a "trust" threshold after collisions, but the design i had in mind stayed in rootmotion for ALL locomotion
I'm still not 100% clear on what saved moves are (even though my code uses them lol). My understanding is that in the simplest terms a "move" is the resulting world location for the character actor after processing all of the player's input which is handled by the CMC. A "saved move" is the vector as predicted by the client and may or may not be used but kept temporarily in a small buffer.
Here's where things become even more unclear for me.
When moves are combined together does it mean the CMC is processing two or more inputs simultaneously?
or does it mean the CMC is processing the first move for input X, then re-runs the code to process another move for input Y and returns a vector all of which occurs on a single frame?
or is it more like the player is pressing W to move forward but the server says no you're pressing space bar to jump and so the end result is both the character moving forwards while also jumping?
Guys a general multiplayer question if I may.
In a game I know, many people are experiencing sync issues, such as like lets say you have 2 items in your inventory and you are not the host. You drop item 1 but host sees it as you drop item 2.
So after game syncs you also see that you dropped item 2 despite wanting to drop item 1
However the dev can't reproduce this when testing. What could cause this in general terms?
A saved move is a single "action" taken by a movement component, either on a client or server. It might be a movement vector for walking, or a signal to start jumping, or some other "input". Also most inputs can be combined into a single move, since you can for example jump at the same time that you move in a direction.
It also contains logic for how to apply, revert, and combine other saved moves so that CMC can replay or rollback movement state when necessary.
On clients the CMC needs to retain a saved move buffer because when the server confirms a move the client may have already applied additional predicted inputs, and if the server's confirmation differs at all then the client needs to replay unconfirmed inputs back on top of the server's confirmed state.
As far as combined moves go, CMC doesn't really process things in terms of inputs. It processes saved moves - which may be produced by inputs.
If on the same frame you hold forward and press jump then the result should be a single combined move that contains both
How that's achieved is somewhat irrelevant, but it could be by each one producing a move and then combining them at the end of the frame
Or potentially only at the next network tick
Ahhh okay this has helped me a lot. Thank you!
latency, bad framerates, different architectures, network loss, lack of validation, race conditions, the list goes on..
mhmm, basically... the overall flow is tick component on client -> if received client correction, fix here -> replicate to server is called -> create saved move + initial fill -> performmovement -> finish saved move + ending fill -> CallServerPacked -> server unpack and setup -> server side perform movement -> check for error -> if no error, send Ack of good move, if error send client adjustment -> tick component on client -> if receive... and so on
Much appreciated everyone. Thats good information!
there's more abstractions beyond that, such as sending an old move, pending move, combining moves that aren't important together, etc. but that's the basic flow for autonomous pawns and the server
idk wtf is wrong here. followed guide as only 2 steps. click generate file click build. fresh "release" version so should build no issues
Exactly we have #cpp
They will tell you not to look at the error list and instead look at the output log
Just a heads up before you ask there
im building src tho its not a cpp issue?!? its src itself. anywho im just pissed boput waiting 2 days for the error on something that shoiuld be click build. not midified a thing XD
Glad I could help
cheers man
You still count π₯ tho πΊ
Does anyone know if World Partition in UE5 works for listen servers? Our game uses player-hosted sessions that other players can join as clients.
IIRC World Composition doesn't work because the server (our hosting player) handles the loading/unloading, so if the server left a zone in our open world but a client was still there, it would be unloaded and they'd fall through the ground into the abyss. Is this still the case for World Partition? Trying to decide if moving my project from 4.26 to 5.1 would be more work than it's worth.
hm... i know there are functions in place via the player controller where when the server loads a sublevel, the clients are informed and told to load that sublevel as well (i had to override that for a recent project), i THINK there is a flow for the other way around no?
By default all cells will be loaded on listen-server, though in 5.1 there seems to be a couple of cvars you can use to make the server load cells that only have a streaming source, so it's less expensive
Keep in mind this is all still experimental
Link to the thing: #multiplayer message
Good to know. Thank you!
thnx. its a bp project im trying to build the dediserver. but iv broke it adding c++ starter content to it to try make the vsproj file as it just crashes now π¦ il get src built first from this guide. then try start again
Ah yes good point, so those three are pretty interlinked, cheers
What would be the best way to rotate a character toward a specified location on a server. I am using GAS and have a custom CharacterMovementComponent on my pawn.
SetActorRotation seems like its not playing well with the movementcomponent and I cant seem to find anything that makes sense in the movementcomponent
Would this help on Character.h? virtual void Character::FaceRotation(FRotator NewControlRotation, float DeltaTime)
I saw that, but didnt know if I had to go through the movementcomponent
I did this to slowly rotate player in that method
const FRotator SmoothRotation = UKismetMathLibrary::RInterpTo(CurrentRotation, NewControlRotation, DeltaTime, RotationFactor);
SetActorRotation(SmoothRotation);```
Ah not sure, don't remember if I had net corrections doing that, i since changed how I handled the rotation
Cause I see that the MovementComponent uses the FaceRotation, but it doesn't seem like there is an explicit way to just rotate the character through it.
I'm think I might need to make something custom
Sorry, as an update FaceRotation wouldn't work. In the game i'm working on we aren't using any controller rotation.
It's all pawn
Heyy ghuys I am following the function replication tutorial here https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/ReplicatingFunctions/
Basically there's a collision box in the world, then through the Level Blueprint, logic is setup so when a player runs into the collision box, a "Switch has Authority" check makes sure that the collision is only handled by the server. The server then calls a replicated function with "Run on Owning Client" replication optiion to update a variable's value on the character that ran into the collision box.
How does the server know which player is the owning client? Is it because of the "Character" parameter passed into the replicated function? This is the logic inside the level blueprint.
Look at how OrientRotationToMovement works
Whatever it's doing, do that I'd guess.
Correct. It chains back to the NetConnection for the actor in question (being RPCed on)
Correct
Not project name though
I don't see this function
Just Engine folder
There is no Engine folder in your project directory anyways
That's in Engine directory
You could see that if you looked at the top
The one below
That's source code
Is source code part of your Project directory?
Yes just add it
You found the file
I thought you added the file for some reason
wow thank you
No
Part of your project directory
Which is obviously not
Sarcasim that is
Laura pls no toxic
That's a boolean on the CMC, presumably it's used somewhere in the CMC and does what it says on the tin. I'd look at how they do it and try replicate that.
To clarify what WizardCell said, it does indeed chain back to the NetConnection for the actor in question, however, in the example you've provided, your RPC's target is "Self" which appears to be a Level Blueprint, in which case the RPC will fail to send to any client. Your "Character" is only an input that would be passed through the RPC but that is not the actor you are RPC'ing on - the target of the RPC is what determines the actor and in this case, your target is "Self" which would be the level blueprint. The only instance this RPC would fire on, even though it's marked to replicate to a client, is the server in a multiplayer scenario.
That slipped under my radar
Good catch Datura
They said they are following the tutorial by Epic. That's why I rolled with closed eyes and just answered the question kekw
Would be funny if Epic did that lol
Oh yeah they indeed did it 
Okay I declared it, I officially lost faith in the official docs
Yeah it's indeed my fault for keeping some hope π
It goes even deeper, they client RPC to change a replicated property on client
Well I guess I can't trash talk YT/Udemy tutorials after today
Link plsss
I'll believe you considering your hat is not Good Looking
You must believe me considering you made both 
man I am never following docs blindly anymore π it messed me up more than it helped, I was scratching my head like why on earth would this work....
It is good that you questioned that at least
thank you, really appreciate the in-depth answer.
Talking about stamina on the CMC with sprinting again, when you say to start or stop sprinting based on a boolean connected to the MoveResponse, what did you mean by this? Is this boolean being set in ClientHandleMoveResponse?
The whole issue I'm trying to solve is. We want our Pawn to OrientToMovement, but on ability use rotate toward the mouse cursor.
the kicker with this is the animations that play for some abilities also apply root motion
So I'm trying to get the CMC to understand that I want a instant rotate the pawn toward the mouse then cast an ability.
I'm too sure i'f i need to override something and do custom logic or if i'm just not understanding how it should be implemented
So look at how Orient to movement does it, and have your ability do that.
ok that took a long while but i managed to get vscode to play nice and build to a point where i can make the dedi server and client builds. seems u have to start the project with this ion mind for it to not break so start with settign it up for this build env and run from vscode editor not epic editor. fingers crossed i can recreate the project. props to wizard and laura for their help earlier
Experiencing a little bit of lag when I feel like I shouldn't. Basically it's on selection of a character. User clicks, I do a get hit result under cursor for objects. I then send that actor reference to the local player state and replicate it as a variable to the server. However, when I click on an actor, there's about a second of lag before it actually updates.
I'm using mostly blueprint interfaces to transfer information - are they laggy in Multiplayer environments? Should I be casting when possible instead?
It's usually set by the server.
In the function where the client handles the move response it should theoretically check if you need to sprint or not and if you are already sprinting or not
And then manually force it to
At least I think so. Always worth checking what epic is doing in the parent class
Are you spawning anything when selecting? Why aren't you simply selecting locally?
There is a very simple philosophy to this, I call it: Local First
If there is anything that does not strictly need to be replicate it, you don't replicate it.
For example UI clicks, VFX from gunshots. If the action affects the game environment and therefore other players, it needs to be replicated. However if the only actions are locally, and it won't out of sync you ... you don't replicate it.
So for the character selection if someone else is supposed to see it, you just simulate locally first for the selection, and the server will update everyone else on your selection.
Simply routing UI clicks through an RPC to the server to then get it later yourself... sounds flawed by design.
And obviously if the action has no visible effect for others at all, it should not get replicated at all
Should I load the content before joining a session or after joining a session?
i see most games start with joining a session and load the content in loading screen
but when I try to use UE default join session, it connect right away, though if the map quite heavy; it hang for a min or so
So, here's me trying Projectiles + Multiplayer. Most of the solutions rely on Multicast + some filter to guarantee a dummy projectile isn't seen to the owner of it (to compensate for lag). Question: this is a waste, right? In the sense of bandwidth.
Why would it be?
At a minimum, everyone needs to know that a projectile was fired from X location at X direction if they're meant to see it.
One way to address "lag" in projectiles is to spawn one locally, then ask the server to spawn dummy ones for the remaining clients. Lots of solutions though suggest doing this technique via Multicast - however, Multicast affects all the clients, including the one that instigated the projectile - which is someone who doesn't care about it.
Guys if I have Basic Thirdpersoncharacter and it has its basic CMC why when I change it to flying and I am moving with my character in game it's not replicated shouldn't it be like when u running on the ground?
@real ridge is Can Fly checked by default? or you are switching it in the game?
Cant you spawn a replicated projectile on server, which has a condition to skipowner
yes and here I changed position of one and it was not replicated
hmm... the movement in character bp is replicated by default, i assume it's something else
are these 2 are standalone application?
i don't see server/client on them
then my second approach is using pawn where I replicate movement by RPC but there is also one problem , when I move only little bit on the other window where it is replicated I see much bigger movement
even I replicated it via rpc
so I dont undestand how to do it
using this settings
but for example I am not replicating moving of propeller and it is replicated
I am confused π
when I try run it in viewport then its replicated properly @vivid prawn i mean this
or maybe do I somehow need use instead this function from cmc and set location there to have my char replicated? i dont know
i see... try to use Add Movement Input instead of moving the actor
that would handle the replication
yes but pawns are not replicated
only characters as I was said
many times here
ou shit its doing some crazy shit :DDD
wtf
i just changed that one blueprint and it suddenly react on WSAD EQ
oh my bad only moving up and down is replicated but it's strange he moved to the left
@real ridge just use character blueprint, everything is already there
I do but you see its working really strange π
i just used also that blueprint for roll etc
and its definitely not good controlling of plane
I just checked the Can Fly and set default land movement Mode to Flying everything replicate nicely on myside
character blueprint
i made one video for you
its uploading
it's just matter of changing the settings
check this is WS AD QE it's turning weird and it does not allow me turn 360Β°
my suggestion is not to reinvent the wheel, you will save more time and have more progress
i am just trying to find the easiest way to use planes in my game π but I have feeeling nothing is working
but you see video ? how nonsense moves it is doing ? I made another one where I am showing what moves I need to get
oh no old video..
this is my pawn and right movement
i see... all that actually exists in CBP
i will try make new project and test it maybe I Fucked something
if u saying
it must work
check Orient Rotation to Movement in Character movement component
also you can use Pawn Control Rotation in SpringArm
ticked too
so u saying it should work so I just will try find where I have mistake
What do you think about Inventory which is based on MySQL database?
I actually figured out that I can just use a RootMotion ability task. The CMC is already looking for rotation changes in the RootMotionParams, but none the currently created tasks change the rotation.
Not arguing but how would you go about synchronising said inventory between servers? Like if you had some kind of "server node" set up? Or is that a completely different problem
hello guys, a question someone uses the plugin "MySQL Integration
"?
Hi!
Are there better options of UGameplayStatics::GetPlayerController to use them developing a multiplayer game?
Thanks.
How can I sync a simulated proxy if its late joining the game? Right now I'm testing two windows on a listen server. If I wait for all players to connect then no worries, but if I let the server/ client (same) run around and do something first, then the new player joins , they don't get any updates (unless the property is replicated). In my case I have a TMap (which can't replicate) and if the original starting player adds an element to this tmap I want to be able to tell the joining player - their Simulated proxy (of the starting player) needs to add this elem to the Map.
They weren't in the game when the OnRep for any replicated variables occured and I don't have one that would suffice. I could keep an integar of the number of elems and create an onrep for that, so when the new player begins their int gets the OnRep because it's not the same, and in this I could do something - but it seems so Meh
Something like instead of GetPlayerController(0) use GetOwningPlayer.. Or APlayerState::GetPawn().
For the most part you should be able to get to the player controller from the controlled pawn via GetController, and through GetOwner on PlayerState - both of which would probably need to be casted to PlayerController to do anything useful with them.
Hey! RE: to Conditional Property Replication (https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/Properties/Conditions/) - any ideas why it's not exposed to BP? What's the rationale behind it?
It is exposed to BP
Is it?
It's the "Replication Conditions" dropdown for a variable
It is exposed?
Hm. I'm quite lost, then, geez.
Not sure if it was a good suggestion tho as im not very network experienced, but it came to mind
Your suggestion is actually what I saw everywhere on the webs.
(Thank you by the way)
The thing is - I just skimmed that docs (shame on me), and thought that could be something that would skip the entire Actor from being spawned to the owner of it (missed the second param of DOREPLIFETIME_CONDITION).
That to ask: can I spawn actors conditionally?
In the sense - I want to spawn a projectile to everyone but the owner of it.
(That actually seems to me a pretty common thing to do in multiplayer games when it comes to lagfree solutions. I'm surprised it's so difficult (taking me hours) to get it done correctly, without the need of a multicast.)
Wait. Where? π€ In the Actor Settings within the Editor you mean?
B/C the only bSkipOwner I saw was this one
(Which relates to a variable)
Yeah that doesn't appear to be a property of AActor.
Maybe this? https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/GameFramework/AActor/IsNetRelevantFor/
Still not sure how to use it yet.
Checks to see if this actor is relevant for a specific network connection
IsNetRelevantFor requires C++.
Not a problem. Whatever it takes to skip an unneeded multicast.
Ok, then it's fairly simple.... One sec.
.h
virtual bool IsNetRelevantFor(const AActor* RealViewer, const AActor* ViewTarget, const FVector& SrcLocation) const override;
.cpp
bool YOURAPIHERE::IsNetRelevantFor(const AActor* RealViewer, const AActor* ViewTarget, const FVector& SrcLocation) const
{
const APlayerController* RealViewerController = Cast<APlayerController>(RealViewer);
if (IsValid(RealViewerController)) {
// Do whatever checks necessary to determine if the PlayerController should view it or not.
// In your case, you'd probably want to return (controller of the instigator of your actor != RealViewerController) thereby, only those who are not the instigator would return true.
}
return false; // Return false if thew viewer was not valid.
}
This would go into your projectile C++ class.
Testing right away. I anticipate my gratitude π
OK so - doing that would mean that when Spawning the Actor implementing this custom IsNetRelevantFor, the server would spawn it everywhere except at where IsNetRelevantFor would return false. Correct?
Yep
So that being said, you may want to add to your condition if the super is true, so any other relevancy may apply rather than just always being relevant for everyone else which it may not necessarily need to be if they're far away for example π
You mean
if (!IsValid(RealViewerController))
{
return Super::IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation);
}
Well damn. You're right, the property is "OnlyRelevantToOwner"
My bad there, mixing it with the cond
return that && the instigator/controller part.
I'm working on a two player co-op. You pick a role (there are two roles) and once both players have indicated they're ready, the game starts.
What are the steps I need to take? Abstractly, I mean. I can host a session and I can join, but I don't know when the other player has joined so I don't know when to show them as joined on screen. Should they just pop-up and do I replicate UI? How do I know when to enable the "start game" button?
A "rtfm" is also fine, I just don't know how to proceed.
@hoary spear What do I use to be notified of players joining? I have a custom game mode in c++ and I have a blueprint of it as well if that helps
OnPostLogin() is the function in game mode where a player has been granted a playercontroller.
OnPost* ah yes
Thank you, that helps a lot.
virtual void OnPostLogin(AController* NewPlayer) override; there she is... If I may be greedy, do you have any pointers on syncing the UI? Player picks a role, and both players connected can see that?
I'm not doing that part until tomorrow, but I thought I'd try my luck π
Datura will provide a better method than what I did xD
( i may have snaked my way through some super redundant rpc bullshit via the gamemode and whatnot)
I found the other method I need for my first question I think, it's called Logout. I was looking for OnPostLogout like a pleb.
Well really, I think it's more about what information it is you want about a player when they join which probably means the Begin Play of the Playerstate may be a better choice as the PlayerState would likely contain that data. The begin play in playerstate on the client could signal something to your UI, possibly by calling something in your HUD class to indicate a player is joining. Your UI would then need to react to that signal, set up any other binds that are required - you may want to read any values and have event dispatchers set up for when changes are made to any OnRep variables (like player name) You can always read the player array from gamestate as well if you want to read the current full list of players and then read their properties and set up binds to their data.
Binds as in umg?
Binds to event dispatcher or binds in umg if you desire.
Ah, right, thank you. I'm taking notes, because I need to look up what those are still.
So far I've done the basic map travel, host session, find and join session... That stuff. Now I need to figure out the rest.
Any docs/tutorials on how this stuff works?
I copied both your messages to notion, so I can go through it using the docs lol
I'll just keep playing around and see what happens π Thank you both
whenever someone did anything in the UI i went through the playercontroller to rpc(ignore the S)
which just passed it forward
which ends with the first function i showed, "Server_UpdatePlayerStatus"
this is probably not an acceptable way to do it at all , but it worked for my 4 man lobby x)
Oh, wait, would gamestate then make sense?
Because that's synced, right?
And it's per game mode, so if I have a game mode for the "lobby" then that has a game state I can use to keep track of who's picking what. That information should be available to both players and is a draft until the real game starts anyway
It's more about what actor is pertinent for what data. PlayerState is a replicated actor just the same as GameState, the difference being only one GameState exists for everyone. Each player would have their own PlayerState, thereby, any data about a specific player that needs to be replicated to other clients and can be replicated at any time regardless of relevancy should likely be stored in PlayerState.
If it's specific to the state of the game or what is happening and isn't specific about any single player, and again, needs to be replicated to others, GameState makes sense to store that value.
PlayerState lives longer - it can stick around and be reassociated to a player that disconnected with a bit of work in C++.
That's good to know
I'm going to tattoo this on my lower back
So rather than having the gamestate store what each player picks, which in order to replicate would require a weird structure and/or some array management hell, you can store what the player picked on their playerstate, and then the playerstate can replicate those values to everyone else, and you'd use OnRep properties on the PlayerState so you get functions that are called when those values change so your UI can be updated when those values change.
I didn't know that was how it worked
Outlive maps... kinda... its going to get reisnantiated with the PC. But you can override CopyProperties to carry the data you need over map transitions.
If you wanted to have something replicated, you'd be able to send a Server RPC on the client's PlayerState with the data you want to send, and then when running on server, set the replicated properties you want with the values that were sent through the RPC.
Wait now I'm getting into "rtfm" territory because I am pretty sure the doc I found will cover this
So I need to keep reading
I strongl, suggest separate lobby and game player state classes with a common base containing all the data you want to persist across levels
Those things tend to grow as you start adding more customization options
I see
Added to my list of messages to decrypt π
I'm reading this now by the way: https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
If there's something else that better explains the concepts I'd love to hear it. I am still finding out who's allowed to change what. But for now I'll go back to reading and being a good student π
Thanks again!
Good choice of light reading material
The validation part confused/surprised me a bit
Failing validation results in a disconnect
Is that really how one wants to handle that?
Just disconnect anyone we decide tried to go outside some bounds during some rpc ?
Guess i just expected a rejected rpc, and nothing more
You can do that, just noz how iz works out of the box
I see
I found the answer to my question on literally the next page I had to read. Iβm sorry
Its basically there to kick out cheaters
You can add your custom validation and call it from RPCs _Implementation , for cases where xou dont want to accept what client sent you, but dont want to kick him either
And just have the _Implementation return out eithout doing anything when it fails
Hey all, I've setup an interaction system - I click on a player and it sets a replicated variable on my player state storing the actor I've clicked on. I've noticed there's a noticeable lag, however of about 1 second between when I click and when it's updated. This is happening on a dedicated server setup.
Anyone have any ideas why this might happen?
If I'm getting this much latency on a local test with selecting an actor now I'm worried what else could be lagging
Quick question, how do server like call of duty or fortnite work? Are those servers dedicated servers?
okay, thanks
PlayerState's default NetUpdateFrequency = 1, which means it's only checking for replicated values once every second.
Ahhh, thank you, that explains it. Luckily I don't need it to be faster for my purposes, but good to know why it's doing that.
Does ForceNetUpdate basically say "Update this right now"?
Or is there a way to change the frequency if I needed to?
I believe so, not sure as I've not messed with it myself.
(nm, I found it in defaults lol)
Hey, so I need to update an entry in an array. I'm telling the array "Increase this entry by 1". On the server, I find the right entry in the array and go through normal steps to update (Break the struct, set the members and then set array elem). It's updating it locally, but won't update the server.
I assume this is because set array elem isn't replicating; would a better way be to clone the array, make the changes to that array then set the actual array to that? THen it's just a simple set that can be replicated.
Yeah that's Blueprints for you
You can try to just call "Set" on the whole Array and pass in the whole array
That might trigger it properly
But that goes for the replication part
You should, even without that, have a correctly updated array on the Server after incrementing the entry. Otherwise you are doing something wrong
Is this different in c++, since you say it like that? Would updating an array element in c++ trigger it ?
if i used loadlevelbp with url/ip how do you know if the level didnt load? would i just add a delay and if im still in the current level when the delay fires i throw up an error dialouge. otherwise iv moved levels and its all good. e.g walk into a tp box to tp from one server to another but if that servers down dont go there and stay where i am. as it doesnt have a success fail output on the bp
Is the only way to have a conditional for whether to replicate a property within a ustruct to also replicate a bool and check against that within NetSerialize?
Or can push model be used to control when properties replicate within a ustruct?
Does anyone know why the character class disables a replicated property as being not replicated? DISABLE_REPLICATED_PROPERTY(ACharacter, JumpMaxCount);
If it's about OnRep, yeah it is different
Is that function called by both?
Also ControlRotation is send from Client to Server
maybe something is going wrong with which ControlRotation is actually being used
ControlRotation is packed and send to the server usually
You'd only need to set it on the Server if you correct the Client iirc
Why the conditional bool property has to be replicated? Couldn't you mark it as NotReplicated?
If it needs to be dynamically set, you usually use a bitmask
If it's known at compile time that you don't want to replicate a specific property, you would do what Wizard said
But a boolean is theoretically also fine
We use a bitmask for the GameplayEffectContext
We have multiple inner structs in that and only if someone calls "SetXYZStruct" on the Context, we flip a bit to 1
And use that to check if we need to load/save that part into the archive
I think that's what Epic also does with their EffectContext
I'm looking over at FRepMovement they do something similar. For example they check against RotationQuantizationLevel to know how to net serialize
Though that is not marked as NotReplicated for some reason
Could be that they use it client-side
You need to replicate the flag/boolean
Cause you need to know on the client if you need to load the value
You are basically writing it in some dynamic order
yeah FRepMovement was the example I was looking at for the bool
So the client needs to know the order in which it has to read
That's if you do it dynamically right?
Yeah
Yes fair enough
Yeah, not entirely sure atm why it would cause corrections
AFAIK Push Model looks for properties by name within the class that you specify, so in theory if you could slap the Struct name in there... then you would be able to control the struct inner properties
But I haven't tried that
Interesting
yeah that's what I was thinking too
How does the bitmask method differ? Isn't it the same as the bool method just packed?
Saving those extra bits ^^
But yeah it probably doesn't make a big difference if you're only looking to conditionally replicate one property, but if you have multiple of them then having a bitmask would be a good idea
awesome, yeah that makes sense
Just to be clear, once I setup an Event as Run on Server... and this may be a dumb question... everything in that event is run on the server, right?
Yes
Potentially run on the server
Potentially
Got it
I wish there was an easier way to visually see player array data on the server
I tried RootMotion last night with the GMC 
I have something not working for some reason though, but I like it nevertheless
Like the workflow or like GMC?
https://www.youtube.com/watch?v=JPmy2H9Damc&list=PLUYBthaeEmJtsIu81Et9mVLIde9xVx9nR&index=4&ab_channel=JimmyVegas
This is the the tutorial I'm following but FSR sim proxies are not able to see the animation montage playing
I can call a server event from a sever event, right? Like it should know it wants to execute on itself?
GMC
The way properties replicate is different to how you replicate them in a non-GMC environment, so it must be that
I fear it's something with the plugin, but I feel I missed something
Yes, it would then run the second server event as a normal function on server, but a good practice is to know not to mark it as an RPC at all
Like it more than the beloved CMC?
To be honest I was not punished enough by the CMC to appreciate enough what the GMC offers, but I can feel the potential the plugin has
@whole grove π A light review
I mean I wouldn't program in BP but the fact that you could prototype something really fast is mind blowing
I still dislike for example some boilerplate, so for example you have to tell the GMC owner about the action/axis mappings that you are using
You also have to bind those inputs with dedicated functions and hardcode the names again
But well you can bypass that using the construction script for example so it's not that big of a deal
Yeah, that part was not all that attractive π . But with enhanced input, you kind of have to do that now anyway. Just asset based now.
But you're eventually going to be doing MP when hired at WizArmyβ’οΈ
I just want a Prediction Plugin Movement Comp
With that sweet sweet debugger
I had to debug Movement shit again
I hate it
you can't log it cause it's obviously not in order when printed
That debugger Dave showed in his youtube video was so awesome
I already thought about just trying to get that to work with the normal CMC
Honestly the dream is if NPP was continued and the CMC worked better in tandem with the GAS
Yeah the NPP would just have a general state
A generic SavedMove
With all info you need
;_; UE6 #believe
See you in a decade π₯²
That kinda sucks because it means I will be at 40
What debugger is that? π
Ah okay I didn't watch the video (I know the video you're referring to)
Basically a timeline that shows the "moves"
And if they were acknowledged, or rejected and replayed
And you can click on them to see the state
Like the variables
Wow... this left me speechless
Apparently not
Did this get scrapped or no?
Pretty sure if it still exists it's part of the NPP
Which is still not integrated into any other class that we daily use
How easy life becomes... debugging tools are the best
Right?
How easy it would be to instantly see the move that got rejected and compare the values
Instead of printing in random places and having to compare timestamps
cause by default the CMC is like "HEY THE POSITION IS SQRT(3) OFF, GET F DUDE!"
Why? Who knows
Maybe you forgot that the CombineMove function is supposed to reset the CMC back to Move1
freaking hell, still haunts me
Cedric dreams in CMC stuff
My whole life is a rejected move
what?
That said, I'm actually working on refactoring something that I released some time ago
Not so interesting for you all, cause you already know how everything works
But(!), I'm rewriting it in a way that others can easily extend and update it
What are we talking about?
Only one knows how everything works π
The Compendium
The Compendium V2 - AKA "The Compendium Wiki"
The Persistent Data Compendium?
Oh.. That's what I was thinking, but the "easily extend" part threw me off π€£
I'm turning it into a React app with MDX, with a public repo for PRs
Yeah - just make new pages on the pdf Thom!
Probably extend it with the Iris stuff? π
It can still be "printed" into a new PDF, if someone still wants that
I mean me and @whole grove only care about a dark theme
But this should make it easier to correct mistakes, update to newer versions and also link specific topics to people
No, Multiplayer is the light in our lives
Dark theme is for Singleplayer
Our opportunity to revamp our #multiplayer learning experience @whole grove
Original main reason why I wanted to redo the doc into a website was so I can easier code custom animations, such as highlighting only specific elements if you hover "Server" or so.
But by now I'm happy that I can use Markdown
I already thank you for the effort because I can already feel the potential
You're definitely out of the "learning experience" already though lol.
Yeah I'm still rewriting it. Lots of the text was cut down due to the limited space I had in the doc before
Finally no more wordpress dropouts? π
And my lack of webdev skills are also a bit time consuming
Cools dudes use Jekyll (and MM for the extra coolness)
I'm even considering moving my guide for C++ Sessions to the same page
Well, other tab, but overall same page
100%. Please save me π
Get a game dev job π
Says the person without game dev job, but you know.
I even recreated the damn diagrams as svg
It's funny that I got a mail two month ago from a random about my website exploited. Poor hacker didn't know I have no "real" database
And, what is also kinda cool, I can use blueprintUE for the BP examples
I asked the creator if they could look into making it printable (well save to PDF) but I think they didn't get far with that
So I might need fallback pictures -.-
I'd like to, but remote is hard to find because gamedev is prehistoric (hard requirement for my situation) and generally the stability and pay is worse.
I'd honestly even be willing to just take a very small pay cut - but the stability....
Hello, I'm having issues with location replication and attachments :
I've got a mesh to which I attach multiple actors, all are set to replicate, as well as the root component.
The thing is that i'm spawning and attaching the actors in the same frame, and on the client, sometimes the attached actors get wrongful offsets (not the same as the ones on the server. I'm using attach rule KeepWorld.
Does someone know a fix ?
Btw it's all runtime (runtime mesh and UGC), so unless I code them myself, sockets are not an option as of now.
It's not Iris specifc, amazing π₯³
Very relatable, also I suck at everything game dev but relatable. I found a whole one studio in my country that I "know" and that make games, have been considering applying for a QA job and see if I can get anything out of that but not sure yet. But everything international is such a pain.
Don't think you need to replicate the root component
Actor Attachment is replicated by default
I even had to turn that shit off cause it was interfering with attaching it to different meshes on different clients..
yeah but for actors with components it's needed otherwise it just doesn't attach
Actors always hae at least one component though
Either way, are you moving while spawning/attaching?
it's not always a scene comp
Doesn't really matter. Actor Attachment is still replicated
yes, there's a bit of gravity but everything happens in one frame and correctly on the server
In theory, it should still be connected in the same place on the client ?
Yeah but the Actors aren't guaranteed to be in the same relative places on Server and Client
Cause they are moving
Yes, but some spawn at the correct location on the client, other spawn at the location of the component they are attached to instead and so theyu don't get the correct offset
Would it be an option for you to, instead, "snap to target" and then set a relative offset?
Is that possible ?
Relative Transform should also be replicated
So if you calculate the relative offset between the World Location and the Attach point, you can snap to target and set that offset as relative location of your attached actor
That should theoretically ensure that client and server use the same offset
If i've understood correctly, I should use Attachment rule to SnapToTarget and then add an attachment offset ?
How can I replicate an animation in standalone modes?
@quasi tide @twilit radish Not to escalate this, but from the POV of the person hiring, I can understand that one doesn't want to bother hiring people across the border. Even within the EU it's annoying to deal with. We do however have three of 5 people work remotely, but within our country.
Can you explain what your problem is?
For example, yeah
Ok thanks, i'll try and keep you updated
Oh yeah - I totally understand not wanting to remote hire international π .
I am trying to replicate an animation of an actor on a map and when I compile and test it on my dedicated server that I run from standalone, the animations are not replicated, I only see them in the actor that runs it but not in the others
You'll have to share your code around that, cause this totally sounds like your code is at fault
But that's exactly why I'm questioning if I should even bother with game dev despite how much it hurts, imagine I get hired by that one company in my country and something happens then I have literally no or very few other options. My country sucks in terms of game dev jobs π₯²
I mean I don't mind hiring someone as a contractor, but not as an employee
GameDev is tricky, yeah
International contractor is fine. From what I've seen, it is generally, "Hey, here is your money. Figure out taxes on your side."
Should probably move it to #career-chat or so, sorry!
#BlameCedric π
Oy, I made sure to help the peeps that asked in between. Otherwise I would be crucified in that feedback thread, which is apparently locked by now (thank goodness).
It does a super weird thing to me, the actor only replicates me when I'm with the other player near the actor who interacted with the object in question to replicate.
all this is for a dedicated server model since the machines are connected by standalone
It works ! Thanks ! Also, would you happen to know why there is self-collision between attached objects on client but not on server ?
No clue. Just make sure to turn off collision on both
And since it's state, preferably via RepNotify/OnRep
Uh before I go down a debugging rabbit hole, are there any known issues with ServerTravel in packaged builds for 5.1? I haven't changed anything since the last time I packaged regarding session hosting apart from upgrading to 5.1. I can do it fine in editor, just not when packaged.
ServerTravel, as in moving together with Clients to the next map?
It basically reloads the main menu when I try it.
No just trying to host a session and travel from the menu to the map
Yeah about to do so
Nevermind, there's still the same issue : the objects spawn at the parent's location on the client and don't get the relative location applied after the snap.
Do you know if there is a way to replicate data to the object so that it has it on BeginPlay ? that would allow me to fix the issue.
Exposed on Spawn variables that are marked as replicated should be available on BeginPlay
Same goes for Deferred spawned Actors in C++
it doesn't seem to be the case, https://forums.unrealengine.com/t/spawn-actor-replication-of-exposed-on-spawn-variable-values/88774/4
according to that and some testing I did on my end (though that was with replicated variables on a component)
Please re-read the thread
Nothing in there says that Replicated Exposed on Spawn Variables wouldn't work
The poster wants ALL exposed on spawn variables to get send to the Client by default
Which is not what I said
[2022.12.28-23.17.26:287][372]LogNet: TravelFailure: ServerTravelFailure, Reason for Failure: 'Failed to load package '/Game/Maps/MixtapeMansion''```
Guess your map isn't packaged?
It always was before. The map is in the same folder as the main menu map.
How do I verify this?
Can you try to travel to it via the console?
yes, but I'm using deferred actor spawning in this instance, so I don't need Expose on spawn ?
Other than that, I would manually mark them when packaging
Expose on Spawn is the BP version of Deferred spawning (more or less)
Concept stays the same
Replicated Variables that are set before Finishing the Spawning are available on the Client
So with deferred spawning, the value of the replicated variables should be set on the client when BeginPlay is called, but that's not what I'm seeing
Can someone please explain me: assuming my GameModeBase has valid UserWidget inside it and I call for example thatWidget->AddToPlayerScreen()
Now, I know that GameMode exists only on server, but AddToPlayerScreen() uses local player. How does it work? Will that widget be added to all players' screens? Links with articles and tuts will be appreciated too
Are you setting it before calling FinishSpawning?
and my values are set before FinishSpawning
but my values are on the components of an actor so maybe it's different ?
GameMode only exists on the Server, as you said. A Widget Reference in the GameMode also only exists on the Server. Calling "AddToPlayerScreen" on it is not a multiplayer action, so this will still only call on the Server
THAT i don't know
I'm only using that with properties on the actor
Sorry, but how do I do this? I've never had to do this and I can't find it in the Packaging tab in project settings π
hmm
Look for the Session Frontend or so
That thing allows for more advanced setups for packaging
Thanks for the help, i'll dig in more
Hey all, I am attempting to test multiplayer using 2 PIE windows with gamepad input routed to the second window. I have checked Route Gamepad to Second Window in Editor Preferences and Skip Assigning Gamepad to Player 1 in Project settings, but it doesn't workβ keyboard/mouse and gamepad get routed to the same window. I am using Enhanced Input as well as CommonUI. Is it possible those are interfering with the behavior? Thanks in advance for any help.
Hmmm
Skip Assigning Gamepad to Player 1 could be only for Splitscreen
Not sure about Route Gamepad to Second Window
that crossed my mind, but here is the tool tip:
oh lol guess that answers that!
thanks for bringing it to my attention
I can ignore it for now then - not critical thankfully, just inconvenient
Is there a way to make two non-replicated objects share the same references when going over the network ?
so that both can be referenced by the client and the server without a link existing
I mean
You can't send non-replicated objects over the net
You need to create them in both places
The only thing to "link" them after that is using some unique identifier that you replicate back and forth
Like a TMap key
What about standalone network mode?
I ask that bcs according to my understanding of your words there will be nothing for local players however In my singleplayer game localplayer sees that widget anyway
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Overview/ :
This mode is used for single-player and local multiplayer games. It will run both server-side logic and client-side logic as appropriate for the local players.
Standalone/Singleplayer has a GameMode
Can I exploit unreal's translation to do that ?
You can't apply Multiplayer Concepts to Singleplayer
I doubt?
You can try and see if an FGUID works
Why not? Surely it's the other way around. Unreal works the same in SP as it does in Listen Server mode, surely? Just without any remote clients.
What I mean is, you can't say "Oh I'm playing the Game, so I'm somewhat of a Client and no GameMode exists, cause GameMode is something a Server has"
Singleplayer has no Server/Client concept. You are basically the Server
That's just a misunderstanding of the situation, rather than applying concepts π
A Listen Server that isn't listening fwiw
Yeah. That's what I mean. ^
You could effectively take a whole MP game and just run it SP, though, as long as it was designed with a Listen Server in mind. So they aren't unapplicable.
Yeah, that's just not what I meant
There may be better ways to do things in SP, though. More efficient.
Less restrictive, yeah
However, there are bonuses to a certain rigidity that comes from MP.
In SP, you could effectively just stick everything in the game mode.
@thin stratus Thanks, checked out the Project Launcher tool and made a launch profile where I manually selected the maps to package π
Still weird how it suddenly stopped packaging that particular map when it was packaging it in 5.0.3.
And that wouldn't be good design.
Everything working now
You mean write your own SP subsystem in gmae mode that you can register things to tick in?!
π
@cunning stirrup if you want something to share state over a network, something needs to be replicated. It doesn't need to be the full data necessarily - you can replicated a key to some data that is stored locally
E.g. when you replicate which mesh to use, you don't send the entire mesh over the network, you simply say, "I am using the mesh at /content/mymeshes/whatever"
right
Can I read about that things without deep diving into MP somewhere? Cause now I totally dont understand differences in game behaviour depending on number of local players
More local players = more player controllers on the machine. About the only difference.... other than the widget/camera space, I guess.
(split screen UI)
I wonder if you can join multiple local players to a server and have it make PCs for thjem all?
(from the same client instance)
and what will happen in situation I imagined (#multiplayer message ) in the case when there are several local players?
For each "local" player, there's a ULocalPlayer object (I believe) and, depending on your settings, potentially a unique screen/camera for each player
Each LocalPlayer object gets its own player controller.
I'm not too familiar with it really beyond that.
You might be able to do single camera / split UI as well?
If you're talking online multiplayer, a reference to a widget existing in the game mode could only exist if it was created on a listen server. For the reference to the widget to be created, that also means the widget would have needed to be created on the listen server host, as widgets do not replicate.
Local multiplayer, well, then calling Add To Player Screen would likely add it to the screen of whoever was set as the owner of the widget.
thank you for your answer, but I mentioned Im curious about standalone with several localplayers
world can be owner as well as game instance
GameInstance and World would assume a single local user
UWidget and WidgetTree probably have their own references to the oiwning player somewhere (probably in their owning objects)
And PlayerController would be owned by a specific local player.
Or mabye not assuming a single local player, but maybe the first local player or a "global" ui element.
Probably implementation (yours) specific
does anyone know what "custom bookkeeping" Fortnite uses to handle fire rates and cooldowns?
I can only tell you that I ended up "custom bookkeeping" Cooldowns for a Client of us a few weeks ago
Cause rapid activation of abilities with GE Cooldowns doesn't work
But "custom bookkeeping" can be pretty much everything
I ended up making it 50% Predicted and 50% Authorative.
- Cooldown is a custom Struct with an Array of another Custom Struct in it
-- That's so the Outer Struct can handle NetSerializing the Array - The Inner Struct has the following properties
-- Cooldown Duration (NotReplicated)
-- Start Cooldown Timestamp (NotReplicated)
-- bServerAck
-- CooldownTag
The "NotReplicated" ones were the headache that had me handle Serialization of the Array by hand, but it's nothing more than custom looping over the new array and updating/removing/adding entries to the local one.
- Client and Server both apply Cooldown when the Ability Commits
- Server calculates a shortened Cooldown Duration (that's why it's not replicated) based on the Round Trip Time (RTT) of the Client, so the Client in theory doesn't suffer from their ping
-- I had a synced NetClock (so a better setup for Timestamps that also gave me info on the RTT of the Client) - Client and Server check if the Cooldown is "over", however the Client only removes the Entry of the Array manually if the bServerAck boolean was never set. That's fallback for when the Server had 0 Cooldown (RTT higher than Cooldown...) and generally so the Client can still somewhat predict. Otherwise only the Server removes the Entry. bServerAck is set to true when the Server applies the Cooldown on its side.
Since adding of the Cooldown is predicted, the Timer for UI is too and the Client won't try to reactivate the ability instantly (cause without predicting this, it would have to wait for the Array to replicate back to the Client, which will allow it to try and activate the ability again during that time).
Removing is not predicted (with the exception of bServerAck being false), so the Client will have to wait on the Server to remove the CD. This will guarantee that when the Cooldown is over for the Client and they try to reactivate the Ability, it is also over on the Server.
Because with GEs you run into the problem that the Client thinks the CD is over and reactivates, only to get rejected later. If you play animations in your GA it will start looking really bad for the player :P
I won't go into more detail, as this is theoretically a really simple setup and can probably be improved. I'm sure you can figure this out from the notes above.
Is it possible to call a server function on an unowned actor? I have a weapon UObject and i want it to call the SetHealth() function on my character but it doesn't work.
I'm still very new to this, but I think it is not possible.
If the RPC is being called from Client to be executed on the Server, the Client must own the Actor that the RPC
is being called on.
https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf page 62. But it shows alternative solutions using the player controller (page 71)
What's the content of the array eXi?
The inner struct
Ah so the tag identifies the cooldown identifier for your abilities π
I think you can get RPCs working on UObjects, but it requires replicating them through an Actor etc.
It is the CooldownTag
Not directly the Ability
The Ability might use that Tag for its Cooldown
yeah gotchu π
yeah so its possible to reuse cooldowns between abilities, simple stuff, really nicely explained
how do i do that?
thanks!
I'm trying to learn how to setup TMap replication and I came across some stuff that goes over bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess) When I declare this struct as a UPROP do I still need to add 'replicated'? Or do I manually call NetSerialize when I modify the TMap within and it then replicates to clients with this struct?
Quick question, does your TMap have thousands of entries?
I know this isn't solving your replication problem, but I'm asking cause if it doesn't then you could save yourself the headache and just use a TArray and place the Key into the Struct.
Because looping that TArray is def faster than solving the hash function for only a few entries.
You can always write yourself a Getter for an Element of the Array that has the Key as an input, so you don't need to loop in all places
No - probably would never exceed 100
Yeah then it's probably worse to even use the TMap
I found this
USTRUCT(BlueprintType)
struct FStructWithMap
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TMap<FString, FString> StringMap;
TArray<FString> StringKeys;
TArray<FString> StringValues;
bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
{
if (Ar.IsLoading())
{
// Move data to Map
Ar << StringKeys;
Ar << StringValues;
for (auto It = StringKeys.CreateConstIterator(); It; ++It)
{
StringMap.Add(StringKeys[It.GetIndex()], StringValues[It.GetIndex()]);
}
} else {
// Move data to Arrays
StringMap.GenerateKeyArray(StringKeys);
StringMap.GenerateValueArray(StringValues);
Ar << StringKeys;
Ar << StringValues;
}
StringKeys.Empty();
StringValues.Empty();
bOutSuccess = true;
return true;
}
};
template<>
struct TStructOpsTypeTraits<FStructWithMap> : public TStructOpsTypeTraitsBase2<FStructWithMap>
{
enum
{
WithNetSerializer = true
};
};```
Yeah it's using 2 Arrays
It moves keys and values between the 2 Arrays and the TMap
Yeah I know
But it's really not worth it if you never exceed 100 entries
I agree - but do you know how the NetSerialize works?
Does it require a call to it and then it pushes this to the clients
or do I need to flag the UPROP somehow - and mark it replicated
NetSerialize is called automaticlaly due to the StructOps you have below
how that exactly works, no idea
Welp I guess I'll try some tests to see if its passing it to the clients
If it works like this, then it doesn't need UPROPERTY
However I do remember that struct props that should replicate needed it
Not sure if that also goes for custom NetSerialization, since you control it anyway
Correct
WithNetSerializer means you are using a custom serializer and are taking control of serialization. So whilst the struct instance still needs to be replicated properly from whichever parent scope is replicating it. Anything within its scope of member variables, the engine is now hands-off beyond calling NetSerialize
You do still need to make them UPROPERTY for garbage collection
Unless that doesn't apply
So I have it inside a comp like so UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category="Overlay") FFw_NetTMap OverlayDataMap; When I add 'Replicated' to the specifiers I get red lines
It's generally a good idea to keep annotating your structs and classes properly even with custom netserializer, in case you ever want to go over them using reflection
I mean it says why π
Yeah because the struct has a map inside it
So then how does this struct replicate
If I remove it
If I have all the netserialize stuff inside the struct - then everything in the struct will replicate, but how do I get the struct itself to replciate?
Like Cedric said. The easiest way is to use Arrays, and then you don't need a custom serializer
custom serializers are really for niche use cases, this looks like you are trying to make a generic struct to use multiple times throughout your game. That's a terrible idea
You either have a struct that's part of one array, and you find the entry via predicate, or you use an array for keys, use the found index to grab the value. Those are your two best bets.
Because very simply put. if you have a map with 1000 entries, and you change one of them. The custom NetSerialize will send over the entire map of 1000 entries.
Normal replication using arrays will only send over the 1 entry diff
Okay so something like this
Programming with Unreal Engine, Houdini, Math, & Graphics
What is going on with this TArray<FExampleItem>
Never seen a Tarray declared like this
that is an error of the code parser
the < is the html code of < if I am not mistaken
ty
guys in standalone can it be replicated?
replicate to whom? xD
I can't replicate animations of an actor when I interact with it. And his status is not reflected in the other players, why is it?
all this when i play on a dedicated server model
then it is not standalone xD
it doesn't matter, if they connect to a dedicated server they become clients
I will tell you about my exact problem, if you can help me I would appreciate it very much since I have been having the same error for a few days and I do not see what it is due to
Giving context would be a good way to go about it xD
Are you using a client-server model or not?
When I start a game, my game mode is in charge of generating some weapon chests for all the players, it turns out that these chests are replicated, when I approach them and try to open it, it opens for the client who interacts with it, but it is not reflected to me for the other clients.
The thing is that I know that the animations have to be executed on the server and then do the rpc for the multicast for the other players but that doesn't do it well for me. To make the animation of the opening of the chest
Then your problem is that the RPC is not firing
who does the RPC?
the rpc that executes the opening animation is executed by the actor that belongs to it, that is, the chest itself
I will pass you screenshots of how I have it mounted
It all sounds very much like you are executing a server RPC for the interaction inside of the chest actor
I'm just doing that.
what I don't know if I should call the rpc from the pawn that I control
if the animation is RPCd by the client copy of a chest, it wonΒ΄t trigger
the RPC has to be executed by a server-owned actor
There is a network example level that show cases this. I forgot what it's called. Maybe Advanced Networking?
It's in the starter kit I believe. It shows chest opening, network relevancy how it relates
GameMode only exists on the server, and thus would only spawnon the server and replicate the actors
Presumably your RPC is on the chest actor, which is a non-client owned actor. Therefore the Server RPC only executes locally
Yes, of course, my actors are all replicated, that's not the problem, the problem is that the states of my actors are not updated when I interact with them from the clients
The solution is to have the server-RPC on the playercontroller
Or one of the other ways that are in pinned messages here in this channel
It's very simple to debug those things, put print strings into your BP logic to see what is and isnt being executed
and fromwhere
I strongly suggest reading more networking guides and materials before working on the game
having a strong grasp of the basic concepts will be more fruitful than continuously making beginner mistakes
especially RPCs can be tricky when you're just starting out with them
yeah but he stated that the chest actor made the RPC, not the game mode
yey exactly π
Thank you so much for your explanation eXit, you clearly know your stuff. I'm going to read it over and over to let it sync in.
I'm stuck again. What I am trying to accomplish is:
- Two players. One runs around doing stuff (VR), the other has a side view of the same map (PC). These are two pawns with their own cameras.
- The build of the game should somehow dictate which player role you have. This never changes.
- The correct pawn should be assigned based on this player role.
- Once both players are ready (meaning PC connected to VR and both pressed some button) the game starts.
I don't know what the order of things should be and where to put them. I don't know where to decide the player role. I don't know where to assign the player role. I don't know where/how to assign a pawn based on the player role. I don't know where to create/assign even the UI.
Does anyone have the patience to, abstractly, help me through this? I've learned quite a bit about the functionality, I know roughly which methods are available and all that... I just don't understand what goes where in what order yet.
I think I got it guys thanks a lot π
β€οΈ
in the end the rpc launched it from the pawn that has a connection
Is there anyway to check and see if all players are loaded/valid in the level? Iβm thinking of holding the number of players, and then incrementing a variable once they are valid in the level
That is an easy and valid approach
You guys having any issue with anim notifies in shipping builds? I know it's bugged in 5.1 but this convar (a.EnableQueuedAnimEventsOnServer=1) fixes it in the editor, but seemingly not in shipping builds, at least for me.
(for the listen server host)
its a known issue https://issues.unrealengine.com/issue/UE-170093
one of the many reasons I'm avoiding 5.1
you'll have to wait until 5.2 for a fix
I didnt know about that console command but if its editor only, I guess its not a solution
I dont know why they didn't decide to do hotfixes like they did for the 5.0 release
some of these bugs are pretty critical
I'm still on 5.0.2 but I'm using a source build
I was like:
seems like 5.0.3 has a few bugs, I guess I'll just wait for the 5.1 release and stick with 5.0.2 for now
meanwhile 5.1 releases and its even worse π
so now I'm like: I guess i'll just wait for 5.2
There's no way they don't fix the issue until 5.2 right?
I mean how long will that be
inb4, 5.2 gets worse
yea we have no idea
I think its going to be a while
anim notifies not firing in multiplayer for listen hosts isn't some minor issue either
yep I know
theres even worse issues in 5.1 than that believe it or not
I'm not touching it
the bug tracker says 5.2 so I dont think they're fixing it before that
Are you talking about the convar?
Yeah - the one you have to put in a .ini file if I recall
Yeah I have that, it fixes it in editor only
Lovely
I packaged a development build and it make it better than it not being on at all, but some anim notifies aren't getting fired still
it's just a mess idk
Me still on ue 4.26. That's craaazy 
I get the impression that 4.27 was the most stable version, alot of the issues I find, I often find comments like: oh yea that used to work but stopped working since 5.0
5 will be solid in 5.27
hopefully π
Hello Everyone! I am having a hard time understanding how the Gameplay Message Subsystem works for Multiplayer in Lyra. I have a widget that broadcasts a message through the GMS and a component attached to the LyraGameState that receives the message and stores it in a replicated variable. What I want is for both the server and clients to update the variable. However, when I run the game it does not work as expected. The host updates the variable on the server and all changes are seen by clients, but the clients only update the variable for themselves. All the tuts I have seen on this involve setting up custom events on the Player Controller and passing those through to the game mode but in Lyra all is done through components. This messaging system seems to be the proper way of doing this in Lyra. Could someone please let me know what I am missing?
Havent looked at lyra or the gameplaymessagesubsystem
But i can tell you that subsystem cant use server rpcs
Subsytems typucally dont replucate
Question about non-player controlled actors. What's the best way to store replicated data for them? For example, let's say I have a game that's PvPvE - obviously for players I'm storing stats like health on the player state so it can be kept in the player array on the server.
How/where would I store that data for mobs?
So send a server rpc with y payliad that then broadcasts the message server side
Why, PS health id only really uaeful with multiple pawns thst share hp
You can access pawn via playerstate
I have other stats that need to persist through player death, so I'm just keeping everything on PS to make it easy
Slightly awkward, but ok. Mobs hp on their pawns
Why not just make death not be a deletion of the pawn
You can add an interface to keep access cobdistent
pawn stats on playerstate just feels gross
Consistent*
the State of the Player is their score. The state of the pawn is the pawn's HP
I don't have the HP, my pawn does
How do I ensure I'm damaging the right mob, though? Again with players, I can just get the actor's owning player state and then pass the information through that, but all actors have different ids on each client, right? Or is that only for player owned actors?
Each actor that is net addressable has a unique NetGUID
in other words you can send an actor pointer through a RPC
Is that available in blueprints or just c++?
Is it being replicated if the messages sent by the server (host of the session) are being replicated which seems to be the case?
Ok, I'll have to look a bit more into this, thanks!
Not neccesarily
Your listen node binds to a delegate (event dispatcher), which lives in a replicated object that receives the delegate then broadcasts
Your node is likely a full object that has a handler function that then broadcasts messahe received, which fires xour exec pin
Cant tell xoumore from s m9bile phone though
But that is a standard pattern for znreal engine
(Cant help typos, small buttons, large fingers)
I think znreal engine means unreal engine
It does

Nah - it's really "Zlo's Unreal Engine"
lol where I can dowload
does it work with ChatGPT
I barely ever modify it!
can it make game with brrr and AI
Objects need an ActorChannel to replicate, and subsystems typically dont have an Actor as an Outer
So they tend to not replicate
Have subsystem spawn an actor to use as a telephone on world begin play?
You would have to also rename it to change outer
Which would kinda break it as a subsystem
huh? I'm talking about the subsystem just talking to the actor
subsystem not actually replicating anything
just using the actor as a fax machine
"Hey Mr Actor here's a copy of my new state, replicate it plz"
"Hey mr subsystem, I got some new state for you"
basically the subsystem's secretary
Actors dont like replicating objects unless they are also objects outer
You could do it indirect
But in this gameplaymessage scenario, you alsi need an actor owned by pc
ooh yeah hadn't thought about ownership. So it could work one way but Client -> Server RPCs wouldn't work
has anyone ever used ActorSpawnParamter.CustomPreSpawnInitalization ?
I want to set some properties before BeginPlay , I was using bDeferConstruction but saw this callback now
I thought the playerstate component was doing the replication because that is where the replicated variable lives.
Even if the object is replicated, it would still need to be wired to always server RPC everything
For it to just work
Not near PC so cant check whats under the hood
i am trying to make the platform looping back and forward but its not synced can somebody tell me what is going on
Look at your replication settings. The server has the correct path because it knows all. However, the client doesn't know its exact position because its movement isn't being replicated correctly via code or settings
BRY has a good series on the basics of multiplayer
Question - I am trying to have a countdown timer that is ran on the host(server) that gets replicated to the clients. However, the countdown only works on the server. I have the option for replication checked for the variable. Any advice?
the funniest explanation of manager actors I've read
also it is totally what I am doing
Ok, so how does one get the Unique NetID for an actor? I put a variable on the player character and then replicated it, but I'm not sure how to access it. @dark edge I'm looking to you since you originally suggested making this change lol.
yeah exactly but how do i replicate that. checking the options doesnt work
Well, the most basic way is to tick the Replicates and ReplicatesMovement checkboxes
But that wouldn't be pretty
Cause that will cause it to literlaly just set the location to the one the server sends
And that is not something happening often enough to look smooth
So you would need to code some interpolation to smooth between previous and new location
That's more a c++ thing though (daily reminder that Multiplayer without C++ is basically not working out one way or another)
Yeah that's pretty wrong for Multiplayer fwiw
oh damn
BeginPlay calls when the Actor spawns on the Client
At that point the Timeline for the Server is already running
This will never sync
sooooo changing it to custom event would work?
Well
noooo
Again, you can mark the Actor is ReplicateMovement