#multiplayer

1 messages · Page 87 of 1

pseudo crest
#

My problem is getting me nutts, my game is returning Unable to load SocketSubsystem module STEAM when I create a session on my PC and laptop but it runs normal on my brother's pc

amber barn
#

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

small grail
#

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?)

sinful tree
# amber barn i dont understand how for two other variables i have this done and i understand ...

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?

amber barn
#

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?

sinful tree
#

Try this:

    UFUNCTION(Server, Reliable, WithValidation)
    void RPC_ChangePlayerName(const FString PlayerNameString);
amber barn
#

yeah I tried that before i sent the msg, doesnt work 😦

small grail
amber barn
#

same error

small grail
amber barn
#

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;
}
small grail
#

Try const FString& Name

amber barn
#

yo, that worked, thanks but why is it a reference?

small grail
#

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

amber barn
#

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

sinful tree
#

That's because you're getting the owning playerstate. All widgets are always owned by the local client.

amber barn
#

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

sinful tree
#

You need to get the playerstate of the pawn that has the widget overhead.

amber barn
#

yeah i think im doing that anyway 😂 oh man.. 😦

amber barn
#

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);
    
}
sinful tree
#

No.
It's in your widget where the problem is.

#
APlayerStateWarlocks* PlayerState = Cast<APlayerStateWarlocks>(GetOwningPlayerState());
#

This is what you have

amber barn
#

ahh ok right, this is getting all of them?

sinful tree
#

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.

amber barn
#

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

sinful tree
#

There is a OnRep_PlayerState() in the pawn.

small grail
#

So you should be able to get the widget through the pawn class

amber barn
#

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?

small grail
#

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

sinful tree
amber barn
#

OnRep_PlayerState() in the pawn.
this just calls the delegate then?

sinful tree
#

No

amber barn
sinful tree
#

It binds to the delegate.

amber barn
#

ahh ok

sinful tree
#

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.

amber barn
#
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

sinful tree
#

Yea

amber barn
#

😢
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?

small grail
#

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.

sinful tree
amber barn
# sinful tree 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);

amber barn
sinful tree
#

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.

amber barn
#

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
sinful tree
#

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?

amber barn
#

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);
}

sinful tree
#

Line 34 is the cast?

amber barn
#

sorry should have said line 34is this StateWarlocks->OnPlayerNameChanged.AddUniqueDynamic(this, &UPlayerName::SetName);

sinful tree
#

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.

amber barn
small grail
#

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

amber barn
#

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 😦

sinful tree
#

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.

amber barn
#

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;
upbeat basin
amber barn
upbeat basin
#

Also is SetName UFUNCTION()?

amber barn
#

ill try that now, thanks

yep its a ufunction

amber barn
#

kinda crazy its not ready but we roll with it haha

upbeat basin
#

So it fixed the crash?

amber barn
#

yepyep

upbeat basin
#

Are the names shown properly as well?

amber barn
#

haha no

#

the function isnt called at all 😦

upbeat basin
#

Okay then there should be a problem on either creating or reaching to the widget

amber barn
#

next problem to solve

sinful tree
#

!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.

amber barn
#

^ agreed but the crash has stopped

upbeat basin
#

It can happen

amber barn
#

hahaha

upbeat basin
#

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

amber barn
#

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

upbeat basin
#

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

sinful tree
#

So then maybe make the UPlayerName::SetName() function a UFUNCTION if it's not already?

amber barn
#

ya, its a ufunc alread

private:
    UFUNCTION()
    void SetName();
sinful tree
#

Sorry, meant UPlayerName::SetPlayerState()

upbeat basin
#

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

sinful tree
#

GetUserWidgetObject()
Returns the user widget object displayed by this component.

GetWidget()
Gets the widget that is used by this Widget Component.

#

Both return UUserWidget.

amber barn
#

i tried GetWidgetjust then same result

#

(no name change and delegate function not called

upbeat basin
sinful tree
#

One thing I can think of, is that perhaps the widget itself hasn't been constructed by the time the playerstate is being replicated.

amber barn
sinful tree
#

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.

amber barn
#

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

blazing thicket
#

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

sinful tree
# blazing thicket Hi guys! Yesterday I wrote about a problem loading a player class on the server....

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.

blazing thicket
sinful tree
# blazing thicket Thank you for your reply! Did I get it right - I have to perform all the actions...

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.

blazing thicket
sinful tree
#

You can take the reference you have to the class and do a is valid on it.

blazing thicket
fierce fiber
#

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!

thin stratus
#

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

fierce fiber
#

Ah I see, thanks!

blazing thicket
# sinful tree You can take the reference you have to the class and do a is valid on it.

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

thin stratus
#

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.

wheat niche
#

hey i saw that the advanced session plugin have a own server travelling function and im wondering what in url means

fathom aspen
oak pond
#

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

icy jetty
oak pond
#

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

quasi tide
#

Well - yeah. A lot of blind leading the blind.

#

The people who are actually making games don't have time to be on reddit.

oak pond
#

do I just have to brute force my way through

#

monkey typewriter type thing

quasi tide
#

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 🙃

oak pond
#

I know boywtf

#

Im packaging and testing that as much as I can

dark edge
oak pond
#

its not so obvious in editor, but the server (on the right) has slower turning

dark edge
#

What are you using control rotation for?

#

anything?

oak pond
#

no I dont use that

dark edge
#

I'd use it for orientation then.

#

you'll have an automagic yaw that gets replicated for you

oak pond
#

how do you mean? how would I use it for this

thin stratus
#

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.

icy jetty
#

I meant, if possible, to turn off the wall’s collision temporarily while readjusting the char’s position

dark edge
oak pond
#

yeah, but they aim towards the cursor in the top down view, is it possible to use control rotation for that?

dark edge
#

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

oak pond
#

oh wow thanks, that seems to have fixed it, I thought control rotation only worked with camera movement

dark edge
#

no, it's just a rotation that the controller has that many other things can opt in to using

fathom aspen
waxen socket
#

Hey Evo. Any chance you ever solved this? I'm having the same error. 🤔

fathom aspen
#

I mean it's telling you that you are destroying the session before there is a valid PlayerState

waxen socket
#

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. 🤔

fathom aspen
#

Yeah a lot of stuff broke and were fixed starting with 5, so it's reasonable

#

Are you calling DestroySession yourself?

waxen socket
#

Yeah, I'm not surprised. 😅

fathom aspen
#

Sounds like you are calling it at a point in time where it's not suitable

waxen socket
#

I don't think I'm calling it at all.

fathom aspen
#

Ah RIP then

waxen socket
#

I think Unreal is destroying the session because it finds the client's player state to be invalid.

fathom aspen
#

Do you get a crash or something? so we can look at the callstack?

#

Or simply just an error log on travel?

waxen socket
#

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

fathom aspen
#

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

waxen socket
#

Thanks for your sympathy at least.

quasi tide
#

Reject multiplayer. Embrace singleplayer. Life was much more simple.

waxen socket
#

Could it be a firewall problem?

waxen socket
fathom aspen
#

Without setting breakpoints and raising your connection timeout config variable(s) you will have a hard time to debug this just to being with

waxen socket
#

I will take memes in lieu of solutions.

quasi tide
waxen socket
#

Thanks, guys. I'll continue to look into this. 🔍

dark edge
#

it'd be so simple

waxen socket
#

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. 🙂

glacial pollen
waxen socket
#

Hey, thanks for your reply. Yes, it’s in PIE.

glacial pollen
#

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.

waxen socket
#

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.

glacial pollen
#

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.

waxen socket
#

Yes, of course. I'll double-check but these issues were nascent with the project's upgrade from 4.27 to 5.2. 🤔

glacial pollen
#

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:

waxen socket
#

Thanks again. 🙂

glacial pollen
#

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)

waxen socket
#

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. 🤔

kindred widget
limpid parcel
#

is there a way around having to call islocallycontrolled in beginplay?

quasi tide
#

Yeah. Just don't.

#

(Without more explanation of what you're doing. We can't say)

zenith pilot
#

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

glacial pollen
fathom aspen
sinful tree
# blazing thicket I have changed the functions in the project a bit. Now on EventBeginPlay event a...

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.

blazing thicket
thin stratus
dark edge
#

Is there an infographic around with all the stock events for pawn / character and WHEN they fire on what machines?

fathom aspen
#

Haha you are not alone, I was mind blown to find that this existed. This was added in ue5 seemingly 😄

sinful tree
#

OnPlayerDoesThatThingThatsSupposedToHappen()

fathom aspen
#

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

blazing thicket
fierce fiber
#

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!

sinful tree
# fierce fiber For some reason, the colour and text is just setting to the clients pov and not ...

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.

dark edge
#

Not the code, the result.

fierce fiber
#

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

dark edge
#

like is there a red team and blue team or is your team always blue?

fierce fiber
#

Yeah I want everyone to see the cubes colour whether its blue or red

#

But only that team can revive their coloured cubes

dark edge
#

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

fierce fiber
#

Yeah I should probably readjust the gamemode to utilize alot of these types of vars within the player state

dark edge
#

However you do it, do not multicast anything

#

this is state

#

use replicated variables (with onreps if you need to respond to them changing)

fierce fiber
#

When should multicasting be used in a FPS multiplayer scenario, because I get confused to what multicasting actually means

dark edge
#

Multicast stuff where it doesn't matter after a second or so

#

sounds, effects, messages

#

basically nothing gameplay related really tbh

fierce fiber
#

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

dark edge
#

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

fierce fiber
#

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

wheat niche
#

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

dark edge
fierce fiber
#

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

fathom aspen
#

HandleStartingNewPlayer gets called always regardless of the travel type

fathom aspen
#

What do you think?

#

Yes

wheat niche
#

Okay nice thank you I’ll try it tomorrow 👍

oak pond
#

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

safe marsh
#

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?

radiant dew
#

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

fathom aspen
#

First of all never use GetPlayerController(0)

#

Second of all, which bp actor is this?

fierce fiber
#

@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

fathom aspen
radiant dew
#

the camera is a pawn

fathom aspen
#

But bp is player controller right?

radiant dew
#

yes

fathom aspen
#

Then why do u use that node that has index zero

radiant dew
#

i figured since when a player spawns that would be easiest to grab the player controller from there

fathom aspen
#

You are already in the bp actor

icy jetty
#

self works fine

radiant dew
#

oh true xD sorry, still seems to face the same problem

fathom aspen
#

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

oak pond
icy jetty
fathom aspen
oak pond
#

where would I look specifically?

fierce fiber
#

This pawn also replicates

fathom aspen
#

Saved/Logs

fierce fiber
#

and I just tested the server only and it didnt work

oak pond
#

but what kinda thing should I be finding there

fathom aspen
#

Where things start going wrong

#

Error...

#

Disconnecting client...

#

Server going brrr...

radiant dew
#

oh seems that the event beginplay/onPossess requires half a second delay on the client before i can set view on it or something...

oak pond
#

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)

dark edge
#

It's a replicated actor, so just destroy it on the server and you're done

radiant dew
fathom aspen
#

Or the map isn't packaged

#

This is not sufficient info

oak pond
#

but it loads the map for one frame

fathom aspen
#

Show us how u wrote the command

#

Did you package your map?

#

Did you add it the list of maps that should be packaged

oak pond
#

yeah Ive done it multiple times and its been fine

fathom aspen
oak pond
#

it loads the map for a frame and then back to main menu map

#

this is all it is

fathom aspen
#

It changes your view @radiant dew

oak pond
#

and everything works in standalone as mentioned

fathom aspen
#

So you know what you can use

fierce fiber
# dark edge No, don't multicast destroying an actor.

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

fathom aspen
#

ReceiveRestarted @radiant dew

#

But that's on the pawn iirc

oak pond
#

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

dark edge
fierce fiber
#

Nice, ty

oak pond
#

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

icy jetty
#

gremlins man

oak pond
#

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

icy jetty
#

do not despair, take breaks 🙂

oak pond
#

then I feel like I’m wasting time trollshock I already don’t work quick enough with most things

ruby rock
#

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

amber barn
#

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?

vivid seal
# ruby rock I want to implement a function in an MP game, C++, the function is fairly simple...

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.

sinful tree
amber barn
#

ahh i thought that wasnt that... for fucks suck

sinful tree
#

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.

amber barn
#

mm right, but like nothing is ready when i try and set the player state

#

ughhh

small grail
#

Sorry to hear you are still struggling...

sinful tree
#

Race conditions are great 😄

amber barn
#

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

sinful tree
#

Maybe something crazier... Like... Constructing the name widget component at runtime.

amber barn
#

is that /s or is that crazy haha

sinful tree
#

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.

amber barn
#

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

sinful tree
#

Because the RPC Implementation is only executed on the server.

amber barn
#

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?

sinful tree
#

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.

amber barn
#

ahhhh right, so i should just create the bloody widget at run time and it would probably solve this

#

ok

sinful tree
#

Possibly, create the widget, execute the binding stuff, feed it into your component. maybe that will work.

amber barn
#

alright, thank you AGAIN, 🤞 i can get it now

upbeat basin
#

Is using GetPlayerController(0)->GetPawn() correct way to reach the locally controlled pawn from anywhere?

karmic briar
#

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

wheat niche
#

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?

fossil spoke
#

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.

wheat niche
#

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

fossil spoke
#

If you are spawning automatically then what are you using HandleStartingNewPlayer for?

wheat niche
#

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

fossil spoke
#

What do you mean handle player join?

#

You arent being specific enough

wheat niche
#

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

fossil spoke
#

🤦‍♂️

wheat niche
#

so what can i do now?

steady cape
fierce fiber
#

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!

wheat niche
steady cape
steady cape
#

I don't know if there's something called when this happens myself

#

I'm quite curious

wheat niche
steady cape
fossil spoke
steady cape
fossil spoke
#

He stated that HandleStartingNewPlayer "isnt working for him".

wheat niche
#

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 🙂

fossil spoke
#

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.

steady cape
#

I see

wheat niche
#

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

steady cape
wheat niche
fossil spoke
#

You should not be doing that

steady cape
#

I think you need to post code that you have

wheat niche
#

calling the event inside blueprint?

fossil spoke
#

HandleStartingNewPlayer is called by the GameMode when it needs to. You should not be calling it manually yourself.

#

Please post code.

wheat niche
fossil spoke
#

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"

wheat niche
#

like this?

fossil spoke
#

Yes

#

Make sure to plug in the NewPlayer

wheat niche
#

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?

fossil spoke
#

Because it has an implementation in C++ that is important

steady cape
wheat niche
#

oh i see

fossil spoke
#
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);
    }
}
steady cape
#

I mean, when they say "override" the method, they mean it

wheat niche
#

well thank you very much guys it helped me a lot and i learned new things

fierce fiber
steady cape
fierce fiber
#

Do you mean the player or the spectator?

steady cape
#

The player

chrome bay
#

The collision being on/off is not replicated, so that might explain what you're seeing.

fierce fiber
#

So I need to set collision for both server and client, gotcha, thanks man!

chrome bay
#

Yeah. Probably the best way is to make a replicated bool of your own, and use an OnRep callback to call SetActorEnableCollision locally.

latent heart
#

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.

oak pond
#

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

oak pond
#

WHAT DO I DO

#

theres nothing online for 90% of my problems yet Im literally just setting it up based on working guides

woven basin
oak pond
#

I did have a look for level searches, but dont know what else to look for

tranquil yoke
#

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 ?

pseudo merlin
#

are RPCs sent at the net update rate? or are they sent ASAP? thanks

oak pond
#

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

oak pond
#

oh my god so the defaultengine settings I put in to supposedly fix something, was in fact causing this problem

#

how

kindred widget
#

Does it change your net drivers? Can't remember if that's in Engine or Game ini.

dark parcel
quasi tide
#

C++

short arrow
dark parcel
#

the character is using the speed from CMC

#

it's just when using a bool to drive the state, character will get rubber banded

short arrow
#

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

dark parcel
#

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

short arrow
#

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

dark edge
#

basically "I want to sprint now" needs to be a move in the context of the CMC

lean sundial
#

Can I replicate UPROPERTYs in a subsystem?

dark edge
#

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

lean sundial
#

i see, i guess i could use that pattern

dark parcel
dark edge
# dark parcel I see, thank you

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...

▶ Play video
dark parcel
#

@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...

▶ Play video
quasi tide
#

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.

dark parcel
#

Yeah looking thru the video he also have sprint/wall running function

#

with prediction

dark edge
#

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

quasi tide
#

lol

dark edge
#

that'll predict just fine, but it's trivial to cheat. Would work in a pinch though

quasi tide
#

I love it

dark edge
#

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

queen escarp
#

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?

icy jetty
#

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

sinful tree
#

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.

icy jetty
#

Oops sorry, int is def better 😅

queen escarp
#

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 ?

sinful tree
#

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.

young spoke
#

learned the hard way that RPCing a current stat value instead of the delta stat value in udp socket is a bad idea...

dark edge
#

Every time someone gets a kill, you can tell the gamemode

#

gamemode can check whatever it wants

lusty portal
#

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

stone beacon
#

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)

dark edge
#

shift-F1 to release cursor so you can click the other window

stone beacon
#

I click it, but I can't move it, the window is selected but the control are working only for one player

dark edge
#

We'd need to see your code

#

is this a template / starter project?

#

or did you make the controls from scratch?

pseudo merlin
#

are RPCs sent at the net update rate? or are they sent ASAP? thanks

fossil spoke
pseudo merlin
#

thanks!

fathom aspen
#

With the exception of unreliable multicasts iirc

elder sable
#

Hi, how to connect to a dedicated server using steam subsystem ?

dark edge
#

yes

elder sable
dark edge
#

That's a separate question, only one question per day, please.

elder sable
#

Thanks

clear island
#

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?

sinful tree
#

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

clear island
#

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

clear island
#

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

clear island
#

ok I ended up overriding APlayerController::CalcCamera, thats more reliable

#

all working now

sinful tree
#

Nice

cold moat
#

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

sinful tree
# cold moat 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.

near granite
#

I made a dedicated server, and join that, but Open xrMsftHandIneraction R Grip not working when joined players number are more than 2

cedar lagoon
#

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,

turbid escarp
#

hey anyone knows why my hud freaks out when a another players joins a session ?

turbid escarp
# turbid escarp

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.

stone beacon
#

Hello, why is this spawning 2 actors in the game ? i just want to spawn one :/

thin stratus
stone beacon
#

Oooh ! thank you !

thin stratus
#

Multicasting this will create the one on the Server, replicated to Clients and a local duplicated version for each Client

stone beacon
#

Oh thank you ! The tutorial was unclear

thin stratus
#

Did you read the Multiplayer Network Compendium yet?

stone beacon
#

Hmm what is it ?

thin stratus
stone beacon
#

Thank yoou !

stone beacon
#

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

thin stratus
#

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

stone beacon
#

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

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

stone beacon
#

so this is right ?

thin stratus
#

Correct

marble fox
#

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

pseudo merlin
#

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

thin stratus
#

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.

marble fox
#

like begin play

thin stratus
#

Not sure what you struggle with

thin stratus
marble fox
#

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

quasi tide
#

Sounds like an anim montage

marble fox
#

doesnt that require a animbp

quasi tide
#

You could also set the animation mode of the skele mesh to play a single animation. No anim BP required

marble fox
#

yea just see that my animation is super weird ingame, it gets tiny

meager spade
#

@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

pseudo merlin
#

@meager spade ah interesting thanks, how do you cap client send rate?

meager spade
#

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
pseudo merlin
#

yeah listen server

#

this is awesome, thanks a ton

meager spade
#
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)

pseudo merlin
#

awesome. thanks!

olive kraken
#

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?

kindred widget
olive kraken
#

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.

oak pond
#

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

oak pond
#

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

open bone
#

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?

icy jetty
#

It was not created in UE, stop trolling every channel

dark parcel
#

😄

formal solar
#

how does repnotify work in hosted mode?

dark edge
formal solar
#

is repnotify called twice on the host client

dark edge
#

BP repnotifies run on server

#

no

formal solar
#

i thought repnotify was more or less equivalent to multicast

#

when called from server

dark edge
#

no

#

repnotify means "run this function when this variable changes"

#

Notify me when it's Replicated

formal solar
#

I understand the first part fully
The second part is a bit over my head.
I usually rely on multicasts

dark edge
#

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

graceful flame
#

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.

formal solar
#

Do i need to call repnotify from server?

dark edge
#

you don't call it

#

its automagically called

#

when you change the variable on the server

formal solar
#

oh yeah I mean by that, change a variable flagged with repnotify

graceful flame
#

Too many reliable multicasts can cause a buffer overflow and force a client to disconnect.

dark edge
#

or rather, when the change is replicated

dark edge
#

ANY time that variable changes, the repnotify will run

formal solar
#

on all clients yes?

dark edge
#

on everyone

formal solar
#

even on the hosting client, only once?

dark edge
#

for bp repnotifies

#

yes

formal solar
#

ok

dark edge
#

c++ repnotifies need to be manually called on server

graceful flame
#

Repnotify ftw

dark edge
#

it's still automagic for clients

#

yes, best feature of Unreal

graceful flame
#

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.

formal solar
#

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

graceful flame
#

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.

dark edge
#

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

formal solar
#

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

graceful flame
#

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.

formal solar
#

I will definitely look into replacing some of my multicasts at any rate

#

Since I do ocassionally get disconnects

graceful flame
#

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.

formal solar
#

yes a simulated proxy

obtuse loom
#
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
graceful flame
#

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.

formal solar
#

a lot of this is over my head but ty again

turbid escarp
#

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?

kindred widget
meager spade
#

@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

dark parcel
#

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?

elder sable
#

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 ?

plucky prawn
elder sable
#

I see thanks !

nova kelp
#
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)```
pseudo merlin
#

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?

near granite
#

When one player logs in dedicated server, the other player's pawn is unpossessed.

near granite
amber barn
#

hi guys, by default how many players/clients can join a game? thats hosted with the 'default' project settings?

wanton bear
#

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

wanton bear
#

the problem was passing rotation values from the server to the client and then multicasting

near granite
# near granite

It was because auto possess player option was turned on in the pawn's class default.🫣
after changing that like this, problem has solved

wanton bear
#

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

turbid escarp
# turbid escarp

@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.

wanton bear
#

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

plucky prawn
#

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).

fossil veldt
#

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

crystal palm
#

Guys how can I make simple replicated character movement but in pawn class?

near granite
#

Who knows what it is..🥲

formal solar
#

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

near granite
formal solar
#

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

near granite
dark parcel
wanton bear
dark parcel
#

yeah but you can pass that variable from client to server when U do the run on server u can add Building Class input

near granite
#

I replicated the variable and set the variable on the server, but the variable does not change on other clients.

limber gyro
#

does any 1 know why when u join a steam session u get a lobby callback?

amber barn
#

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 🙂

pliant tulip
#

better to use RepNotify than multicast

dark parcel
#

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?

fierce fiber
#

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:

fierce fiber
#

Ah I managed to fix it! Just needed some tweaks with the replication

near granite
#

Help me..I replicated the variable, but the variable is still false on the other client. why is this

near granite
dark edge
#

is that variable being set ANYWHERE else?

near granite
#

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?

dark edge
#

assuming the code you've show is all of it and you don't have any weird settings that should work.

dark edge
dark edge
#

What actor is this code in?

#

is it a pawn?

near granite
#

Yes

dark edge
#

then it should work. Put a breakpoint on the server side of the RPC and make sure it's firing

gray orchid
#

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

wanton bear
#

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 7739monkathink

#

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?

thin stratus
#

@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.

wanton bear
#

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?

thin stratus
#

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

dark parcel
#

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

sour geyser
#

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

dark edge
wanton bear
dark edge
#

look for references to your main menu level

sour geyser
#

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

wanton bear
#

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

lean sundial
wanton bear
sour geyser
#

why would this not function? its only when i have "listen" as the option in open level, that i cant open the level

thin stratus
#

You'd need to check your logs

wooden abyss
turbid escarp
#

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

sour geyser
turbid escarp
sour geyser
wooden abyss
#

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

turbid escarp
#

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.

wooden abyss
#

No I'm not

#

Let me clarify what happens exactly and what exactly is the problem

turbid escarp
#

are u have a button that leaves to main menu? like a pause menu widget ?

wooden abyss
#

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

wooden abyss
#

And that also opens the main menu level but like i said its never triggered

turbid escarp
#

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.

wanton bear
#

child actor is not replicating

kindred widget
# wanton bear 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.

wanton bear
late marlin
waxen socket
late marlin
waxen socket
#

Here's a good basic setup. 🙂

late marlin
#

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

waxen socket
#

I've not worked much with swimming but have you looked into the built-in swimming controls in the Character Movement component?

late marlin
#

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

waxen socket
#

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.

waxen socket
#

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.

naive wind
#

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

near granite
#

Who knows what it is?

dark edge
#

you need to do stuff in the context of the character movement component

naive wind
#

Gah

#

Sucks

dark edge
#

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"

rose comet
#

Is it possible to use physical based movement with the CMC?

dark edge
#

define "physical based"

rose comet
#

like by adding force to a static mesh

dark edge
#

CMC can respond to add force

rose comet
#

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?

dark edge
#

I can't vouch for how good this is but he covers 2 ways of doing a dash

naive wind
#

Oh awesome

#

I appreciate it

waxen socket
#

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. 🙂

dark edge
waxen socket
#

I was spawning them attached, yes.

#

But it's a fairly stationary boss, why?

naive wind
#

Looks like I’m gonna be making a custom CMC. Woohoo

dark edge
# waxen socket I was spawning them attached, yes.

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

waxen socket
#

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?

dark edge
#

just spawn a replicated actor and let it go

#

I wouldn't mess with anything ping related

waxen socket
#

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?

dark edge
#

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

waxen socket
#

I'm running a looping line trace between the endpoints of the links on the server.

dark edge
#

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

waxen socket
#

Interesting, okay. I think I understand. But then what's the point of AALink being replicated at all?

dark edge
#

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

waxen socket
# dark edge I'd do it with 1 replicated actor

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.

queen escarp
#

worked fine untill this t

#

worked before but suddently not

#

can really se the error

#

tips?

cursive steeple
# queen escarp 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.

queen escarp
#

it is for a dedicated server i mean isent that multiplayer related ?

#

build for dedicated on binary build menas what ?

foggy shoal
#

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?

hollow eagle
# queen escarp

You cannot build dedicated server targets with an engine obtained from the epic launcher.

hollow eagle
queen escarp
#

wait what .O ? but i have tho

hollow eagle
#

No, you haven't.

#

You've probably made standalone game builds that may operate in server mode.

queen escarp
#

i mean im building it from source

hollow eagle
#

Ok, so you're not using a launcher build then

cursive steeple
queen escarp
#

well no, but im building the server from launcher from wich ive set up the server build via source kinda

hollow eagle
#

You're either using a launcher build or you're not

queen escarp
#

obviously i followed a tutorial for it

hollow eagle
#

there is no in-between

hollow eagle
#

A source build is not a launcher build

#

are you using a launcher build or not

cursive steeple
#

Source build: clone github repo->build in vs (or an alternative)->create server target->build server.
This or something else?

queen escarp
#

yeah that

#

but its set up so i can build it from the launcer really :/

#

launcher*

hollow eagle
#

what

#

the epic launcher doesn't deal with source builds whatsoever

cursive steeple
#

Havent heard of that kind of black magic before

hollow eagle
#

it may show your project but that's not what I'm asking

queen escarp
#

i mean i just followed the tutorial

#

and it allows me to build the "server" & Client side from the aluncher

hollow eagle
#

that's not the epic launcher

queen escarp
#

oh no not the launcher lol

#

mb

cursive steeple
#

Launcher=editor I see

queen escarp
#

aye so what could be the issue or am i doing it wrong ?

cursive steeple
#

Have you built your project for development editor and development server (for example) in vs?

queen escarp
#

yeah

cursive steeple
#

Builds properly for server in vs then yes?

queen escarp
#

ive done it like 4-5 times before and its worked fine just dosent work now

#

yeah

foggy shoal
# hollow eagle The answer depends on the game.

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.

hollow eagle
#

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.

cursive steeple
foggy shoal
#

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.

cursive steeple
foggy shoal
#

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

quasi tide
#

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.

cursive steeple
# foggy shoal Agreed. As someone who is new to UE, it seems like GAS might be a bit much, but...

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.

foggy shoal
#

good points

foggy shoal
cursive steeple
foggy shoal
#

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.

quasi tide
#

There isn't a "right" way like you're thinking

cursive steeple
late marlin
#

Hey i have an issue with replicating water volume if user 1 press Key Ä both player have this enabled how can i fix that

cursive steeple
foggy shoal
late marlin
cursive steeple
#

This way all clients will see the change. If you need to execute some code on all clients, use repnotifies instead of simple replication.

late marlin
cursive steeple
cursive steeple
#

I'm saying this without knowing what you're actually doing with your logic

cursive steeple
late marlin
#

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

cursive steeple
late marlin
#

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

cursive steeple
late marlin
#

so i can rebuild everything unreal engine coded with that bool to make it posible ^^

cursive steeple
#

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.

fleet viper
#

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.

kindred widget
dark edge
#

Are you replicating a variable or trying to use RPCs?

fleet viper
#

I also need to call rpcs for entering and exiting and those things

#

So i definitely need ownership

dark edge
#

no you don't not on the vehicle itself

#

not for entering

fleet viper
#

So i just do the whole logic in the character?

dark edge
#

You also have a PlayerController

fleet viper
#

Or that

#

Ok so then it's clear what I have to do

dark edge
#

PlayerController can request to possess the vehicle

fleet viper
#

Thanks for the quick tip

dark edge
#

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

fleet viper
#

Since the main part of my interact functionality is inside the pawn I think it's best that I code it in the pawn

dark edge
#

just make sure the actual interact call happens serverside