#multiplayer
1 messages · Page 87 of 1
i dont understand how for two other variables i have this done and i understand it but for this... i just cant get it
so i need another method that is an RPC from the playerstate to call game mode on changename
You need to set a replicated variable from game mode then it will be onrep in any replicated class
You need to do something like:
Server: Gamemode->Get player state for specific player->Set the value in that player state
Client: Got OnRep event from server side playerstate->Do you logic (change the name?)
GameInstance:
You're using your console command to set the name. This needs to be sent as an RPC to the server through a replicated actor owned by the client. PlayerState is a good choice for this.
PlayerState:
You want to change the name but this function is handled within the GameMode's ChangeName() function. You are currently running on the server if you called the RPC metioned above, so you can call the ChangeName() function in the GameMode.
GameMode:
You're calling the ChangeName() function on this, and that's it. Doing so will trigger the OnRep_PlayerName() in the PlayerState (this function is predefined and you'd need to override it).
PlayerState OnRep_PlayerName():
now you need to broadcast your OnPlayerNameChanged delegate.
UI: Should work as you already have it without changing anything.
Is &ThisClass an actually valid identifier?
ok thanks for the help it sounds like im 80% there
i changed it a bit but im getting this error
Replicated FString parameters must be passed by const reference [UnrealHeaderTool Error]
on this function in player state
UFUNCTION(Server, Reliable, WithValidation)
void RPC_ChangePlayerName(FString PlayerNameString);
from my gameinstance console command im calling that
void UPuzzleGameInstance::SetPlayerName(const FString& s)
{
APlayerController* PlayerController = GetFirstLocalPlayerController();
if (!ensure(PlayerController != nullptr)) return;
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(PlayerController->PlayerState);
if (!ensure(PlayerState != nullptr)) return;
// PlayerState->SetPlayerName(s);
PlayerState->RPC_ChangePlayerName(s);
}
right?
i dunno how to fix that error, it says ineed to replicate the variable.. but... the variable already exists in gamemode?
Try this:
UFUNCTION(Server, Reliable, WithValidation)
void RPC_ChangePlayerName(const FString PlayerNameString);
yeah I tried that before i sent the msg, doesnt work 😦
It says about the parameter, not the variable.
same error
How about your implement function?
ya, added it there but same error
void APlayerStateWarlocks::RPC_ChangePlayerName_Implementation(const FString Name)
{
AGameModeBase* GameModeBase = GetWorld()->GetAuthGameMode();
if (!ensure(GameModeBase != nullptr)) return;
APlayerController* PlayerController = GetOwner<APlayerController>();
if (!ensure(PlayerController != nullptr)) return;
GameModeBase->ChangeName(PlayerController, Name, true);
}
bool APlayerStateWarlocks::RPC_ChangePlayerName_Validate(const FString Name)
{
return true;
}
Try const FString& Name
yo, that worked, thanks but why is it a reference?
I think the reason is RPC doesn't want it be changed during the time passing from one side to another.
That makes the variable not reliable you know
GameInstance:
You're using your console command to set the name. This needs to be sent as an RPC to the server through a replicated actor owned by the client. PlayerState is a good choice for this.
void UPuzzleGameInstance::SetPlayerName(const FString& s)
{
APlayerController* PlayerController = GetFirstLocalPlayerController();
if (!ensure(PlayerController != nullptr)) return;
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(PlayerController->PlayerState);
if (!ensure(PlayerState != nullptr)) return;
PlayerState->RPC_ChangePlayerName(s);
}
PlayerState:
You want to change the name but this function is handled within the GameMode's ChangeName() function. You are currently running on the server if you called the RPC metioned above, so you can call the ChangeName() function in the GameMode.
void APlayerStateWarlocks::RPC_ChangePlayerName_Implementation(const FString& Name)
{
AGameModeBase* GameModeBase = GetWorld()->GetAuthGameMode();
if (!ensure(GameModeBase != nullptr)) return;
APlayerController* PlayerController = GetOwner<APlayerController>();
if (!ensure(PlayerController != nullptr)) return;
GameModeBase->ChangeName(PlayerController, Name, true);
}
bool APlayerStateWarlocks::RPC_ChangePlayerName_Validate(const FString& Name)
{
return true;
}
void APlayerStateWarlocks::OnRep_PlayerName()
{
Super::OnRep_PlayerName();
OnPlayerNameChanged.Broadcast();
}
GameMode:
You're calling the ChangeName() function on this, and that's it. Doing so will trigger the OnRep_PlayerName() in the PlayerState (this function is predefined and you'd need to override it).
no changes required here right? just use the change name from player state
PlayerState OnRep_PlayerName():
now you need to broadcast your OnPlayerNameChanged delegate.
UI: Should work as you already have it without changing anything.
Is &ThisClass an actually valid identifier?
I changed to UPlayerName just incase
void UPlayerName::NativeConstruct()
{
Super::NativeConstruct();
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(GetOwningPlayerState());
if ( !PlayerState ) {return;}
PlayerState->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);
}
void UPlayerName::SetName()
{
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(GetOwningPlayerState());
if ( !PlayerState ) {return;}
FString PlayerName = PlayerState->GetPlayerName();
PlayerNameLabel->SetText(FText::FromString(PlayerName));
UE_LOG(LogTemp, Warning, TEXT("Player name is %s"), *PlayerName);
}
this looks ok to me but i get this
after setting the player name on the listen server
That's because you're getting the owning playerstate. All widgets are always owned by the local client.
oh shit... i need to get the local players playerstate
ok that helps but still shouldnt the client get updated when i do this?
i should see something? even when i run the console command on the client nothing happens
You need to get the playerstate of the pawn that has the widget overhead.
yeah i think im doing that anyway 😂 oh man.. 😦
right...
like this?
void UPuzzleGameInstance::SetPlayerName(const FString& s)
{
APlayerController* PlayerController = GetFirstLocalPlayerController();
if (!ensure(PlayerController != nullptr)) return;
APlayerPawn* PlayerPawn = Cast<APlayerPawn>(PlayerController->GetPawn());
if (!ensure(PlayerPawn != nullptr)) return;
APlayerStateWarlocks* PlayerStatePawn = Cast<APlayerStateWarlocks>(PlayerPawn->GetPlayerState());
if (!ensure(PlayerStatePawn != nullptr)) return;
PlayerStatePawn->RPC_ChangePlayerName(s);
}
No.
It's in your widget where the problem is.
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(GetOwningPlayerState());
This is what you have
ahh ok right, this is getting all of them?
GetOwningPlayerState() means you're Getting the Widget Owner's PlayerState. The owner of all widgets is always the local playercontroller, so you'd be getting the playerstate of the local player controller.
On the pawn, you would need to push in a reference to the pawn itself or the playerstate of that pawn into the widget so you can appropriately bind and read the value from that pawn's playerstate.
ok right, i get you
so im already doing this in my pawn
UPlayerName* PlayerNameLabel = Cast<UPlayerName>( PlayerNameWidgetComp->GetUserWidgetObject() );
PlayerNameLabel->SetOwner( this );
in beginplay
i should use the pawn to get the player state
ill try
im going to hit this race condition when i try this i reckon ill add a hack to test if it doesnt work
There is a OnRep_PlayerState() in the pawn.
So you should be able to get the widget through the pawn class
ahh ok so when the onrep player state runs,,, like when i change the name
i can update the widget to set the name
right?
Or if you are lazy like me, you can bind your widget text with a function that the value of the replicated var from the player state
Not recommended because bind function runs every tick IIRC
No, you instead want to have a function in your widget that reads the playername value and sets the bind to your delegate.
OnRep_PlayerState() in the pawn.
this just calls the delegate then?
No

It binds to the delegate.
ahh ok
In the OnRep_Playerstate you get your widget reference, and call a function that passes in the playerstate reference, so you can then bind to the OnPlayerNameChanged delegate on your PlayerState that you have already set up.
void APlayerPawn::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
UPlayerName* PlayerNameLabel = Cast<UPlayerName>( PlayerNameWidgetComp->GetUserWidgetObject() );
PlayerNameLabel->SetPlayerState( Cast<APlayerStateWarlocks>( GetPlayerState() ) );
}
something like this?
I just need to create a setplayerstate in my widget now
Yea
😢
this is crashing my editor
void UPlayerName::SetPlayerState(APlayerStateWarlocks* Cast)
{
if ( !Cast ) {return;}
Cast->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);
}
i thought this would be ok?
You may try what I suggest to see it works or not first like binding the text value of your widget with the variable for the name replicated in the player state.
You don't even need OnRep event to do anything though.
What line is it crashing on? What's the error?
Assertion failed: InUserObject != nullptr && InMethodPtr != nullptr [File:D:\apps\UE_5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl] [Line: 1150]
UnrealEditor_PuzzlePlatformMP_0056!UPlayerName::SetPlayerState() [..\PlayerName.cpp:31]
line 31 = Cast->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);
will try after i give this a red hot go, i feel like im close haha
Maybe instead of doing !Cast, you do an !IsValid(Cast)?
or would it be !Cast.IsValid()
I'd also maybe avoid using the word Cast for the variable name as it itself is a keyword in the language.
bah true, cast is a keyword, silly to pick it
changed code to this
void UPlayerName::SetPlayerState(APlayerStateWarlocks* StateWarlocks)
{
if (!ensure(StateWarlocks != nullptr)) return;
StateWarlocks->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);
}
void APlayerPawn::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
UPlayerName* PlayerNameWidget = Cast<UPlayerName>( PlayerNameWidgetComp->GetUserWidgetObject() );
PlayerNameWidget->SetPlayerState( Cast<APlayerStateWarlocks>( GetPlayerState() ) );
}
``` still getting the error 😦
doesnt make sense to me
So, I have this exact set up pretty much in one of my projects, the only thing I'm doing different is that I overrode OnRep_PlayerState in the Character so it calls a blueprint Implementable event.
That event then calls into the widget passing in a reference to the playerstate (not casted), and I cast within the widget to access the delegate, which I also had created in blueprint.
Maybe try passing the GetPlayerState() without casting first, and cast the reference once you're inside the widget?
ahh ok cool thanks
that got further, if just pass the player state and dont cast it, no crash
when i added the cast it crashed again
Assertion failed: InUserObject != nullptr && InMethodPtr != nullptr [File:D:\apps\UE_5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl] [Line: 1150]
UnrealEditor_PuzzlePlatformMP_0062!UPlayerName::SetPlayerState() ...PlayerName.cpp:34]
void UPlayerName::SetPlayerState(APlayerState* PlayerState)
{
if (!ensure(PlayerState != nullptr)) {return;}
APlayerStateWarlocks* StateWarlocks = Cast<APlayerStateWarlocks>(PlayerState);
if (!ensure(StateWarlocks != nullptr)) {return;}
StateWarlocks->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);
}
Line 34 is the cast?
sorry should have said line 34is this StateWarlocks->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);
Ok if I'm reading the error right, it's more talking about what is contained within .AddUniqueDynamic(this, &UPlayerName::SetName), where this would be the widget, and &UPlayerName::SetName should be the function... "this" should always be valid if you've made it this far, and you do have UPlayerName::SetName still defined and declared, yes?
You could also try .AddDynamic instead of AddUniqueDynamic.
ah ok, i trie adddynamic instead and still crashing
yep still declared, is it ok to be public or protected? and ufunction or not?
ill try all combos haha
I mean since it is a delegate bond function, usually I'll make it private.
Unless you've something else really does need to access it
yeah, thats what i had, trying anything at this point haha
ive confirmed that StateWarlocks isnt null ever either it doesnt run the code until its not null 😦
It's got nothing to do with the state, it has everything to do with what is going into the .AddDynamic/.AddUniqueDynamic. I don't know enough to really troubleshoot this issue, but what you have looks right based on all the examples I can find about binding delegates.
no worries, thanks for your help today again! ill play around some more
in myplayer state this is how ive set it up and looks fine to me
h file
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnPlayerNameChangedDelegate);
UPROPERTY(BlueprintAssignable)
FOnPlayerNameChangedDelegate OnPlayerNameChanged;
Don't have an idea about the problem yet but what is UPlayerName and where do you store it?
hi, its a widget, um its stored on the pawn? i think if thats what you mean
Thanks, yes that's whay I meant. Well as Datura pointed, it looks like either your function or this is not valid. Can you try to add if ( !this ) {return;} to see if there is a valid object where you call the SetPlayerState?
Also is SetName UFUNCTION()?
ill try that now, thanks
yep its a ufunction
ahh!! that was it! if (!this){return;}
kinda crazy its not ready but we roll with it haha
So it fixed the crash?
yepyep
Are the names shown properly as well?
Okay then there should be a problem on either creating or reaching to the widget
next problem to solve
Something with this
!this makes no sense. this is a reference to the current object. If the object didn't exist, the function couldn't be called on it.
^ agreed but the crash has stopped
It can happen
hahaha
I don't exactly remember the reason but it's possible that the functions can be called on the null objects. Until you need the object itself (this) it runs perfectly
Let me see if I can find the answers I got from #cpp about it
i still think something is wrong with it because my SetName is never called when i run the command but maybe its not the delegate?
or the delegate not registering correctly when i set the player state
In summary it's more about object the function is called on being given to the function as a hidden parameter, instead of actually calling the function on it. So you're not actually calling the function on your object. So unless you try to use anything related to this (which is just given as a parameter to the function you call) it doesn't make a problem
Might be UFUNCTION() magic
So then maybe make the UPlayerName::SetName() function a UFUNCTION if it's not already?
ya, its a ufunc alread
private:
UFUNCTION()
void SetName();
Sorry, meant UPlayerName::SetPlayerState()
Hmm what does GetUserWidgetObject return here? Didn't WidgetComponent had a function named GetWidget to get the underlying widget?
Maybe what you get from that function isn't the actual UUserWidget, so the cast fails
So you call SetPlayerState on a null object
And then this is null
GetUserWidgetObject()
Returns the user widget object displayed by this component.
GetWidget()
Gets the widget that is used by this Widget Component.
Both return UUserWidget.
i tried GetWidgetjust then same result
(no name change and delegate function not called
Can you null check PlayerNameLabel here before calling to function to see if this is actually the problem?
One thing I can think of, is that perhaps the widget itself hasn't been constructed by the time the playerstate is being replicated.
and therefore the delegate isnt registering?
checking
Therefore your widget isn't valid when you're trying to call the function, but apparently it'll let you call that function anyway and then when trying to bind it, it fails.
should i just set the playerstate in the contruct?
i could just add a delay to test this theory
i added this line UE_LOG(LogTemp, Warning, TEXT("PlayerNameWidget: %s"), *PlayerNameWidget->GetName()); and it crashed the editor
so i guess its null
the widget aint created yet imo
Hi guys! Yesterday I wrote about a problem loading a player class on the server. I must have tried everything - I output the saved class via GameInstance, PlayerState, GameMode, GameState, PlayerController and the result is always the same. On the client, the previously saved class is loaded, but as soon as I switch to the server, the character class is lost somewhere. I don't know what to do about it anymore. Please help me with advice on what I should pay attention to
This delay and then sending a bunch of RPCs should not be required. You shouldn't need to send a whole bunch of RPCs to the server to tell it to do all these things, especially if you're trying to wait for other things to happen.
You are currently attempting to send along your selected character class earlier in an RPC - from that RPC all the rest of the actions you need to happen should be able to execute from there, especially the "SR Spawn Player" as that could technically be called before the appropriate class is RPC'd over.
You're not validating that the "Saved Character" class that is stored in the save game is valid. If it's not valid, then provide a default class and spawn that instead. You also likely do not want to store the selected class in the game instance on the server - it shouldn't be necessary as you're storing it on the player controller already and should be able to retrieve it from the player controller when you're attempting to spawn the character for the player.
Thank you for your reply! Did I get it right - I have to perform all the actions I've broken down into separate RPC functions in one RPC function? And instead of the character class spawn function, should I set the selected class from the player controller on GameMode in the GetDefaultPawnClass function?
You don't have to put them into a single RPC, the idea is that if you're just asking the server to do something without passing any values, you don't need to call them all separately. The single earlier call where you're passing along the class should be enough to start from as you're going to be running on the server from that point so then you can call whatever necessary functions you need to that the server needs to execute from there. It's also bad to have a bunch of random RPCs if you care about cheating, as you then have to create checks on all of them to ensure that a player isn't calling them when they shouldn't be, otherwise a malicious player could muck things up by forcing the software to call those RPCs when you're not expecting them to - like spawning the player even if the player was already spawned, or resetting their equipment values.
You can use the character class spawn function you've made. The thing is, you don't have anything checking if the class you're passing is valid, so let's say right now your save game has an invalid value, you're passing along that invalid value, then you RPC that to the server and it's still invalid when you're trying to spawn the class. Check if it is valid, if not, then set the value to a default of your choosing and you should probably do this check just before you're trying to spawn. You can technically set this in the game mode as you say and then get the default class if you want, but that also means the Game Mode will attempt to spawn the defaults for everyone when they join the game unless you override the functions that do that automatically.
After you spawn the player, you could start doing the other functions you need, like setting up the stats, equipment values, and the inventory.
I have tried setting the default character spawn class and yes, you are right, in this case the Server creates the same character class for all players. That's why I decided to use the new character spawn feature.
You are talking about checking the existence of the selected character class and I apologize for the possibly stupid question🙂 but how can I do that?
You can take the reference you have to the class and do a is valid on it.
ah yes, thank you so much! I'm going to try it
For some reason, the firstperson character is being read properly in the branch nodes, would anyone happen to understand what I might have done wrong? Many thanks!
It's not the first person character
You are multicasting and passing PlayerControllers along
Those aren't valid on all players
Only on server and whoever owns that PlayerController
@fierce fiber
Ah I see, thanks!
I have changed the functions in the project a bit. Now on EventBeginPlay event after loading data from save into PlayerController I call only 1 RPC function Spawn Player. This function sets a class variable in GameMode and calls the SpawnPlayer function to execute.
Checked the variable and it is indeed NotValid on the server, but exists on the client and for some reason is not passed to the server. How can I transfer this variable to the server? It turns out that it is not passed through the RPC function?
This is what the server log looks like now
LogStreaming: Warning: LoadPackage: SkipPackage: /Game/AdvancedLocomotionV4/Blueprints/CharacterLogic/KokoTeam_Characters/ALS_HumanKid_Koko (0xED0C39AF78E055F6) - The package to load does not exist on disk or in the loader
LogNetPackageMap: Warning: UPackageMapClient::InternalLoadObject: Unable to resolve default guid from client: ObjectName: /Game/AdvancedLocomotionV4/Blueprints/CharacterLogic/KokoTeam_Characters/ALS_HumanKid_Koko, ObjOuter: NULL
LogBlueprintUserMessages: [Combat_PlayerController_C_2147482465]
LogBlueprintUserMessages: [DCSGameMode_C_2147482489] Not Valid CharClass on GameMode
Is there some sort of reliable way to get a Character out of a Collision?
We have an Ability where one Character can push another. And sometimes that manages to push the Character slightly into Geometry and not even "FindTeleportPoint" seems to be able to find an adjusted point.
hey i saw that the advanced session plugin have a own server travelling function and im wondering what in url means
Most probably this https://wizardcell.com/unreal/persistent-data/#url-structure
pretty sure Im doing something wrong here, hows the best way to replicate the player turning here? not sure if the rinterp should be only done clientside then sent to server, or if server needs to do it too, I have no idea, but right now the clients have much slower turning than the host
Can you find a navigable point in radius and force it back onto the mesh with a move directly to? Or are you saying it returns nothing ?You might need to turn off collisions temporarily tho
Im so sick of not having the answers man
having to try and get help with every little thing
everything about multiplayer on the forums/reddit etc is such a mess
Well - yeah. A lot of blind leading the blind.
The people who are actually making games don't have time to be on reddit.
I mean...you're not going to learn through osmosis.
What makes multiplayer even more fun™️ is when you learn that what happens in your testing isn't necessarily what's going to happen when you release 🙃
What's the general setup here, is this some sort of 3rd person or 1st person character or what?
turning these 3rd person players with the mouse cursor https://gyazo.com/96d5cbd05908162337136236dcc71c30
its not so obvious in editor, but the server (on the right) has slower turning
no I dont use that
I'd use it for orientation then.
you'll have an automagic yaw that gets replicated for you
how do you mean? how would I use it for this
The Collision is off while being grabbed and when ending the grab we basically just detach in world location and turn collision back on.
And I then additional check if that current actor location is actually valid via GetWorld()->FindTeleportPoint or whatever it is called.
Which returns false if it can't figure out an adjustment.
I was hoping, since the intersection seems minimal, that the CMC could auto fix this
But it just gets stuck in the geometry and you can't move anymore.
I will, tomorrow, try to simply move the Actor by Capsule Radius away from the wall if I can't find a valid spot.
I meant, if possible, to turn off the wall’s collision temporarily while readjusting the char’s position
Then you could just just have the character use control rotation and it'll automagically replicate everywhere. Do they always face their aim direction?
yeah, but they aim towards the cursor in the top down view, is it possible to use control rotation for that?
yeah just
Tick -> if locally controlled -> cursor stuff -> set control rotation based on cursor and character locations
control rotation doesn't exactly replicate but the character / CMC will handle the yaw of the character for you and be driven by control rotation
oh wow thanks, that seems to have fixed it, I thought control rotation only worked with camera movement
no, it's just a rotation that the controller has that many other things can opt in to using
Wasn't there code in GameMode where the pawn gets spawned where it checks IsEncroachingGeometry and then finds an adjusted point?
Hey Evo. Any chance you ever solved this? I'm having the same error. 🤔
I mean it's telling you that you are destroying the session before there is a valid PlayerState
Thanks for your reply, Wizard. I've upgraded from 4.27.2 where this error didn't occur. Now in 5.2 it sometimes occurs during travel. 🤔
Yeah a lot of stuff broke and were fixed starting with 5, so it's reasonable
Are you calling DestroySession yourself?
Yeah, I'm not surprised. 😅
Sounds like you are calling it at a point in time where it's not suitable
I don't think I'm calling it at all.
Ah RIP then
I think Unreal is destroying the session because it finds the client's player state to be invalid.
Do you get a crash or something? so we can look at the callstack?
Or simply just an error log on travel?
No crash, just a couple lines in the output log.
Here's the most relevant lines:
**LogNet: **NetworkFailure: ConnectionLost, Error: 'UIpNetConnection::HandleSocketSendResult: Socket->SendTo failed with error 10 (SE_ENOTSOCK). [UNetConnection] RemoteAddr: [IP], Name: IpConnection_12, Driver: GameNetDriver IpNetDriver_11, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: NULL:[ComputerName].local-D24497ECD94C4D01B5C32EB65413486B Connection will be closed during next Tick()!'
LogScript: Warning: Script Msg: DestroySession - Invalid player state
Yeah it's failing due to something else (socket going brrr) and then it destroy the session and finds the PlayerState to be invalid. So that last warning is a side effect I would say
But yeah these are a pain in the arse to debug
Thanks for your sympathy at least.
Reject multiplayer. Embrace singleplayer. Life was much more simple.
Could it be a firewall problem?
I've dug too deep.
Without setting breakpoints and raising your connection timeout config variable(s) you will have a hard time to debug this just to being with
I will take memes in lieu of solutions.
More like elevated to a higher plane 😈
Thanks, guys. I'll continue to look into this. 🔍
I wish I had a good singleplayer or turn-based idea
it'd be so simple
Hi Siretu. 👋 It looks like you had the same issue as me about two months ago. Were you able to solve this? If so, would you mind sharing your solution? Thanks for your time. 🙂
Uhh. This is in editor right?
Hey, thanks for your reply. Yes, it’s in PIE.
I believe (it was in 2019 forgive me) it was the order in which things are initialized.
See PIE likes to initialize stuff in a different order depending on if you use Same Viewport, Standalone, and even between SinglePlayer vs Multiplayer.
A quick way to verify this, would be to test in Standalone, and or single vs multiplayer, and see if you don't crash.
Okay. Thanks for the tips. I think that my player state is invalid because the connection is being lost during travel for some reason. I’ll see if that’s true in Standalone.
Again from vague memory, Unreal will sometimes lie to you in the log. What you see may be the result of something else failing, and not printing in the log. Which then causes the player state to not be created, and then you get the log about the player state.
Another thing that can trip you up:
Check that you have a player start in the map you are traveling to.
Yes, of course. I'll double-check but these issues were nascent with the project's upgrade from 4.27 to 5.2. 🤔
If the problem goes away by switching SP/MP or SelectedViewPort/Standalone, then it is going to be something you are doing in BeginPlay. (You'd need to break point DestroySession to see the callstack to see why)
But the fix would be to figure out what is being called out of "order" and rework the logic.
For example, say Controller BeingPlay tries to reference HUD, and HUD in MP loads AFTER Controller BeginPlay, and in SP HUD loads BEFORE Controller BeginPlay. You could instead use PlayerState BeginPlay to call the HUD initializer to init HUD, as both the HUD and Controller would have been setup by then. (Just an example, I don't remember the actual order, I just remember having to debug weird failures that were not obvious from the log)
Also make sure this is turned on:
Thanks again. 🙂
I have NO IDEA why Epic would have this off by default, it lets Blueprints skip over errors without breakpointing, creating silent bugs. (Unless you stare at the log all day)
The log reveals a bunch of connection attempts to different ports. Sometimes it's [IP]:7777 like I'd suspect. But on other lines it looks like it's trying to connect to other ports. 🤔
It's under the experimental branch.
is there a way around having to call islocallycontrolled in beginplay?
This seems to be a bug with Unreals default collab viewer template. UE5.2. Notice the highlight around the car. On one player its black and on the other player its white. However its supposed to be the color of the laser, IE, red and blue. Can anyone help fix, then they can submit bug to Epic games.
#blueprint message
It's been like that for like a few years now...
Using the event ReceiveRestarted is one option, but you will have to call IsLocallyControlled still
Classes can be passed through RPCs. What looks like may be happening is you have an invalid class reference in your save game and that ends up getting passed through and it is seemingly registered as valid while on the client. Normally a class of "None" will cause any Validated Get of a class variable to fail.
Try this:
Disconnect the pin going into your SR Spawn Server node on your player controller and select one of your character classes directly on the node. If it doesn't spawn it still, then that means your save game is fine, if it does, then it's something to do with your save game.
Thanks! I'm trying that one now
That's what the FindTeleportPoint or w/e it's called already uses :<
I swear I find out about some other poorly named default event every day.
Is there an infographic around with all the stock events for pawn / character and WHEN they fire on what machines?
Haha you are not alone, I was mind blown to find that this existed. This was added in ue5 seemingly 😄
OnPlayerDoesThatThingThatsSupposedToHappen()
Cedric drew my attention to it
The other event is ReceiveControllerChanged or something with a similar name, and they run server and owning client side with a guaranteed possessed pawn
Well, the character is loaded. You were right, the problem really is in the save file. Thank you for your help! I'll figure out what's wrong with the save file
For some reason, the colour and text is just setting to the clients pov and not for everyone else, if anyone has any advice or solutions Id really appreciate it!
PlayerControllers only exist on the owning client and the server, and passing a reference through to a player controller will not be received on any clients other than the client that player controller belongs to. This means your multicast is reading "None" when attempting to access the booleans and the Get Player Name function. To fix this, you likely want to store these values on the PlayerState instead.
Additionally, you should not need to pass through references to components like you appear to be doing here - if they are replicated components or ones that you've added to the actor in the editor then you should be able to just get the references without having to pass them through the RPC.
What are you actually trying to have happen here?
Not the code, the result.
Ah alrighty, thanks for the tip!
When the player dies, they enter a spectating mode, and in the spectator blueprint is a cube, I essentially want the cube to change to either blue or red depending on the dead players team colour, then later once I've figured out how to set the name and colour, I want other players from that specific team to revive the player out of spectator mode
So if the cube is red, only red team members can interact with it
But Ive realised what I can do now thanks to Datura, is create varaibles within the spectator bp, and have them assigned from the dead players controller from the FPS character
Through the "spawn class" node that is
Does EVERYONE see them blue or red or do you see friendlies as blue and enemies as red?
like is there a red team and blue team or is your team always blue?
Yeah I want everyone to see the cubes colour whether its blue or red
But only that team can revive their coloured cubes
yeah so put Team on PlayerState
every PlayerState has a Team variable
On begin play for any pawn, it can look up the corrosponding PlayerState for itself and pick a color etc
Yeah I should probably readjust the gamemode to utilize alot of these types of vars within the player state
However you do it, do not multicast anything
this is state
use replicated variables (with onreps if you need to respond to them changing)
When should multicasting be used in a FPS multiplayer scenario, because I get confused to what multicasting actually means
Multicast stuff where it doesn't matter after a second or so
sounds, effects, messages
basically nothing gameplay related really tbh
Ah alrighty, gonna take a screenshot of this convo if you dont mind, so I can save it and refer back to it later? also thanks for your help! and you too @sinful tree
For an FPS, depending on your architecture, you might multicast each gun shot maybe
but that really depends on how your stuff is set up
Yeah I think for the gunshot stuff, I have that running on the server from an only client event and it seems to work very well
hey i have a small issue i called the execute console command inside my gamemode class (Lobby) command: servertravel MAPNAME thsi map got its own gamemode but by using this console command function the postlogin method does not called anymore does anyone know why and can help me
how do other clients hear your guy shoot his gun?
Oh my bad, it wasn't done on only client Im chatting, Its done on an action event leading into a custom server event
The gun effects are done through multicast and sound
It won't for example if you are seamless travelling
HandleStartingNewPlayer gets called always regardless of the travel type
Is this a event
Okay nice thank you I’ll try it tomorrow 👍
is there anything thats known to stop servers starting or disconnect them? my game is really inconsistent, sometimes I can get in and start a server like normal, and then I launch the game again and just suddenly it kicks me out the map immediately?
like within the space of a few minutes
and after the first time trying to join but failing, then nothing works after that
hi, is there some way to avoid client:server version mismatch when testing in dev?
iirc there is some way to bypass it, right now I am hosting a listen server via EOS and I cant see the lobby on another client because its on a different platform?
Anyone know why beginplay on client opens the view for half a second then closes it. Code is in my playercontroller. This only happens once so i can re-open it with a tick event but would rather not use that. I have 2 players, 1 server and 1 is client
First of all never use GetPlayerController(0)
Second of all, which bp actor is this?
@dark edge Is this a correct way to use multicast? The print strings are reading properly when another player collides with the cube but the destroy isn't functioning
Ah code is in player controller, missed that
the camera is a pawn
But bp is player controller right?
yes
Then why do u use that node that has index zero
i figured since when a player spawns that would be easiest to grab the player controller from there
You are already in the bp actor
self works fine
oh true xD sorry, still seems to face the same problem
And use an event like OnPossess instead
Most probably the camera is moved when the controller possesses something
And you can even guard it with authority. SetViewTarget is authority driven
Ah well OnPossess is server only
So no need to guard it really
jeez its more of this again. works fine in editor, works fine in standalone, packaged though, just suddenly kicks me out the map to the main menu, I dont get it, I havent done anything to tell it to do that. theres literally no way to quit to menu in my project right now but this is what it does
From what I’m reading on the forums you need to create and destroy the actor only on server side, and just have the actor set to replicate. Else you’re creating multiple copies so when you call destroy it’s not catching all of them
Check the logs. There are about million reasons for this to happen
where would I look specifically?
Hmm, thats strange, because the pawn is being created on the server
This pawn also replicates
Saved/Logs
and I just tested the server only and it didnt work
but what kinda thing should I be finding there
Where things start going wrong
Error...
Disconnecting client...
Server going brrr...
oh seems that the event beginplay/onPossess requires half a second delay on the client before i can set view on it or something...
do these mean anything
[2023.05.25-23.40.02:662][347]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = NetDriverListenFailure, ErrorString = , Driver = GameNetDriver IpNetDriver_2147482509
[2023.05.25-23.40.02:662][347]LogNet: Error: LoadMap: failed to Listen(/Game/ThirdPersonBP/Maps/ThirdPersonExampleMap?listen)
No, don't multicast destroying an actor.
It's a replicated actor, so just destroy it on the server and you're done
might be my computer or something... who knows
Might have wrote the command incorrectly
Or the map isn't packaged
This is not sufficient info
but it loads the map for one frame
Show us how u wrote the command
Did you package your map?
Did you add it the list of maps that should be packaged
yeah Ive done it multiple times and its been fine
Because on client you need to wait for OnRep_Pawn to happen first
It changes your view @radiant dew
and everything works in standalone as mentioned
So you know what you can use
Can a pawn be destroyed whilst another player is possessing it? Or does that controller need to possess something else first before the pawn is destroyed? Because it still doesn't seem to work, these print strings are reading but doesn't seem to tackle the destroy node, The not valid print string also isn't reading
Im just expecting to find something I put in my script that deletes the player or something
but theres literally nothing, I have so few scripts right now and disabled everything to check
just does what it wants
If server destroys an actor it goes byebye
Nice, ty
I have literally nothing to go from
its been working for like the first 5 times Ive packaged it
didnt even change much since but now suddenly it just cant work
just clicking around randomly now and packaging again
theres nothing I can get from this
havent changed anything significant since before
gremlins man
right
set my defaultengine to one I found online
now hosting works
NOT JOINING THOUGH

joining is literally one node
which worked
I cant take much more of this
and its literally only the start
I mean Im thinking like sure this is one of the most important parts to set up hosting so sure Ill do that first and then focus on the rest but I cant do much if everything I do can suddenly just randomly break the hosting/joining with nothing to indicate whats wrong with it
I just have to magically know everything dont I
do not despair, take breaks 🙂
then I feel like I’m wasting time
I already don’t work quick enough with most things
I want to implement a function in an MP game, C++, the function is fairly simple, given two factions, return their "enmnity". So if they are the same faction, enmity = friend, human and orc, enmity = enemy, etc. My question is where is the best place to put this function - I have it in the GameMode at the moment, but was wondering if GameInstance would be better?e
alright guys im back again, i have successfully binded my widget to the player state
void UPlayerName::NativeOnInitialized()
{
Super::NativeOnInitialized();
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(GetOwningPlayerState());
if ( !PlayerState ) {return;}
UE_LOG(LogTemp, Warning, TEXT("NativeOnInitialized() binded"));
PlayerState->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);
}
void UPlayerName::SetName()
{
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(GetOwningPlayerState());
if (!ensure(PlayerState != nullptr)) {return;}
FString PlayerName = PlayerState->GetPlayerName();
PlayerNameLabel->SetText(FText::FromString(PlayerName));
UE_LOG(LogTemp, Warning, TEXT("Player name is %s"), *PlayerName);
}
but again.. when i set the listen server player name via the console command it sets both pawns names.. but it shouldnt do that now cause i moved away from the method that returned all the widgets?
I just made this a function in a blueprint function library. They’re accessible anywhere in BP and can also be easily called in c++, and the function doesn’t have to live on some other thing like the game instance or game mode that it really doesn’t have anything to do with. I generally do this with any helper function that doesn’t need any additional context than what is passed into it and doesn’t belong to a specific class.
And again, you cannot GetOwningPlayerState() as that is the owner of the widget which will always be the local player controller, so then you're always getting the local player controller's playerstate.
ahh i thought that wasnt that... for fucks suck
You must feed in a reference to the pawn the widget component is on into the widget so you can get the playerstate of that pawn.
What we were doing yesterday was just trying to ensure that the playerstate was valid.
And for some odd reason, the widget isn't valid when the playerstate is replicated.
Sorry to hear you are still struggling...
Race conditions are great 😄
dude i printed literally every function i can call or override and nothing is ready on the widget set to take in playerstate
im going to have to pass the state when i call the command or something
Maybe something crazier... Like... Constructing the name widget component at runtime.
is that /s or is that crazy haha
No being serious.
If you're constructing it at that point, how could it not be valid?
I'm wondering if you could even just feed in a widget to a widget component on an actor.
InitWidget() should possibly make it valid?
There is a SetWidget() on WidgetComponent class too.
omfg progress
void APlayerStateWarlocks::RPC_ChangePlayerName_Implementation(const FString& Name)
{
AGameModeBase* GameModeBase = GetWorld()->GetAuthGameMode();
if (!ensure(GameModeBase != nullptr)) return;
APlayerController* PlayerController = GetOwner<APlayerController>();
if (!ensure(PlayerController != nullptr)) return;
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(PlayerController->PlayerState);
if (!ensure(PlayerState != nullptr)) return;
APlayerPawn* PlayerPawn = Cast<APlayerPawn>(PlayerController->GetPawn());
if (!ensure(PlayerPawn != nullptr)) return;
PlayerPawn->BindWidgets();
UE_LOG(LogTemp, Warning, TEXT("RPC_ChangePlayerName_Implementation() called"));
GameModeBase->ChangeName(PlayerController, Name, true);
}
i ran the command on listen server and just set the name of client 1 to 1
then ran the command on the client and changed its name
only problem now is that the client isnt getting the update
i hate that it does this every time you set use the command but at this point...
could just add a bool so it only does it once i guess (the binding)
but not sure why the client doesnt get the update
Because the RPC Implementation is only executed on the server.
To declare a function as an RPC that will be called on the client, but executed on the server is very similar but uses the Server keyword:
😦
makes sense but then i need another client rpc function>?
or multicast?
It doesn't make sense to do it like that.
You have an OnRep of the playerstate. At that point, you know the playerstate is valid, and therefore you can read values from it.
We're waiting for that OnRep on the pawn to ensure that when we are binding to the playerstate to know when the name changes as someone could change it at any time. The issue you're facing is that your WidgetComponent hasn't created the widget before the OnRep of the playerstate is coming in.
Handling it VIA RPCs means you'll lose that stateful means of handling it. As pawns can go out of relevancy, the widget can be destroyed when they do, thus, you have to rebind the widget when they come back into relevancy which you can't really do with RPCs, and setting up a function to do it automatically (like on Begin Play) would still result in the same problem you're having. However, with using OnReps, those OnReps will fire when the pawn is created on clients when they come into relevancy.
So the problem to solve is how to make that widget valid.
ahhhh right, so i should just create the bloody widget at run time and it would probably solve this
ok
Possibly, create the widget, execute the binding stuff, feed it into your component. maybe that will work.
alright, thank you AGAIN, 🤞 i can get it now
Is using GetPlayerController(0)->GetPawn() correct way to reach the locally controlled pawn from anywhere?
hello, i want to ask, for something like mantling and vault, do i need to do the trace and use motionwarping in CMC so i dont get CMC?
currently, im doing it inside Gameplay ability but i dont think thats a good place to do it
with two different prediction system im confused how can i approach this (what i mean is the prediction in GAS and the general prediction in CMC)
any of yall have tried this before, what yall do for something like this?
tag me btw
Hey, i have a small issue i implemented seamless travel it work so far but i used onpostlogin to handle player join and since im using seamless travel i cant use it anymore im using handle starting new player but if i use this the clients does not get spawned why?
OnPostLogin is only called once per Client when they initially join the Server.
You would need to give us more information about how you are spawning Players.
As it stands with what you have said its hard to guess as to what the issue would be.
i added two player start inside my map so they are spawning automaticly
and as i said since im using seamless travel i cant use onpostlogin anymore ican use handle starting new player but if i use this the server only gets spawned
If you are spawning automatically then what are you using HandleStartingNewPlayer for?
i want to handle player join and someone said i could use handle starting new player event but its not working for me
inside my gamemode class
the OnPostLogin event gets called if a player has successfully logged in and i want to handle this event but as i said i cant use this anymore and someone suggested me to use handle starrting new player instead but its not working for me as i wish i want that all palyers get spawned as normal but the server only gets spawned and the client are spectators i gues
🤦♂️
so what can i do now?
I'm pretty sure this guy clearly stated they want an event that would fire when player has travelled to the map
I have a spectator event that is called on the player who gets killed, the dead player possessing spectator mode works fine, and the ragdoll works fine too. I have the collision of the capsule collision disabled when they are dead through the "enable ragdoll" event. Image 2, In the spectator bp, shows the sphere collision around a box that the player needs to walk into in order to revive the dead player. Image 3 shows the collision settings for that sphere collider. Image 4 shows a component overlap event with a print string contained in the spectator bp. For some reason, when the player dies, the overlap event is called, even though collisions are disabled for the dead player, I've been stumped on this for 3 days and have no idea where to go from here, if anyone is willing to talk me through what I might have done wrong it would be appreciated!
do you maybe know what the issue is?
I mean, OnPostLogin isn't called for players that seamlessly travel to the level
right
thats correct and i tried to use handle starting new player but i get a weired issue i have two player start inside my map so they should spawn the server and client right so but if i use handle starting new player the server gets spawned and the client not
Put a breakpoint on HandleStartingNewPlayer I guess
No, he didnt state that at all.
He stated that HandleStartingNewPlayer "isnt working for him".
i descripted my current problem more than 2 times no worries all good i mean if you guys have a solution it would be very helpfull 🙂
I then asked what he is using it for to understand why it might not be working for him.
But he didnt answer the question.
He just kept reiterating what he said previously.
I see
i overread the message my bad again before i used seamless travel i used OnPostLogin to handle the player join inside this event i called a function that checks how many players are missing to start the game and since im using seamless travel i cant use OnPostLogin now. Yesterday someone recommended me to use handle starting new player i did it but as a result i got that only the server gets spawned instead of server and client
Do you call Super::HandleStartingNewPlayer by any chance?
im calling handle starting new player inside blueprint because i have some functions that i programmed currently in blueprint
You should not be doing that
I think you need to post code that you have
calling the event inside blueprint?
HandleStartingNewPlayer is called by the GameMode when it needs to. You should not be calling it manually yourself.
Please post code.
Ok so you are using the wrong terminology
You arent "calling" it yourself
You are "overriding" it
You also arent calling its parent implementation.
Right click on the Red HandleStartingNewPlayer node and select the option that says "Call Parent Implementation"
like this?
yes i did it ill test it right know ill let you know if the issue is gone
damn it worked nice
thank you could you tell me why i have to call the parent?
Because it has an implementation in C++ that is important
...because the parent implementation actually spawns the player
oh i see
void AGameModeBase::HandleStartingNewPlayer_Implementation(APlayerController* NewPlayer)
{
// If players should start as spectators, leave them in the spectator state
if (!bStartPlayersAsSpectators && !MustSpectate(NewPlayer) && PlayerCanRestart(NewPlayer))
{
// Otherwise spawn their pawn immediately
RestartPlayer(NewPlayer);
}
}
I mean, when they say "override" the method, they mean it
well thank you very much guys it helped me a lot and i learned new things
To add on, I added a few more checks to see if the player is still colliding and it is, I even added an "actor enabled collision" node to stop the collision of the player, but for some reason, it is still being detected, the first image is from my player controller, 2nd is the spectator pawn bp, and the third shows the current code in action
What's the collision settings of the pawn itself?
Do you mean the player or the spectator?
The player
Just note that that "Set Actor Enable Collision" will only take effect on the Server. On Client, it'll still have collision.
The collision being on/off is not replicated, so that might explain what you're seeing.
So I need to set collision for both server and client, gotcha, thanks man!
Yeah. Probably the best way is to make a replicated bool of your own, and use an OnRep callback to call SetActorEnableCollision locally.
You may want to take a step back from just a collision bool and use an enum-based state. Then you can set other non-replicated variables at the same time if you happen to add some in the future.
found out more about my problem. my game definitely does "successfully" join the multiplayer session, but it doesnt open the actual map, it just reloads the main menu map. not sure what to do because its just the join session node, and it worked fine before
WHAT DO I DO
theres nothing online for 90% of my problems yet Im literally just setting it up based on working guides
check your log files - there must be something about why it is not joining the map
I did have a look for level searches, but dont know what else to look for
FailureType = ConnectionLost, ErrorString = UIpNetConnection::HandleSocketSendResult: Socket->SendTo failed with error 23
I am getting this error, this happens when we have joined a server and after few minutes i get this . anyone have some idea about this ?
are RPCs sent at the net update rate? or are they sent ASAP? thanks
I mean I still have the failed to listen error, but couldnt find any help on that anyway
bro Im actually sick of this
what is the answer at this point, Im just wasting entire days sitting here clicking randomly hoping to find some answer
oh my god so the defaultengine settings I put in to supposedly fix something, was in fact causing this problem

how
Does it change your net drivers? Can't remember if that's in Engine or Game ini.
Hi guys, what are ways to add prediction for sprinting in order to remove/minimize rubber banding effect?
C++
the amount of effort it's going to take for you to make your own movement prediction. An alternative to what Duroxxigar said, marketplace asset, a good one, anyway...
I thought Unreal CMC already have prediction
the character is using the speed from CMC
it's just when using a bool to drive the state, character will get rubber banded
it does, it's enabled by default, I thought you were wanting to make your own because cmc's is no good (expensive) or something
still trying to figure out ways to do MP with blueprint =(, can't seems to get replicate condition to work in blueprint only C++
im not able to do stuff like Skip Owner in blueprint
in the cmc there are some exposed variables under Character Movement (Networking) that deal with prediction
as far as sprinting
sometimes it's simply a matter of needing to call set movement speed on client and server at the same time, for the local character that is running
It does, you just have to extend it to have the state of trying to sprint be one of the predicted properties.
basically "I want to sprint now" needs to be a move in the context of the CMC
Can I replicate UPROPERTYs in a subsystem?
subsystems don't replicate
unless you're doing something fancy
the typical approach is to have the subsystem spawn a replicated actor to act as the replicator and send data through
i see, i guess i could use that pattern
I see, thank you
That's what I did but that doesn;'t involve prediction thus the rubber band effect on High ping
I think I recall this being a decent explanation.
https://youtu.be/RtQRMcupJs0
Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv
Join our community discord!
Discord: https://dis...
@dark edge tysm
https://youtu.be/RtQRMcupJs0?t=1621 This timeline explains it explicitly
Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv
Join our community discord!
Discord: https://dis...
Pretty sure Reids video is like one of 3 videos on YT that actually detail the issue and how to solve it.
Reids stuff is generally pretty good.
Yeah looking thru the video he also have sprint/wall running function
with prediction
I haven't tried this, it'd be super easy to cheat, but you could just do it with inputs
have 0.5 input BE your normal speed
and sprinting is basically 1.0 size input
lol
that'll predict just fine, but it's trivial to cheat. Would work in a pinch though
I love it
If there are no restrictions on sprinting and instead the effect that sprinting has on gameplay is handled by speed (can't shoot if moving over X uu/sec), then it'd probably actually work lol
hey guys how would i track players in game ? like for game mode first player to reach 20 kills blabla how would i get the playher s?
Just add +1 to a float variable (and set the variable again) every time it makes a kill, then grab that variable and display it
I'd use an integer, but otherwise, yeah, store the kill count on the playerstate, when you increment you can do the check directly there and then call whatever function if >= 20 or whatever other variable you may have stored to keep track of how many kills a player needs to end the round.
Oops sorry, int is def better 😅
yeah but like how would i get "if [4]" players are in game Get player[1] check stats get player [2] etc
is there some built in functionsto get players ?
You don't need to do that. When a player has killed someone, you're incrementing on that playerstate their kill count, so when you're doing that increment you do your check.
The check can be a function you call anywhere you want, or directly on the playerstate, your choice.
learned the hard way that RPCing a current stat value instead of the delta stat value in udp socket is a bad idea...
Playerstate should hold the kills
Every time someone gets a kill, you can tell the gamemode
gamemode can check whatever it wants
has anyone had any luck getting x360ce to work to emulate a second controller?
i'm trying to get splitscreen to work but no input is routing into the second person, even when "skip assigning gamepad to player 1" is ticked
I am sorry, i am a beginner, do you know why when I test my multiplayer game, I can only move one player, the other one on the other window is there, but I cant control it (UE 5.2)
shift-F1 to release cursor so you can click the other window
I click it, but I can't move it, the window is selected but the control are working only for one player
We'd need to see your code
is this a template / starter project?
or did you make the controls from scratch?
are RPCs sent at the net update rate? or are they sent ASAP? thanks
They are sent ASAP
thanks!
With the exception of unreliable multicasts iirc
Hi, how to connect to a dedicated server using steam subsystem ?
yes
How ? :p
That's a separate question, only one question per day, please.
Thanks
when I unpossess a character on the server, I'd like to set the camera location on the client
I noticed that when a controller has no pawn, calling Controller->SetSpawnLocation() can be used to set the camera location
so on the client, I'm checking during tick() when GetPawn() == nullptr, I change the controller camera location using Controller->SetSpawnLocation()
and that works, but only sometimes, other times it seems to ignore it for some reason
if I use a timer to delay it, it always works, so it seem like sometimes its called too soon
so when is the correct time call Controller->SetSpawnLocation() after I call unpossess on the server ? It seems like calling it exactly after GetPawn() is nullptr is not very reliable
what do people use to detect on the client, when a character is unposssed?
On the client you can bind to OnPossessedPawnChanged delegate in the player controller. If the new pawn is invalid, then they're no longer possessing a pawn.
@clear island
it seems like this is never being called
the delegate
unless I'm doing something wrong here
on BeginPlay I do: ```cpp
OnPossessedPawnChanged.AddDynamic(this, &ThisClass::PawnChanged);
void AVFPlayerController::PawnChanged(APawn* Old, APawn* New)
{
UE_LOG(LogTemp, Warning, TEXT("PAWN CHANGED !!!!!!!!!!!!!!!!!!!"));
}
its never being called
server or client
ah wait
didnt mark function with UFUNCTION
ok just tested now and it has the same issue
actually seems a bit worse, it never works, unless I delay it with a timer
so it seems its also too soon to call SetSpawnLocation
ok I ended up overriding APlayerController::CalcCamera, thats more reliable
all working now
Nice
Guys is there an easy way to get the network id of a player controller?
Server returns 0 and players -1
I basically want like an index of its connection number between all players
You don't really want to do this over online multiplayer. It's very difficult to keep track of which player is which by any sort of index.
On the server, both the pawn and playerstate can get a reference to the controller that they belong to.
Both the player controller and playerstate have a reference to the controlled pawn on the server. On client, so long as the pawn is within relevant then you can get reference to the pawn through playerstate only (as clients only receive their player controller, no one else's)
Both the player controller and pawn can get reference to the playerstate. On client, again, so long as the pawn is relevant, you can use that pawn to get its playerstate.
Keeping this in mind, you should be able to get a reference to the playerstate and the pawn fairly easily on clients and including the controller on the server.
Gamestate also holds the Player Array which is the list of playerstates present in the game, and this is accessible to clients and the server.
I made a dedicated server, and join that, but Open xrMsftHandIneraction R Grip not working when joined players number are more than 2
Hi, I have several issues with multiplayer implementation with a simple lobby system that I can not understand at all.
Anyway, I would greatly appreciate any help if someone knows about multiplayer.
Just so you know, I made a complete mutiplayer game in another project but was using directly the "Play as Listen-Server" options for all the dev.
Now I try to use lobby system with "Steam Advanced Session" and can't get it work to do what I want.
Thanks,
my structure that contains my stats are replicated. its just i am geting my structure and character reference to hud with a bp interface. then i set these values in my hud. lastly i am getting these variables from hud to widget hud to update a stat.
Hello, why is this spawning 2 actors in the game ? i just want to spawn one :/
Because replicated Actors should only be spawned on the Server
Oooh ! thank you !
Multicasting this will create the one on the Server, replicated to Clients and a local duplicated version for each Client
Oh thank you ! The tutorial was unclear
Did you read the Multiplayer Network Compendium yet?
Hmm what is it ?
This compendium is meant to give you a good start into multiplayer programming for Unreal Engine.
Thank yoou !
By the way, I already have a possess pawn when I spawn, and when I interact with an object, I want to spawn it and take the control of it but it jsut spawn. Do you have an idea ?
It wont possess it and so switch character
You are connecting it wrong
You need to call Possess after the SpawnActor node
The RPC moves the call to the Server
So you are executing it on two different games/instance
@stone beacon
One way would be like this
Since you can execute RPCs in the Character you are in, I assume you have a valid Controller, so you can just call "GetController" to get the Controller of the current Character
GetPlayerController0 doesn't help here
GetPlayerController don't get the local player ?
I don't have valid controller, I begin in to this, I need to have a variable controller that refer to the local player ?
@thin stratus
@stone beacon That wouldn't make sense
You are in a Character blueprint
You are performing an RPC
The RPC would not work if the Character isn't possessed
You should be able to do "GetController" and use that for the possess call after the SpawnActor node
"GetPlayerController0" gives you the local player, yes, but relative to who calls it
After the ServerRPC you aren't local anymore
Oooooh okay !
so this is right ?
Correct
how can i play the draw animation for both my hands and my weapon
like i have for my hands which are playing, but my guns draw anim isnt playing so the slide doesnt like drag back
Hey, I'm getting a lot of latency in my project even when simulating with 2 editor standalones on same machine, with network simulation off. Here is a profile of a clients upstream, is 6kbs a second a lot? the connection is just sending CMC RPCs
You usually just call an additional PlayMontage on the weapon mesh
Or, if the Weapon has none, you gotta make sure it's attached to the hand
Nothing build into the Engine. You'd need to code that fully yourself in C++.
I would assume a Socket Connection between the Servers to communicate.
but how would i do that with a draw animtion
like begin play
Not sure what you struggle with
hard to say cause we don't know your project. Also you might want to switch to Unreal Insights Network Profiler, which is newer
hard to explain
ok so i made a animation for drawing my gun yea, the animtion for the arms work as they should
but since its a glock i drag the slide back and i want the slide to drag back in game too, but idk how to trigger that
Sounds like an anim montage
doesnt that require a animbp
You could also set the animation mode of the skele mesh to play a single animation. No anim BP required
yea just see that my animation is super weird ingame, it gets tiny
@pseudo merlin if the player is running at like 200fps
that is a lot of updates its sending
we normally cap the amount of updates to and from the server
and also cap the server to 60fps
@meager spade ah interesting thanks, how do you cap client send rate?
look into GameNetworkManager and NetConnection, is it listen server?
TotalNetBandwidth=32000
MaxDynamicBandwidth=7000
MinDynamicBandwidth=4000
MoveRepSize=42.0f
MAXPOSITIONERRORSQUARED=6.0f
MAXNEARZEROVELOCITYSQUARED=9.0f
CLIENTADJUSTUPDATECOST=180.0f
MAXCLIENTUPDATEINTERVAL=1.2f
MaxClientForcedUpdateDuration=1.0f
ServerForcedUpdateHitchThreshold=0.550f
ServerForcedUpdateHitchCooldown=0.100f
MaxMoveDeltaTime=0.250f
MaxClientSmoothingDeltaTime=0.8f
ClientNetSendMoveDeltaTime=0.0666
ClientNetSendMoveDeltaTimeThrottled=0.0888
ClientNetSendMoveDeltaTimeStationary=0.1
ClientNetSendMoveThrottleAtNetSpeed=10000
ClientNetSendMoveThrottleOverPlayerCount=10
ClientAuthorativePosition=false
ClientErrorUpdateRateLimit=0.0f
bMovementTimeDiscrepancyDetection=false
bMovementTimeDiscrepancyResolution=false
MovementTimeDiscrepancyMaxTimeMargin=0.25f
MovementTimeDiscrepancyMinTimeMargin=-0.25f
MovementTimeDiscrepancyResolutionRate=1.0f
MovementTimeDiscrepancyDriftAllowance=0.0f
bMovementTimeDiscrepancyForceCorrectionsDuringResolution=false
bUseDistanceBasedRelevancy=true``` small example of what we use
NetConnectionClassName=/Script/SteamSockets.SteamSocketsNetConnection
ReplicationDriverClassName="/Script/TwinStick.RTS_ReplicationGraph"
ConnectionTimeout=80.0
bNeverApplyNetworkEmulationSettings=true
InitialConnectTimeout=120.0
NetServerMaxTickRate=60
bClampListenServerTickRate=true
MaxNetTickRate=60
KeepAliveTime=0.2
MaxClientRate=120000
MaxInternetClientRate=120000
RelevantTimeout=5.0
SpawnPrioritySeconds=2.0
ServerTravelPause=4.0```
this clamps the tick rates
of the server (and listen server)
awesome. thanks!
I think I'm missing something really stupid, but I got a integer replicated as repnotify in the Player State and the notify is not called. Is it related due to PS already replicates everything?
Make sure that the value arriving on the client is not the same value that the client already has. Or change it to NotifyAlways
Yeah, printing value and there is a change, gonna try NotifyAlways thou, thanks
Don't see a notifyalways option, the condition is none as the default one, which I believe makes it to always call the repnotify event
so yeah, not firing. Just wanted to double check if RepNotify are meant to fire in PS too.
Lol, I knew it, since it is not the first time this happens.
Reseting the editor starts to call again the repnotifies...
It is a bug I noticed that also happens with breakpoints... can stop firing. Reset editor, all back to normal.
Annoying.
why is this giving me problems? Ive made sure those input variables replicate, Ive checked with print strings, nothings wrong with them, but this animation transition cant work properly. at one point it started working again without me seeming to do anything to it, now its gone again
so just wondering if theres anything weird with animation transitions or this is just me
I literally set these variables on the same event as another variable that works completely fine
ok so separating the event to set the variable fixed it? is there something wrong with trying to replicate too many variables in one event or what
hey guys, I play Minecraft and it's probably created on Unreal Engine. How to enable Multiplayer mode there? Should I install C++ for that?
It was not created in UE, stop trolling every channel
😄
how does repnotify work in hosted mode?
the same
is repnotify called twice on the host client
i thought repnotify was more or less equivalent to multicast
when called from server
no
repnotify means "run this function when this variable changes"
Notify me when it's Replicated
I understand the first part fully
The second part is a bit over my head.
I usually rely on multicasts
no
Delete every multicast in your project
they are only useful for non-important stuff, pretty much.
playing sound effects, spawning particles, etc
They can be useful but they're a nub trap. If you care about the STATE of a thing, use replication and repnotify
Don’t rely on unreliable multicasts and don’t just mark them as reliable either. Both are not going to work all that well. Use repnotify instead.
Do i need to call repnotify from server?
you don't call it
its automagically called
when you change the variable on the server
oh yeah I mean by that, change a variable flagged with repnotify
Too many reliable multicasts can cause a buffer overflow and force a client to disconnect.
or rather, when the change is replicated
just change the variable, that's it
ANY time that variable changes, the repnotify will run
on all clients yes?
on everyone
even on the hosting client, only once?
ok
c++ repnotifies need to be manually called on server
Repnotify ftw
But set them as the server
only set a repnotify variable from client if you’re doing client side prediction
Because it will be rest to whatever value the server says it should be anyways.
so repnotify is kind of an automatic call on server > multicast
if called on client
this is helpful, i just watched a vid saying repnotify is more efficient
If you call it on client it doesn’t “upload” the change for others. It only changes it locally which can be useful to help reduce the feeling of input lag if you’re also doing some rpc which changes the same variable to the same value anyways.
no
repnotify is code that runs whenever the variable changes
that's it
it can be changed by setting it locally OR it can be changed by being replicated from the server
oh yeah thats what i meant kinda i know fully the stuff about the automatic function creation
i am still a newb about the replication side of it
If you change it only on the client the server will go ah ha that’s incorrect it should be this value instead. But since networks have latency due physical location distances you can predict the correct value client side and rpc the change to the server so it’s kept in sync before traversing the network.
sounds like very advanced stuff
I will definitely look into replacing some of my multicasts at any rate
Since I do ocassionally get disconnects
Because after all the clients are just running a simulation of the real game. The real game is being played on the server. You’re only seeing a latency delayed replay of what just happend.
yes a simulated proxy
void AMasterCharacter::Rotate(int RotationDirection)
{
//FRotator NewR = FRotator(GetSprite()->GetComponentRotation().Pitch + RotationDirection * UGameplayStatics::GetWorldDeltaSeconds(this) * RotationSpeed,0,0);
//AddActorLocalRotation( FRotator(RotationDirection * UGameplayStatics::GetWorldDeltaSeconds(this)* RotationSpeed,0,0));
ServerRPC_Rotate( FRotator(RotationDirection * UGameplayStatics::GetWorldDeltaSeconds(this)* RotationSpeed,0,0));
}
void AMasterCharacter::ServerRPC_Rotate_Implementation(FRotator NewRotation)
{
AddActorLocalRotation(NewRotation);
}
``` Hey guys any idea why my rotation on the server appears smooth but on the client it becomes choppy? i am calling the rotate function when i click the screen
So you can predict some stuff to keep input lag down but be careful because you want to avoid making it easy for cheaters. So ideally you want most variables set on the sever and replicate the values to clients. Not the other way around.
a lot of this is over my head but ty again
While connecting the bps of 2 different characters to a single hud, there is no problem in a structure with active replication that I transferred with the bp interface, the values in it are correct and I can write it in the hud, but when a second player connects to the session, the host tries to write the structure of the player to its own hud and the player tries to write the host's to its own hud. When this is the case, the numbers are intertwined. The values in the variable are normal, but there is such a problem when writing to hud, I think the problem is that hud did not find the right character reference correctly, but I already sent the character reference with the bp interface. any idea?
You might need to show some code about what you're doing. Technically an interface isn't really necessary here at all.
@obtuse loom you want to interpolate the incoming rotation
so client sends the rotation they want, server sends it out, but the simulated proxies need to interpolate (probably via exponential), to the new rotation
and keep it going, else they will strutter
and this is the replication for the rotation
Is there a way to sync the values for the client?
The problem is more apparent the higher the ms
Hmmm reckon repnotify and interpolate will do the trick?
Hi i started to watch how steam works with dedicated servers, it seems we have to register to a steam master server but does that mean we need a steamid or we can use the testing one ?
Might get an answer in #online-subsystems
Your server will automatically register when you start a steam session. You can use the valve test steam appid but if you make any kind of server browser it will list every single game using that appid so you will need to add extra filtering... Or get your own
I see thanks !
I am a bit lost in the replication, I have the following use case and leverage more than usefull Jambax article (Thx a lot for that):
BaseObject : UObject
-> Replicated
MyObject_A : BaseObject
MyObject_B : BaseObject
TArray<MyObject_A> ArrayOfMyObject_A
MyActorComponent : ActorComponent
TArray<MyObject_B> ArrayOfMyObject_B
I have implemented well some of the logic meaning:
The array in my actor component for ArrayOfMyObject_B is replicated well using the new unreal 5 system. However when creating a new MyObject_A ArrayOfMyObject_A the element on the clien side when priting is having nullptr, I saw some thread in that discord saying:
* OnRep doesn't fire after all the entries are valid On array I mean That's just not how it works
* First time array replicates it sends the size So you will see entries but all null
So here is my question how can I replicate a TArray<UObject> property inside an already UObject since all function used from an ActorComponent to do so are not available (aka AddReplicatedSubObject)```
is it possible to make simulated proxies ignore server corrections? My use case is a coop listen server game, I'd like clients to be able to launch server controlled bots instantly and not wait for server to react. I turned the bIgnoreClientMovementErrorChecksAndCorrection to true and verified its true with logging but I still see corrections happen on client. Edit: what seems to work is swapping to autonomousproxy on client, enabling physics while no controller, and disabling client error correction. I have not tested thoroughly but so far works ok.
I'm only enabling on client, i wonder if i need to enable to server too?
When one player logs in dedicated server, the other player's pawn is unpossessed.
hi guys, by default how many players/clients can join a game? thats hosted with the 'default' project settings?
This bug is making me laugh... The rotation resets (despite the value being correct) on the owning client, once i add a random float it makes it stop resetting. it only happens when the value doesn't change... i guess i could make a check to not change it when the value doesn't change but, just why
ok not doing it for server either, just seemingly perfect replication on any other client
the problem was passing rotation values from the server to the client and then multicasting
It was because auto possess player option was turned on in the pawn's class default.🫣
after changing that like this, problem has solved
why isnt this working
exact same logic and it works
in the same blueprint...
only works doing it on the server for the first image
the second one works for both client and server
ok so its the variables
@kindred widget for now i deleted 2 bps and created only 1. Last time i was changing the character but now i just created a simple chatacter creation menu and i am changing skeletal meshes and grooms.
now its more clean code i was using same all logic in both character.
Now i think the hud working because there is a only one character reference here.
The only thing now clients cant see hosts custom character but server can see them.
for preventing cheating but not going too hard on it, should you focus on non-constant variables? i assume this would stop cheat engine and the like
i wouldnt spend a ton of time on cheat prevention. people will always find a way around it. dont send data to the clients that they dont need and dont let the clients make the decisions. if they want to do something, treat it as a suggestion to the server which you then verify whatever criteria you need. eg, if the player wants to open a door, make sure they are near the door, looking at it and within some range AND that the door can be opened by them (if your doors have access, or the door is locked, whatever).
The key is to dampen the impact of cheating
like you say you will never stop it, the best you can do is make it downright annoying, easy to detect and lower the advantage you get from cheats
Guys how can I make simple replicated character movement but in pawn class?
Who knows what it is..🥲
that has nothing to do with it being multiplayer
it's just an accessed none error where you are trying to reference something that doesn't exist
Oh..can you explain in a bit more detail?
u are better off asking in general blueprints but this is a very beginner question
u're trying to reference something that's invalid
for example, maybe you spawn an actor and reference it, then destroy it in some other outside blueprint, and try to reference it after it's destroyed
just an example of why that might happen
show code in #blueprint
thanks for the explanation! I got a little bit of why, I'll ask in blueprints too!
The building class is probably invalid on client (maybe not replicated)
The variables had to be set on the server
yeah but you can pass that variable from client to server when U do the run on server u can add Building Class input
I replicated the variable and set the variable on the server, but the variable does not change on other clients.
does any 1 know why when u join a steam session u get a lobby callback?
hi guys, dunno if anyone is on from the last week or so that helped me with my playername netowkring code, but i ended up getting it to work, just had to set the player state correctly, thanks for all your help 🙂
in order to have other clients see the updated variable, you have to multicast the change from the server to all clients, or set a RepNotify function, replicating the variable only won't let other clients know about it
better to use RepNotify than multicast
Hi Guys I have rubber banding effect when the character move and suddenly play a montage. Basically the server try to correct the root location while playing the montage. How can I remove this artifact?
Hey everyone, Im having an issue where only 1 client is getting the count down timer shown to them?
Here is my Gamemode bp:
Player Controller:
Widget:
Ah I managed to fix it! Just needed some tweaks with the replication
Help me..I replicated the variable, but the variable is still false on the other client. why is this
How do you know it's false?
in the Tick code of pawn, I printed the IS GRIP variable
is that variable being set ANYWHERE else?
that's only set by player's Grip action..
If player 1 on computer 1 changes the variable A to True, what should I do to make the variable A of Player2 on computer 2 also change to True?
assuming the code you've show is all of it and you don't have any weird settings that should work.
You mean it's only set by the server, based on a RPC from the player's input
Yes!
Yes
then it should work. Put a breakpoint on the server side of the RPC and make sure it's firing
How would I go about getting the players current session info
for some reason I cant figure it out and I need it to keep working on my game
So for a building system i spawn a building, add arrows to its corners, do some math, rotate it to the ground, do more math, rotate it better to the ground, add player rotation and move it to the ground, then add a component if its in an unbuildable location
how can i do it all client side and then spawn it on the server 
im starting to think i should do it all on the client and then just delete their building and spawn the servers in the correct location and do some sort of check to make sure its not breaking some rules
or can i somehow replicate the building but only after all the movement has been done
spawn actor -> bunch of movement and adding components -> get new location -> spawn server actor and replicate only to non owning client?
@wanton bear Not sure if you are overcomplicating this or not.
You can just handle it all on the Client until the Client presses a button.
You can spawn a local preview actor etc., handle all the collision checks and what not, and when the Client is happy, they press a Key which you then use to send a ServerRPC with what they want to build and its Transform, as well as destroy the preview actor and end the building mode.
Bonus points for double checking on the Server side if Building and Transform can actually be placed there to stop cheating.
i think i've just done this in a dumb way, im spawning the building at the start, adding arrows to the corners and doing maths and moving the building. if i just spawned another building on server side and replicated it, it would end up with the client having two
destroying the preview feels wasteful?
Why
Like, sure you spawned an Actor and Destroyed it, but that doesn't really cost you performance or so
You can go the hard way of trying to get the replicated connection of the actor going after spawning it on the Client, but that's C++ territory
And really overcomplicating this
Hi guys how can we play anim montage in multiplayer game? When my character run and play a montage in this case an attack animation. It rubberband a few step back while playing the animation. I suspect root motion conflicts with the movement component? How will I go to get rid of this artefact?
My montage contains root animation
when i open level using "listen", the level only opens for a split second, and then it goes back to the main menu. i cant seem to find any solution, so any help would be appreciated
opening the level probably implicitily re-opens the main menu in some way
you're right
look for references to your main menu level
it says there a none 🤔
but the debug level i made is referenced in the game instance
its weird because i am copying all the network related stuff from an earlier project i did, where the multiplayer works fine
this may be a dumb question, but is there a way to use client variables in a server RPC without having to replicate them and make sure they're replicated before you use them
although i guess if its all in the same call it should be executed in order
just add input paramters on a server RPC, when you call it from client you can pass whatever you want from the client and operate on those parameters on the server
I havent found that works? ill try it again
why would this not function? its only when i have "listen" as the option in open level, that i cant open the level
You'd need to check your logs
I have the same issue. When I do Open Level without the listen option (if playing singleplayer) it works without a problem. With the listen option it opens for a splitsecond and goes back to the main menu level. The log doesnt show any errors. Sometimes it says Match state is changed from InProgress to LeavingMap. But not all the time
if you are gonna open a LAN host try using listen?bIsLanMatch=1 command, if you are gonna open steam host just use listen.
that works for me
@wooden abyss
But i dont use lan
try using openlevelbyname not openlevelbyreference.
I have tried that too. Ive also tried using execute console command
Not really sure what I should take away from that cause its not relevant to my problem
After the OpenLevel-Node with the listen option the session is obviously created successfully. After being sent back to the starting level when I try to create a new session it just says that it cant cause a session already exists
my bad i wrote wrong. when you are going back to your mainmenu level
are u destroying that session ? because if u are not it will say already exists.
are u have a button that leaves to main menu? like a pause menu widget ?
First I start to create a session. Then OpenLevel with listen option is called. The "Lobby" Level opens for a split second and I get send back to the starting level.
When I then try to create a new session it says the session already exists.
So I'm getting send back to the starting level without the session being destroyed.
There is no open level or anything that is getting called in the "Lobby" level
And the session isnt destroyed which could send me back
The level stays open when I open it without the listen option
I have a button that destroys the session in the widget that opens up in the lobby level but it is never called. I debugged that
And that also opens the main menu level but like i said its never triggered
i was having the same problem when i using first time that plugin. like a small error box says level already exist and crashes whole engine. but i really dont remember how i fix it.
u can try check your logic one more time maybe u missed some logic somewhere. also maybe u can try recompile project from vs. lemme check come forums maybe i can find out.
child actor is not replicating
The component likely is replicating just fine. Have you tested prints on clients? If you're expecting to test it visually, the class that this component uses to spawn an actor is not replicated. So you probably have a replicated actor with a replicated component, but the component isn't doing anything on clients.
ah i see, i had to replicate it in the blueprint thanks
Hey i am working on a swimming system and have the issue that the character jitters in the water i made a smaler function where i set the location of the character and have the same issue only if i play as standalone it works with no issues here is a gif https://gyazo.com/bb1e0338326d76965709eba09278e480
I wouldn't recommend using SetActorLocation() for pawns. There's more sophisticated built-in functionality for replicating pawns and their movement. Have you tried a Character Movement component?
i use default tp character template which function would you use to set the player position?
Here's a good basic setup. 🙂
i use that too but i make a swimming system and i need to keep the positin of the character
so that the character dosnt fall down to the ground
I've not worked much with swimming but have you looked into the built-in swimming controls in the Character Movement component?
i am not using the build in water plugin so i cant use them
and i have a similar swimming system they use the same method i am trying to use and there is no jittering
If you insist on using SetActorLocation() then I'd only point out that in the nodes you shared, you're only setting the location on the client. The reason it's jittering I'd guess is because as soon as the location replicates, the client is setting the location back to match the server since you never set it there.
Try setting the location only on the server and see how well that replicates if you haven't already.
Hello. 👋
Today I have a big question about enemy projectile replication with some special considerations. I'd appreciate any ideas as to solutions. 🙂
I'm building a side-scrolling space shooter with a fixed camera. In one stage, the boss periodically fires square pulses of energy that the player must avoid and navigate. 🔳 These squares consist of one to four links of energy that surround the boss as they radiate out from its centre. ⛓️
To accomplish this, I spawn a pair of actors for each link and move them across the screen. I then use these actors as the beginning and end point of a Niagara beam, forming the line of energy. I thought if I enabled bReplicatesMovement it would create pretty smooth motion but unfortunately the jitter is quite noticeable. 😕
My next idea is to try calculating the ping before each pulse and then synchronise the release of energy on server and client. ⏰ I'm wary that this will be unreliable.
Will it be possible to match the motion of these energy links on the server and client in a smooth and playable fashion and if so, how? ✍️
Any ideas would be appreciated. 🙂
Cheers.
I have a personal project here, and i've implemented a dash mechanic. It works by creating a linetrace to check for any objects within the dash distance, and sets the dash destination respectively to make sure you do not clip into any objects that the trace may hit. I then lerp the actor location from the start to destination using a timeline. I noticed that the player who dashes (left)will experience some jitters due to server correction. Is there a way I can mitigate these jitters?
Flow:
-Dash key pressed -> play dash timeline (only can run on client)
-OnDashTimelineUpdateClient -> set actor location -> call OnDashTimelineUpdateServer (i want to run client first for responsiveness)
-OnDashTimelineUpdateServer -> Set actor location on server
Thank you I will!!
Who knows what it is?
c++ land
you need to do stuff in the context of the character movement component
What you have right now is basically taking the entire 10k line character movement component and saying "nah, we're using a timeline to set the position of the character"
Is it possible to use physical based movement with the CMC?
define "physical based"
like by adding force to a static mesh
CMC can respond to add force
you helped me with some replication stuff a few days ago but I'm trying to make it better now. I watched the video you linked some other guy by reid and thought that it could be good to implement the cmc with physics but wasnt sure where to start
how could I get started with a custom cmc movement mode by adding force on player input?
https://discord.gg/uQjhcJSsRG
In this video I am introducing a series I will be making which explores the character movement component and how you can extend it in depth.
0:00 Intro
1:00 What is the CMC?
2:00 Do you need a custom CMC?
5:35 What does the CMC provide?
7:10 Outro
I can't vouch for how good this is but he covers 2 ways of doing a dash
Hey Adriel. If you have time, would you mind taking a look at my question just above Ryguy's today? Please let me know if you have any thoughts. 🙂
Do the links move with the boss or no?
Looks like I’m gonna be making a custom CMC. Woohoo
Once spawned, is there any change to the speed they move out that would need to be replicated? They can just be an actor that spawns attached, but the components (the things the links are between) move locally everywhere
no need to replicate anything other than the fact that the actor is spawned and that it's attached to the boss
I would start non-attached tho
There's no change to the speed after spawning. They move at a fixed rate.
So is my idea to calculate the ping and try to spawn at the same moment in time a good solution, you think?
just spawn a replicated actor and let it go
I wouldn't mess with anything ping related
If I spawn a replicated AALink, and I start it off moving across the screen, won't it be a little behind on the client?
yup
I mean you could maybe run ahead on each client based on ping if you wanted to
but it depends on how you're doing your hit detection and all that
I'm running a looping line trace between the endpoints of the links on the server.
I wouldn't delay the spawn tho. Spawn it, then instantly add ping/2 to the effective time for the time to distance math
Time goes in, link distance from boss comes out
Interesting, okay. I think I understand. But then what's the point of AALink being replicated at all?
so it shows up on other machines
I'd do it with 1 replicated actor
and do something like this
ignore my ping stuff, you need to figure out the local machines ping to server
but this will help you sort of "fast forward" instantly on spawn so it's in sync with the server side. You could also use timestamps etc or some other way
Instead of spawning on each machine without replication? You think it would be that much better to replicate the actor? I'm thinking of how I handle player projectiles which are not replicated.
worked fine untill this t
worked before but suddently not
can really se the error
tips?
Doesnt seem multiplayer related, just something wrong with your build targets. Bet youre trying to build for dedicated server on a binary build, or you dont have your server target set up properly.
it is for a dedicated server i mean isent that multiplayer related ?
build for dedicated on binary build menas what ?
Hello, sorry, I know this is a broad question, but I am kind of confused on when to use or not use the Gameplay Ability System. It seems that with Epic using it in Lyra, it is the preferred/recommended approach to making multiplayer games?
You cannot build dedicated server targets with an engine obtained from the epic launcher.
The answer depends on the game.
wait what .O ? but i have tho
No, you haven't.
You've probably made standalone game builds that may operate in server mode.
i mean im building it from source
Ok, so you're not using a launcher build then
Build targets are more engine architecture than multiplayer in my eyes, plus the general channel gets more eyes on the issue, but up to you!
well no, but im building the server from launcher from wich ive set up the server build via source kinda
You're either using a launcher build or you're not
obviously i followed a tutorial for it
there is no in-between
Patreon: https://www.patreon.com/SneakyKittyGaming
Discord: https://discord.gg/W5g6pZXfjh
In this video I walk you through installing the UE4 source build, specifically 4.26 :)
Source build: clone github repo->build in vs (or an alternative)->create server target->build server.
This or something else?
Havent heard of that kind of black magic before
it may show your project but that's not what I'm asking
i mean i just followed the tutorial
and it allows me to build the "server" & Client side from the aluncher
that's not the epic launcher
Launcher=editor I see
aye so what could be the issue or am i doing it wrong ?
Have you built your project for development editor and development server (for example) in vs?
yeah
Builds properly for server in vs then yes?
How so? Sorry if this is a dumb question. I was thinking GAS was best for RPG type games, but then i saw Epic using it in Lyra, which is a shooter, and i think i read they build the system for paragon which is a shooter/moba hybrid.
What do you mean "how so" - it depends on the kind of game you're building, and it depends on whether you want to structure your game such that it fits the model GAS expects.
there is also a channel dedicated to this - #gameplay-ability-system
GAS is built to be generic enough to be used with any genre that involves..well..abilities. It does mean however that youre building your game around it, so you need to plan and decide to use it or not. Has abit of learning curve afaik, so unless you need multiple features from it, for simple projects you probly dont need to use GAS.
Tldr as above, depends on your needs.
Ok, "depends on your needs" makes sense. I knew of the GAS system, but also just assumed it was more for RPGs or dealing with Damage or healing over time effects, etc, but not really for shooters. Then when i saw that Lyra used it, i got sort of confused on when to use it or not.
Makes sense. I guess the question is less if your genre would be compatible with it, and more if you need its premade systems with their inherent complexity.
Agreed. As someone who is new to UE, it seems like GAS might be a bit much, but if GAS is what epic recommends via the Lyra example, I might go down that rabbit hole a bit
I mean, if you try and base everything off what Lyra does, you'll have an over-engineered game for a large portion of indies.
As I understood, lyra aims to respect industry standards and generally optimal solutions while providing maximum extensibility to serve as a generic base for any semi-professional/professional shooter game projects. Also very good as a learning example to see how certain features and systems are used the way epic designed them and the way it's intended. I dont think it automatically means that it should be used wherever possible, I think for a lot of games actually avoiding GAS would be the optimal design decision.
good points
That's fair, multiplayer development seems like a large time investment, i was just wanting to invest my time doing it the "epic approved" way, if Lyra is such a thing. I am probably over thinking what Lyra was meant to be though
What's the scope/scale? Do you need lyra/GAS -specific features?
No i dont think i do. Its a co-op shooter game. There will be over time effects, etc. I wanted to study Lyra on how to do something, and realized they use GAS, and that's when i asked my question here. Wasnt sure the "right" way to make multiplayer games.
There isn't a "right" way like you're thinking
I dont wanna ask too many things or overcomplicate it here, but have you made similar projects before? I think lyra is really good for intermediate devs that see through lyra's relatively complicated systems/setup, while UE beginners are probly better of learning the engine via setting up their learning projects in a simpler way. But this is up for debate and your preference.
Hey i have an issue with replicating water volume if user 1 press Key Ä both player have this enabled how can i fix that
Youre asking the server to execute a multicast event, it'll execute your last bit of code on all clients and the server.
I have started and stopped many projects, lol. Wanted to come back though and try again. To answer your question though. I am a noob.
yes because its nessasary that all clients know that for example client 1 has water volume enabled or not?
Client presses key, executes and rpc that execs on server. Server then sets the variable's correct value. The bool needs to be set to replicated.
This way all clients will see the change. If you need to execute some code on all clients, use repnotifies instead of simple replication.
but the bool is from the physics volume ho i can set the physics volume replicated?
You can pass the correct value on your rpc to the server.
Alright I see it now. How abt you use a replicated bool as I said in whatever class youre currently in, and set the physics volume's bool on each client locally via a repnotify?
I'm saying this without knowing what you're actually doing with your logic
I guess if youre interested, lyra's there to study c: if you really just wanna progress with your project and you can complete all systems you need by yourself in a reasonable time, then no need for gas and its framework.
i dont see where i can change the bool (replicated or repnotify) :S
i made if user1 enters water set movement mode to swimming and then enable the water volume that the user1 is floating on the water but my isue is that if user2 goes inside the water user1 falls down to ground because water volume is set to false
but i just use for now movement mode flying there i dont need the water volume
I meant you'd create your own bool or enum for the movement mode and set it replicated. And each client would set the correct movement mode when your custom variable changes (repnotify).
i dont create a bool with water volume its a build in unreal engine bool
the movement mode works perfect but not the water volume
Since thats a built in bool, thats why I suggested you create your own bool as you can change its replication settings.
so i can rebuild everything unreal engine coded with that bool to make it posible ^^
I think you're misunderstanding my suggestion.
-You have a built in bool that is not replicated.
->Could create a custom bool in your blueprint and replicated THAT, then set the original built in (nonreplicated) bool on all clients.
-Consequence: you only had to add 1 bool to your blueprint, and now the built in bool is "replicated" to all clients.
Cant put it any other way to simplify the idea.
hey there, im currently implementing vehicles into my game which can be possessed by the player controllers. That vehicle has health and therefore needs to replicate that. The problem is it cant be replicated at the moment because it has no owner. Any design suggestions on how i should approach this problem? Im programming for listen servers btw.
GAS is nothing but a basic framework for handling abilities and stats. It can apply to most game styles and is not shooter specific. It would fit an RPG just as well as a shooter, as well as an RTS, as well as a platformer, as well as a village builder. It isn't required, but it does save on a lot of initial structure coding in most cases.
Sure it can replicate
Are you replicating a variable or trying to use RPCs?
I also need to call rpcs for entering and exiting and those things
So i definitely need ownership
So i just do the whole logic in the character?
You also have a PlayerController
PlayerController can request to possess the vehicle
Thanks for the quick tip
Character can too
Either way:
Input -> Choose what to interact with -> Run on Server Event -> Serverside PC / Pawn calls Interact on the thing, passing in a ref to self
Vehicle.Interact -> get playercontroller from passed in ref -> possess -> ??? -> profit
Whether or not it makes sense to put that stuff in the PC or Pawn depends on your design.
if getting in a vehicle always implies being in a Character at the time, then putting it as a regular interaction thing is fine
if you can body swap all over the place like from vehicle to vehicle then I'd put it in the playercontroller
Since the main part of my interact functionality is inside the pawn I think it's best that I code it in the pawn
just make sure the actual interact call happens serverside
