#multiplayer
1 messages Β· Page 30 of 1
please don't shoot me
aighty so... you know hud is local already
you can get the local controller I think using "getowningplayer"
Setting owner for widget is optional, but it's good practice to set it if it relates to that player
correct
you gotta understand I work on japanese factories so when I can use the computer my brain is already on 2% 
The owner should always be the local player. You can't set the owner in online multiplayer to other player controllers.
You can still pass in a reference to the PlayerState or PlayerCharacter that you need to reference.
so if you want to
Don't mix up OwningPlayer with Owner actor because they are two different things
display a "you won" message in your hud
usually you'd throw a client rpc to the controller from your gamemode
then from the clientside controller you can forward it to the hud
2019 vibes 
in which u can create the widget ~
Oh, gotta remember this, didn't knew about it
The latter is vital to understand when you can RPC for example
And when you use replication conditions
This is also very good to remember
But all that is irrelevant when we talking about a local class like HUD/UserWidget
I appreciate your help, a lot, been trying but for some reason I still cannot do it, when playing as clients I receive errors and when I play as "server" with a few clients, every event I call from the widget applies to the "server" player UI, don't know why
I'm giving up for now, got sad with it, but I'll try again tomorrow
Leaving a better written explanation before going to bed, tested a lot because I really want to fix this.
Playing as server makes it work normally, I made a print on the "get hud" node results and the hud class is there normally.
Though, playing as a client alone, the print does not bring anything, like if there is no HUD class there, empty string on the print, but why wouldn't the HUD class be there? In this case, I receive errors as there is no HUD class to get from the "get hud" node.
If I play with both client and server open, and I take damage as the client, the server UI loses damage, which to me doesn't make any sense since the HUD class is local, how can the UI be shared... No errors on this case though.
I don't know if this makes any sense, I hope the explanation is a bit clearer
Good but we still haven't seen your updated code
Oh my bad, I wrote that on mobile, I'll take the screenshots tomorrow after work
but again I appreciate a lot
thank you for taking your time to help me
Are you using IsLocallyControlled on BeginPlay in character
Because that was what I suggested and I want to step back and say that it's not reliable
There is a possibility that the pawn hasn't got possessed yet so IsLocallyControlled will yield false
not anymore, I moved the widget creation to the hud class so on the character itself I'm just casting to the hud class to call events
Then I have to see the full context and where you're trying to access HUD to find that it's not there
I'll update to event dispatchers when I get it working though, to make it more modular
I'll make sure to take nice screenshots asap
Have fun time at work
hello, got an urgent issue. Solved thanks
if I set two replicated properties on an actor with on_rep functions in a specific order, Are those properties always replicated in that same specific order?
When it comes to order guarantees, the best guarantee you can get is they replicating in the same packet. If you are asking for more than that then you're asking for violence
But take it with a grain of salt, order depends on how you layout your properties inside GetLifetimeReplicatedProps
First being those up top
And ofc that's for non UObject* types
i see, thank you!
got another question! π I see that SceneComponent replicates its attachment state by default. Is there a way I can override this if i want to have a scene component that has a different attachment component on local vs remote clients? AKA i guess not replicate this property?
I'm not sure I get the question. Can you link me to the replicated property in question?
The UI is not shared. Make your HUD/UI such that it doesn't even know or care about anything networked.
You're probably doing some Get Player Pawn 0 magic in there
Idk if it's just me, but I get hyped every time I see Ethan is typing 
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_WITH_PARAMS_FAST(USceneComponent, AttachParent, SharedParams);
DOREPLIFETIME_WITH_PARAMS_FAST(USceneComponent, AttachChildren, SharedParams);
DOREPLIFETIME_WITH_PARAMS_FAST(USceneComponent, AttachSocketName, SharedParams);
DOREPLIFETIME_WITH_PARAMS_FAST(USceneComponent, Mobility, SharedParams);
}```
i find this in scene component, so im assuming if i set functions like "AttachToActor" etc on a server event, that those properties would be replicated
without me doing anything else
but in my case, im trying to attach a weapon to either a First person arms mesh, if locally controlled, or a third person mesh if viewing from a remote client, similar to something like CS or COD (im assuming)
If AttachToActor changes any of these properties then yes
But as you said if you want attachment to happen for autonomous proxy only then use IsLocallyControlled (else being remote proxies aka simulated)
"Turning replication off" for these properties isn't what you're looking for. Not from the sounds of it at least
yea i might be thinking of it the wrong way.
if (Rep_AttachmentOwner) {
ARedTideCharacter* RedTideCharacter = Cast<ARedTideCharacter>(Rep_AttachmentOwner);
if (RedTideCharacter) {
if (RedTideCharacter->IsLocallyControlled()) {
FAttachmentTransformRules AttachRules = FAttachmentTransformRules::SnapToTargetNotIncludingScale;
this->AttachToComponent(RedTideCharacter->GetPlayerFirstPersonArms(), AttachRules, "WeaponSocket");
}
else if (!(RedTideCharacter->IsLocallyControlled())) {
FAttachmentTransformRules AttachRules = FAttachmentTransformRules::SnapToTargetNotIncludingScale;
this->AttachToComponent(RedTideCharacter->GetCharacterThirdPersonMeshComponent(), AttachRules, "WeaponSocket");
}
}
}``` This is what I came up with based on what you said
time to test π
else if (...) else
yea π well I ran into some strange problems probably related to something else LogNetTraffic: Error: ReadContentBlockHeader: Client attempted to create sub-object. Actor: BP_RedTideCharacter_C_0 LogNet: Error: UActorChannel::ReadContentBlockPayload: ReadContentBlockHeader FAILED. Bunch.IsError() == TRUE. Closing connection. RepObj: NULL, Channel: 3 LogNet: Error: UActorChannel::ReceivedBunch: ReadContentBlockPayload FAILED. Bunch.IsError() == TRUE. Closing connection. RepObj: NULL, Channel: 3
it kicks my client out of the PIE server
What is Rep_AttachmentOwner? How do you get it?
{
// Set ownership for the weapon.
SetOwner(FromActor);
ARedTideCharacter* RedTideCharacter = Cast<ARedTideCharacter>(FromActor);
if (RedTideCharacter) {
Rep_AttachmentOwner = FromActor;
OnRep_AttachmentOwner();
}
}```
Server,Reliable function called from my Player Character
If Rep_AttachmentOwner is already casted to your type, why do you cast it again? (Not that it's related to upper issue)
OCD maybe π Im saving the variable type as AActor but im only doing so if its a character
too obsessed with abstraction maybe
I would trace this issue to see where things are going brrr
I have a βWeaponβ Actor Component class, which is spawned at runtime by itβs owning actor and added to itβs inventory. These Components replicate, and are correctly created on the client and behave as theyβre supposed to. However, if I try to destroy this component on the Server WITHOUT destroying the actor that owns it (e.g, to replace the wea...
This might help
thanks so much ill look into it
You can check my answer to the follow-up question which I just posted
nice! i noticed π Im just having a bit of trouble actually tracking down which function of mine is actually causing this problem
You can start by break pointing the error log and looking through the call stack
yea the call stack is just showing me this
im gonna look at it with fresh eyes tomorrow, thanks for all your help, at least i have some stuff i can track down. I am trying to do a lot of dynamic component spawning and stuff, i must be doing something wrong somewhere
Hey guys, I've been thinking
"in a multiplayer game, widgets communication should be done by the character or the controller?"
Widgets don't hold state, so they don't need to communicate
But if they do then that's HUD
HUD is what (should) manages widgets
I see, interesting! Never thought that way
But anyway, who is supposed to send player data to the HUD though?
So I've fixed this problem:
#ue5-general message
by using CharacterMovement -> SetVelocity on OnWalkingOffLedge event, but while is it's not replicated on client, it's also somehow gets overriden on the next ping (I guess) even on server. Player owned by server works fine, but the players owned by client not, which is strange as I assume that since it's server authoritative, all players running on server should run the same logic. Is there something I missed that I should check to make the client players works like server's player?
Here's a picture to describe the problem, red is player owned by client, and green owned by server
Hey guys! I'm back once again. Right now i'm working on a multiplayer game and I'm having an issue replicating the control rotation of a player (looking up and down and affecting torso) to clients. Right now it shows the player rotating from player-->server but not back to others.
Here is some of my messy method in my animbp
Please ping me if you have any ideas!
Hi, is the process for setting up dedicated servers for android games the same as that for desktop applications, or there are some other configurations/steps needed.
The Server itself, running on Windows or Linux, should be the same setup
ControlRotation is incorrect here. Use BaseAimRotation.
That one is already replicated, so no need for the RPCs
Hi,
I'm spawning a level in runtime, the replicated actors don't get spawned on client due to bNetStartUp is set to true because they're spawned in from a level.
If I set them to bNetStartUp to false, nothing is happening. How do I assure these loaded actors get also spawned for the client?
Hi, anyone uses advanced sessions on UE5? I updated my plugins but its not working in packaged game π
Anyone knows there's any documentation for UE5 & Advanced sessions maybe?
Can you disable NetLoadOnClient for those actors?
If there are, they will probably be in #online-subsystems π
Are you doing RPCs in your anim BP?
Ah well, seems only shipping builds do not work, the rest do. (Just in case anyone wanna know)
Nope, doesn't seem to do the trick π¦
If I spawn an actor with a template from one of the replicated actors, it works
But then references to that actor will not work. I can maybe name them the same name, so softptrs will still work
Hi! Question regarding autonomous proxy
i have a listen server setup, and it seems that movement on client (autonomus proxy) is just a little bit stuttery
are there any variables regarding the movement of the autonomus proxy that i could be playing with?
i'm working with blueprints only
@full tree any idea what needs to change to make corrections less frequent?
If you have default setup it should work like a charm, need some details
i have defaults, but i don't like how smooth my autonomous proxy is. it's just barely noticable, but i want it perfect
i have wsad movement via "add movement input"
the fields at the top and bottom of this you should start with I think
i test it on two computers
if the ping is low, and it shutters even without hardcore button smashing check server fps. Also debug correction are not visual shutters just a signal that move is corrected and interpolated
I was expecting a client's player controller on client to be Role=Autonomous Proxy | RemoteRole=Authority and on listen server to be Role=Authority | RemoteRole=Simulated Proxy. However it's Role=Authority | RemoteRole=None.
Similarly I was expecting listen server's player controller to be Role=Authority | RemoteRole=None. However it's Role=Authority | RemoteRole=Simulated Proxy
It feels like.. remote roles should have been reversed. Am I missing a point here? Or are they simply reversed?
Only server can see Role=Autonomous Proxy as client dont replicate actor to the server
Where is that being seen?
roles are reversed depending on where you check it, for example Server checking his controller will see Role=Authority and RemoteRole=Simulated Proxy because is simulated proxy for all the clients but when client check it form his perspective roles are reversed
because for client there is only server (no other clients)
So is the RemoteRole getting a set union of the actors role on other devices?
I get that roles do get reversed between server-client viewpoint. But it's not exactly reversed in the example I gave, that's the point can't get my head around
I make mistake, not controller, Pawn*, client don't have any other controller than his
That's why I was expecting the listen server's controller to be RemoteRole=None, while it's being RemoteRole=SimulatedProxy. Like where does it being simulated at?
Hi i am making an mmo and have a couple of questions, Do i need a manager to handle data persistence and to handle the creacion y destruccion of multiple instance of a server?, also i need a online session for the server?
Is there an unreal way to graceful finish a dedicated server? just closing the dedicated server works fine but it looks a bit forced on clients, I'm thinking of taking all the player controls and notify them of them being kicked out i guess.
Like??
Have you checked latest message in pins?
data persistence is somehow close to persistent data
OnLogout gets called when that happens, you could take advantage of that
just saw it, thx
Don't get too confused with roles as long as you know how things are being controlled. On Listen-server instance all actors have a LocalRole of authority, Remote isn't that useful (whether none or simulated)
hmm yeah i use onlogout, but i meant more like
void ShutdownServer(){
for all players{
player.NotifyExit();
}
FGenericPlatformMisc::RequestExit(false);
}
i can just do an rpc to player controllers, but was wondering if there was another way
It is just a role set this way, doesn't mean that is simulated/existing anywhere else
You can do that. You already have AGameMode::Say
There is an override you might make use of. I don't remember which exactly, but one of them handles the client being kicked back to a default main menu when disconnected. You can override this and not force them back immediately so that you can display a message easier.
Default is just to boot them back to main menu and display an error message.
oh wow, that one was new to me
Only issue with Say is localization. It doesn't handle it well since it can only pass a string. Might be possible to FName that and do a table lookup for localization though.
Hi!
I'm trying to develop a multiplayer game. The players have a Blueprint Widget above their head with their name. When I change it in one player, the other player doesn't seen the change. Any advice?
Thanks!
I think I have to change the name at server, but how do I run a blueprint node on server?
from reading the code there's also BroadcastLocalized which seems to handle that situation i think.
but for my purposes say works fine
The name is already a replicated property in PlayerState, set it, inside OnRep set the repped down property to the widget component
repped? Sorry, it's the first time I do this.
How does the server and client link up the bNetStartUp actors?
Hm, can I manually link them somehow?
Yes if you deterministically name them the same on all machines and override IsFullNameStableForNetworking to return true and make sure bNetLoadOnClient is also set to true
But again that is if you are spawning them dynamically. If they are being loaded from package they are already stably named
Hm, alright. I'm still trying to get replicated actors work with my level instances.
Because I want instance changes to come with the actor too. I could respawn all replicated actors, and it works
But the instances changes will not work then
Like changing a static mesh on one actor in its instance
I'm not sure what you're talking about
I'm spawning levels dynamically that has replicated actors inside of them
And they don't link up if I load the same level on both server/client
Stream in a level with a specific location and rotation.
Hey can anybody tell me why
IOnlineSession::GetResolvedConnectString
is used? I mean what does it do?
I understand blueprint node of Join Session.It takes SessionResult and I get it. But why do we use above one?
I mean does it gives the address of currently joined session or of session whose name is passed as argument?
Oh wait, I maybe found something
yea, just read it haha
It works now 
Guess I need to head home from work
I used it lately (https://forums.unrealengine.com/t/passing-options-trhough-join-session-node/660087/9?u=wizardcell) as a workaround to passing an options string to JoinSession node
Currently joined, but it should be same as passed
Thanks!
Hey can anybody tell me what is bAllowJoinViaPresence ?
Hi! Iβve been told that behavior trees are a better way to handle my ai logic for an RTS game (currently written in blueprints). Iβm confused as to how I do this with my multiplayer setup.
How do you pass the behavior tree logic to the server so it can execute the commands?
It means if your session is publicly visible to be joined iirc
But that's more of a #online-subsystems question
And what does bUsesPresence does?
Does it makes all the players playing in that session to show their presence to all of the players?
BTs are already run on server, at least that's how they should act. Reason being they are run by AIController which inherently server-only
It's not any different from how you would do it in SP. Pawns move, they got CMC attached, they simulate the same to all clients
I would suggest you learn BTs first before you do it in MP
which are logged in?
If I set it to false then will it be invite only right?
Probably. This is not the channel for OSS and session questions fwiw, the channel for that is #online-subsystems
ok thanks!
Thanks! Thatβs probably why I couldnβt find any information on my question. π€¦ββοΈ
Hello people, how are you? my name is Lucas, I'm new to unreal engine I wanted to ask you if you can give me a hand in connecting the database with the game and the web (for user registration and more). If you know what documentation or courses I can see to help me, please tell me. Thanks a lot!
(I'm fine, glad I could help)
TIL attachment + root motion = bad
Was it root motion?
the combo
Will take a look at that when I get home
RPC?
I think I know what you mean but mind explaining
Remote Procedure Call
Adriel meant to say that RPCs can't run in AnimBPs
As they are not actors
While you get home, enjoy that it works
(You're welcomeβ’οΈ)
So run it through my player, and get the rotation from a variable in my player?
No. What you're looking for is BaseAimRotation as Cedric suggested
@tranquil swallow Your animation system shouldn't know or care about networking
It looks at LOCAL data and outputs a pose.
Same with your UI.
Gotcha
In your case you either want to use BaseAimRotation or replicate a rotation yourself.
My game is top down so I literally don't have vertical aiming so I haven't had to do it.
I was planning to do a top-down but I instead went towards a tps because it's more in the environment
wish I stuck with top-down lol
When a match starts via AGameMode::StartMatch, and the GameState is notified, are all instances of GameState notified?
When OnRep_MatchState() fires for each and every one of them they do
That method fires every time that the MatchState values changes, right?
And that the match state's local value is different from the server's
How should I tell actors that the match has started?
I created a delegate and broadcasted it in HandleMatchHasStarted but that doesn't seem to work
Yeah each actor would subscribe to a delegate in the GameState, what's not working with it?
Oh, the delegate belongs to the GameMode, do I just need to move it to the GameState?
GameMode only exists on the server
So actors would only run the callback there
I have a replicated MatchState enum in the GameState that brodcasts the delegate in the OnRep function call
So everyone can respond locally when it changes
Delegates are local only, they are not RPCs
But GameState::HandleMatchHasStarted will run on every machine, right?
Yes, including server
Hey, what is the difference between presence and normal session?
I can't wrap my head around it.
I believe presence is just relating to joining via friend menus say in steam "join in progress" whereas the session is the actual multiplayer game session that you are in
I meant to ask, what is the difference between session created with bUsesPresence set to false and another session set to true?
I believe it just means players can join via the steam menus and can advertise "Playing Team Deathmatch" while in a game (all visible to other players from the Steam menu itself)
Hey Lucas π I'm doing something similar and I haven't found many useful tutorials/docs, and none that would answer your question in one go.
Your question doesn't give a lot of detail but at a super high level - you can connect to a database using C++ (for security, only do this in types that only exist on the server, e.g. GameMode or GameSession, unless you aren't sharing the game with anyone else). That's basically my approach except I've added a HTTP server between the game server and the database. I don't know if there's any plugins which would let you do any of this in blueprint.
Once that's working you can read/write to the same database the UE server is using from another application - e.g., from a web app where users can sign up in a browser.
But imo it'll be far easier/quicker/safer to use Steam unless you have a strong need for doing something else.
Hello Penthesilea, thank you very much for the help. I would love to do it through steam but my work group told me that it is impossible, the registration in a web application has to work.
I did the web too, it only has a frontend, I still haven't done anything on the backend, it's spa. Thanks, Laura
Wait they tweak Character and PC too much? darn.
So those are good news to me (tho I don't give an F about the BP part)
Honestly I thought it wasn't that stable for MP, but you proved my thoughts wrong
Wow, that's more than I (or any indie team really) would ask for π
Thanks for the forbidden knowledge tho, now I'm in a much better spot!
GenMovementReplicationComponent hmmm 
Are there any replication issues / complications with putting logic in an UActorComponent? Or important considerations to make?
Logic no, replication yes
Replicating ActorComps adds a NetGUID of 4 bytes and a footer of 2 iirc
Pretty much why Epic ended up moving all their CMC RPC calls to the Character
But that's a heavy ActorComp so don't take it as a general practice
how to restore player information like his name and how much money he has after he delate the game and re install it later on android ?
Is optimization wrt replication generally important for a multiplayer game of five players? Or are games of that size generally small enough that it doesn't matter?
Net Insights would know better. Profile and judge it yourself
how to restore player information like his name and how much money he has after he delate the game and re install it later on android ?
I want the player can sign in to his account with another mobile ?
like signing in with google acount
You want to make your own database where you save data for clients against some unique identifier, in Unreal it's called UniqueNetId
I would suggest you start looking the terms up rather than keep asking the same question again
I don't know if that's a compliment, but I'll take it as one.
And I'm here to explain.
You literally asked the same question again without replying to any of my messages so it seemed like an ignorance from your side
Welcome, hope you a cool learning journey!
im storing my setup data in a data table, should i keep it on the server only?
If that makes sense to your game then sure
@fathom aspen I see you here a lot, but wanted to say thank you for always helping out the newer people. It's really awesome seeing that π
wouldnt that be prone to hacking i suppose
when i say setup data, i mean stuff like lists of all the items, abilities, etc
Good to hear I'm being helpful. Hopefully I don't get blocked for that
Usually you want to ask yourself who has authority over that object.
If that's the server, then it's a server-authoritative. Usually being replicated and managed by the server.
would it make sense to have two data tables, one on the client and server. one for checking and another for validation only
~~Butbutbut... I'm not β£οΈ ~~
No
You only need 1 data table.
It doesn't matter if players change the data on the client side, so long as all calculations regarding any item data is done on the server.
Eg. You can have an item that has a "damage" field set to 5. If a client changes that field to 500, it shouldn't matter as the server would be the only one reading the damage value when actual damage is calculated and changing the data table value client side wouldn't effect the server.
that makes sense, ty
I don't know what that is, I'm busy buying NFTs
When server is replicating an Actor, where does server save it to replicate ?
how does server know i have to create another client ?
Is it possible I can share SnapShot of the server (All Replicated Acotrs, Clients ) with other Server so it can mimic what first server is doing ?
Like if something is spawned on Server1 , it should be like spawning it on Server2. so clients connected to server1 and server2 can see the spawnedObject exactly at the same place ?
hi, is it normal for a client's character to jitter and out of sync when the Character Movement -> Max Acceleration is too big, I set it out to 10000.0 currently (default is 2048.0) . I need the character to move without acceleration (instantaneous) and turning off Requested Move Use Acceleration doesnt seem to work (it still accelerates)
what could be the reasons for low client fps compared to listen server which works flawlessly?
Isn't there a boolean to just force max acceleration?
If you need something custom then you will have to override CalcVelocity on your own CMC
Yup, there is, I think it's [Requested Move Use Acceleration] but unfortunately it doesnt work, it still accelerates
RequestedMoveUseAcceleration is AI stuff
The bool is called bForceMaxAccel
And it seems to not be exposed to BPs
void UCharacterMovementComponent::CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration)
{
// Do not update velocity when using root motion or when SimulatedProxy and not simulating root motion - SimulatedProxy are repped their Velocity
if (!HasValidData() || HasAnimRootMotion() || DeltaTime < MIN_TICK_TIME || (CharacterOwner && CharacterOwner->GetLocalRole() == ROLE_SimulatedProxy && !bWasSimulatingRootMotion))
{
return;
}
Friction = FMath::Max(0.f, Friction);
const float MaxAccel = GetMaxAcceleration();
float MaxSpeed = GetMaxSpeed();
// Check if path following requested movement
bool bZeroRequestedAcceleration = true;
FVector RequestedAcceleration = FVector::ZeroVector;
float RequestedSpeed = 0.0f;
if (ApplyRequestedMove(DeltaTime, MaxAccel, MaxSpeed, Friction, BrakingDeceleration, RequestedAcceleration, RequestedSpeed))
{
bZeroRequestedAcceleration = false;
}
if (bForceMaxAccel) // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
{
// Force acceleration at full speed.
// In consideration order for direction: Acceleration, then Velocity, then Pawn's rotation.
if (Acceleration.SizeSquared() > SMALL_NUMBER)
{
Acceleration = Acceleration.GetSafeNormal() * MaxAccel;
}
else
{
Acceleration = MaxAccel * (Velocity.SizeSquared() < SMALL_NUMBER ? UpdatedComponent->GetForwardVector() : Velocity.GetSafeNormal());
}
AnalogInputModifier = 1.f;
}
/** Ignores size of acceleration component, and forces max acceleration to drive character at full velocity. */
UPROPERTY()
uint8 bForceMaxAccel:1;
So you'll need a C++ Child of the CMC
@ivory wolf
Nice, I'll check that, thanks π
Not sure when I should be using FUniqueNetIdPtr vs FUniqueNetIdRef vs FUniqueNetIdRepl
Since multicast delegates are more often used in mp, maybe I can ask here π
I have a multicast delegate with 1 str param named Foo.
When I want to sub to the delegate, I want to: Foo.Add(OnFoo)
void OnFoo(const FString& Result)
{
}
However, I'm definitely missing something. Maybe like TBaseDelegate<OnFoo> or SOMETHING like that missing?
create session Node if I set use lan to true . do other players cant join?
I mean network players
Multicast Delegates and Multicast RPC are two different things. This is not at all multiplayer relevant?
Interesting
Does the ==operator work for that wrapper? I can't really tell.
Why wouldn't it
Well because the wrapper could contain ref or a ptr beneath it
Looks like from the code it should work
But why have the FUniqueNetId be opaque in the first place?
Should there ever only be one per exact ID match?
OSS seem to return FUniqueNetId directly not the wrapper
And sometimes they return FUniqueNetIdPtr
Because there are specialisations of it depending on what platform your on, and they aren't compatible
The USTRUCT wrapper types exist so you can at least pass it around reflected code
So whenever I get one I should just wrap it in FUniqueNetIdRepl and move on?
Depends what you want to do with it I guess
But the point is just initializing a wrapper should be safe for most cases?
Hey guys, so I have a server rpc in the player controller which calls a multicast rpc and sets the location of a replicated actor. But the location change does not seem to get replicated to the clients. Weirdly enough, the multicast rpc runs only twice, even when I have 3 players in the session. The actor has its bReplicated attribute set to true, I can't really guess whats going on.
`void APlayerControllerBase::EquipWeaponServer_Implementation(class AWeapon* WeaponToEquip)
{
ReplicateEquipWeapon(WeaponToEquip)
}
void APlayerControllerBase::ReplicateEquipWeapon_Implementation(class AWeapon* WeaponToEquip)
{
// set WeaponToEquip's location
}
void APlayerControllerBase::EquipWeapon(class AWeapon* WeaponToEquip)
{
EquipWeaponServer(WeaponToEquip);
}`
I even tried setting the actor's location on server, but even that wouldnt work
The player controller is only replicated to the owning client, so calling a multicast on a PC will just send it back to the client that sent the server rpc.
You should send the rpc broadcast on something everyone has, like a game state or player state - or even just the weapon itself.
ah ic, thanks for the help, I'll try out your solution
The proper place to put it might be on your pawn/character, tbh.
However, you should attach it on the server and let it replicate...
(Or do that and send an rpc... can't hurt)
right, thanks a bunch for the help, I'll try out this as well
If I have a ServerRPC that alters a replicated property and then instantly sends a MulticastRPC to all clients, can I somehow guarantee that the RPC is received by the client before they receive the replicated value?
Smells like a job for RepNotify
That's all well and good if you aren't hoping to send extra parameters.
Ya I would do one or the other. Either replicate or RPC, not both.
@dark edge but.. it can't hurt? π₯²
Hey now, that's a different thing entirely! π
tbf RPC for weapon equip is weird anyway π
Depends on what you're doing. What if you want to send this rpc once (or once in a while or on specific events) but the variable itself changes/replicates a lot?
I think the problem in this case is it sounds like one is depending on the other getting there first, which is the prob
Totally.
You could send the current value of the variable in the rpc and then use that value instead of the client value.
Just in case things have gotten there in the "wrong" order.
What's the actual mechanic? What are you trying to do here
GAS has a workaround for this kinda thing but it's ofc very specific
Hopefully super-quick question. I have a map specific replication graph which according to documentation should be created by bounding the creation process to UReplicationDriver::CreateReplicationDriverDelegate(). What would be the correct place to do binding to this delegate? Source - https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/ReplicationGraph/
Game instance perhaps?
Yah, this is unrelated:)
I am performing a "transaction"(struct) on a shared inventory. I was hoping to avoid keeping a local shadow ledge of transactions, and rather just pass my transaction to Server without updating my own UI, and make the server Multicast the transaction if it's valid, so that everyone can reflect it in UI immediately (including me). But I still need it "Replicated" for new players, and as a safe-guard against rogue transactions going bad.
So the plan was
- Client->Server "do this transaction"
- Server: Checks transaction
- Server->Multicast "do this transaction"
- Client does transaction
- Client receives replicated result at some replication-time.
But I guess it doesn't make sense. I've just experienced replication/OnRep to be too slow to reactive UI.
Would constructor of GameMode be a good place? Or does client also need to know about this override?
I wouldn't multicast the transaction, just the state
Well, RPC isn't going to make it any faster because they'll still be delayed. The property will obviously be later still if you have a low net update frequency, you can call ForceNetUpdate() to get around that somewhat.
Can't you just predict transaction, Server RPC transaction, then let server do it and replicate state?
That's the "easiest" way, in a sense.
Send an ID to identify the transaction. Either you receive an RPC that says "failed" and client removes it, or you receive a replicated update and can "ack" it
Other clients don't need to see your bank statements, just your balance, so to speak
You can probably just do a forced replication even if it doesnt change serverside (say the transaction fails serverside), although idk if that'd trigger an onrep to refresh UI
It wouldn't but ticking UI ftw π
Or include timestamp in your replication so it has to update lmao
Yeah, the thing is, the transaction is smaller than the balance, so to speak. Faster to send. And I was going for speed, as people may edit the same inventory at the same time..
Well if that's the case, screw prediction then
This is the smartest solution, but I didn't really want to backtrack transactions
If you've got lots of clients messing with one container prediction isn't going to help much
That method above is essentially how GAS prediction works in a nutshell, but even GAS doesn't let multiple players predict actions on one target
True.. So my best bet is replicated content? I didn't know I could force a replication, so I'll try that.
There are diffing replication containers
You can't force a replication. ForceNetUpdate() is badly named, all it actually does is reset the "last time I sent an update" time
So unless a property has actually changed, it still won't replicate
Timestamp it is then
Right, but when used right after a change, it'll practically work as a force?
I mentioned it for the case where nothing changes
a failed transaction
It just means that the object should replicate at the end of the frame. It's really only there for actors which have a really low net update frequency by default
If you predict an item move but the server disagrees
Honestly I wouldn't bother with prediction tho especially if you need multiple players involved
But IMO, if you've got multiple clients interacting with one container - you really are just going to have to live with the latency
plenty of games don't predict
Makes it simple, RPC the transaction, then just let the repnotify do the thing
or plain old replication if you're ticking UI
Allrighty, I'll give that a go. Thanks guys π
Hi!
I'm calling PlayerState::SetPlayerName from Blueprint and it doesn't call OnRep_PlayerName. I have created a custom PlayerState class. Any idea? This is how I call it from blueprint (it's inside Blueprint Widget):
Thanks!
It doesn't run the OnRep_PlayerName because GetNetMode() returns NM_Client(3). So, I think, the problem is to execute a blueprint node on server. But, I don't know how to do it.
OnRep are only called on Clients in C++
Blueprint OnReps are a meme
If you mix the two it'll cause a lot of confusion
Oh incredible, Epic bypasses that in C++ for this one particular case. Even better.
SetPlayerName() needs to be called from the Server anyway to have any effect
It's basically the same problem as a 3-way crash in a vehicle game. Pure hell from a prediction standpoint.
No. I'm not calling OnRep on Blueprint. This is why I have shared the blueprint code, to show you that I'm calling SetPlayerName. As you can read, later on, I've noticed the problem is to run the blueprint code on the server.
Yep, you're calling it from a widget - which is only client side. Set Player Name needs to be called Server-side to have any actual effect
But stupidly, the function is not marked as authority only.
What is the best way for me to sync a "timer" on a HUD for all players? At the moment I'm repping down a value that is the total timer amount (i.e. 60s) PLUS the ServerWorldTimeSeconds. Then on the clients, OnTick I'm subtracting the ServerWorldTimeSeconds from that value that was repped down. Despite this I'm still seeing some desync of a few seconds between various clients.
Default GameState's ServerWorldTimeInSeconds seem to be somewhat unreliable unless you crank up the update rate by a lot
In this message, guy says they wrote a better one. This one is pinned, so I have no reasons not to trust them
#multiplayer message
@fathom aspen @dark edge Hey again, regarding the UI issue I had, I was working today and snapped on my mind the solution to my issue. What I didn't thought that day we were discussing, is that the On Damage event on my game is networked, so it would be always called on server, that's why clients couldn't find the UI class, because it is local only and you cannot grab from others such as the server, where it was trying to.
Although I noticed this and now know that I just have to call it locally instead of inside a "run in server" event, I noticed I have no clue on a nice way of triggering it outside of server. Since my game is networked, enemies attack between getting damaged is all networked, and I'm not very sure to call something locally when functions all run on server. Do you have any suggestion?
You can force replication with the push model though, can't you?
Nah, same deal
Server never sends anything to the client if it doesn't think it has to
Are you trying to have UI show health or UI do damage number or event popups?
oh of course all you're doing is marking the property as dirty
UI show health
I know I can just bind the variable on UMG but I have a brush/material and I'm setting inside a parameter of this material
yee. Server will compare it, but may still not send
Then the UI just shows the health. It knows and cares nothing about whether or not there is a server
Are you managing UI through PlayerController or HUD?
Makes sense - bandwidth is very limited after all
but in order to show the health difference I have to run the event or function from the UI when the player is damaged somehow
HUD, made some events to trigger when stuff happen and apply differences on the UI
Onrep_HP or just poll the HP value on tick in the widget
either way
polling is probably less trouble until you have a LOT of UI
but isn't on rep server side?
Do you know what onrep / repnotify is?
Just poll
How much UI do you have? On the scale from Mario to EVE
yeah, value changes then call function repnotify
I love the comparison here lol I would say in the middle
I don't have much UI but I have information about players, status basically
this will probably be safer for me for now (as I'm dumb)
when you bind stuff you can't usually change the binding in runtime right?
Binding is just a function that runs all the time updating values
You can program it however you want
Oh that's why it can get heavy with a lot of stuff?
hey guys, any ideas why the client wont connect to the local host server while the server is clearly running on port 7779 too? Could game state instead of game state base parent class cause this issue?
same happens with default 7777 port too
Yes. Health won't change on tick. Also read this: https://benui.ca/unreal/ui-best-practices/#dont-use-bind-variable
Oh, hey there!!! Thank you so much, I'll read it right now :D
You would probably want to look through the client logs too
WHat if it does change on tick tho
regen etc
I just bind hp and call it a day, especially if it's constantly moving
It won't change on tick in Mario, but it will in Dota or WoW
Binding anything to UI is in general a bad approach, ideally you use rep notify variables, call a dispatcher on the update, make your UI listen to that dispatcher and update the visuals. Keeping anything possible off tick and UI binds is the best approach @dark edge
I doubt it will ever change every tick
That still doesn't mean the property should be checked if changed on tick
even WoW life regen has a slow change of health
Maybe if you breakpointed that and traced your way up then you could get a slight idea of what is happening there
It happens inside UChannel::CleanUp
how would i do that?
You would breakpoint that line and look at the call stack
from the engine code?
Yes
The UI changed on client 1 now, on 2 it did not weirdly, client 2 got damaged and changed client 1 UI's, is the local controller different on each client as I'm playing on the same computer with two games? Two games on local connection?
Also tried with only 1 client running, it worked fine but there's a lot of errors, I think server is still trying to run the code even on client somehow (on this situation I should use authority remote?)
Is there something like AcknowledgePossession() on AAIController? Initializeing my Blackboard for an AI controller in OnPossess() and I guess I need to do that for all clients as well.
I guess OnRep_Pawn would work?
It does, but AIControllers are inherently server-sided
Trying to access AIC on client won't help you if that's why you trying to do
Doesn't hurt to share with us what you did π (code-wise)
Nah, I just assumed I would have to Initialize the blackboard on clients as well but maybe not?
Good idea, just a sec
I haven't done AI stuff in a while, but I'm not sure if that's safe or if that is something you would want to do
I mean you can always replicate AICs but that comes at a cost
On the HUD class, I create the widget normally
On the character status component, I created a function to get the HUD and the sub-widgets such as player status
then on the health rep notify I call the events to play with the UI (change amount and color)
the events though are simple and just play with my material parameters
That's all I done for now with UI, nothing much
Let's start by fixing things step by step
GetOwningPlayerController instead of GetPlayerController(0)
GetController instead of GetPlayerController(0)
Try not to use the evil GPC(0)
Hm so even though it is local, we shouldn't use the GPC(0)?
Yes not even local, because there are always other ways
Okay! With GetController you meant the Pawn node GetController?
Right
Now to explain why you're getting errors. OnRep health fires on all proxies (autonomous and simulated) - autonomous is the only proxy that has the local controller, simulated guys sadly doesn't have any
Do I make a method NetMulticast if I want to call it from the GameMode, and have it run on every machine?
But wouldn't NetMulticast cause the method to be called on every machine?
On every machine that the Gamemode exists on, which is exactly 1
I mean I know you're right lol I'm just curious why NetMulticast isn't the answer
the host
If the actor was replicated, and relevant to every connection
GameMode is neither one
GameState is both
@proven fog
The Character class has an inverted translucent cylinder which acts as a fake fog, so I only want it to be visible to the owning player. (Sorry, I should have started with context).
Is that a component?
The Get HUD node needs a Player Controller though hmmm
Yeah, just a UStaticMeshComponent
You have SetOwnerOnlySee
Is what info I've found correct, CMC does not replicate flying movement out the box, I need to add movement and handle this myself?
What I'm doing is using a BT to MoveDirectlyToward.
Set Only Owner See
Cast it to one
Oh sorry, meant to reply this one
Ahhhh, I thought that was only for skeletal meshes. It makes more sense that it wouldn't
Yeah, it becomes a MovementMode and you add a flag to the CMC that gets translated to a SavedMove and here my knowledge ends.
Same answer still apply
Cast Controller to PlayerController
Check the video pinned in this channel, might help you with that @still arch
Alright, will do that! As always, thanks πͺ
Are you trying to replicate UI health widget?
Nope hm
Because it seems like you're trying to replicate UMG widget changes and that's not viable
You would instead use a Widget Component
You are clearly accessing PlayerControllers on simulated proxies and that doesn't work
But how exactly? Nothing on it is replicated π€
Explain to me what you are trying to do
I have the player UI, I want to put it on screen and use it, to be honest this is all 
Replicate health changes via UI to other players is what I guessed and you said no
At the moment I don't want to show other players status, just getting the basic main player (the one playing) would be fine
Amazing
You have two options
- Replicate health variable with OwnerOnly condition
That way other players won't know about your health tho
- Use IsLocallyControlled inside that OnRep
I think this one fits better
How to use it on components though 
I tried parent but it didn't work
GetOwner -> cast it to Pawn -> IsLocallyControlled
And just to double check you have the replicated health property on the component?
Yeah, is the component for Status & States, I also use it on enemies etc
You know that component has to be replicated right?
It's okay, I mean who likes English language after all
About this part.............
I still get so lost with node types on UE
how can be "target is HUD" if I'm using it to get hud
GetController does not connect to GetHUD and GetController is not a HUD object to connect with GetOwningPlayerController
GetOwningPlayerController was meant for this one
Yeah sorry, I just tried before asking to be sure 
For the second it's GetController
But considering you're doing it from component so you have to go another step and do GetOwner
You can do GetOwner 2 times and cast to PC π
if i call a client method within an RPC, is that potentially hackable?
for example, if i have a method that heals a player based off a skillid, and i call a method that heals the player within the RPC, is that ok?
if the method that heals is on the client
If that's a server RPC then yes and healing is done server-side
Health is a state, state change is done server-side and replicated to clients
To run it through an event that has the potential to run on the server, or to run it through a server RPC
Thanks
Sorry I was AFK for a while
what you mean by GetOwner 2 times
you can get the owner of the owner
yeah but for what exactly?
getting the owner of the owner still doesn't allow GetController to connect on GetHUD, I'm not sure where to use it
Using GetOwner after GetController makes an actor pin
GetOwner->GetOwner->Cast to PlayerController -> Get HUD
can you explain to me why though? I'm not doubting I just want to understand how it works xD
Components owner is usually the actor they are attached to, which is Pawn in your case. Pawn's owner is Controller they are possessed by usually
If you read the error message it tells you why. The input pin on the node says "Self" which is a reference to the current blueprint. Then it says "This blueprint (self) is not a HUD" and the node itself tells you what the expected target is.
When inside of an actor component a "Get Owner" node like below would return whatever actor the actor component is attached to. So if you had this actor component attached to the player controller, the return value would be the player controller, but in its generic "Actor" format, meaning you'd have to cast it to player controller to be able to use the "Get HUD" node.
If the actor component is attached to your controlled pawn, the owner of said pawn is your player controller. So if you get the owner of the Actor Component (The Pawn) and then get the owner of the The Pawn (your player controller) you then have a reference to the player controller, but again, only in "actor" format, so you'd need to cast to use the Get HUD node.
If I only had Datura's energy to write like that, I would write 3 blog posts per day π
I'm still gonna give youπ₯ 
If I had energy to write π«
It gets even worse, when you have no energy to work 
Done, what's next
Sleep, work, repeat?
Can you tell what this "sleep" is? I only know the other two
Actually at this point ending the conversation so this channel may stay on track
bruh x'D
yet proceeds to write one of the bests slate-umg compendiums π
How Can I tell if a UniqueNetId belongs to a local player?
Find its corresponding PlayerState, then PlayerController and check if IsLocalController?
Said I don't have the energy, doesn't stop me from writing 
How to have your hand handle a lamp torch and being seen by others handling the torch too ? (first screenshot is phasmophobia)
I succeed doing this but somehow my lamp torch is flashing for some reason and also there's no hand on the screen https://gyazo.com/a53f5dacc99e0a6eca3006091a409fd2.mp4
Use some kind of enumerator variable that keeps track of what is in the player's hand. Set it so it is replicated w/ notify.
When you want to change what appears in the players hands, set the variable on the server. The OnRep function will trigger when the variable is replicated - use the value that is replicated to swap/spawn whatever actors and attach to your player as needed, and set whatever is needed for the animation state to show the hand holding the item.
If you want a hand to appear, you probably need a first person model and animations that only shows on the owning client.
For now I have this
Where can I get the unreal mannequin first person hands ?
Probably the first person template.
And how to get the hand place correctly with the torch ?
Oh π
Not that it's this channel's department. #ue5-general will either help you or switch you to the correct channel
Already tried in #ue5-general and my message got burried because of multiple people needing help and other channels are kinda dead
Quick question for ya, sometimes a server that's been created isn't destroyed, and it's still running even tho the host has the game closed. To fix it I have to manually close something with task manager (something something packaged.exe I forgot the name)
Is there a reason why?
Is there any sort of debug view that visualizes how often RPCs are being called?
Network Profiler?
Ah yeah, i forgot about that one.
Hi, I have a question. Is there a way to make player travel between servers without lag? If I use "OpenLevel" or "TravelPlayer" the player get lag, and then its teleported to the new server, is there a way to avoid this lag, to e.g. let player move in the meantime?
No. Well, it's one of those "if you have to ask..." type questions. It might be technically possible, but nobody here can do it or has done it.
unreal 4 dedicated server crash when using MeshMergeFunctionLibrary for the main character? when i try to connect locally to the server it crash cause of that
how to handle if the server disconnected on listen server ?
Technically it is possible, but you'd have to not use unreal's networking.
do you really have to go into C++ if you intend to have more advanced movement options?
Hi! I'm troubleshooting micro jittering of my autonomous proxy in a listen server setup
I was suggested to enable p.shownetcorrections
can someone take a look at the video and say if this is normal or am i facing some issue?
I'm also getting a lot of these
[2022.11.11-07.20.55:879][910]LogNetPlayerMovement: Warning: *** Client: Error for Khaimera_C_0 at Time=223.362 is 2.025 LocDiff(X=1.996 Y=0.342 Z=0.000) ClientLoc(X=-1080.883 Y=1476.642 Z=202.150) ServerLoc(X=-1082.880 Y=1476.300 Z=202.150) NewBase: MainMap1:PersistentLevel.Landscape1.LandscapeHeightfieldCollisionComponent_20 NewBone: None ClientVel(X=79.498 Y=13.608 Z=0.000) ServerVel(X=63.399 Y=10.850 Z=0.000) SavedMoves 3
[2022.11.11-07.20.56:010][915]LogNetPlayerMovement: Warning: *** Client: Error for Khaimera_C_0 at Time=223.465 is 2.000 LocDiff(X=1.972 Y=0.337 Z=0.000) ClientLoc(X=-1077.128 Y=1477.284 Z=202.150) ServerLoc(X=-1079.099 Y=1476.947 Z=202.150) NewBase: MainMap1:PersistentLevel.Landscape1.LandscapeHeightfieldCollisionComponent_20 NewBone: None ClientVel(X=41.373 Y=7.078 Z=0.000) ServerVel(X=21.563 Y=3.689 Z=0.000) SavedMoves 4
[2022.11.11-07.20.56:137][920]LogNetPlayerMovement: Warning: *** Client: Error for Khaimera_C_0 at Time=223.622 is 2.517 LocDiff(X=2.481 Y=0.425 Z=0.000) ClientLoc(X=-1076.296 Y=1477.427 Z=202.150) ServerLoc(X=-1078.777 Y=1477.002 Z=202.150) NewBase: MainMap1:PersistentLevel.Landscape1.LandscapeHeightfieldCollisionComponent_20 NewBone: None ClientVel(X=13.383 Y=2.292 Z=0.000) ServerVel(X=0.000 Y=0.000 Z=0.000) SavedMoves 3
So i'm wondering is my jitter somehow connected to this client error
It's not normal
Way too many corrections
Are you changing the walk speed runtime?
nope
could it have something to do with collision?
it seems when the character jumps, than the drawing stops
Actually im changing the speed at runtime, but only once or when an item is picked up
If that matters
Hey guys,
Im trying to implement voice chat system on my project with dedicated server, but im not finding any good doc references or tutorials to implement it.
Can anyone share or help me with this topic.
any lead or insights will be highly appreciated.
We evaluated the built in voice chat system a couple of years back and found it just wasn't very good. It also uses your server bandwidth.
We ended up integrating Vivox which has been flawless.
The other option would be EOS voice chat but I think that's a bit more involved
Ok so after creating a session, how do I actually get the session
It just gives me the name?
Hello, just wanted to check i understand things correctly, there will be one game instance on all instances, dedicated server and client, they are separated and not shared, replicated etc and the same would apply if i created a game instance subsystem?
correct - it's local only
and every machine has one
The same is true to all subsystems, they have no networking support. If you want some kind of networking, the solution is to spawn a proxy actor that communicates/interops with it. My advice is to leave that purely to world subsystems however.
i don't want any, i was going to make a game instance subsystem that pulls in the configuration, which i would update clients by rpc call, or as you put it a proxy actor
thanks π
Hi!
I want to learn unreal engine networking. Do you recommend me a good tutorial/book to start with? Yes, I've read the UE4 Network Compendium from Cedric, but I don't understand anything. I learn better with examples or with Cookbook.
I've googled "learn unreal engine networking" there are a lot of videos and I don't know where to start from.
Thanks a lot!
I have a small overlap capsule in front on character, if any other character overlaps it, he will get pushed to the side.
Currently I'm using Add Force on CMC (inside Tick), but how do I do it so it's synchronized, without network corrections?
Do I need to Add Force on both server and client? Or just on Server? Or having synchronized Add Force is not as easy as that?
The problem is all clients are in different frames of time reference. The local client is ahead by RTT / 2, all other clients are behind by your RTT / 2 + their own RTT / 2.
So you can't really have different clients bumping into each other without some kind of correction, it's impossible to avoid
Yes that's what I was worried about. Because currently I'm stuck on resolving issues with characters colliding with each other, which will prevent them from moving (if they don't hit their sides, in this case the just slide around each other), first I thought just adding another small capsule collision just for pawns is going to be good, but CMC only works with the root capsule collision, which is used for environment, where I don't want characters to get too close to walls, etc. And removing collisions completely with other pawns is not very visually appealing.
So then I just thought that I will push other characters away, but corrections would be painful π
.
Ultimately so long as the local client is predicting ahead of the server, there are always going to be corrections - but every game with prediction has that problem. You could try to "solve" it before it becomes a problem, like biasing the characters input to "steer away" from other players locally, without actually using collision.
It's not perfect ofc, but at least avoids issues with corrections etc.
yike
Hi guys,
Can we create multiplayer on listen server model and integrate EOS without using unreal Engine source build?
MeshMergeFunctionLibrary (for merge skeletal meshes into one character) causing dedicated server crash when client try to connect...anyone experienced this issue?
Is it possible to replicate a UObject without having it be owned by something? The problem I'm trying to fix is I want to pass an object as a parameter through an RPC function, and the object is a pointer that can be polymorphic - maybe this can be done in a different way so I'm open to suggestions
negative
If it's a runtime object, it has to be a sub component of an actor. Assets, or other stably-named objects can be referenced however, but cannot replicate properties.
The alternative is to use structs instead of objects
but you can't pass structs as pointers through an RPC right?
No, but you can create a "wrapper" struct which serializes the data into raw bits
The EZ mode way to do it, is to merge this PR: https://github.com/EpicGames/UnrealEngine/pull/9280 - and use an FInstancedStruct
Hi!
I want to learn unreal engine networking. Do you recommend me a good tutorial/book to start with? Yes, I've read the UE4 Network Compendium from Cedric, but I don't understand anything.
Any advice?
Thanks.
That's was exactly my use case though, sharing RPC's/functions for different raw data
we aren't set up to compile from Engine yet π₯² but when we are, I'll definitely request for that to be added. Thanks!
You can merge that PR without an engine compile, you can move the plugin out of the engine into your project directory and modify it there. Epic are (apparently) taking that PR in 5.1 though hopefully, so I'm told
oh okay, we're going to be upgrading to 5.1 soon anyway
yeah, I think they're too close to release to take it but you never know..
Otherwise though you can just create your own wrapper type. I did the same before this plugin was a thing
lol I found your Twitter by searching FInstancedStruct
yee π
IDK why nobody sees the POTENTIAL
It's so powerful
being able to pass arbitrary data around, with reflection support, without having to mess around or worry about UObjects and their lifetimes
void subsystems
I'm probably overstating it tbf, but it is super useful
I think it depends, if you're in multiplayer land it's a PITA
but singleplayer it's no problem ofc
You know what's also useful and no one talks about and seems to use? Sparse Class Data! flies away
The bp version of static const?
Sort of
Make a pawn with a static mesh, make it change color with the push of a button, make it work in multiplayer
The best way to learn is by doing.
Thanks
Wait WHAT where do I find out about this?
Does anybody know what ServiceResponse and ServiceRequest UFUNCTION specifiers mean and how do can you use them?
I think those are UFUNCTION specifiers, not UPROPERTY.
https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/GameplayArchitecture/Functions/
corrected but that doesn't solve my problem π₯²
Hello all,
Quick question, for replicating actors, what are my options?
I have this inventory system where at first I was storing pointers to actors. This is fine for single players. But when we get to multiplayer, the pointers become null. My current option is to store the actor (when it is not spawned in game). However, my current huddle is communication. I have the replication setup and working. But I need to know what data I need to communication between the server and the client
You need to send info to server that you want to do smth with a certain item
So it properly give an update to clients
Yeah, so would that be an FArchive object??
can you know if a variable float or int has decreased or increased on rep notify?
You need to replicate whatever data that the client doesn't know or doesn't have access to know about themselves.
Eg. If you used an "Item ID" as the basis for your inventory, then that can easily be turned into a data table lookup on the client end, negating the need to send all possible data about the item to the client as they can look it up themselves.
Same going from client to server, but with a caveat: You never want to allow the client to just send the server "Put Item ID in Slot 3" as that can lead to players being able to dupe items. To work around this, you have to only allow the client to communicate minimal data about the inventory slots that are being manipulated. Eg. "Move item in slot 3 to slot 1"
Ok I see. You bring up a good point Datura. If I am sending entire actors through the connection, there could be a significant bottleneck on the bandwidth. During my initial design here, it is fine because there is not much going on. But I want to learn best practices here and not have to rework the code later down the road.
Now, from a developers point of view, there are many paths to the solution. Are there any best practices in this situation?
A data table sounds great. Send out a number that corresponds to the class that is supposed to be added. As I make more item classes, I just need to expand the data table. In addition, I would have to send out data specific for the particular class (eg weapon damage or armor rating).
In C++ you can get the previous value in the OnRep method.
OnRep_Speed(int OldValue) it'd look somethin' like this
Hm no way to do it on blueprint? My entire code is currently blueprint
πͺ¦
β¦I guess on BP you could have a local variable βpreRPCstoreβ, and then during OnRep, you can see the pre store, then update it yourself during the Rep with the new value. Means you have to track the variable twice though. Just a random thought I had to help, defintely not optimalβ¦
Double the variables, double the fun!
Yeah I guess that works! Probably not the best method but works
How do I loop through the lobby to see if there are more than 2 players
What do you need the player count for?
To start the gamemode
So if 2 people are in the lobby load up the map and start the gamemode
This lobby is a map that they've already loaded into?
If so I'd probably just use GameState's PlayerArray.
Yes
Ok
How do i get the player count
Like this?
I guess? Though just getting the array length would maybe be better than a loop.
I have another question
Im using the default gamestatebase for the gamestate
But I can't edit the gamestatebase
When I try to create a new gamestate the character does not respond to inputs
Inheritting GameMode and GameState need to match.
GameMode + GameState = Good
GameModeBase + GameStateBase = Good
GameMode + GameStateBase = Bad
GameModeBase + GameState = Bad
oh kk
One last thing aha
If I were replicating to show all players that a character threw a lightsaber
is this correct?
Thrower can be server or client
Hey there! Does anybody know what ServiceResponse and ServiceRequest UFUNCTION specifiers mean and how do can you use them?
Is subsystem online important for multiplayer game ? what happen if I didnt use any?
For online multiplayer, yes, but it depends on what you're trying to accomplish. If you don't use an online subsystem, you'll have to make up your own means of connecting players to servers/hosts.
This can be as basic as telling players to set up port forwarding themselves and sharing their IP address with people who want to play, or it can be as complicated as writing your own system that your servers can report to advising their online & looking for players, then on clients you retrieve the list of servers/display them.
@sinful tree I want to make a game for android Can I use anysubsystem or must be google subsystem?
You can use any that are valid for the particular platform. I'm not an android developer so I'm not sure of the exact options.
I'd imagine that Steam wouldn't be able to be used on an Android for example.
Hi!
I'm working with Unreal 5, and on an ACharacter I have tried this: if (Role == ROLE_Authority) but it seems that Role is private now. I'm new on mutiplayer and I'm following an UE4 tutorial.
How can I do that? Because there is a GetLocalRole and also a GetRemoteRole.
Thanks
GetLocalRole is what you're looking for in this case, it tells you what the actor's role is on the current machine. GetRemoteRole tells you what the actor's role would be for a different machine. Check out the networking compendium in the pins, it goes over local and remote role somewhere in there I believe.
Hi! I still haven't been able to find a root cause for my micro client corrections which stutter the autonomous proxy in a listen server setup. I tried to cap fps to 30 on both client and server and it didn't help. THis is the debug view (p.shownetcorrections) from both client and server perspective
Any ideas?
I don't think the normal netcode could even make something stutter this bad under default settings
my first guess is that the character is colliding with himself because some of his components or some actor he is dragging around has blocking collision
try turning collision off on everything other than your Character capsule
i did try that π¦ but i'll double check
wouldn't server character stutter as well if the collision was the problem?
maybe
is the client making adjustments to the speed of the character?
hmm, you mean there could be discrepancy between the client /server movement speed?
if you write code anywhere that changes run speed while the game is running, it can cause hitches if the code isn't run on both client and server
let me check
i'm setting speed on server when for example speed is changed for gameplay purposes
should i set it on client as well?
yes
I don't think so
i'll try though, thanks
@low helm @thin stratus it was the speed dispcrepancy between client and server
weeks of troubleshooting
thank you very much!
i'm so happy now
atleast i learned a bit about troubleshooting π
Hey guys I'm using an Tile View into an inventory system, that is creating tiles when I'm looting items, it creates a class and passes the info, My issue is that only the server can get tiles added into his inventory, even tho I'm using multi cast and "Has authority" node on the multi cast, I tried many things like " has authority" or "is locally controlled" nothing worked so far, any help ? Maybe tile view cant be replicated ?? IDK.
If u use has authority then the multicast only runs on the server. If you use IsLocallyControlled then it runs on the autonomous proxy. If you neither use one, you are still multicasting, and multicasts are bad for state changes (yes inventory is a state).
So all those options are bad.
Instead you want to use replicated properties.
At a very basic level, investory is just a replicated array that you add to/remove from.
So what I should just replicate the widget that I use has an inventory ?
Widgets don't replicate
You replicate the inventory
The widget listens for state changes
I should make it a component maybe ?
You can make it whatever you want
everything is into a widget RN ^^
Well then that means you don't understand the basics of unreal's networking
Find the multiplayer compendium in pinned messages
Read it a few times
So they are as promising as NFTs are?
I should probably change the system and make it an array stored into an "inventory actor component" that is properly replicated, and then construct and fill up the widget from the strored item data of the array, to refresh the widget, Right ?
Right, you can.
The inventory actor component would be attached to an actor that is replicable
Usually Character (Can be PlayerState too)
I had the same result so far tho... But I think it's because I was not refreshing the Widget properly ^^
I'm creating a rollback networking plugin for my own purposes and I'm planning to use a subsystem to manage some aspects of it. I cannot decide if a UWorldSubsystem or a UEngineSubsystem makes more sense. Since it's going to use an Actor as a replication proxy anyway, which needs a UWorld, I'm thinking a world subsystem makes the most sense, but I'm curious if anyone else has a good sense of when to use engine vs. world for a subsystem.
You are not going to be making rollbacks before runtime. UWorldSubsystem ftw.
Why hold a subsystem in memory if I'm not using it
Tho I think Editor has a World, that's why when you PIE for example objects are copied into a new world, so you can get back to where you was when you stop PIE. Meaning you might even have UWorldSbusystem before runtime, but still UWorldSubsystem makes more sense to me.
well I'm still stuck and have the same result π€
Yeah I agree. I can check for PIE in Initialize().
So the array Is replicated, The component is aswell and yet still only my server is the only guy able to really loot and display what he looted
You kinda told it to do that though. You multicasted to everyone, but only the authority can loot.
I removed the has authority now, tho I saw it was still there
Probably still shouldn't be being done on a multicast. This is stateful stuff. Client should RPC to server that it wants to loot. Server should do all of the looting, destroying the object, etc. Then replicate new state back to the client. Client's UI can either display from a client RPC with a list of looted things, or the OnRep of their own inventory's items can trigger it.
So it should run on server only ? when Client loots ? And since evrything is replicated it shouldnt cause issues, right ?
even my items are replicated so they should destroy normally, but what if there is a late join ? ^^
What if there is?
Multicasts are the ones that don't keep state. Using Replicated actors and replicated state means late joiners have no problems being updated. If you multicast an item's destruction, new joiner has no way to know that
so replicated items act like Rep notifys I assume
I can't remember if the server will tell the client to automatically destroy an object preplaced on map.
well I will see on my next test I guess ^^
Well I called it on server only, items destroy but still same result, should I put the "Has authority " back ? π€
Not fully sure. Chain of logic should just be... ClientInput->ServerLootItem->InterfaceToLootItem for starts. That'll be your gameplay logic, it should pick up the items to the inventory, which should be replicating them back to clients. Then destroy the pickup, which should automatically destroy on clients as well.
currently what I'm doing is
Client input -> call server event "loot" -> Send message to Item Interface -> Item transmit his Struct to the player inventory component ( not replicated struct /Instance edit Expose on spawn but replicated item) -> Struct creates an Item object and add it to the tile view of the widget that is holded into the inventory component (Component replicated Array of Item object replicated).
I'm thinking that this struct I'm passing should be replicated ??
well replicated or not the item struct is not showing into clients inventory, still π¦
How do you see the logs on clients into a standalone test version ?
My message log shows nothing in editor and output log either ^^
Should I be using a gamemode or gamemodebase for my mode? it needs to contain the round number and wins etc
gamemodebase is lighter and has less stuff
gamemode is more suitable for fps-like games
look into the gamemode class and see if you need the functionality it provides, or if you don't
got it!
I could use gamemodebase to change the map after 2 players are in the lobby right?
Idk, it's been long since I used it. Read the class to see what functionality it provides
On Listen Server, low FPS clients' animations are pretty laggy/jittery. How can I solve this issue?
I see it's quite a common problem, but so far I was unsuccessful in finding a solution for it.
Where do you put game logic, in gamestate or gamemode ? Gamestate should be easier for client/server common code ?
That's not enough to tell where "game logic" should reside
Yes, example you can ServerTravel
Servertravel is a node or just open level?
Are you BP only?
ServerTravel isn't a node but it can become one if you use ExecuteConsoleCommand
See what options are in BP: https://wizardcell.com/unreal/persistent-data/#travel-drivers
Can data assets be replicated? I use TSubclassOf<> to replicate data objects currently and I'm not happy with it currently
So that mean's it's ok to use the gamestate for actions ? (not just states)
It means you didn't give me enough info on what logic you're referring to so I could answer your question
Mhh was a general question, i don't really know what should be in the gamemode, i'm just initializing and spawning the game here, dunno if it should be use for something else
I use the game state for the rest
Look at the two class headers and you will understand on your own what should reside in each
GameMode being rules of the game, while
GameState is just game state
Mhh ok
Wondering what you mean by TSubClassOf to replicate objects?
If you are replicating runtime objects then you are going to replicate them thorugh some actor channel
i formalized incorrectly, i was meaning replicating the pointer to object. I replicate the TSubclassOf property in actor and get CDO when I need to access its default values
nice. so data assets allow us to reference them over the network 
do any of you have a recommended sample project or marketplace pack for a barebones multiplayer FPS game? i'm a web dev/noob to UE5, looking to tinker around with a basic client/server setup
i'm sure this gets asked a lot, so I'll search around too
ShooterGame / Lyra for Epic Samples
thanks, Lyra looks like a great way to start out
Hey guys
Why do I get this error on the client after this code is ran?
The one who hosts the server has no error and loads the level fine
Few things I can see as problems.
-
You don't want to have the client sending an RPC to the server to tell the server to change the level as malicious clients can then exploit that RPC to force the server to perform the action when it wasn't intended. The server itself also knows whether or not there are 2 players, so it doesn't need a client (actually all clients) telling the server to do the level change. Instead, gate your Tick using a Has Authority > Authority node - this will ensure that only the server/host will be executing the code as the game state is an actor the server has authority over.
-
If you have a server already running with clients connected and you use Open Level to move the server's level, you're going to be booting all other players from the game as only the server will open to that map and ignore all connected clients. You'll need to look up server travel - there's a means of having the server transition to a new level and keep existing clients connected. This could also be why you're receiving the message you are as the clients are being booted and trying to load the main menu map which perhaps doesn't exist? Keep in mind that Server Travel is also not the same thing as Seamless Travel, and I don't think you can test it working without running as "Play Standalone".
-
If you are opening a new level, setting the value and playing a sound immediately after is somewhat pointless. As soon as that open level command is executed, everything else after it won't happen and in the case of the variable, it's not going to save.
-
And finally, a small optimization - you shouldn't need to be checking how many players are present on tick. Game mode gives you an event when a new client has joined the server (OnPostLogin is the event I believe). That event could then be used to call that particular check in your game state so it's only checking how many players when a player joins.
Hi! I have a steam listen server and i would like to display server ping via umg
BP only project
Any way to do this?
(while the client is connected to the server to be more precise)
thanks
Thanks. That's what I'm doing, but without some guidance it's quite difficult: https://forums.unrealengine.com/t/change-on-one-playerstate-playername-updates-all-players-with-the-same-name/689398
Hi! Iβve just started to develop my first Multiplayer game. Thereβll be two players with their names above of their heads. When the game begins, the player has to set his/her name. I have a Blueprint widget with an Editable Text. When the player hits the Enter key: I have created my custom PlayerState in C++. The header: #pragma on...
the server is the server.
That message made entirely zero sense.
Is it common to use a dedicated server ALSO as a central server to help players connect with each other? I always thought that the usual approach would be to make an independent backend for user/room management, and let dedicated servers just run games
A lobby server?
You could use a ue dedi server for that. Like the warhammer game that betad the other week, where they have 100 people running around a ship while waiting for a game.
But you'd only use it if you actually want people to interact that way.
As you said, it's a lot easier to host a map locally and just query a dedicated backend service if you don't wnat people to see each other in that kind of animated context.
Hey, I'm still stuck with my stuff, So my clients cant display what they looted, but the item they looted is destroyed for everyone, only the server can see what he looted into the inventory, anyone could help with that ? I'm still pretty new to all the replicated stuff ^^ thats the code in the right order.
Items are replicated, Inventory component is replicated to a player class that is replicated aswel
If I have two players, why do I have only one PlayerController?
Because you are looking at the client world
On client only exists the owning PlayerController
I'm having a lot of problems with this. Because I want to change the name for the client player and it changes the name in the server and in the client. I have a widget above the character's head and it changes there in both players.
I'm struggling to find the best way to do something. I have a replicated ActiveWeapon variable, there's an OnRep callback that updates relevant HUD & Meshes. I am trying to implement clientside prediction for weapon switching, where ActiveWeapon is set instantly on the client to avoid input delay. The issue is when swapping weapons quickly, as the ActiveWeapon variable is set serverside and replicated back, meaning it will repeat the sequence with a delay depending on ping. It still ends up in the same place, but it obviously looks very bad.
This variable is also used by other players to show a third person weapon, which complicates it further
Ideally I could only replicate the variables to certain players at certain times, but from what i've read you can't have this much control with replicated properties
The closest thing I found was DOREPLIFETIME_ACTIVE_OVERRIDE, but this only works on a per actor basis not a per connection basis
I could achieve what I want with RPCs but it would be hacky and lose the stateful replication, which is not what I want to do
Hey I followed what you said, how do I target all the players in the lobby though so they travel?
How can I get the player controller for the current player in a Multiplayer game? I don't think it is always at index 0, or am I wrong?
The player controller only exists for the client and the server, meaning other clients don't have access to other clients playercontrollers. So besides splitscreen local multiplayer it will always be at 0
There will always only be 1 player controller in an online multiplayer game for clients
Like this?
Thanks!
Well, I've change my system again, using the exact same code with a Scroll box and adding childs to it, and this solution is working with the exact same code,
Anyone has any itel about tile views being impossible to replicate or work with in multiplayers projects ?
my issue was there BTW
So I'm reading force net update and flush net dormancy in c++
what the heck is the difference?
It looks like in essence force net update just checks if it's the server, and if it is then it calls flush net dormancy... while flush net dormancy will only run if it's the server...
{
if (GetLocalRole() == ROLE_Authority)
{
// ForceNetUpdate on the game net driver only if we are the authority...
UNetDriver* NetDriver = GetNetDriver();
if (NetDriver && NetDriver->GetNetMode() < ENetMode::NM_Client) // ... and not a client
{
NetDriver->ForceNetUpdate(this);
if (NetDormancy > DORM_Awake)
{
FlushNetDormancy();
}
}
}```
Why wouldn't I just call flushnetdormancy directly?
My replicated actor holds a UPROPERTY(Replicated) UMyObject* MyObject (just a subclass of UObject). It's instantiated during the actor's constructor, using MyObject = CreateDefaultSubobject<UMyObject>("name");
That UObjects holds a UPROPERTY(ReplicatedUsing=OnRep_MyArray) TArray<int> MyArray. I'm having a hard time replicating everything properly.
At first, the MyObject-instance wasn't replicated at all. It was NULL for clients. Props were set up correctly, but apparently I had to implement and return true in IsSupportedForNetworking(). Using this, the UObject suddenly existed for every client. However, server-changes to MyArray doesn't seem to replicate at all.
what are you trying to do? get all clients to move to a different map?
Yeah server and 1 other client
To a different map
there should be a node "ChangeMap (Server)" in game instance
which automatically travels the server and clients to the specified map
I'm trying to do it in the gamestatebase though
Do you mean this i couldnt find that in the gameinstance
Yeah that server travel node does nothing at all
Howd you get this node? lol
is it not in your game instance?
hmm actually I think it's a plugin nevermind. It does exactly what you're trying to do though, I genuinely think you should remove the specific player
TargetPC->ConsoleCommand(TEXT("servertravel ") + Map + Args, true);
yup
it's the same thing
I don't use any specified player
I just call it on the server
and all players travel as well
@quartz iris If you use ServerTravel all clients should follow
maybe the name is incorrect?
GetWorld()->ServerTravel
try using a different map, or the current map you're in with what Ghetto suggested
GetWorld()->ServerTravel
see if that works
like this
not quite
UWorld::ServerTravel
GetWorld()->ServerTravel()
Can i use it with append?
You supply a URL to the function
So yes, just append what you want to an FString and pass it in
with a space?
No
For example
The url is a path to your map uasset
You can add parameters to the url as well, for example adding ?listen to the end of the url will host it as a listen server
without the umap
ok
just the name
yeah i mean if the map name doesn't change you can just pass in the fstring, the append is for if you want to change the map based on some variables or whatever
no no no
one sec
Go back to what Neon said. it's done slightly differently in blueprints
It seems like you do have to execute a console command
Just make sure you are running the command on the server
i did it through a custom event on the gamestatebase
oh okay if you're doing it that way instead of console commands sure
What you have looks fine, you might need an extra / at the start before Game
oh ye
I know how it works in c++ not blueprints
I think advanced sessions is just calling the ServerTravel function but I'm not sure
Give it a try anyway
How is the travel to server event called
I mean for one, if this is in gamestate it's running on client and server but your authority check isn't wired up, so it's gonna try and call it on client and server. But it still should be doing something which is weird
Try adding a log before the ServerTravel to make sure it's actually being called
its being ran for sure
it printed text
This goes back to what I said earlier:
Keep in mind that Server Travel is also not the same thing as Seamless Travel, and I don't think you can test it working without running as "Play Standalone".
Its running as standalone
2 standalone one joins the server the other created
Ah yes I remember having to do that now
Please repeate, how to make couple room on server and somehow name them?
π€
@sinful tree Any chance I can get your thoughts on this?
Yeah tick it π
oh kk
WAIT so
If this works after doing that
does that mean it will work when i package the game and players play the game?
yeah should do
