#multiplayer
1 messages Β· Page 193 of 1
there is problems with it getting out of sync but not too often.. What would the ideal way to do this be? or is how im doing it okay
if you MUST know about every single little score event for cosmetics (popups, sounds) on client, I'd do it like this.
Score is replicated
ScoreEvent is an RPC, with whatever info is required
GameState replication frequency is turned up
Thank you π
What's the current best way to stream large amounts of largeish data items (~32KB) to specific clients without requiring Iris?
Is UChannel the way to go?
Might help?
Ah I appreciate it but I don't like to do it with RPCs honestly
I wanted a more robust solution
It is quite incredible how long the engine has existed and nobody still seems to have figured out a proper solution to this
Use a Socket?
eh but then I can't do any sort of decent load balancing
ima be sending ALOT of data
I honestly might just use UChannel
that's Iris
ahah
It is annoying because it would be great but I feel like none of this new fancy stuff is actually usable at this point
I am not sure what is required to make a raw data channel work from scratch
like, which parts does unreal hide from me that I would have to implement
I have made my own datachannel but it sucked because I had to make engine changes
UReplicationSystem::InitDataStreams should include a for loop that goes over your new ones but no dice
for example
UNetTokenDataStream final : public UDataStream
is how iris sends exports across I think
personally I am hoping to get away with RPCs
I pray
Is there anyway to call a method and only have it execute on the client?
if(!HasAuthority())
You can also check the NetMode
if(IsNetMode(NM_Client))
thank you
and if I wanted to call a server authoritative method would it just be HasAuthority?
be careful to consider listen servers though
Yep, he did ask specifically for Client though
A Listen Server isnt a Client
That is true, out of curiosity how would I deal with it if I wanted something to happen only on the clients and on then only on the client host as well in a listen-server setting
it depends on the context
if(!IsNetMode(NM_DedicatedServer))
AController::IsLocalController returns basically that
if i wanted to play a sound when a player pressed a button but only for that player
You would have to check if they are Locally Controlled
and this yeah, that's 90% of it when it's about IF it's something the dedicated will never do (rendering, visuals, input handling)
BP has a macro called CanExecuteCosmeticEvents which does the same thing.
Its helpful, similar to HasAuthority in BP.
the important thing: ROLES are defined PER ACTOR that is replicated
NET MODES are global for the world (generally speaking, replays and replay playback mess with this a bit)
I guess per net driver more accurately
which there is generally one of per world (?)
There can be multiple net drivers
If you record replays, then there is a separate net driver for that.
ah yeah, actors define NetDriverName
what is a net driver? dont think i came accross that in the compendium
it's the core netcode manager that handles the actual packets going up and down
Check out our website:
https://hraqe.pro/
linkedin:
https://www.linkedin.com/company/90669236/
You can find full project code here:
https://github.com/hraqe-pro/TCPTutorial/tree/master
1:02 - Required dependencies and required variables
2:17 - TcpListener descriptions
2:45 - Function general description
3:44 - Client connection server side fun...
Its not something you would normally be exposed to.
yea okay
Its quite low level
thanks for sharing the vid tho as I am curous in general
it's not really a big concern most of the time for gameplay code
with Iris you do kind of have to grab it indirectly to change actor replication properties sometimes but even then it's mostly "just call these static utils"
Iris not working correctly for you? π¦
I saw an earlier post from you about how Iris splits up data for you automagically - that's obviously not working fully for you?
sockets exist in unreal? I knew it!
This info is from the Voxel Plugin discord - because its one of the few places where you need to send large amounts of raw data - so the topic comes up a bit over there.
Iris is still experimental and Mostly works
the problem is the parts that are missing are very tough to figure out
which part(s) are missing?
thanks - not seen that link before I dont think - will read it now
a lot of iris is bending over backwards to make it seamless but it's still going to do things weirdly
I had a brief read of that link, and didnt see this mentioned. I'll read it properly shortly, but is this point covered there, or just something you noticed?
Currently RPC order is garunteed when reliable on the same actor channel - is that different in Iris?
iris has no actor channels
this is the core part of iris that receives bunches
this thing is getting hammered with changes that affect deserialization orders to this day
kk - thanks mate - I'll look into all this a bit more today. I've got a source build of the engine that I'm going to switch over to Iris this week, so its very timely for me
at least they are working on it...
So I am trying to play a sound only on the clients
if (IsNetMode(NM_Client)) {
UGameaplayStatics::PlaySoundAtLocation(sound, GetActorLocation());
}
but the sound doesn't play on server or client.. I am calling from Pawn class which is possessed by player controller so should have Client mode
Where are you calling it?
Its best when submitting code in Discord to post the entire function scope.
{
if (OtherActor->HasTag("Enemy") && Character) {
Character->TargetHit();
}
}```
that other method is just the targetHit method
And does the function even get called?
yes
if I dont use the netmode if statement it is just called on server
would it need to be an rpc?
that would be weird
What PIE settings are you using?
listen server
ah would the second payer not be a client?
You didnt say you had a second client.
apologies
Thats why I asked what settings you were using
Important to answer specific questions with specific answers.
ahh yes Listen server and 2 players
Ok cool.
i didnt touch advanced settings
Where are you binding the BeginOverlap?
begin play
Does BeginOverlap get called on the Clients at all?
No
ah
Stop going to RPC as the first answer
RPC should be your last choice
Not your first
Overlaps can occur on both the Client and Server
Therefore you need to work out why the Overlap isnt happening on the Client
Think about why something isnt happening.
Investigate why its not happening.
Understand why its not happening.
Then you can reason about an appropriate solution to the problem.
Stop jumping straight to an answer without understanding the problem.
I think my replication settings look good
good advice thank you
I will do some more research
Good luck
yeah not planning to go directly with sockets, but with UChannel
There's certain times when it's broken and it's especially annoying not being able to turn it off
the part where it splits it up works great - but NPP is broken / sussy with it and I don't have time to go fix / PR the engine atm
and I don't much like using the features that are exclusive to Iris because it means I can't turn it off if I need
I've been trying to figure out how to display a game state variable in the client HUD. I've tried using a dispatcher to update a client-side variable as well. For some reason, the above blueprint tries to access none when executed on the client. I feel like it's obvious, but I'm blind to it after staring at it for so long.
Can anyone tell me why this is throwing the tried to access none error?
show the gamemode
Gamemode only exists on server
This is an indication that the running game state is not set to BP_GameStateSoccer as the cast is resulting in a fail but then you're still trying to access the variable from the cast which would be "None".
But, I'm not trying to access game mode. I'm trying to get the data from the game state
Clarifying question: if I am calling a netmulticast RPC on an actor owned by the server, in a listen server, will the event fire twice for the client host?
no, if the server is also a listen server it only fires once still
A Listen Server is not a Client!!!
Its literally in the name
Listen SERVER.
yea okay
sorry am just trying to wrap my head around everything and understand how it works. Am new to networking.
Thats ok. It takes time.
matt, not sure if you seen or not but uextm got his pr merged #cpp message to fix the issue with TInstancedStructs in arrays and the issue with the base struct meta thing, might be finally able to update that note on your genericItemization plugin when it gets fixed
Oh cool
Yeah I havent had much time to continue development on the plugin.
Ive just been making sure it compiles with latest.
Yeah it gets a bit like that with needing to maintain released stuff, I also think they are moving the plugin to the engine modules instead too
network newbie here who is having trouble googling how to get started converting my project to multiplayer:
how would one go about replicating things like thumbstick input? in my case, I have a space sim where player input controls thrust to move/rotate the ship. naively trying to use the "replicates movement" setting results in the clients stuttering back to the original orientation. should I be sending the stick axis values from the clients to the server and having the server replicate the thrusted position/orientation back to the clients? is this robust to latency? am I completely off track?
buffered inputs is one way of going about but its older and not used with unreal, instead it replicates the things those inputs drive in the form of flags (like bSprint, bJump or bCrouch, just one off things that are binary) and then values like your velocity, acceleration, even your pitch/yaw get replicated automatically.
I would worry less about the character movement being networked (since its already implemented) and more on what else you do care about like
-
State - for example health, it would be a replicated float, its state needs to be maintained and replicated
-
Event - for example shooting a weapon, its a once off sound and VFX event we want to run on clients but its not persistent (I know about "burst combo" techiques but just keep it simple and general)
i heard that some projectile prediction systems actually rewinds EVERYONES position temporarily on the server while it moves the projectile.. seems like a real easy solution but it also seems very hard on performance.. anyone ever try something like this?
yep - server side rewind
The trick is to not move the players at all
If your looking for a way to do it - I can highly recommend Unreal Engine 5 C++ Multiplayer Shooter Course - he covers the topic in great detail and by the end you'd have a full working version.
and yeah - its more about hitbox captures over frames from memory
been 1-2 years since I did the course - cant remember the specifics
Ignore players and trace against simulated capsule positions instead. Also keep in mind this is a massive hueristic, trying to make it too perfect is just throwing performance away for literally zero gain
probably depends how competitive/accurate you want it to be
The issue is you're not trying to estimate what happened on the Server, you're trying to estimate what happened on the shooting client at that time, which the Server can never know with 100% accuracy
Unless ofc you have a perfectly lockstep game (which I doubt)
yeah.. the way i do it now is have the client send an RPC when it detects a hit and the server does it thing with rewinding the hit player based on ping ect.. i was thinking server side move might be more accurate since the clients RPC can take a variable amount of time to arrive.. but like Jambax said, the game isn't lockstep so trying to get a 100% accurate hit prediction system is probably a waste of energy
well also all other players are being updated on your client at variable times
The client shouldnt be telling the server about a 'hit'.
The client should ask the server that it wants to shoot. The server checks ammo, is stunned, is reloading etc - and if allowed, the server "shoots". The server then decides/rewinds and determins if any hits occured, and if so, broadcasts to each client the hit.
The client firing can do prediction on the firing, for local animation, but the actual projectile is spawned on server. You could also do local hit prediction, but that creates issues if the local client "predicites" it hit someone, creating a blood splatter, but the server doesnt calculate that.
I disagree, client should send the hit - but server should just validate it
But the client A might not have the right location of the other client B?
why would the client decide a hit?
the server handles the shoot? it can decide the hit?
Because otherwise they'd miss all the time, your local client would have to account for lead time
yeah the projectiles are spawned locally, so it could look like a hit on the client but miss on the server
hmmmm - yeah ok fair - I see where you are coming from
Jsut for the record; Fornite only does projectile spawning on server. Clients only do local effects prediction. The 'projectile' comes from server, otherwise it wouldnt sync.
Once the hit gets to the server, you try to work out "roughly" where all players were on the shooters' client at that time, then resimulate/validate the hit locally based on that info
IDK how that course says to do it but that's how we/I did it on HLL at least, minus the gory details
thats basically exactly how i've got mine set up haha
its been 1-2 years since I did it, so I'm not doing it justice π
I'll defer to you here, your answer makes sense
Just hitscan everything, so much easier π
haha - yeah
the complexity vs the actual difference to gameplay is borderline depressing
yeah.. all my projectiles are slow moving tribes style projectiles lol
yeah, I guess our case was just bullets
which is why it also has to be spawned locally, or else theres a very noticable delay
is there though? Fortnite does server side only projectile spawning - and you never notice the delay.
The trick is the client does the firing animation, sound, smoke etc instantly, but the projectile comes from the server. Unless you are playing with 200ms+ pings, it would be fine, especially for slow moving arrows etc
so the local prediction makes it "feel" instant
otherwise your client shoots from a slightly different lcoation to the server, so the predicted projectile doesnt fully match the server generated one. You just create different issues...
KaosSpectrum spoke a few times in here how that is how the did it that way as well
yeah predicted projectiles is fine but over a certain ping, it falls apart
sometimes its easier just to smoke and mirror it client side
iirc games like overwatch spawn a dummy projectile client side, and the server side projectile never goes to the client, but the server projectile is the one that decides what got hit
but i could be wrong, but that seems right to what i heard
how to get the client camera's pitch rotation to server?
is the camera component replicated and is the actor its on replicated?
I m doing this now, its working too, is it good?
Make it unreliable
Can someone give some insight on if I am using RPCβs the wrong way in this scenario please:
I have a method called on a player controller, which calls a server RPC with a validation check. Then that server RPC calls a client RPC to then play an animation.
The idea is that the server is being used to validate this action happening but then it needs to replicate back to clients.
I tried it a few ways and found that even with no RPCβs it still executes on both server and client, but I am thinking this way that the server validates it. I also need the client RPC to go back to clients as if it just plays anim on server rpc then the clients donβt receive.
Also Possibly related:
Would someone be able to clarify if my understanding of Invoked from Client vs Invoked from Server is accurate please?
My understanding is that invoking from client means some processing happened on the clients machine like an overlap event of a projectile spawned by a player pawn or a sound played by a client player pawn firing a gun and that is calling an RPC.
why?
ou so there is no need for it to processed in order?
Because IA_Look is pretty much called on tick and you don't want reliable RPCs to be called so frequently. Unreliable may drop a packet, but it doesn't matter - it is being sent so frequently, it'll have an updated one in no time.
ou oki
Too many reliable RPCs fills up the buffer and could lead to people being kicked.
thanks
RPCs are used as a means to communicate between the server and clients.
Server RPCs are used to have a client request the server to do something. These can only be sent to the server if executed on a client owned actor, or if they are called while already executing on the server.
Client RPCs are used to have the server request the owning client to do something. These will only be sent to the client that owns the actor. If there is no owner, then it will not be sent to any clients.
Multicasts are used to have the server tell all clients to do something.
One thing to keep in mind with RPCs and Multicasts is that they are not stateful. They are "fire and forget" so if you happen to say, play a looping animation on a multicast, and someone joins the game later and comes across your character that should be playing that looping animation, it would not be playing that animation on their end as they weren't present when that multicast was sent. If you need something to retain state, then you use an OnRep variable and its associated function to then execute what is needed.
Some events, like the overlaps you were mentioning, can happen in more than one place as each copy of the game would have their own instances of those actors spawned and each instance of the game can locally detect said overlaps or trigger those events without any network communication happening. So if I move my replicated actor into an overlap on my copy of the game, my copy of the game would detect that overlap and meanwhile, my location is being sent to the server, and the server then moves my character to that location on its copy and then it too would detect that overlap, and finally, because the server is replicating my location to all other clients, then my character's location is replicated out to all other clients, and then they too detect that I overlapped --- All this happened without my game telling the server that I overlapped or the server telling anyone else that I overlapped.
Thank you for this very in depth explanation!
At this point, I think Datura just has a template they copy paste and change around a bit to make it more aligned with the users question.
So in the example you gave in the last paragraph, in order to have the server validate it I would need to only have the behavior in the overlap happen if there was authority, and then call a server rpc or repnotify to have it validate the overlap
Had a weird situation the last day or two where GEs are not removing for like 8-9s after the server removes them while I'm in PIE. I don't believe I have network lag simulating either. Any thoughts?
If you were wanting the server to do something on the overlap, then just have the server do it during the overlap using the "Has Authority". There would not be a need to send a server RPC.
i see that makes sense
You could also have the trigger box only exist on the server and not on the client at all. That's how I handle those things personally.
That's another thing to keep in mind, each time you mark an event as a Server RPC, that's a potential way for clients to tell the server to do it. It's like leaving a door open allowing someone to potentially utilize it even if you never have any events that run on a client that call to it, it's still left open - that means someone with enough know-how could potentially "spoof" a call to that RPC and make the server execute it, so don't just mark everything as "Run On Server" just to indicate that it's something you want executing on the server.
thats interesting! how would I only spawn on server? use an HasAuthority when I create it in cpp?
On the actor, turn off "Net load on client"
thakn you for this
I understand how that would work well for booleans like sprint/crouch, but I'm talking specifically about continuous analog inputs.
In my case character movement isn't working automatically. I have the values from my flight-stick(s) continuously adjusting thruster outputs on the ship, which works locally. When I try to network it, any attempted movement is snapped back to the original position/orientation.
Has anyone had it where you spawn an actor set the ownership etc all correctly (least to my knowledge) but it doesn't work at first glance till you tab out and select it in the Outliner.
In my context this is spawning a FPWeapon and TPWeapon. And at first the player can see both weapons even though the visibility settings (OwnerNoSee and OnlyOwnerSee) are set correctly. But if I "tab" out and select the item in the outliner the visibility then fixes itself. Is this some weird replication ownership bug or? Cause the ownership has to be set correctly since just selecting the weapons in the outliner fixes them somehow. But trying to resolve why I need to select them in the outliner in the first place.
If needed this is my code in the items.
HEADER
class GAME_API AItem : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AItem();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated)
USkeletalMeshComponent* SkeletalMeshComponent;
UPROPERTY(Replicated)
bool bFPItem;
UFUNCTION(Server, Reliable)
void SetupMeshOnServer(bool bIsFPItem);
UFUNCTION(NetMulticast, Reliable)
void SetupMesh(bool bIsFpItem);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
CPP
void AItem::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AItem, SkeletalMeshComponent);
DOREPLIFETIME(AItem, bFPItem);
}
void AItem::SetupMeshOnServer_Implementation(bool bIsFPItem)
{
if (HasAuthority())
{
SetupMesh(bIsFPItem);
}
}
void AItem::SetupMesh_Implementation(bool bIsFPItem)
{
if (bFPItem == true)
{
SkeletalMeshComponent->bOnlyOwnerSee = true;
SkeletalMeshComponent->CastShadow = false;
}
else SkeletalMeshComponent->bOwnerNoSee = true;
FString RoleString = HasAuthority() ? TEXT("Server") : TEXT("Client");
UE_LOG(LogTemp, Log, TEXT("[%s] : Set Actor Visibility"), *RoleString);
// Print to Screen
if (GEngine)
{
FString ScreenMessage = FString::Printf(TEXT("[%s] : Set Actor Visibility"), *RoleString);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, ScreenMessage) ;
}
}
// Called when the game starts or when spawned
void AItem::BeginPlay()
{
Super::BeginPlay();
// Check if we are on the server
if (HasAuthority())
{
SetupMeshOnServer(bFPItem);
}
}
I have a super simple question (sorry everyone above me, I cannot help)
I have a widget that is on the client only. When I click the widget button, I want to call a function that runs on the server that takes in a GameplayEffect Class.
What should I do? This sounds so simple, but I've had a ton of issues getting this to work via GAS, so now I'm looking for any method
Widgets are only ever local, so in order to send an RPC, you'd need to call the RPC on a replicated actor or component that is owned by the client that needs to make the call.
Easiest way would likely be to make a Component that is attached to your PlayerController that handles whatever this widget is supposed to control. Then it's just a matter of from within the wiget get the owning player, get component by class from that reference, call the RPC.
That has almost nothing to do with ownership. The correlation of the Owner in each name is misleading here. OwnerNoSee OnlyOwnerSee are shitty names that should actually read as ViewTargetNoSee, OnlyViewTargetSee, or similar. Because they are only related to the "owner" via a loose concept that it's "usually" the owner who sees them because the owner's view target is the one set on the pawn.
In reality those values work based on the viewer. EG if you're spectating another player and you've got them set as a view target, you would see their OnlyOwnerSee and not see their OwnerNoSee even though you as the spectating player do not have ownership over said pawn/actor.
As far as why selecting them in the outliner fixes it, I've no idea initially.
Owner is probably the most overused/overloaded term in UE's dictionary.
heyy guys, i made a procedural aim offset, how can i replicate it? i tried a lot of methods but when move mouse up and down in multiplayer mode, my hands are stuttering
gotcha gotcha, in regards of ownership etc its me just throwing ideas out cause i cant figure out why it wont work first time but if i do the outliner thing it fixes it. Just been confusing me past day or so cause its like it works but doesnt at the same time
overall obviously it doesnt work but everything is set correctly
Hey, how expensive is sending an array of actor pointers through an rpc as opposed to looping through the array and sending each actor pointer as a separate rpc? Which is preferred?
Sending an RPC for each individual actor would probably be worse on account that each RPC likely has some overhead, and likely wouldn't even make sense to do depending on what it is you're actually trying to do with that list of actors.
What is it you're trying to do?
Actor "selection" system. Need to clear a player's array of selected actors at some point. Theres multiple facets to this because I've also got some primordial client prediction going on which would mean I need to save the array so I can at a later point rollback on it should the clearing not go through. Already have the single actor selection setup with rpcs so i figured I could just do the same logic as when single selecting only that I'm sending multiple rpcs through, in case of failure on an actor I can always roll back just that one actor.
Multiple rpcs feels more malleable than sending a whole array through at least with what I've got setup so far.
This is for like an RTS style selection system?
Yes
I set up a host migration system that if my listen server host disconnects, it will auto rehost. My issue is persistence. When it rehosts my player gets destroyed along with the player state. Any pointer on which class I could save player data on that survives more than the player state that is replicated?
All my important player info is on the player state yikes
I'd think client prediction wouldn't be an issue with something like this as selecting units can be done entirely client side without impacting gameplay.
On the server end, yes, it can matter what units they have selected, however, you probably don't need to have the server be the authority over what units they have selected, only over what actions are taken with the selected units.
To that, I'm not sure I'd have the selected units as a state of some kind. You could just as easily allow a client to pass through the array of selected actors when issuing a command and having the server filter out invalid units at that point. Once a reference is passed across the network it's generally very small to reference it, if I remember right it's only like 4 bytes, and in which case, if you had 100 units selected, that would only be 400 bytes of data to send in that RPC which is next to nothing in the grand scheme of things.
Server isn't the authority, both client and server hold a local list of "selected" actors and each actor keeps track of the player who selected it by uid. The only authority the server has is telling the client if what he selected is available for selection or not, if its not then just rollback. So in a way, clearing the selection wouldn't require validation due to the fact that we're already doing that during the initial selection of each actor, which is why I preferred the single actor rpc for each element in the array. Both selected actor arrays are kept in sync but not replicated.
anyone?
the uid itself is replicated.
Sounds like you need the Client to smooth on their end.
Before the Aim Offset is queried.
how to do that?
"Client Prediction" insinuates server authority. It's a means of saying that you're allowing the client to do something before the server allows it, and if the server doesn't like it, then the client must adhere to what the server wants (ie. the server is the authority). Selecting a unit "predictively" means you're allowing the client to select a unit before the server OKs it, and rolling it back if they don't - but again, this isn't something that is strictly tied to gameplay or latency in the first place - the server shouldn't really care about what is selected, only what actions a player is allowed to take with the units it has selected. For example, you wouldn't want a client to be able to tell the server to move an actor that is supposed to be controlled by an enemy.
The actors themselves also shouldn't care about whether they are selected or not. The client can maintain an array locally of all selected actors. You can do checks client side to ensure they're not selecting actors they're not supposed to. When they issue a command, you pass that array to the server, and the server then loops through the array, checks if the client should've been able to issue a command with the selected actor, and if not, does nothing, otherwise, perform the action for that actor.
For proxies Interpolate from current to target value on tick. Target being the incoming value from the server
do you know how to turn off this stupid window? i can't connect any variables because of this window
I don't
π΅βπ«
do i need to use this for aim offset?
I dunnoe, depend on what you need, I can't do math. For my use case I just need the character to bend up and down for free aiming.
Iirc only use the get base aim rotation. (Got to remap it for non locally controller characters because of compression)
This is not a question for #multiplayer anymore. Please ask in #animation
i just need to replicate my aim offset, when play in single player all is ok, but when run multiplayer hands are stuttering
people from animation are sending me to multiplayer, and people from multiplayer are sending me to animation?π
Probably because you are using the wrong terminology.
You dont need to replicate the Aim Offset
No one has ever needed to replicate an Aim Offset
You need to smooth the aiming.
and how to do this?
why i dont need it if i use transform bone and not aim offset animations
I dont know your setup or what to recommend. You are better to re-ask the question in #animation
Without using the phrase "replicate"
Because that isnt the issue
i have to use multiplayerate?π
He only have the problem in networked environment tho, isn't that multiplayer issue. A video probably help.
what video?
Jerky pitch rotation when pitch is replicated from control rotation
is like this guy
he has same problem
looks like this
K so u already have the problem in single playee
That's not even multiplayer issue then
single player not
how i said this problem is only for multiplayer
Happend to the character you controlled?
in single player aim is smooth
Well I don't know that. I suggest taking a video of what you have and post it, maybe someone knows if it's network problem or not.
I'm going b to bed, gl
fixed for my controlled with this, but when watch from another player, my player is a little stuttering but not so much notable
Smooth it out with interpolation
Computers can't send data fast enough to show a smooth motion over the network
If it work then I guess? I'm new my self. The problem I see is that you should interpolate to smooth the motion for proxies characters
ok thanks
If you already have the correct rotation then just interpolate and you should be good
with FInterp node?
If you only care about the roll, I guess
Interp from current roll, target is w.e u have atm
ok thanks
does anyone know of a plugin or something that exposes icmp to blueprints?
i need to fix 9999 ping issue with Steam π
does anyone know how GetWorld()->GetFirstPlayerController() behaves over multiplayer. If there is 4 players on 4 different systems, would the first player controller be the local player for each of those systems? or is it always ordered the same for everyone, and the listen server would be the first player controller?
This exact topic is covered in Wizard's guide - have a check here: https://wizardcell.com/unreal/multiplayer-tips-and-tricks/
I have code for controlling a spaceship's orientation based on enhanced input axes for pitch/yaw/roll. it calculates thrust values and then applies them, which works fine on a standalone. what would be the best way to make this work over the network? should I move the input processing to the PlayerController class and then have the client version send the input data to the server version of the PlayerController?
Actor replication for a 2 player rock paper scissors game. The options are displayed on 3d cards. The server spawns the 6 cards and places them in front of the players. Having spawned from the server, the host can see all the options. But those aren't being replicated to the client. I'm not sure how to set up an RPC to tell the client about the options. I've tried setting the created actors as replicated variables, I've tried doing RPC to set variables on the player controller.. any advice?
If the Server calls a Server RPC, it just calls it as if it was a regular function.
Are the Cards their own separate Actors?
Yeah, if you want, I have the project spelled out in this Google doc
Game: Rock Paper Scissors Description: Top down stationary game with the game angled so the player can clearly see their cards and not the opponents. 3 cards spawn in front of the player to choose. Clicking on the card locks in their choice. Clicking on your opponent's cards does nothing. Text...
Maybe not.
Make a BP_Card Actor Blueprint.
Create an Enumeration asset
Which contains your card types
Rock, Paper, Scissors
Yup did that
Create a replicated property in the Card actor
That will be the type
Set it to Expose on Spawn
And I have the variable of that enum set on spawn.
Spawn the Card on the Server, set each to the appropriate type
Make sure the CardType property is RepNotify
Override the RepNotify function
Which is where you would set the mesh/materials
For the card type.
If you follow all of that, it should work.
If it doesnt, you have done something wrong.
That sounds like the thing I'm missing!
Hello. I wonder if other players can see if another player is playing a short animation. I'm making TurnInPlace for a multiplayer game. It's done inside the Animaton Blueprint of the Character that the players control. . Looking forward to your help, thank you
Nothing about the ABP is replicated
Why do ABP's running/idle/jump animations still work normally?
Do you mean variables?
oh, thank you for helping
It's similar to how UI would work. The AnimBP grabs data from the Character that it uses to determine its state. That data would be replicated in the Character. Similar to how a Health variable might be replicated in the Character and displayed in the UI as a bar.
Any data inside the AnimBP doesn't support replication, so if there is anything directly set on it from outside or it produces any kind of animation state from data that is not replicated, it would not really sync up between players
But, that said, the data doesn't only need to be in the character. It just has to replicate somewhere where it makes sense.
if a sword is spawned on the server, its overlaps also being on the server, how does it know its position when swung with a montage on the client?
It's working correctly just wondering how the server knows about the position changes
the server plays the montage too
Everyone have copies of the sword
The overlap happend respective to each machine
It's not like you are sharing a world with anyone, you have your own.
Multiplayer is about synchronising your world so you have an experience that make it seems like you are seeing the same thing
Ofc if you don't want care about the overlap that happend on client machine, just filter it with switch has authority
So when the overlap happend in a client machine, it simply do nothing
well I just did a authority check and since the weapon is spawned on the server, and bind also happens on the server the overlap is server only.
It makes more sense if the montage plays server side (which I didn't think it did) otherwise it seems the position is replicated up which doesnt make sense
Wdym by if the montage play server side
It will just play if you call play montage node, if you don't call it on client, then it won't play the montage there
If the weapon is a replicated actor, a copy will be made for clients
the overlap never happens on the client, it is spawned and the bind only happens on the server, the logs I get follow this
Why wouldn't it happend on the client if a weapon exist in the client?
If you add switch has authority you simply filtering, what code runs on client what code runs on server
i think he was just wondering how the swords hitbox moves on the server when the montage is playing on the client
Client playing montage won't move anything on the server machine
because on the client it's not bound to a function
The server won't even know the client is playing a montage
right exactly so is a dedi server playing the montage for the purpose of positioning or no?
I think you must try to pin this in your head. Every player have their own instance of the game
It's not a question of that
yeah if your hitbox is reliant on the animation then the dedicated server will need to play the montage
You can play a montage on client but that will only happend in the client machine.
At the same time you can tell server via server rpc. Hey make my character in your machine to play this montage I'm playing.
Then each machine will play the montage, respective to when they get the play montage call.
So what position matter is up to you to decide.
If you only care about the hit box in the server version then you can just check the anim notify that happend on the server.
So in a sense the client play the montage ahead just for visual, but all gameplay element only matter in the server.
Not saying that's what you should do, but just my 2 cent trying to illustrate
what happens if a same UObject is getting replicated as a subobject by many actors/comp ?
Likely just warnings
But it'll still be replicated through the actor that owns the subobject
okay thanks
are physics constraints replicable for late joiners ?
Does anyone know how to cache/get the exportNetGuids from PackageMap and reapply/set them?
I'm serializing properties and one of them is UScriptStruct*, I'm caching the writer before or after sending it incase of a packetloss
When packet is lost I send the cached writer instead of serializing again but UScriptStruct* is null on client side
After debugging it seems I need to send netguids or something so it can resolve UScriptStruct* on client side, been looking into PackageMapClient for sometime with no luck
What do you mean "reapply" them?
But yes, objects are addressed over the network by a numeric ID which each connection independently agrees on
Add them to the PackageMap when sending cached writer so they can be sent to the client, hope that makes sense
I'm extra confused by sending the cached writer
Maybe I'm not following something here, might need to see code
You don't need to do anything special to handle packet loss, the engine covers all of that for you
This is where I serialize and cache the writer
FBitWriter TempWriter = FNetBitWriter(Map, 1024);
// Serialize properties including UScriptStruct* . <- Important comment
FSerializedState SerializedState;
SerializedState.Writer = TempWriter;
SerializedStatesMap.Add(Somekey, SerializedState);
DeltaParams->Writer->SerializeBits(SerializedState.Writer.GetData(), SerializedState.Writer.GetNumBits());
return true;```
And in case of packetloss I get the cached writer which is where I'm facing issues, client cannot resolve the property `UScriptStruct*`
```cpp
auto SerializedState = SerializedStatesMap.Find(Somekey);
DeltaParams->Writer->SerializeBits(SerializedState.Writer.GetData(), SerializedState.Writer.GetNumBits());
return true;```
unfortunately my code broke when I introduced packetloss
That sounds like a code issue tbh. Packetloss is inherently handled for property replication already. Perhaps your code isn't resilient to the lossy changes of replication?
You're not guaranteed to get every state, just the eventual state - but that's true to all replicated properties
Re the GUID's, I don't know what you can do here or why it would fail. FNetworkGUID's are acked and agreed upon independently of individual packets being read in. If you had to do this, I would just reserialize it
I'm honestly not sure, I've been on this issue for 1-2 days I forgot why it broke with packetloss, IIRC I was getting "garbage" data on client when reserializing after a packetloss on server, But I think you're right, high chances it's code issue
Makes sense, I noticed that when debugging this π, I think I will go with reserializing as you mentioned and figure out why it was failing on packetloss, Thanks π
Hey, is it possible to add a player in editor multiplayer tests on runtime?
are u looking for this?
yeah but you need to enable it in defaultengine.ini or summin. One sec
yeah but on runtime, I want to do some tests for later joining players
If you search "create player" in the console it should find the command, but there is also an option you can enable to show the button in editor
if you need to handle disconnects and reconnects there as a very nice article by wizardcell pinned here
since you are testing late connects i assume u might be interested in reconnects as well
tbf it's essentially the same thing as far as networking is concerned
Reconnect means all new objects and data
Yeah this comes in later, actually I read about multicasts and want to test about different behaviors. Yesterday I learned that my actually implementation isnt good
I actually don't know if my game will get a multiplayer, it is a nice to have. So I want to setup stuff to be prepared for that
Its a cozy game, play with 1 or 2 maybe 3 friends coop
some basic stuff actually is to understand how things should be done (item pickup, harvest stones and trees / harvestables)
The general rule to follow is:
Persistent State = Replicated Property
One-Off/Transient Event = RPC
If you are modifying game state through RPCs, then yeah that will not survive join-in-progress/reconnect etc - but it also won't likely survive in the same session either when you consider things like relevancy.
so
Harvestables (stones, trees) are replicated -> server destroy event are auto replicated ?
Yeah, that is inherently replicated (if the actor itself replicates)
Yeah, if those actors are replicated those changes will propagate to the clients when they join
This message appears to me in the log all the time, and it's causing hitches in my game, but it's not even multiplayer, how do I deactivate this feature?
Turn off the UDP Messaging Plugin
Ancient bug that's never been fixed
thanksssssssss ^^
lmao
ancient bug from an ancient engine (4.27.2)
honestly might still be an issue now, though I haven't seen it for some time so maybe they eventually snubbed it
but yeah, it's like a hitch every half second or so - extremely annoying
ah I actually read the OnRep boolean stuff
but for my case I didn't get it (I have a Player Character Component that checks for overlapping Items the nearest Item is selected (actually I destroy it on server with multicast)
This is the article
the Example show a very static example
in my case I have a param (reference of item)
or Should the Item Actor have a bool (bActorDestroyed) that I set via Interface from my BP and destroy itself on notify
Destroying a replicated actor is implicitly handled, so you don't need to add anything special
Assuming you mean the literal "DestroyActor" call
And not a game-centric destroy thing
ok, so my example is bad for the OnRep stuff π
Yep. In editor settings.
Then when you start with 1 player, there is a "add player" button near the start stop
And you literally add late joiners anytime
Thanks1
Does RepNotify work in plain classes?
lets say im in a widget (so client side), and i want to call a server RPC on a component, the owner of the component has authority
is it the same to do :
In Widget : MyComp->CallServerRPC;
and
InWidget : MyComp->SomeInternalMethod
In MyComp::SomeInternalMethod: CallServerRPC;
Not sure what you mean? No networking/replication works in non-uobject classes regardless
It's the same yeah
oh, that's sad
maybe I do need to create my entire Networking System
okay thanks
Unreals networking is centered entirely arounds UObject and UPROPERTY, none of which "works" in a native class
why not just use UObjects?
Rebuilding networking to avoid using UObjects is quite insane
remaking whole unreal networking is insane work
I got a normal RepNotify that doesn't even trigger
in a UObject ?
or Actor/Comp
yes
did you added it as subobject in an actor/comp ?
uobject arent replicated by default
it's in a struct in an actor component on the character so I think ye
never used subobject
doesnt matter
its still a not replicated uobject
check https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-uobjects-in-unreal-engine
Learn how to replicate UObjects in Unreal Engine.
Can this be in a struct from an actor component ?
yeah, but in that case the struct itself should be replicated. Replicated inside a USTRUCT is not needed
so I can skip this step?
The UObject instance itself still needs to be a replicated subobject regardless
After creating the UObject itself, I'mn trying to replicate it but it can't find the variable (prob since it's private):
CurrentWearableItem = NewObject<UStaticMeshComponent>(OwnerActor);
CurrentWearableItem->bReplicateUsingRegisteredSubObjectList
bReplicateUsingRegisteredSubObjectList is a property of the owning actor not the object you create
Just read through the guide more carefully
Actually, hold that thought
read again the doc page
It's an Actor Component, so you don't need to do anything - just mark the component as replicated
all instructions are there
You also need to register the component
the Component works fine, it is in a UObject tho and the RepNotify doesn't trigger
that's already done, but the RepNotify doesn't trigger
.h
UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;
UFUNCTION()
void OnRep_WearableMeshComponent();
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual bool IsSupportedForNetworking() const override { return true; }
.cpp
void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
// Add any replicated properties here
DOREPLIFETIME(UWearables, CurrentWearableMeshComponent)
}```
You tutorial and all other says to set the Object to be replicated on the actor, but the problem is, that I could have tons of these object (not just 1)
And what is UWearables?
derived from UObject
Okay, so when you create that object, you need to call AddReplicatedSubObject to whatever owns it
Presumably the actor
it's an actor component here
And that actor (or component) needs bReplicateUsingRegisteredSubObjectList to be true
AND, both the actor and component need to be replicated
Also make sure you're only creating all this server side
that's the tricky part, the object isn't accessible from the Actor component... (and there could be multiple)
Well something must create and own it surely? Where's the NewObject call?
CurrentWearableItem = NewObject<UStaticMeshComponent>(OwnerActor);
```ye
Yeah okay, so in this case you can do OwnerActor->AddReplicatedSubobject(CurrentWearableItem)
would that work considering that the bReplicateUsingRegisteredSubObjectList was set to true in an actor component from that actor?
Does anyone have any experience replicating physics constraint components?
ActorComponent:
SetIsReplicatedByDefault(true);
bReplicateUsingRegisteredSubObjectList = true;
Wearable.cpp
CurrentWearableItem = NewObject<UStaticMeshComponent>(OwnerActor->FindComponentByClass<UInventoryComponent>());
OwnerActor->FindComponentByClass<UInventoryComponent>()->AddReplicatedSubObject(CurrentWearableMeshComponent);
void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
// Add any replicated properties here
DOREPLIFETIME(UWearables, CurrentWearableMeshComponent)
}
Wearable.h
UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;
UFUNCTION()
void OnRep_WearableMeshComponent();
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual bool IsSupportedForNetworking() const override { return true; }
AddReplicatedSubObject(CurrentWearableMeshComponent); that doesn't look right. It's the UWearable that needs to be the replicated subobject
oh
If the mesh component is a replicated component, it'll replicate already - don't need to do anything there. The problem you have is that UWearable is not replicated, so that pointer never populates
'this' would be good, since it's the pointer for this class
I want to avoid replicating the component entirely, so just using a RepNotify to Spawn on the client as well without replication
Realistically that needs to be a replicated subobject of whatever owns it, and only setup once
If you don't replicate the component then that pointer can't populate and you won't get a rep notify
If you don't need the mesh component to be replicated don't bother, just use a bool or something instead i.e. "bWantsMeshes" or whatever
I think it's because I'm creating a new object of StaticMeshComponent, but not the UObject class
π oh man Multiplayer will drive me crazy
I have no clue no more
I'm not sure if this is important information, but the UObject (UWearable) is actually stored in the Item Struct (This struct is not derived from anything) at run time. Every time you add an item, it's created. Should I mark it as ReplicatedSubObject on the constructor of that struct?
UPROPERTY()
TObjectPtr<UWearable> WearableItem;
``` @chrome bay
OMG Nothing seems to work π₯²
anyone have any experience with resimulation? I have enabled it on my physics-controlled pawns, and it 'works', but it doesn't seem to be correcting the pawn positions when the simulation drifts
Should my item struct be also derived from UObject ? (and changed to a class? - I'm so confused rn)
I'm not sure if, since this struct is NOT derived from UObject, Can his members still be replicated using UObject and RepNotifies? Or do I have to derive it to UObject as well
Maybe someone give me a tip how I can handle this stuff?
this is my no multiplayer solution
I hit a "stone"
I spawn particles, then I loop some item actors to pick up
remove the niagara component
and destroy the actor (the big stone I hit)
the lootable Item Actors are set to replicated, so my first thought was to do this stuff on a server event
but this doesnt work
Next thought was to split up visual stuff and "hard" stuff (niagara are visuals so they can be done with multicast)
I dont need final solution, some tips will be cool
Serverside:
Event Do The Thing -> call multicast TheThingIsHappeningShowCosmetics -> loop -> spawn replicated actors
Everywhere:
TheThingIsHappeningShowCosmetics -> show cosmetics
you also should be able to fire and forget a niagara system
assuming it's set up right
i got a fast array which contains a ref to the component who is containing the fast array.
in a fast array item PostReplicated[...], how can i check if it was called on "client side" of the owner ?
example :
i got Listen Server (Comp Instance 0), Client 1 (Comp Instance 1) and Client 2 (Comp Instance 2)
each of them changes some items values on server
- if PostReplicatedChange gets called on Client 2 (Comp Instance 2), but its a change on Comp Instance 1 items, fail check
- if PostReplicatedChange gets called on Client 1 (Comp Instance 1), and its a change made on Comp Instance 1, check suceed
i need to pass an array to a character that is being spawned and possesed, im thinking about doing "SpawnActorDeferred" to pass the value, or is there any better/more correct way?
Anyone have any experience dealing with connection time outs in hosting lobbies?
We're working on connecting but when we try it just times out, already had to do a bunch of unusual steps to just get the lobbies to show up properly.
This is exactly what I want:
https://stackoverflow.com/questions/72525905/how-to-replicate-uobject-inside-ustruct
but I replicate the Struct like this on the ActorComponent:
DOREPLIFETIME_CONDITION(UInventoryComponent, ItemsArray, COND_OwnerOnly)
```The UObject inside the struct doesn't get replicated... How to make it replicate and use RepNotify?
you didnt correctly made the uobject rep
show UObject code and the code in the comp you are using to make it reped
This is the struct:
USTRUCT(BlueprintType)
struct FItem
{
GENERATED_BODY()
UPROPERTY(EditAnywhere)
TObjectPtr<UWearables> WearableItem;
};
This is the Wearable class that should be replicated once the item is created:
UCLASS(BlueprintType)
class UWearables : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;
UFUNCTION()
void OnRep_WearableMeshComponent();
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual bool IsSupportedForNetworking() const override { return true; }
};```
I need to make it replicated to use a RepNotify, because at the moment, the RepNotify NEVER triggers
in the Wearable.cpp, I've got this too:
void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
// Add any replicated properties here
DOREPLIFETIME(UWearables, CurrentWearableMeshComponent)
}```UObject replication is weird
The UWearable?
the one you want to rep
I want to replicate the UstaticMeshcomponent which is inside a UObject...
then you want to rep UWearables
FItem(UItemsDataAsset* CurrentDA) : ItemDataAsset( CurrentDA ), WearableItem( nullptr )
{
for (auto EffectType : CurrentDA->GetAdvancedEffects())
{
if (UWearables* CurrentWearable = Cast<UWearables>(EffectType))
{
// Assigning the UObject
WearableItem = CurrentWearable;
}
}
}
```This is where I *create* the UObject @lament flax
yeah you missed some steps
What step?
read again https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-uobjects-in-unreal-engine
Learn how to replicate UObjects in Unreal Engine.
mostly at Registered Subobjects List
I tried registering earlier
well i used that doc alone to make it replicating and its working
you failed somewhere
show you comp constructor
because we aren't doing the same thing lmao
doesnt matter where you store the uobject, you rep it the same way
comp?
Component
I've used it: bReplicateUsingRegisteredSubObjectList = true;
is the comp replicating
what is MyActorSubObject here?
your uobject
for example, here, I don't see any memeber like this:
if (UWearables* CurrentWearable = Cast<UWearables>(EffectType))
{
WearableItem = NewObject<UWearables>();
WearableItem->ReplicatedValue = 1;
AddRelicatedSubObject(WearableItem);
}```
ReplicatedValue & AddRelicatedSubObject aren't there
wdym
I don't see them, they aren't visible at least
where are you doing this ?
in a struct why is attached to an actor component
AddRelicatedSubObject is a actor and actor comp method
even in the source files, I can't find 'ReplicatedValue'
...
ReplicatedValue is a example prop in the doc
Thanks, I do it again after my daughter time π . The Niagara Stuff was the only one that work as it should xD
ohhh I see
I was confused
@lament flax still doesn't trigger the OnRep π
Would this be ok?
WearableItem = CurrentWearable;
CurrentPlayer->AddReplicatedSubObject(WearableItem);```
if you do this CurrentPlayer needs to have the setup to rep subobjects
this line?
bReplicateUsingRegisteredSubObjectList = true;
this, and GetLifetimeReplicatedProps and DOREPLIFETIME(AMyActor, MyActorSubobject)
all written https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-uobjects-in-unreal-engine
Learn how to replicate UObjects in Unreal Engine.
got it but will that work if I have 2 UObject on the actor?
what if I want 2 reference, lol?
ref each ot them
using an array or seperated vars
then store it elsewhere
What is safe/correct way to manage admins in server? I have now:
- server launch parameter takes steamIDs to be admins
- those are stored to gameMode variable (gamemode exist only on server)
- If I want to access admin tools I check on serverRPC -> compare my steamID to admins ID's and if it is found I can access tools.
Is it normal that MP stuff hits hard in the First steps? Last 2-3 Weeks I made huge Progress, nothing ist perfect but after today IT feels as a Punch in my face xD
Yes. There's lots of pitfalls with multiplayer, and you have to think very differently about how to handle things with multiplayer in mind.
Yeah, OK than i'am reassured
Yeah my actual Scripts seems useless
ππ€£
Thanks π
implementing multiplayer afterwards is a common mistake. you will need to rewrite everything if you dont start with it in mind
yeah thats it why I do it now
I started about 3 weeks ago
first really rought prototype
1,5 weeks ago I restarted and make it a bit better
now I'am Happy I "restart" and begin with multiplayer stuff
if my actual stuff works with multiplayer that would be cool
I have a Question
Does anyone know why my OnRep doesn't trigger? the class is derived from UObject and I think that I did everything I should.. What's wrong?:
Initialization of the UObject class:
WearableItem = CurrentWearable;
InventoryComponent->AddReplicatedSubObject(WearableItem);
Stored in an actor component attached to the player:
.cpp
bReplicateUsingRegisteredSubObjectList = true;
```.h
```cpp
UPROPERTY(Replicated)
TObjectPtr<class UWearables> DefaultActorComponentSubObject;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override{
DOREPLIFETIME(UInventoryComponent, DefaultActorComponentSubObject);
}
UObject itself:
.h
UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;
UFUNCTION()
void OnRep_WearableMeshComponent();
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual bool IsSupportedForNetworking() const override { return true; }
```.cpp
```cpp
void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(UWearables, CurrentWearableMeshComponent);
}```
I actually spawn a Actor with DataTableRowHandle
this event runs on server
the Item are spawned on client and server
but client doesnt get the DTRowHandle
I can also set it after Spawn but this feels better and I can run a construct script where I get the mesh of the item
@nova wasp you wanted everything, there you go! I'll owe you one if you find the error (or why it doesn't work), since no one was able, yet...
why not just give it here
Can widgets get gamemode variables? Like for example, can I call "get game mode" on a widget?
i know that widgets are on clients, so im not sure
widgets are local only and gamemode is server only so that'll only work for a listen server or standalone
a connected client can't get gamemode
so if the multiplayer game is of type listen server, this would work for client?
I have a listen server setup, trying to disable UI visibility based on the gamemode
You want to think twice if it's going on production. Having a hard ref in data table can be undesirable.
the client doesnt get the pin its unset on the client
wat
the item should only be spawned on server
wait
π€
only server should be calling spawn item
it'll replicate across
This opinion is my own but doing that on construction script sound sketchy
left is server and right is client
when do you USE the datatablerowhandle?
at the start I do it on construct
now its on on rep
first make sure that a data table row handle can be replicated
I don't know for sure if it can or can't
print the table and row name here
somebody know how to change it ?
Editor Preferences has a language setting.
Show how you print it
OnRep is only executed on Client
OnClienbt now it works
but on server not
I'am confused now
π€
On rep meant to be called on client only. While in bp it gets called by server and the client if the server make the changes, in cpp it is only get called by client as it should
You need to pass in the variables across the server
Show how you spawn the actor, in entirely
As client, server rpc (passing the dt handle (if that can be replicated, I don't know)
it is only a test spawn action
actually the OnRep works on client
and it sets the mesh
on server it doesnt
so the mesh cant be changed there
Hmm so the dt is hard coded, the problem might lies else where.
at the start I thought I set the mesh on construct of the actor
Regardless I'd recommend actually packaging and testing
A lot of stuff don't work when they should in the editor; and work when they shouldn't; mostly the later
is it so
This kind of stuff should work in pie
that makes testing really hard
Probably just things like joining lobbies
That you have to be in standalone or package
Anyone is willing to help me? (long code tho - 20 lines)
if I change the mesh after the spawn on server I bet it will work
Do you still have anything in your construction script? If so post it
Gtg now, might check later
did u set ur replication var to true?
what var exactly?
The 'CurrentWearableMeshComponent' is using RepNotify
with this in addition server and client works (I need to check if dt is valid because the client run into error)
well this is just a wild guess, components have a variable called bReplicates(not sure about the name) that might need to be true in order for it to replicate and for u to get the notifies
ok thanks for your help, It works... but I dont know if this is okay
well its not just components, i think its all actors
yea but I want to not Replicate it, since if I do, it will work but replicate all his property on tick over the machines when in fact, I can only recreate that actor on all clients when the RepNotify triggers...
i might be wrong here but i think u need it to replicate to have rep notifies trigger
as the name implies, its a notification of a replication
Not what we told you to do, you want to replicate a single object that has properties
the rep notify function is only there to let u know that the value changed since unreal only sends values when needed if i am not mistaken
We told you not to create new replicated objects for every item, not to never replicate
Can't help more right now as I'm busy
I think it might need a replicated object as the outer, unsure
Also look into replicated subobject list docs if that helps
I did that, and nothing work lol
so what should be set as replicated?
i cant answer that, that depends on what ur doing and ur architecture
when I spawn / use the UObject, I do:
InventoryComponent->AddReplicatedSubObject(WearableItem);
which should make the UObject replicated
this is my architechture:
- Storing UObject ref on the ActorComponent (that's the only option?)
- ActorComponent -> Array of Struct (FItem) -> TObjectPtr<SomeUObjectDerivedClass>...
dude i cant answer that for you lol, i have no idea what you are building
Do you know a good tutorial about Replication of UObject that I could follow?
also, I' mtrying to replicate a derived class from another derived class from UObject
UObject -> Class 1 -> Class to Replicate
The in between class is not a good idea here
You can have them point to one another internally or whatever, but I think you want a replicated actor or component as the outer that you know works instead of this chain of pointers
It's pointless then
It's better to keep it simple here if it's new stuff
ex: in BP, I want to see all the class of a type...
You can organize things in a bunch of ways that don't involve pointer indirection, being fancy here is just complicating what unreal wants
1 StaticMeshComponent, for a RepNotify, but for that, the Uobject most be setup properly, which doesn't work rn
a mesh on the character
I don't know too, I wouldn't use construction script here personally. Also it help to test games with delay because in real world, you won't get 0 ms. So what may seems to work may not work when latency introduced.
so u want to replicate a mesh on a character, what for?
so other player can see?
i mean, what is it
is it a weapon?
is it armor?
a power up?
what is it
is it attached?
attached to a socket
i dont think u need to do all that at all, u probably just need to attach that actor in the server and set it to replicate
that was working but is not efficient
you could probably just attach it in the server and in the client
and it would look the same if i am not mistaken
as they would be synced
@nova wasp told me to do it in a better way
I don't care what the replicated property is on, it could be an actor component or whatever
yea, I need a repnotify to fire on all clients
I understand what you mean, I think your Point May the reason why on Clientside the construct doesnt work
But whatever it is on must replicate
u need to think of solutions that fit your problems, theres no need to do things more complicated if they work properly when done in a simpler fashion
why not?
SetIsReplicated(true) works, but it's not what good devs do
0 optimized
if that attachment is simply cosmetic you can just attach it in the server and in the client, attach it in the client and send an RPC to the server
What??
When you mark something as 'net Load On Client' You are not causing it to actually replicate. You are just allowing it to exist in client; no server-client communication is happening.
If you have your actor, and replicate its movement; that does get udpated; communication is happening in that regard.
The visuals are not being transmited or anything like that. If you think they are
In Client the Mesh ist Set via the repnote on Server this doesnt fire Here IT works because Server is also the Client
You are just throwing words right?
maybe I could set replicated to false directly after?
Leaving out the context here
What do you want to achieve?
dude stop trying to over engineer a simple task lol
We said don't spam a new replicated static mesh components each time something is picked up, not to never replicate any objects
so, SetReplicated(true) would work and is optimized?
its not optimized
Do not worry about optimization until/if you understand how it works
attaching in the client and then sending a reliable RPC to the server is probably the most optimized way
as its a 1 time thing
it's already on the server at first
I understand what I wrote lol (not UObject replication but my code yes, :3)
Meaningless statement without context for the situation and hardware/bandwidth requirements and even then... Profile it
that doesnt say much, in order fot you to have a working solution you need to understand your constraints, you can have it replicate by default no problem in say a 3v3 game with not a ton of items around, but if your looking at an MMO thats probably not gonna be a good idea, it all depends on what your doing
I want it working well for 100k of items
I didn't mean that uwu. Just that; you were asking for advice and asking if x is the more optimized way of donig things. I am a sucker for optimization and love all of that. But usually that is something you do yourself rather than ask what the best way of doing things is. Cuz like... ultimately you are just vulnerable to getting bad advice otherwise and there is no insurance what you'll do will actually be optimized to begin with. so to speak.
well then ur probably gonna have to dig into engine code as thats a lot of items lol, u might wanna rething ur scope
if u wanna have that many items, ur only bet would probably be just sending the 1 time RPC
and forget about those items moving around with physics
and being in sync
maybe I could set it to replicated, and the next frame, set the replication to false since i don't need it anymore
I can say for sure that a new entire unique object recreated is kind of overkill when a pre-existing replicating object onrepping a property will do though
could work, but its a messy aproach
what's the property?
This is kind of how the replication graph etc work, I think in general the simple thing is to just use push model
does any 1 know if the playerState always exists before a character is created?
If you just want to load stuff in the client all you need is 'Net Load On Client'
Pretty sure we have told you this already, it's a simple representation of what the clients need to know to get the results you want
Gotta go
OnRep doesn't work since my uObject doesn't replicate
dont use it then lol
No Replication = No UPROPERTY(replication smt here)
I think a simple setup could be starting with it as a property on your pawn or playerstate just to mess around
Once again, there is still a replicating object but you have one that stays instead of making new ones. Like a replicating actor component that's present in the CDO or something
something like "isEquiped"
RPCs
Server -> All Clients
what's the name of that rpc?
All Clients RPC
you need a owning object for that tho
tru
You can use the Secondary All Clients RPG that doesn't need owning objects
theres a function thats is something like "get all players", u can call a client RPC on that, theres probably a better way to do that with a multicast im just not seeing it
What is that? I've never heard of that
It's like the RPC but does not need owning obj.
Server -> All Clients RPG
Is it efficient?
YES
can u shoot me a link to the docs for that? i cant find anything on google
Multicast by server but use it if you know what it does.
Don't use it for stateful behavior as it can get dropped and only called on relevant players
same
I don't have a single multicast rpc soo far. Probably gonna have one later for sfx and chat messages.
im using one for beams SFX but i think its the only one
im calling it from a character, i was wondering if any 1 has an example of a multicast being called from the game mode for example
No point, game mode only exist on server
ye but you could fetch connections like player state
something to send an effect to every one directly from the server
like if the game is over spawn some particles, this is a dumb example i know
@brittle ledge docs?
I will just use GAS
its probably not meant to be used like that
gas does that too? i havent gotten into it yet
Gameplay effects
oh yeah
c++ or blueprints?
c++
C++
where does it say that?
where are the rpgs?
bro is trolling
i am confused
Every rpc use actor channel afaik
I don't know what it means to not need an owning object
how would my thing be done (without multicast)
Can a non-player owned actor tell the gamemode to do something?
I'm basically implementing an "extraction zone" where if the zone overlaps with an actor that has a actor component of type AC_ExtractionObject, then increase the "Progress" variable in gamemode by 1
It does explain it properly
Read the π
like I realize the gamemode is in the server
maybe game state would be better?
THE WHAT
This compendium is meant to give you a good start into multiplayer programming for Unreal Engine.
Clients don't have access to game mode. It doesn't exist on their machine.
Bro's like minimum effort was a person
this is just an actor, non player
what the hell?
what
there's no link between new RPC and the normal compendium
Don't matter it depends who's running the function.
Not the way to think about it. As the game mode exists on the server, you can only call things on it when you're certain you're running on the server, doesn't matter about ownership.
idk, someone talked about a RPc calling on all clients on the server, without knowing about them
I believe Nova was talking about multicasts.
Okay, so what would be the best way to do this? I could probably get a reference to the player controller, then it can be from player controller to gamemode. Or like a multicast event
multicast is probably best
each client needs to know this anyways
These are unreliable, tho, aren't they?
Then multicast is not the way
There is even dev that ship game with 0 multicast
okay, good for that dev
You can mark them as reliable, but it's usually not recommended to do so.
I mean, multicast is abused a lot by people who just started multiplayer and unbeknown to them always used for the wrong reason.
Because "progress" is something stateful. not something you need to multicast.
What can I do then?
Okay I see where I went the wrong way
Multicast only get called on relevant players, think about late joiners and players outside relevancy
I'm still unsure how I can communicate from a non-client actor to a server
or at least the gamemode
The page I sent had good info ngl
What r u trying to do?
without using multicast
Give a use case so maybe it can be explained better.
Multiplayer is literally just communication in between server and client. YOu want everyone to be on track while causing the least amount of stress on the server. The onyl way to achieve this is to know the tools you got to work with; just gotta read the documentation and all that.
Edit: to adress why it isn't as simple as just tellig you what to do step by step is because there is no general solution, it does depend on exactly what you want to do.
I'm currently implementing an "extraction zone" prototype, at the moment it's just a trigger box that detects if the overlapping actor has an actor component AC_ExtractionObject. If it does, I'd want the A_ExtractionZone actor to tell the gamemode "hey, the players made progress, +1 to progress int"
The overlap will happend respective to each machine.
In saying that, you don't need to care when the actor overlap in client machine
On overlap, switch has authority
If authority get game mode do w.e
when will the item have authority?
So only the overlap in server machine is accounted for and since it's the server it have access to game mode
I see
Wdym by this?
so overlap is a server registered event?
No
?
maybe replicating for 1 frame is the better solution, it might be tricky but it's safe, reliable and always the same
Everyone running their own instance, everyone have a world on their own. Everyone is running the codes that you packaged in their own instance
What do you guys think?
yes?
The overlap may happend in my machine , your machine. It gets called when ever it gets called. So it's not about registering or w.e that means
You simply filter the code
So when Ur the client u do nothing when the overlap is called
the logic for this is happening in the ExtractionZone actor though
not the player controller
K and?
okay bro
It have overlap function yeah?
Overlap, switch has authority.
If authority (server) get game mode , do w.e
The overlap happens on the client and server, what cold summer is saying is that you only do something when itβs the server version
And if your the client overlap event you just ignore it
I'd think that I can bind and set the replication to stop on the next frame, right?
Player controller don't even come to the picture btw. Neither ownership like datura mention @gloomy axle
When overlap happens, it happens on the client and server no matter what the objects overlapping are?
that's what I'm concerned about
Right so if you have your object in the world and overlap
The server will call it and the client
Okay great
Switch has authority is making sure the server version is the one your doing the code on
thanks for the clarification @worthy oak @dark parcel
yea that I get, I was unsure about if it matter the actors were clients or not
Nope π
thank ya
Of course
What do you guys think of that?
Cat I think you really need to try more things on your own and read documentation. Being stuck is good you learn a lot
I just asked if you think it was a good solution to my problem, if yes, thjen I'll try to implement it
Are you saying you can see thru his ninja outfit?
Try it for science
π
Maybe π
Will you? You get countless answers and donβt listen
I will, I'm trying to find the best efficient way...
Donβt.
Get it working first
I usually hate that advice but in this scenario I agree. If you are truly at a loss that's the only way.
I wanted to talk about it and know more... that's all, no spoonfeed
Agree with you there I hate giving it. But in this situation thatβs what it is
The question you just asked is something you can try and find out
I know it will work, is it efficient?
Again thatβs not your concern
Getting a working example is
it's already working lol
is it XD
Try it. Profile it, see if itβs more efficient
test different uses cases to make sure itβs actually working
never used the profiler
And not just working in a specific example
You see why I say efficient is the least of your concern?
I interact with an actor, I run this event (on server)
true, I'll learn about the profiler and see the difference (at least try)
with server it will be executed, if I interact with client it doesnt
I am trying to be genuine too. You will learn more by being stuck and working through it
Then someone giving you the answer
yea, there's no official answer anyways...
All the function does is print string and change boolean in server machine
Server rpc from client = hey server, run this code in your machine.
I mean there is. Thatβs what βbest practiceβ boils down too
what's the best practise here then?
To read the documentation
You too huh π
You can only call rpc on clients from things you own. By default that's your controller , pawn, player state
im 80% done with making this minimum viable product/prototype
then i cant work on art
I already did and let me tell you, there's no rpc for all clients
So in your case assuming you do it on some item actor and never setting the ownership, your rpc is simply dropped
damn
damn
make art and make it working, both?
I suspected such stuff
Multicast
no
the name is differnt lol
Literally me designing levels βah perfect now to make it so dark you canβt tell Iβm shit at this XD β
thas the reason my test on player controller works
I think it says all client on the function in blueprint. The nitt picking don't matter anyway
i cant even begin to imagine the replication logic in fortnite blueprints
if they even use blueprints
Yup, and setting ownership might not be a good idea either so there are times where you have to route rpcs to things the client owned.
let me tell you, the core doesn't use bp
thought so lol
yeah this are rocks staying around in level
the player can pick on it
it breaks and drop small stones
nice, you made rock simulator 3000
yeah π
now sell it on steam for 5 bucks and make millions
CurrentWearableItem->SetIsReplicated(true); // WOO! but so dog water for fps
I need socket lvl optimization
current wearable item, like a cosmetic?
Your fps dropped from marking a variable replicated?
I'm just gonna call bs
or maybe he's calling it in an event tick
lmao no, but it's not optimizzed
Network bandwidth management != fps
hm? π
How are they collerate
What?! πππ
kinda
sorry wrong reply
