#multiplayer
1 messages ยท Page 81 of 1
But out of like 9 hours of off-and-on research and compiling I managed to get this:
I tried doing the declare event macro but it wants an owningtype and I couldn't figure that part out lol
I tried making a struct with both FStrings in it, and it wouldn't compile. This was the only way I got it to work
UFUNCTION(BlueprintImplementableEvent)
void PreLoginAuth(FString ClientNetId, FString ClientToken);
This would have been sufficient to expose a Blueprint event to the GameMode graph.
so you would add that in the .h file and then how do you call it? PreLoginAuth(networkid,token);?
Yep exactly like that, its a function.
Its easier to deal with than a Delegate for a beginner.
multi-cast would go out to everyone if I have been reading properly so it might just be unnecessary traffic
It allows many subscribers to receive the event, they have to bind to it (like in the image you have).
ahhh ya I don't need that
void AMyGameMode::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
{
Super::PreLogin(Options, Address, UniqueId, ErrorMessage);
// Do retrieval of NetId and Token
FString ClientNetId = UniqueId.ToString();
FString ClientToken = ;// Retrieve Token how you need to.
PreLoginAuth(ClientNetId, ClientToken);
}
Might look something like that
my flow is something like:
User Logs In on Login Map
API Authenticates and returns Session Token
Joins map with ?Token=123 on Open Level By Name
Custom Game Mode records Network ID and Token
At some point, when the actor is going to be spawned, I want to request the users information on the database like their world location, equipment etc., and spawn their character accordingly.
The logging in Client has its PlayerController spawned at the end of the Login chain during AGameModeBase::Login
You can decide when to spawn them a Pawn at any point.
They will be assigned a Pawn by default though.
Which is decided by the DefaultPawnClass on the GameMode.
You can leave this empty.
And manually spawn them a Pawn whenever you like.
Like if there was a Character selection screen or something.
Hey how to save data from the game like a specific player's money count, bought items etc. And retrieve or change this data when needed?
Link that to a Database?
Yes
Im sure there is a plugin that allows you to easily communicate with a DB somewhere
Its not an easy question to answer without you doing your own research
I made my own API that I use to do it. And use VaRest (free) along with DBJson to serialize structures to Json objects to insert into the database.
Currently it holds all the users customizations in a json object that is a structure created in UE5
Thanks for help guys
Hello, i'm struggling with the FFastArraySerializer stuff. This is basically the code that is called client side whenever the fast array is updated (changed)
void FCardItem::PostReplicatedChange(const struct FCardContainer& InArraySerializer)
{
for (int32 Index = 0; Index < InArraySerializer.Items.Num() - 1; Index++) {
if (InArraySerializer.Items[Index].Card == this->Card) {
InArraySerializer.BookOwner->OnBookUpdated.Broadcast(this->Card.CardRowName, Index);
}
}
}```
So the server is never calling this
Whenever you Add/Remove/Modify an element of a FastArray you must mark it dirty appropriately.
Where you mark it dirty for a modification is where the server should also be manually calling this function
I'm already marking it dirty
and i was wrong, the server calls the function
but it does not work
There is some very extensive documented examples within the NetSerialization.h header for how to work with FastArrays
I recommend taking a look there to verify that you are using it correctly.
Thank you i'll try harder
the current setup is not wrong I'd say however it is pretty basic
If you are using UE5 they moved the FastArray stuff
Its found here
Read ALL of the comments ๐
Trying to replicate a 'seed' for my actor
But I only care to replicate it once I don't need the replication system checking it every tick
Is there a way to do this? Or better yet, is something like the 'actor spawn time' replicated that is the same for all clients that I could then derive a seed from?
Ok masta lets kill da ho !!
Are there default properties of an Actor that use that?
What do you mean?
Like say the actor has the ability to get it's lifetime. I know that's not a variable that is replicated for example, but I think some things are replicated. Is there a way to see what tings are currently replicated on a vanilla actor other than checking ever dorep function in the class hierarchy?
Pretty sure you can filter for Replicated variables within the Details panel.
You can also filter for all derived variables to
So coupling those together you should be able to display ALL replicated variables, at least those that are exposed to Blueprint.
That may only work for Blueprint based variables though, not ones exposed through C++
Otherwise, im not sure of any other mechanism to display all Replicated vars.
If thats what you are asking for?
Hi to all! When i'm trying to play in pie, with 2 clients, or 1 client, 1 listen server, i have two players, that cannot see each other, how can i solve this?
It is, thank you
Does anyone know when iris is suppose to be released an in a working/shippable state
or any updates really?
when replicating a variable , what should I choose so it will work fine
Probably years away
Is this a guaranteed rep option?
In the comments it says 'Attempt to send on initial bunch'
If you arent sure what the options are for, leave it as None
InitialOnly replicates the value only once when the Client first sees the Actor.
This is still true for net relevancy as well, each time the Actor Channel is opened, it will replicate the variables value, then it is ignored after that.
This is really good to know, thank you
leaving it as none, will still be normal replicated?
That is normal replication yes
thank You very much
Thank you. It's close, but still seems off a bit. Will keep poking around.
Well, I am doing something wrong. It keeps saying that my UFUNCTION has a required return type missing
UFUNCTION(BlueprintImplementableEvent, Category = "Authentication Event Dispatchers");
void OnClientAuthCaptured(FString NetworkId, FString Token)
do I have to put a 'void' somewhere in the UFUNCTION delcaration?
I don't see a 'return type' in the docs for ufunctions
The closing ; is on the wrong line
UFUNCTION()
void MyFunction(); // <------- this line
Hello guys
Hello guys, may I ask for your help about RepNotifes?
I have 3 simple classes, SwordClass, An ActorComponent named SampleActorComponent, and a Character class.
In the character class, there is a E key pressed feature where the sword is set. Why does the UE_LOG() in the RepNotify function OnRep_Sword is not showing?
Are you running as a Client or a Listen Server (Host)?
Oh sorry, I am running as a Client
So you are using Dedicated Server as the NetMode?
I am using a Listen Server
Ok well if you are using Listen Server then you arent a Client
You are a Host
Which means you are the Server.
In C++ OnRep_xxx functions are not automatically called for the Server
They must be called manually in code for the Server
Only Clients get these called for them automatically.
Oh. I am using the Listen Server as a NetMode, but I am playing as a Client, like this:
When the variable replicates to them.
Eitherway, what I said is still true.
Also.
As a Client
Setting a replicated variable will only change its value locally for that Client
It will not have OnRep_xxx called for it
As the value was not changed due to replication.
So calling SetSword on the E Key Press will not result in OnRep_xxx being called because you are doing it locally to that Client.
You would need the Client to send an RPC to the Server that tells the Server that the Client had pressed the E Key and to perform the necesssary action on their behalf.
We need RPC t-shirts, really
In the Server RPC, should I implement it like this?
Sure, if thats how you want it to work.
Is that okay or it could be improve?
Thats fine for a beginner.
Networking/Multiplayer is a field you can build a career around, so it gets vastly more complicated.
Yea. That's why I want to learn it
Uhmmm, If you do not mind me asking
How would you do a Server RPC when E Key is pressed?
Your image above looks like you are achieving that already?
Is that how you would do it also?
It depends on what I was trying to achieve.
Oh okay. After adding that Server RPC, will the "Sample Sword Log Text" appear?
Run it and find out?
How am I supposed to know what your code is going to do without having the same code to run on my machine?
What is USampleActorComponent attached to?
I created it at the Character class
Can you show me the Server RPC declaration
Here are the declarations
Yup. I Tried putting a log, and it shows
You want to breakpoint in the Server RPC implementation and check what the value of NewSword is
Is this it (the red circle)?
So then you need to find out why
Should I declare another Server RPC in the SwordClass and then call it here?
Your Player isnt having the Sword variable set on the Clients.
Its only set by the Server (Authority) because you have gated the Overlap Events from only happening on the Server.
Therefore when you press the E Key, the Client is passing the Sword value of nullptr to the RPC.
hello, So im trying to set it up to where if the max number of players joins then the session locks and no one can join, for some reason its not working but it looks to me like it should be working, can anyone help me?
You either need to let the Overlap Events be also called by Clients, or, find a way for the Clients to get the Sword value to change when its set by the Server on the Overlap.
Uhhh you dont want to do that
Set the max number of Slots.
oh
To however many players you want it to support.
New players wont be able to join if its already full.
well I also want it to not show up on my server list, that part works.
so change the get max number of players to get max number of slots?
No?
If you set the max number of slots to 4
Only 4 people can join.
A 5th person wont be able to join.
Because they would exceed the slot count
Does allowing the Overlap event called by clients is a good practice or should I find another way?
For you, as a beginner, its fine.
Oh okay. I'll try to find another way
Should I make the SetSword() a multicast function?
I tried making it a multicast function, it works now. But is it okay to make the SetSword() function a multicast function since it is a public function?
You cant keep asking me if xxx thing is okay to do. There are many many ways to achieve something and the answer is usually going to be "it depends".
Learning how to do things correctly takes time.
You seem very very new on your journey.
You have a lot to learn.
I would be less concerned with doing it "correctly" at your stage right now.
hi guys, for some reason one of my onrep methods isnt running.
void APlayerPawn::OnHealthUpdate()
{
//Client-specific functionality
if (IsLocallyControlled())
{
}
//Server-specific functionality
if (GetLocalRole() == ROLE_Authority)
{
}
//Functions that occur on all machines.
if (CurrentHealth <= 0)
{
SetDead();
}
}
void APlayerPawn::SetDead()
{
bIsDead = true;
SetActorHiddenInGame(true);
SetActorEnableCollision(false);
}
void APlayerPawn::OnRep_IsDead()
{
// is this function running log
UE_LOG(LogTemp, Warning, TEXT("OnRep_IsDead is running"));
OnDeathUpdate();
}
UPROPERTY(ReplicatedUsing = OnRep_IsDead)
bool bIsDead;
UFUNCTION()
void OnRep_IsDead();
void OnDeathUpdate();
i have confirmed APlayerPawn::SetDead() code is running correctly (both clients and server) but it i never get the log message when the bIsDead value changes, not sure what im doing wrong
If you are setting it locally as well then it wont be called as the value is the same.
interesting, that makes sense tbh, so i should set it server side/ client side only
SetDead() should probably also call OnRep_IsDead()
hmm ok
void APlayerPawn::OnHealthUpdate()
{
//Client-specific functionality
if (IsLocallyControlled())
{
}
//Server-specific functionality
if (GetLocalRole() == ROLE_Authority)
{
if (CurrentHealth <= 0)
{
bIsDead = true;
}
}
//Functions that occur on all machines.
if (CurrentHealth <= 0)
{
SetActorHiddenInGame(true);
SetActorEnableCollision(false);
}
}
this has most of the death behavior i want but it still doesnt trigger the onrep isdead for some reason'
Did you forget to add the DOREP for it?
oh ffs
ty yeah i missed that, just learning netcode atm
๐
sorry mate...
my death code and behavior is working perfectly and im trying basically the same thing for but respawning but i can't get it to work
void APlayerPawn::OnDeathUpdate()
{
// log player death
UE_LOG(LogTemp, Warning, TEXT("Player %s has died"), *GetName());
if (bIsDead)
{
FTimerHandle respawnTimer;
GetWorld()->GetTimerManager().SetTimer(respawnTimer, this, &APlayerPawn::Respawn, 2.0f, false);
}
//Client-specific functionality
if (IsLocallyControlled() && bIsDead)
{
}
//Server-specific functionality
if (GetLocalRole() == ROLE_Authority && bIsDead)
{
bIsDead = false;
}
}
void APlayerPawn::OnRep_IsDead()
{
OnDeathUpdate();
}
void APlayerPawn::Respawn()
{
CurrentHealth = MaxHealth;
SetActorHiddenInGame(false);
SetActorEnableCollision(true);
}
code is confirmed to be running but depending where i call respawn i get different behavior (obviously) i would have thought settling the bool on the server... and then doing the respawn function on all machies would work fine?
Whats not working exactly?
Respawn should most likely be managed by the Server only.
It should also not be handled by changing a variable like bIsDead
Let the Respawn function set bIsDead to false
Respawn is like "resetting" the pawn.
That should be a discrete operation on its own, not tied to the value of another variable.
OnDeathUpdate should not be changing bIsDead
on my pure client it 'respawns' but is not controllable, doesnt respawn on client+server side
i think i get what you mean
Why are you only hiding the pawn instead of destroying it when it "dies"?
no particular reason just the first methods i stumbled across, just trying to get something working to understand the netcode if that makes sense
Sure.
on death though,
void APlayerPawn::OnHealthUpdate()
{
//Client-specific functionality
if (IsLocallyControlled())
{
}
//Server-specific functionality
if (GetLocalRole() == ROLE_Authority)
{
if (CurrentHealth <= 0)
{
bIsDead = true;
}
}
//Functions that occur on all machines.
if (CurrentHealth <= 0)
{
SetActorHiddenInGame(true);
SetActorEnableCollision(false);
}
}
i hide and disable collisions on both server and clients? i figured the same for respawn?
Its common to spawn a new Pawn upon respawn for a Player.
ahh ok will switch to that
And let the "dead" Pawn be destroyed
That way you dont have to worry to much about correctly resetting them back to a default state etc
i guess i would then need to do this at the player state level not on the pawn itself
makes sense
We handle respawning our Players within the GameMode.
The PlayerController has a flag on it that says that Player wants to Respawn
yeah or gamemode, makes sense
The GameMode constantly checks each Players flag
yep im planning on doing something similar
If one is true, it calls RestartPlayer on that PlayerController
We display a respawn screen on the HUD when the Player dies.
They opt into a respawn via the HUD
Therefore the HUD sets that Flag for the Player when they want to respawn
The GameMode handles the rest from there.
AGameModeBase::RestartPlayer is a function you should research.
ooo thank you
when you say research.. am i using the docs wrong? https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/GameFramework/AGameModeBase/RestartPlayer/ there isn't much here ๐
Tries to spawn the player's pawn, at the location returned by FindPlayerStart
The actual source code is what I meant
Read the source code for that function and find where else throughout the code base it is called
So you can understand how it is used and why.
ahh yep makes sense sorry
Do we really not have a blog post about UObject replication pinned?
I could swear we had something
I'm having this issue in host client mode, not in solo
What's the newest way to do that? Trying to do this in a Component. Overriding ReplicateSubobjects isn't really listed anymore in the docs.
You gotta make sure you aren't creating Widgets on non-local players. We can only help you if you also show the code that it's reporting
Yeah BeginPlay is called by every instance of an Actor
PlayerController exists on Server and owning Client
The Server calls this for Client PlayerControllers
You have to put a "IsLocalPlayerController + Branch" in front of the UI stuff
it works! thanks
Found it, was James' blog post
Idk, I can't find the pin
Repin it is
I should update that for the subobject list in UE5..
Does that Subobject list thing affect UObjects in Components?
Couldn't find anything about that
I have a pawn that has to replace the character when the player interact with it
it works in solo, but in host client works only in host
in the client the camera moves like the pawn get possessed right, but no inputs
the setvisibility doesn't work too, but no errors in console
You make a lot of assumptions here
- Is this being called on Client or Server? The little Icon on the "Possess" node means that this has to be called on the Server. Destroy Actor also needs to be called by the Authority/Server.
- SetVisibility might not be replicated, and if you again call this on the Client, it won't replicated.
Question: If I have a UObject Pointer replicated with RepNotify. And I have an Array (that is not replicated) of supported UObjects, of which one can be set to that single pointer, does the PrevValue of OnRep functions work on this?
Urrhm.. I do not know.. but also maybe don't understand the Q ๐
I'd imagine the non-replicated version doesn't interfere, as the OnRep only cares about the property it's for
Question is mainly if this would give me the proper "previous uobject" on the client when the OnRep calls:
UFUNCTION()
void OnRep_CurrentState(UState* PrevState);
UPROPERTY(Transient)
TArray<UState*> States;
UPROPERTY(Transient, ReplicatedUsing = "OnRep_CurrentState")
UState* CurrentState;
But I will just assume it does
Oh roger.. yeah I'm pretty sure that would be fine
hello! ๐
Does anyone know if there is a way to know when the playerstate has been replicated?
wait, sounds like what I need ๐
OnRep_PlayerState
I found this way to get the last element changed in the Fast Array :
void FCardItem::PostReplicatedChange(const struct FCardContainer& InArraySerializer)
{
const int32* Temp = InArraySerializer.ItemMap.Find(ReplicationID);
InArraySerializer.BookOwner->OnBookUpdated.Broadcast(Card.CardRowName, *Temp);
/*for (int32 Index = 0; Index < InArraySerializer.Items.Num() - 1; Index++) {
if (InArraySerializer.Items[Index].Card == Card) {
InArraySerializer.BookOwner->OnBookUpdated.Broadcast(Card.CardRowName, Index);
return;
}
}*/
}```
Is it the way to go or it has some issues ? But it is still not updating server-side, only client side. It might be a widget problem tho
I'm stupid, thanks man! ๐
The Serializer itself contains those callback methods as well
Isnt it what i'm using rn ? With PostReplicatedChange() ?
The two are different really
How can I use it ?
Just declare the stuff you need:
I only read about PostReplicateChange() personnally
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms);
void PostReplicatedAdd(const TArrayView<int32>& AddedIndices, int32 FinalSize);
void PostReplicatedChange(const TArrayView<int32>& ChangedIndices, int32 FinalSize);
void PreReplicatedRemove(const TArrayView<int32>& RemovedIndices, int32 FinalSize);```
Oh nice
So i can isolate the index that has been changed in FFastArraySerializerItem
Saves the awkward lookup of the index
I prefer this way myself
They also fixed PostReplicatedChange not being called when UObjects were mapped too, in 5.0 I think
There used to be a bug where only the element received that call if an internal UObject was mapped
Oh I see
But in my testing, that seems to have been fixed
Looks like okay for me too
But why an array of indices ? I don't see when it is called ^^'
So you can access the elements directly
e.g.
{
for (const int32 Idx : ChangedIndices)
{
const FInventoryEntry& Entry = Inventory[Idx];
}
}```
Is the post by @pallid mesa pinned? I didnโt see it: https://vorixo.github.io/devtricks/data-stream/
Super awesome resource.
Yeah but we do add each element at a time so why isnt it called at each time we add/change/remove an element with the specific index ? Or is it waiting a bit to be called so we can save bandwidth ? Or something like this ?
Guys I'm running into a problem and I wonder if anyone could point me in the right direction? =/ I have a listen server which on BeginPlay spawns a few characters (turn based tactical combat game), then places these characters in a list ordered by their turn priority, and then sends a multicast to tell all clients about this list. The thing is that when I send the RPC, the references to the characters on the client side come through empty. I assume this is because the characters haven't actually spawned yet on the client (despite them being replicated), and the RPC is arriving before that happens? I'm just wondering if there's an elegant solution to this?
It's only called locally after replication - it doesn't use any bandwidth to call these functions
They're never called Server-Side
Same for the per-element calls
It's pinned in heart๐
Oh I see, so replication is like periodic if i remember well (checking every frame which property to send, etc)
yeah. Usually all the changes to the fast array are received at once
Ok thanks !
Because i have a function that gives 3 cards, a simple for loop that calls AddCard() 3x times and sometimes I just add a simple card.
in both scenarios, i should be able to handle the changes
This is my "Melee attack". It works fine when playing on dedicated server as client but problem is it doesn't work when playing offline/solo.
that switch has authority is problem I think but if I connect "authority" then it play like two times when playing client. i mean that sound play 2 times row.
i.e. the difference btw, this is literally how it's called - so directly afterwards. So it doesn't really matter if you use the per-item or serializer callback, but serializer is just more convenient at times
{
Items[idx].PostReplicatedChange(ArraySerializer);
}
ArraySerializer.PostReplicatedChange(ChangedIndices, FinalSize);```
Yeah just checked source but i'm sticking with serializer for some tests
how?
I just forgot that I cant replicate a uobject
I understand how to replicate stuff and what it does
I just have a problem with replicating the data.
And making an array of UObjects is not a good idea
because I need to replicate what is inside the object
I know that FinalSize wont be used at all since I have a fixed card limit storage fixed in BeginPlay()
but if the array is not replicate I cant get to what is inside it that I want to replicate?
so what do you think I should do?
Move the data somewhere where it can be replicated. Have clients spawn objects that the list view can look at locally.
Don't replicate the objects themselves, that'd be ridiculous
Hello friends. I have a problem in a multiplayer project. As in the video, I created a function like repnotify and there is a destroy command in that function. The actor is fully replicated. What I want to do is make the severed head disappear. It works on the server, but the client does not. What would be the reason.
I wrote a ListView specialisation that uses FNames as keys instead of objects, so it can be used to index into an array of structs and it still works with BP/UMG. The UMG list view only supporting UObject is pretty dumb IMO
There's something hideously ironic about it being a performance-oriented widget, which then needs a UObject created for every entry.
Hi, I need a tutorial for possessing pawn in multiplayer
but when I use AddItem I have to add a UObject
that contains the data if want to see it on the list view
The server still does not broadcast the delegate
void FCardContainer::PostReplicatedChange(const TArrayView<int32>& ChangedIndices, int32 FinalSize)
{
for (int32 i = 0; i < ChangedIndices.Num(); i++) {
int32 Index = ChangedIndices[i];
BookOwner->OnBookUpdated.Broadcast(Items[Index].Card.CardRowName, Index);
}```
Move the data somewhere else, then spawn a UObject locally that just references that data
You cannot replicate the objects, so you have no choice but to move it somewhere else
The Server never calls those functions, only the Client
If you want the Server to do it, call it manually when you change/add the item
The server actually calls the function but the changes are only made in the clients HUD
Oh I see
They are only called when replication data is recieved
like an OnRep
yep
oh I think I got you, so like in the Gamestate I can save the struct and I will just reference the struct in the UObject?
yes
ok thanks I will try that
anyone knows how is order and deserialization of OnRep_ and netmulticast RPC on client ?
thats what I get from the follwing code.
//this is what I get on client
//bIsOpen is updated to new value
//CastOpen_Implementation is called (both bIsOpen and bNewState have same value )
//OnRep_IsOpen is called then
UPROPERTY(ReplicatedUsing=OnRep_IsOpen)
bool bIsOpen;
UFUNCTION(NetMulticast, Unreliable)
void CastOpen(bool bOpen);
void CastOpen_Implementation(bool bNewState)
{
bIsOpen = bNewState;
}
this is very annoying cause I need to do different things if its initial replication
if they just became net relevent, I dont want to play sound or ...
thats why im using OnRep_ and NetMuticast at the same time
You can do that a much easier way
{
const bool bIsOpenChannelPacket = GetWorld()->TimeSince(CreationTime) == 0.f;
}```
The order between RPC's and properties is undefined and varies depending on RPC type as well. Generally it's not something you can rely on
Is there a pretty way to replicate State Data that is specific to a state as well as State Data that is "general"?
I currently have a system with one Struct, lots of Data and a really ugly OnRep. That OnRep handles a lot of "From -> To" State stuff.
I now changed it to be a UObject per State, (instead of an Enum), so I can easier make new States and ensure the specific logic of each state can be handled in Enter/Exit.
A lot cleaner. However I still have general data that is not specific to a State. Like who touched the actor the last time or some timestamps.
Those are important when the state changes (and replicates), so I need them replicated when the State change (UObject pointer) replicates. I guess I can't just replicate them as individual properties.
I assume I would still need the Struct, but have the general data and a pointer to the current UObject State in there, or is there something prettier?
How can I reference the only other player in the lobby so I can show their name inside text? This will be used for the end screen to show who won
Do you have a variable that stores the name?
The GetOwner->HasAuthority()) is useless since the function is only called by server right ? It will always return true ?
if (GetOwner()->HasAuthority()) {
if (APawn* MyPawn = Cast<APawn>(GetOwner())) {
if (MyPawn->IsLocallyControlled()) {
OnBookUpdated.Broadcast(Book.Items[Slot].Card.CardRowName, Slot);
}
}
}```
@chrome bay Btw finally got it working !
void FCardContainer::PostReplicatedChange(const TArrayView<int32>& ChangedIndices, int32 FinalSize)
{
if (ChangedIndices.IsEmpty()) {
return;
}
if (APawn* MyPawn = Cast<APawn>(BookOwner->GetOwner())) {
if (MyPawn->IsLocallyControlled()) {
for (int32 i = 0; i < ChangedIndices.Num(); i++) {
int32 Index = ChangedIndices[i];
BookOwner->OnBookUpdated.Broadcast(Items[Index].Card.CardRowName, Index);
}
}
}
}```
And in the AddCard() :
Book.Items[Slot].Card = TempCard;
Book.MarkItemDirty(Book.Items[Slot]);
if (APawn MyPawn = Cast<APawn>(GetOwner())) {
if (MyPawn->IsLocallyControlled()) {
OnBookUpdated.Broadcast(Book.Items[Slot].Card.CardRowName, Slot);
}
}```
Hi All, I've encountered lately an issue when using Blueprints RPC/Multicast - as soon as you introduce lag/latency to the game, it all goes to sh** and get rubber banding like crazy
is there a way around that - or only option is to use C++ and use Custom CharacterMovementComponent in order to use the built-in client predictions stuff?
If I want to add a basic text chat system, how do I do it the right way?
Does it amount to just same old RTPCs in whatever-class-that-works (like a player state) or should there be more to it?
There is no easy way around it, predicting things needs to be cared for explicitly
I'm not sure how to set that up
Like how do I get the reference of the other player in the lobby
and display it proplery on a widget string/text?
hello guys all right? I have a question. I wanted to make a Bolean type variable update only in the client that needs it and not in all the clients, for that I created this function that I leave in the image. The question is: is what I did correct or is it the most optimal? Thank you so much
Hey guys, I am trying to replicate Dynamic Combat System. So I got the character to replicate movement and draw weapon. However if the player switch to combat stance before someone join. The person that join later doesn't see the changes ( Other player still in non Combat stance ). How can I update the state of the game when a person join?
Sounds like you need onRepNotify
The variable is in sync with connected clients. The problem comes when a new player Connect the game, after the draw weapon is done
Yep, you need to notify the new client that the variable has changed.
Else, itโll go with the default
Thanks for the help, can I get a bit of guidance >_>
Suppose there are 2 players, one of them changed the variable. How can the newly connected client knows the specific actor that have changed it's value?
I post the video to illustrate the problem
just replicate bHasDrawnAnimeWeapon
They already told you. OnRepNotify
Read the pinned posts to learn the basics of networking in Unreal.
I am still learning the basic, I think I got the concept wrong. Making the variable replicate should keep the value of the variable.
Perhaps my problem is I didn't have component replicate checked
gonna see if that fix the issue.
For the third time, use OnRepNotify. The variable needs to be an OnRep variable.
You will run into future issues with state management if you are not using OnReps
Got it, thanks
you today?
Again, go through the pinned posts.

Hi! I'm testing the Lyra Starter Game project and trying to join to a LAN session, the game find correctly the session I previously create in another PC but every time I tried to join to that session, it fails...Does anyone have the same problem?? I've tried playing the game from the editor and from a development build and get the same results.
Can anyone help with this?
I think first you need to have a way to store said playerโs name. Like a text box or something that stores the input as a string, so that you can grab that controller and its copy of the variable
So the only thing I changed is to move the UStruct declaration to the game state.
Can I replicate the struct variable in the UObject?
no I also need to change the place of the variable
and replicate it in another place
but what about the UObject?
I need to add item with data in it.
So I'm having an issue in this gamemode now. It seems that when I added this stuff, the PreLogin all gets called, but none of the OnPostLogin is getting called, do I have to add in some kind of call for that somewhere in the C++ so it continues or?
going to throw some other debug messages in to see if I can catch where it's breaking.
I bet you the network id I am grabbing on the C++ end is not the same as the one from the blueprint...
yea.....
[2023.05.04-06.03.53:850][439]LogBlueprintUserMessages: DESKTOP-SDE8QNO-C8057D284D5169947F8C19867A8D73EE
[2023.05.04-06.03.53:850][439]LogBlueprintUserMessages: DESKTOP-SDE8QNO-C805
so that has to be fixed somehow ...
@storm zinc Did you forget to call the Super implementation when you overrode PreLogin?
Show your code for your PreLogin function
void ACustomGameMode511::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
{
Super::PreLogin(Options, Address, UniqueId, ErrorMessage);
FString playerToken = UGameplayStatics::ParseOption(Options, TEXT("Token"));
if (playerToken.IsEmpty())
{
ErrorMessage = TEXT("Player Token not found");
}
OnClientAuthCaptured(UniqueId->ToString(), playerToken);
UE_LOG(LogTemp, Display, TEXT("The Client's Token is %s"), *playerToken);
}
I think it's working but...
that UniqueId->ToString() is giving me some serialized data at the end, that i'm not sure how to get that in the blueprint...
You mean this C8057D284D5169947F8C19867A8D73EE?
ya, after the C805
the bottom row is the one from the..
which is just a default one.
But that PlayerState doesn't seem to have any 'get unique id'
It should
it isn't a real player state object, it's just a default class (built-in)
Huh?
it doesn't have an actual blueprint assigned to it
it's just the unreal default association
Thats fine
The UniqueNetId wont just be the Player name.
It all depends on what OnlineSubsystem is being used as to how the UniqueNetId will look
ya, the value that is coming back is the pc name, I have steam turned off.
If you were running Steam, it would be your SteamId
If you were using EOS it would be some EOS based Id.
mm
So do you know of any way to pull the controllers unique id from blueprint?
like with that extra serialized data, or would that be the replicated part being added.
however the engine identifies the unique player should they have the same 'name' assigned in the Name=""
when you open a level
I assume that's what it does, uuid type of thing for 'randomness'
Dont get caught up in all that. Just accept the fact that the UniqueNetId is a unique identifier.
What version of Unreal are you using?
right, that I can handle. But the ToString() of that value has the extra characters, that the 'name' of the player does not have. And I don't see any way to get it.
It's Unreal 5.1.1
Thats what Im saying, the ToString value is the UniqueNetId, the "extra characters" arent extra
ahhh
The entire string is the UniqueNetId
The fact that it contains the name of the Player is neither here nor there.
Dont rely on that
right
Rely on that the entire thing is unique
UE5 might have an exposed UniqueNetId via the PlayerState
But I doubt it.
You would likely have to expose it yourself
mm ya I don't see one, even without context sensitivity on
In the same way you exposed that Event in the GameMode
ya that's what I was afraid of LOL
You will probably have to override the PlayerState in C++
Or alternatively, create a Function Library
That might be easier for you?
UE exposed it to BPs via FUniqueNetIdRepl but it's not exposed by default
hm
Im on 4.27 so not really sure what 5 exposes or not
The go to way is to either have a PlayerState CPP class that exposes it or to write a simple static function in a CPP function library
The easiest approach would be for you to create a Blueprint function library (which is a C++ class) and create a function which takes in a PlayerState and returns the UniqueNetId
this is like 200% more C++ than I was hoping I'd have to write HAHAHA
That way you dont have to override the PS and do Casts everywhere
Multiplayer will require CPP one way or another
:/
If you want to do anything of any complexity
ya, I mean, the way this thing is doing is meant for Sessions.
Blueprint only MP is not going to allow you to do much outside of the basics.
Which I can't use.
Just a matter of time until a given user hits a wall with blueprints. For you it's the unique net Id then
You are already in C++ land anyway already, so why stop now ๐
oh god
I haven't even written the event system and I am starting to regret it HAHA
I didn't understand that a dedicated server is one map either.
You wont regret learning C++
I thought that your server would run and people could load maps and the server would load the map for that user.
Unreal has always been one server one map.
So I am assuming that at some point, if a user say interacts with a portal. The server gets an event fired that triggers a 'load player into a map' but transfers them to a server in some way so it can handle multiple maps / instances
In order for one Player to have a different map, they would have to either be sent to another server that has that map, or load that map themselves as their own session.
Depending if you are doing Dedicated or Listen Servers.
gotcha
for now, I think we're going to just make the 'event' far far away from the rest of the server area. lol
give it its own skybox.
be done.
And that game looks pretty slick DevilsD
the ship combat looks pretty smooth.
When you do something like that, do you have like... one server that flips maps and just has like 'lobby mode' and then the server loads a map and players connect w hen it's loaded?
Do something like what?
The FPS Levels are streaming levels inside the Ship combat levels
ahhhh
one of the other guys is making a 'train' is a level with one of the new features.
he thinks it will work, but I told him I don't know...
This train goes around the world in real time, and he wants them to 'port to the level streaming portion' that moves around...
but I assume it's still going to affect multiplayer because now you're updating like X number of peoples positions in the world
he thought about doing like some camera with texture projections to a remote train area away from other people so they would not be 'loaded' in the same area as they move around... But
that way people inside the train would see the outside world as it went around
kind of like how a minimap would work in a way
How to implement change pawn possession in multiplayer?
You may need to explain with a little more detail what you are asking for help with?
I did this blueprint to make the player going on boat, it works in local, it works on host, but not on client
on client the camera change correctly, but no visibility change happens and inputs doesn't works anymore
Hey, if I call a client RPC and pass a pointer to a replicated actor, but that has not yet been replicated to the client, it will call the RPC with a nullptr, is there a way to wait for the object to be replicated before the RPC is executed on the client?
what info you need?
No, its impossible to know when it would be replicated, the only way to know is to have the Actor send an RPC back to the Server when it BeginsPlay to tell it that it was received.
@lucid wren Possessing a Pawn can only be handled by the Server.
See these Icons.
That indicates that only the Server will execute those
Ok, thank you
so, how can I handle it?
May I need to create an rpc from server to client. where is an example?
I'm reading this
Other ways for Replication are so-called โRPCโs. Short form for โRemote Procedure Callโ.
how to create that rpcs?
mine are different from yours
So these are the two things in the playerstate.h for UE5:
/** Gets the literal value of UniqueId. */
const FUniqueNetIdRepl& GetUniqueId() const
{
return UniqueId;
}
/** Gets the online unique id for a player. If a player is logged in this will be consistent across all clients and servers. */
UFUNCTION(BlueprintCallable, Category = "PlayerState", meta = (DisplayName = "Get Unique Net Id"))
FUniqueNetIdRepl BP_GetUniqueId() const;
I am assuming that the UFUNCTION one is the blueprint one that I can see by default, while the other one is the one that is what I want.
So perhaps just adding a UFUNCTION thing in there, and putting a different name on it may work?
You need to create a new PlayerState child class though
Dont change the Engine Source code
ya.
So I did this
UFUNCTION(BlueprintCallable, Category = "PlayerState", meta = (DisplayName = "Get Literal Unique Net Id"))
FUniqueNetIdRepl& GetLiteralUniqueId();
And then I have this in cpp:
const FUniqueNetIdRepl LiteralUniqueId;
FUniqueNetIdRepl& APT_PlayerState::GetLiteralUniqueId()
{
return LiteralUniqueId;
}
I am assuming in the constructor I have to somehow assign it maybe?
No you likely want to return it as a string, since your function in the GameMode is passing it out as a string as well
Im guessing you want to use it in conjunction with that?
To compare?
ya just doing a compare to match it up with what was received in the PreLogin part.
So right now it looks like this:
#include "PT_PlayerState.h"
#include "GameFramework/PlayerState.h"
#include "GameFramework/OnlineReplStructs.h"
const FUniqueNetIdRepl LiteralUniqueId;
// Sets default values
APT_PlayerState::APT_PlayerState() : Super(ObjectInitializer)
{
}
FUniqueNetIdRepl& APT_PlayerState::GetLiteralUniqueId()
{
return LiteralUniqueId->ToString();
}
Not sure if that super thing needs to be there
Why are you adding LiteralUniqueId?
Also you cant just return it as a string if the function is expecting you to return a different type
I thought that it would get mistaken for the one that exists, and isn't the one that I want
You dont need to make a new one.
OOOH right it has to be FString
Just call the function
ahh k
return GetUniqueId().ToString();
I have to go, someone else maybe able to help you if you get stuck.
Good luck.
ok ๐
ty so much for your help ๐
I have to create an rpc client to server and call it for Possess?
can rpc inputs params have controller object ref?
help pls
the visibility problem is fixed now
but inputs still not working on client
Pro-Tip, when you have the UE PlayerState.h file open in VS. Don't Build with it open, because it will select that project and rebuild UE5 LOLOL I caught it afterwards, hasn't completed, now I have to wait for the engine to compile again... then finish my playerstate HAHA
sigh
thank god for 16 cores I guess
it's strange... inputs are recognized, but the boat doesn't move it seems that it's trying to go forwards but gets pushed backwards on next frame
Hello, someone can help me with the replication in all clients?
I dont understand the Server,NetMulticas,Reliable flags in UFunction
afaik that doesn't work if actor is loaded from file and bNetLoadClient=true.
btw GetGameTimeSinceCreation() == 0 made some problems for me I don't remember well but it gave wrong result at level load time. Actor.CreationTime was 0 but MyWorld->GetTimeSeconds() was higher . I finally wrote the following :
bool TDUtils::IsInitialReplication(AActor* actor)
{
if(!actor->HasActorBegunPlay() || actor->GetGameTimeSinceCreation() < 0.1)
return true;
return false;
}```
I finally added a new replicated property bIsOpenChangedRecently. this way client will be aware if the property changed recently. it seems there wasn't any other way for me.
NetMulticast if you want to call from server to all clients
Reliable if you absolutly need that this rpc gets executed (don't use it on rpc called frequently)
I can share you my code? bc i dont know what im doing wrong
I'm new in UE too, so i don't know much. i'm strunggling with multiplayer things ahha
look at this, very good doc https://cedric-neukirchen.net/docs/multiplayer-compendium/remote-procedure-calls#rpcs-in-ue
Other ways for Replication are so-called โRPCโs. Short form for โRemote Procedure Callโ.
I have this with server reliable, playing with 2 player as Clients but dosent move, should move right?
this happens only on client....
@chrome bay
how would this become 50
if playerstat is preset to "500" default hp
and item stats input is set to 50
is it better to replicate variable or rpc to server for sending inputs to server?
You can't replicate variables to the server
Replication is from Server to Client only
So that option doesn't even exist
So your only option for sending information to the Server is via an RPC
this is working!! finally my boats can move even on clients
hello when i spawn actors on the server i use SetActorLabel and Rename to give them different names but the client doesn't receive the new name, what can i do to replicate that?
Is too hard to replicate playing as client, works as lisent server but not at client
what do you mean?
I cant replicate the movement of a Elevator playing in client, i dont know how to do it
If i put the property server dosent work, if i put the property netmulticast only works where i activate the button to trigger the elevator movemetn
Hi all, currently having a bit of issue with this one, Server spawns the users, logic runs fine in editor even running a separate server instance. I get that vale, but when I run it on a live server. There is no value
I am guessing it might be something to do with the Unpossess event since that gets unpossessed server side?.. Not sure
Side note: Server RPC is needles as OnUnpossess is server only
Unless you have a meaningful use for it somewhere else and you're just calling it here
Right, thanks WizardCell, I want to send the User Id on OnUnpssess which is in the PC and in editor it seems to get through, but as I mentioned on the live server not. Should I store this User Id on the Pawn perhaps?
Hello everybody!! I have a dumb question realted to the replication graph. When I launch a client from the editor, I can use all the Net.RepGraph.* commands the Replication Graph has. But when I launch a local server, and then I connect to it with a client, I cannot use them. I'm sure I'm missing something obvious here, but I can't find it.
So, do you know how to use RepGraph debug commands from a client?
Thank you very much!
I think you need to run EnableCheats command first to enable the CheatManager on client
I'll try that to see if it works! Thanks
I just noticed replicating movement and predicting isn't an easy task for someone with no knowledge of C++
time to grab Udemy Tutorial and learn from the ground up.....
Youtube Multiplayer Bp tutorials can only get soo far ๐ฆ
@young kiln if those debugs cmds are console variables , then u r just chanaging them on client.
use 'ServerExec Net.xxx value' to run them on server
Does anyone know if the player's platform is replicated somewhere?
Or is it only possible by calling GetPlatform on the client?
every oncomponentbeginoverlap happens server side?
That did it! Now I have to solve other things but at least I got the breakpoint hit when calling it! Thank you very much!!
Happens on server & client
Spawn Actor has to be made server only or for all?
Try it and see what happens
server only spawn on everybody, client only spawn on client only.
Then you need to go through the pinned posts and learn the foundations of networking inside of Unreal.
Cedric's network compendium is pretty much where everyone starts these days.
it works!
finally i finished the blueprint of my boat to be possessed and unpossessed by players in multiplayer env
There is a way, net.DelayUnmappedRPCs 1
Can you make multiplayer in bluprints not even looking at C++?
yeah
depends on what though, if you want to use something like the gameplay ability system, you'll need a bit of c++ to set it up still I think
I have this with server reliable, playing with 2 player as Clients but dosent move, should move right?
hey, does anyone have any idea why net.DelayUnmappedRPCs is not reliable? seems to fix the issue of pointers being null in reliable RPC calls when the actor that it points to has not yet replicated
however, with around 400 ping, and 10% pktloss, it just seems to call it nullptr
How to do this in Multiplayer?! Is there a "Play Sequence By Int" or some way to seed this?
I keep getting No owning connection for actor The actor is there on map load, it has these settings.
If I fire a function as client with a keybind, it says it won't process the server function.
In my head I believe it spawns once on server, and when a client joins, then it's replicated to them as well so there is 1 per client and 1 on server. how is the server actor not the owner of the client ones?
Clients are separate instances, not children of the server
if it's doing net load on client aren't those actors on the clients owned by the server actor?
No Owning Connection means you are calling a Client or ServerRPC on a non-Client owned Actor, or not?
There should be. Select or Switch maybe?
Maybe ask in #animation
how would I ensure that across clients this bp is owned by the server actor?
I don't quite follow what your goal is here
The Actor is owned by the Server if you don't set a Client as Owner
I'm making a BP_VehicleRequestManager
it's a single bp
it's loaded on the map
and anyone who joins the game should have a client version of it... hopefully
Sure, and ?
they can hit a key that's set, and then call a server event (reliable)
the server spawns a vehicle that belongs to that requesting player
Server RPC on non Client owned Actors don't work
spawning the vehicle and leading up to the event of requesting the vehicle from server is fine
ok
so how do i make the actor owned by the server?
so that clients can rpc using it
Doesn't work.. I tried on #animation but wasn't getting any responses. I suppose this is an animation question if we can't replicate the random sequence node.
the goal was to have these bp managers be things I can plug and play in any multiplayer level
so in order to have that kind of communication it could only be done through gamestate/PC/Char?
PC/Char/PlayerState
You can't ServerRPC in Actors if the aren't owned by the Client that wants to do the RPC
sorry I'm really getting hung up on the net load on client thing then I'm struggling a bit.
So net load on client. The server owns the actor.
but when it replicates to clients. Those clients don't own the actors replicated to them?
NetLoadOnClient has nothing to do with ownership
Only one Player/Server can own an Actor at a given time
Ownership is a property of replication
You can provide an owner when spawning replicated Actors on the Server or set them afterwards with SetOwner, but still requires the Actor. And again only ONE Player can own an Actor at a time
An Actor in the Level is by default owned by no one. Which is basically similar to it being owned by the Server.
There is 100% a node that allows selecting a sequence based on an int
It might just be called a bit strange
Try "On int" or so when searching
Also please read the Network Compendium. Especially the Ownership part
Thank you, yesss I used that alot with the GS/GM/PC/PS/Char replication stuff which I luckily had no problems with when it came to replication.
But I'm definitely failing to understand actor ownership. I'll definitely look into that. thanks again!
can someone help me?
so
AddItem function of the list view requires a UObject with a data to add to the list view but the problem is that the data needs to be in the UObject but I cant replicate it, so I made a struct that contains he data in the GameState and tried to reference it in the UObject but it still wont work because I cant replicate the UObject and I have to use it because of AddItem.
Does anyone have an idea about how to fix that, I am struggling with this for days, Thanks!
if you need to see something from my code to help me, just tell me what and I will send it. I really need that help
Hey all, running an event from the exiting player controller OnLogout from the Game Mode, fails to run.. I guess something to do with the controller already destroyed.
I want to get the custom ID of the exiting controller into an array on the server which removes this Id in the end, but i am getting an empty variable instead. Any advice on how to do this? Thanks
If this is a Server RPC, then no, it shouldn't work. You can only trigger a ServerRPC through a client owned actor, which means something that the PlayerController owns. As they're unlikely to own the elevator, you need to make the RPC through something the player owns. Like their PlayerController or Pawn. Usually you can do this by RPCing some generic stuff or a pointer through the controller or pawn and then call an interface function on what you want to use.
Does this help: https://youtu.be/pvDgmnxewuk
๐ง๐ปโ๐Support us on our ๐ฒPatreon for awesome benefits: https://www.patreon.com/kekdot
In this video we start working on a nice base setup for multiplayer projects. We go over how players connect and disconnect and how we can have an overview of the connected players in our session by storing a reference of them in our Game Mode once the OnPostLog...
doing this on Game Mode and the pickup is spawned in the level but the Pickup mesh is invisible
setting replicated for the static mesh works perfectly
the actual actor is set to replicated true
actors basically replicates sub components, so why the mesh is not replicated?
with and without PickupMesh->SetReplicated(true);
this red line is draw debug line
what are you doing @nocturne quail
multicast? to spawn a replicated actor?
i recommend reading the UE networking basics
yes multicast
Oh I found it.. it was Select but it can't plug the pins, have to use the dropdown.
you can expose the pins
I meant like plugging animation sequence into Select node, it's not possible to do.
I did it, I successfully replicated UObject by using repkey.
but on actors It is not working
and i tried all other options, all need to set replicated on the component
That doesn't work I'm doing sequences not poses. That blend poses by int just plays one frame instead of the entire sequence.
no it doesnt
the actor is itself replicated
How can I play the whole sequence using blend poses by bool?
It doesn't work. It just plays one frame and skips to the next one. Hit play and see.
then you did something wrong
i have been using ue for like 6 years, and i know what i am talking about ๐
and doing the same thing on level blueprints, works fine
with GM it has problems
How many times have you actually done this in 6 years? It just plays one frame at a time.. stick a random number in there to see.
what is that picture supposed to be
That's using blend poses by int, it's stuttering because it's changing the animation every frame... Plug a random number to see..
working fine
you can't do random int like that
that will change every frame
that int will change every frame 
This only lets you pick out of two and you're not using a random number.
If you use a random number the index also changes every frame so it doesn't keep playing the same animation.. 6 years huh๐คฆ
its your logic that is flawed
you never stated you are changing the index every frame
am i a mind reader?
Show me with a random number.. I need to use a random number so only logic using random number please.. Not interested in anything else.
Thereโs a better way to have this convo, surely
Oh you didn't see my previous question.. that was what I was asking.
little bit of googling and searching can return that
I did all those and it doesn't work in multiplayer.
Very Funny... ๐ #multiplayer message
but most games for idle stuff, they go through the idles in a sequence
not randomly, and if you ever played games like CoD, the idle animations are different on each client ๐
I'm not making most games.
like i said, you can not do random, you need to do a seeded random
ie, it needs to be determenistic
I already found a couple of solutions.
as long as there is no rpc's/networking involved, hopefully those solutions work
Can use transitions to branch or select node.. the blend poses and random sequence player do not work for what I'm doing.
Your solutions are much weaker / lazier in comparision to these far superior solutions.
๐
COD team must be lazy.. I think these modern games are just copying each other.. Playing Redfall feels like Atomic Heart and High on Life.. My game may never get released so I may as well attempt it properly and because I'm a hobbyist and a masochist. ๐
it's not lazy
its the fact, other clients don't really care what idle animation they see
so why waste resources/time
You're on the COD team? Redfall has wierd walls of water and then so does Atomic Heart... I do not know how they all got the same idea at the same time.
Good point but it's just one int and I have first and third person view with seperate shadow meshes so it gets a bit tricky if I have desyncing. I still have to do that part and will keep this in mind.
Why would this matter though? The local client would play the idle animations locally for both, which would locally sync both for that one client. That won't change anything based on syncing it for other clients.
Sure but I'm not just intending to use this for idle.
How does GAS do that? I haven't looked into that yet. I thought they were using some sort of persistent Cue actor to multicast montages or something.
Oh man I haven't gotten to GAS yet. This sort of thing works for multiplayer. I'm still using random sequence player because it has more options and I may not replicate the idle animations but I have a feeling I'll need this for other stuff because I want to do some of the montage things in the anim bp instead.
I think Lyra would be a good one to check out as well. I guess now I do not need to and I can't understand those complex methods anyways.
I love Lyra for other stuff. I normally deal with UI, and more generic implementations. I rarely venture to the land of animations. I really should cover more ground there some day.
that above again, will change the animation every frame unless the sequence player does not allow changing, but it will be changing that index every frame
I wasted two months on Lyra.. and didn't understand much.. so I'm building my own framework. Atleast I know how it works. The Common UI and GAS are the hard bits. Lyra is awesome but to use it properly you kind of have to be able to build it from scratch anyways.
Oh you're right. It doesn't work ๐คฆ
CommonUI is easy... but maybe that's just because I had to learn it on a broken 4.27 version. ๐
IMO if you just get used to the activatable hierarchy, you'll learn CommonUI a lot faster. They handle the automatic input mode switching, the default focus target, and what buttons can be used "Globally"
CommonUI just needs a serious amount of hardening.. and ideally splitting the lower level stuff into it's own plugin
Okay this is more convoluted but atleast it works. I may just do what COD does and be lazy..
Alritey seems like there isn't any elegant solution to this and it's unnecessary for idle animations.. so unless I really need it for something else I won't bother with this.
I would have to check when the animation is finished before changing the random number which is just convoluted to do.
And if I do that then I may as well use blend poses by int instead of all this.
I find the lack of Common UI resources to be disturbing. Lyra has a really good implementation but there's a reason why every Lyra Devlog uses the default interface. It's actually not easy to customize. Infact taking this further it's been more a year now and nobody has even made a game in Lyra yet. People are still figuring out how to make really simple changes. It's not easy. I realised they were just doing it to show off / demo new features instead of intending it as an actual template.. People here told me that it's not a proper template at the time but I was being stubborn.
Two months wasted down the drain trying to learn Lyra..
A year is not really a long enough time for people to be releasing games on it. That's like a third to a quarter of a dev cycle. Except for really small games maybe.
What do you mean by the customization though? The frontend is super easy to customize. And most of the gameplay isn't really CommonUI stuff, that's mostly UIExtensions and CommonGame.
The Common UI is hard to customize and so is the gameplay because you have to do it the Lyra way! Unless you just want to pick some coins doing anything complex is hard and the UI is superhard to customize.. I haven't ever seen anyone do this successfully till today.. not even slight customizations.. everyone's using the default UI even after a year of devving.. look at the Lyra devlogs and see.
But which part are you talking about? Frontend or gameplay?
Both.. it's easy to create an experience and add characters but once you get beyond this it all turns difficult.. Mind you there aren't that many steps.. I did get a basic game working. It would be really amazing for someoen who built it themselves to do quick games in it. For me I just want to make one game and I want to understand how it works. I already did a Bp multiplayer template and ditched it for Lyra and now I'm doing C++ mp template which is pretty much Lyra. I wouldn't be doing this if I could actualy understand Lyra. I foudn I had to wait for tutorials for simple things and there aren't many. While it's a lot easier for me to just write things myself.
And many things are simply obsfucated because i'ts a "template" so you make experiences and other nonsense which is a bit like using wordpress.. however games are complex things like you wouldn't use wordpress or drupal to make Amazon.. although you surely can.
I mean. Customizing the frontend is super easy. You either edit the base widgets it uses for display, the UserWidgets it pushes to the screen, or the materials used in either of those.
There's many little things like images and all.. it's not that easy as it seems.
so many textures and all.. so unnecessary.
have to change each one because you can't just copy UI
How can I display the other player in a lobby of 2 on a widget?
If the other character has variables like the player id or customizations these should get replicated and you can just grab all the players to spawn or recreate the character for the widget.
So my replicated movement just stopped working completely. The client pawn moves on the client's screen but that pawn never moves at all on the other screen(s). I don't think I changed anything that should affect this. E.g. the movement component is still set to replicate movement.
Could you show me how to do it with code so I don't mess it up again
Too much code.. you first need to get all the players on the local machine, which is your own player and the other replicated clients to figure out which meshes to spawn. Then in the widget you just spawn each player and you may need to make a rendertarget and post process material to display it in the widget.
But how can I reference the player within the widget there's literally no way I can find atm
Hey guys, quick question, aren't ELifetimeCondition::COND_OwnerOnly and COND_AutonomousOnly meant to the same? i.e if you call SetOwner, won't the actor be an autonomous proxy on the client?
i.e if I have a variable set to COND_AutonomousOnly, it seems to be replicated to all clients, not just the owning client. but when I check the LocalRole, only the owner is Autonomous
Playing Redfall......... masochist...... checks out.
Oh you can create a rendertarget to use as the image in the widget.. look up rendertarget tutorials. This is basically a camera which on the spawned character which gets displayed in the rendertarget.
I mean like how do I show the player name of the other player inside the text on a player's widget
One way is to store the playernames as variables in the characters then when you grab all the players you can read this and show the mesh. You'll have to setup the rendertarget camera and spawn another mesh unless you want to film the actual characters running around by sticking another camera on them which you can also do. Then you use a postprocess material to hide the rest, which is actually the trickiest part.
For Pawns this is true.
The PlayerState for example is not Autonomous on the Client side. But it is owned by a PlayerController, which is likely a Client
Therefore if you only want a variable on the PlayerState to replicate to only its owner, you wouldnt use AutonomousOnly.
You only need to put a postprocess material on the camera if you're making the background transparent. If you just stick a caemra on them mid game you can show their photo (or video) with the background which is easy to do. It's a little bit trickier to get high resolution in post process with a transparent background.
how do you prevent it from being autonomous?
so if I have a random actor, and set the owner to be the player controller or even the player pawn, doesn't that actors role change to autonomous proxy on the owning client by default?
Only Pawns and PlayerControllers are ever Autonomous, since they are "Controlled" by the Player.
Random Actors cant be autonomous.
If you search the code base for ROLE_AutonomousProxy you will notice its mostly restricted to PlayerController
There is a function called SetAutonomousProxy in the Actor class.
Which is pretty much only called for Pawns during possession.
And the PlayerController when it is spawned.
๐ have I been doing this wrong, I have a bunch of items (actors) that I call SetOwner(OwningPawn) on, and then I do checks to see if GetLocalRole() == ROLE_AutonomousProxy
Setting the Owner doesnt magically change its role.
wtf, how has any of stuff been working so far. I always assumed that the role is set by the server when I call SetOwner
Look at what SetOwner is doing
Can you change an actor's role? I've never tried.
is this a correct network basic model?
You can.
Nope, for a few reasons:
- GameMode isn't replicated.
- Even if it was, not all Actors can do Server RPCs.
- And even if they were, not all of them can do them as soon as BeginPlay is called @opaque pivot
Tips and tricks article in pins should hopefully make that clear once and for all
what is game mode in network?
Server
you can do it, GM is server itself afaik
It's an Actor, like any other, but it's mainly for setting what the game rules are. That's why it exists only on the server
It exists for me to put server only components on.
what are server only comps?
I find it rare to need to attach components to it
Authaer has been leaning more into the component approach and has been doing components on their game mode
I mean yeah better encapsulation, but I kinda hate it when that encapsulation adds network bandwidth (replicated comps ugh)
GM comps aren't an issue there though
Which is not the case here obviously
GS would be, assuming the components are replicated.
I'm trying to eradicate the ASC from our GS ๐ฅฒ
You put an ASC on the GS?
why does a GS have an ASC on it O.o
Haha yeah literally no idea
oh wait, lyra did a dumb thing like that too
What was the idea behind that?
"hey we need a state machine for game phases, you know what'd be great? abilities for states"
It's used for some kind of a GameplayCue stuff on some other Actor that gets destroyed before their GC gets to run, but well I don't like it that it's on the GS
But yeah right Lyra has it for game phases iirc
I liked the idea of the phases when I first looked at Lyra but when I thought more about it, they seemed to overengineered.
that's my feeling as well
a simple blueprintable state object would work plenty well
Pretty much everything in Lyra appears to over engineered.
But i guess thats what happens when you want a project that can be/do anything
I find that most of lyra actually makes sense for building a specific kind of live service thing. Except for phases.
I mean this works all and well in single-player, but from a multiplayer pov, I hate it. Just adds an extra needless bandwidth, that could be utilized for something else
Iris will be nice lol
3 years from now though
Yeah indeed, just turn on that flag
hey iris did just finally get async asset loading...
in ue5-main, not sure if it's in the 5.2 branch
It is experimental though, so dont hate on it to much lol
Thats what I mean, dont get upset for things it doesnt have yet lol
Speaking of Iris - has anyone messed with the new online stuff that got introduced in 5.1 and is supposed to be a replacement for online subsystems?
Whats replacing OSSs?
Online settings they called right? I can barely remember the name ugh...
Online Services Plugin
So they are just moving OSSs to plugins?
it's a new api iirc
OSS is old as shit anyway
Shit they are just replacing everything online-wise
Thankfully
New system of replicating uobjects too
lol
it's so much better
call one function to add an object instead of having to manually write every object? yes pls
Oh yeah, and you can get pretty much far with it
Is that the AddReplicatedSubObject thing? Ive seen that somewhere recently.
yeah
By the way, can you use both systems at the same time?
Unfortunately I don't think so. You can support both at the same time, but only one will be active per actor iirc
you can mix them across different actors
Makes a lot of sense, I see
oh yeah, the new thing also allows using a COND_ for replicated subobjects
Thats cool
Totally
I still can't wait for the first actual working example of Iris. See what it's all about and all.
Much better than doing that the dirty way inside ReplicateSubobjects
The description for it has been awfully vague
I can imagine Iris wont terribly change a lot of the code you write.
I doubt anyone is using it in production
FN might be?
Hobbyist projects at best
The lower level stuff is entirely different but yeah, the UObject level of things doesn't change much unless you want it to.
But they are at 5.6 ๐คญ
Im still stuck in 4.27 so I have to hear it from others as to the cool new things that are coming.
I doubt it. They only just recently started using Nanite and Lumen, and they were actually pushing those two things quite hard.
I believe they've explicitly said they're not using it yet
at least as of a few months ago
You can at least expect FN will be using it first
Seems FN is their test bed for everything
Finally, be sure to call RemoveReplicatedSubObject whenever you modify or delete a subobject.
it's too new and as of 5.1 was still missing a ton of features. Async asset loading was a big one that just got fixed, another is that push model was basically useless with it despite iris being entirely based on something similar.
That cant be right?
Available in 5.1 is the new, experimental replication system named โIris,โ which seeks to improve the performance, scalability, and maintainability of the engineโs current replication system.
Like - this is the typical explanation for it wherever you see it. But...what are the stats? How is it supposed to be better in all these regards?
Call RemoveReplicatedSubObject when you modify it?
I think that's a typo
Seems like PushModel vibes to me
Yeah but modify?
No, it's a typo. Or they mean if you want to stop its replication.
Has to be a typo
I've used the new system in a few places, you don't call that when you change the object lol
Indeed
Im sure as it matures all that will be explained
one big part is that the entire thing is push-based. I'm probably getting some stuff wrong but last time I looked into what they're doing they have the concept of "fragments" and you mark individual fragments for modification at which point they replicate. That's the low level system though - UObjects still support checking for changes each network tick but under the hood it's implemented by marking fragments as being modified.
Problem is, I think right now every object gets a single fragment which means the old push model is almost useless since it marks the entire object for modification...
I'm only sad about the ReplicationGraph that is going to be replaced by it, before I got even to touch it
I'm more sad about more stuff being slapped on but things aren't being removed
Oh also, a big part of iris is that I believe you can programmatically control relevancy and such much more granularly. I'm guessing per-fragment, but I haven't actually looked into it.
Yeah I didnt get to use it either.
UE6 will remove all the stuff thats being transitioned away from now ๐
Maybe I'm too smooth brain, but how does that actually improve things? Haven't people tested that doing a full push-based doesn't change things all that much? Or is it also because things are being handled differently at the base layer?
Something something Damage system
I wouldnt doubt that there are significant improvements to the data transfer layer as well
Hopefully they are finally removing IsNetRelevantFor once and for all
Or at least that it's somehow not virtual ๐ฅฒ
๐
They're working on removing a lot of the virtual stuff
Well, it is
for backwards compat
but you can implement a much better version of it without that
And I saw that relevancy was one of 'em
But why not just make all functions virtual ๐
Part of it is also that you don't need to tie changes to net update frequency anymore - iris' new prioritization system I think is supposed to replace that.
The "Replication Control" section
Oh right prioritization...
sNetRelevantFor() is now managed by Irisโ Filtering API. In an actorโs BeginReplication() function, flags such as bAlwaysRelevant, bNetUseOwnerRelevancy, and bOnlyRelevantToOwner are used to set up these filters. For more information, you can check out NetObjectFilter.h, as well as NetObjectGridFilter.h/.cpp for an example of a more advanced filter.
This section specifically
Seems to me like Adaptive Network Frequency but much more involved
That makes more sense
I wonder how much of the work being done on Iris will be relied on by Mass and its potential replication.
I havent heard much about Mass and replication recently.
Though it is being worked on AFAIK
I haven't heard much from MieszkoZ lately to be honest
He frequents the #gameplay-ai channel.
As do I
His participation has noticeably dropped ๐ (not that I'm complaining or anything)
Guess he is hard at work on Mass Replication ๐
If that is the case then I take back my ๐ face
Anyone know possible reasons why a single array set to replicate could totally disable the replication of the character movement component? When I turn replication off on this array my movement works like normal again.
even more weird, when I disconnect this pin the whole thing works again even with that array set to replicate
so I added a delay of 3s and the moment that RESIZE node hits? all movement replication is dead
Your problem most likely is coming from somewhere else, also I wouldn't replicate an inventory struct
Thats lot of cpu time
I'll try to narrow it down more.
Question: When I run the game in 'standalone' instead of client/server mode, it runs a server but it automatically connects to the server. How do I prevent that so I could actually 'test it' without having to build the server/clients themselves every time.
is it some sort of default map setting where I have to set it to the 'login' map?
It is getting very tiresome to have to build both versions and run them everytime I make a change ;s
It's like the client/server version doesn't abide by the override array of map -> game modes list you set in the project settings.
What do you mean by it runs a server in standalone mode?
sec
project settings:
And if I choose standalone it does this:
so it's launching a dedicated server
but then the editor connects to it on the "login map"
Are you talking about standalone mode or standalone game?
netmode standalone
Because standalone game will bring up that CLI but it doesn't mean it's the server
It will also do that
You gotta select standalone mode
Idk if that makes sense
I did but
if I play as client, it tries to auto-connect to the server it launches
Then I get cool stuff like this:
cause the model isn't attached to a controller LOL
If I try to use the menu (which works) to login to the system, it authenticates and everything but doesn't load any further for whatever reason.
I am assuming that the 'server' is loaded into the login map and not the normal map at that point
and doesn't know how to handle the login request because it's a different gamemode
Yeah you'll have to connect first and then send the login information to the server
ya that doesn't work
What kind of login is it? Do you have some database or what?
ya, so right now I have a login map, and a widget that does uname/pwd. And it goes to an API to authenticate. Returns a session token.
well, just to test things but
cause I need to test these C++ things
but I am having to rebuild client/server everytime I make a change in Visual Studio, and then again in the Engine.
it's just taking forever
You shouldnt need to rebuild the engine...
What are you trying to test again?
but the constant editor packaging is what i'm trying to avoid
I need to be able to see a variable on the player
and I can only do that in the editor
I want to see what my player state is assigning (if anything)
what's the API for?
we're sort of trying to piece together what you have, and what you're trying to do. It's a little unclear
ok so
Can you convert it to a string and put it in a text box with some makeshift widget? Or is that too much effort for it?
This is the structure that is "Supposed" to be converted from a database back into unreal engine's language:
and I need to see what this value is. It is being set on the player controller in the OnPostLogin
it's a structure
Ah
naaaah
so the only way I can see what is being returned is to do it in the editor
that stuff is coming in from an API?
ya, my own
it's a base64 encoded string of the actual structure
that I decode on the engine's end when it comes back
Are you doing this for a learning experience? I don't know everything, but I feel like that's over designed
why not make a save file that remembers all of this stuff, and create an API to tell the character what they have locked and unlocked
well, the items are from a character customizer
I don't think it's a good idea to deal with object references this way
xd
it's a project for crypto that has 10,000 'dolls' that are wardrobes right
depending on what you purchased, you can select from those items on the doll
so I have two datatables
each one references a particular skeletal mesh, another material
You are sending this as a string in the Options during connection for the Client right?
no but the token you send is a reference point to your character's entry in the database, which will return the structure (json object) of all the items.
there are \ // ' and such
so I had to base64 it
it was breaking sql
So the Server receives the token, decodes it into a JSON blob and then does what with it?
Why not just print the JSON blob, it is just a string after all.
Or you are trying to debug that your lookup is working?
ya it's fine to do that, but every time I make a change I have to recompile the editor/client/server in visual studio for the project, then go into unreal engine and package a client/server
Not really sure which part here that you are trying to debug
Why do you have to package everytime?
because if I run it in a netmode 'play as client' the editor automatically tries to connect to the 'server' it starts
it's not running in one process. I looked
You are using Dedicated Servers yes?
yes
And you have a Dedicated Server exe?
if I compile it in vs yes