GameMode vs GameModeBase

Hello everyone!
I build the SessionSystem the same way as in Course and everything works fine in both case in NULL system and In Steam system. then I needed Persistent PlayerState Class and there for my GameModeBase class changed to GameMode class and after that Client can not connect to Server, FindSession() no more working.
Can anyone explain why GameModeBase is compatible for our code and GameMode ?
and how can I fix the problem?
Engine v4.19.2

I don’t know why the switch would have broken anything. But you shouldn’t need to switch away to use PlayerState.

Ok Sam

But how can i use PlayerState class. after connection in Lobby level I set PlayerName PlayerState::SetPlayerNameInternal() I use this function for HostServer and Client and when we travel next Level Server had his Name but Client lost, Because PlayerState::CopyProperties() was executed only Server. what I did wrong?

and where is a better place to set Character type, Player Name and same things. Before Connection in MainMenu Level or after Connection in Lobby Level or it’s no matter?

I don’t think you should be calling PlayerState::SetPlayerNameInternal(). It is labelled as “Internal” which seems to indicate it isn’t meant to be used.

no I use SetPlayerName() and in it is called SetPlayerNameInternal();
but I can’t understand how PlayerState work.
In every forum in every video in every document which i found are mentioned that for persistent data is useable PlayerState::CopyProperties() function but it’s not replicated and executed only server side not for Client
after tow days I decided to give it up and store my data in GameInstance but I don’t think it’s good practice
Have you any Idea how can I use PlayerState Class properly ?
and one more Does PlayerController Persistent Class during the Level travel or such Persistent Class is only GameInstance ?

So have you overridden CopyProperties or are you trying to call it? I’m struggling to get the bigger picture from your description. Could you try to give a more full description of what you are doing and what you have tried?

Hello Sam

Code is Simple. Create and Join Session code is the same as it in your course.

first in first I create connection because before connection we have not seamless travel and without seamless travel CopyProperties() function is not executed at all.

after connection in Lobby Level I set name for Server and for Client and then I travel in GameLevel
after traveling Name and all other set data is persisted only Server not Client

here is map:

here is code:
PlayerState Class:

Widget Set Data

Widget Print Data

and this Widget I create in BP_PlayerController::BeginPlaye()
As you can see I use PlayerState default variable PlayerName and also local variable OwnerPlayerName
but it Does not work in either case

@Bryant_Schaper could you see if you can make out what’s happening here?

@sampattuzzi I’ll take a look

Hello Guys i fix it
Player Setter data I wrapped in Custom Event in PlayerController side and marked it “Run on Server” and then this Event used in Widget. like so:

Sam_1

As it seems data is stored only client side and server doesn’t know about it
PlayerState and LevelTravel is executed only Server side and use the data which is stored only server side

But why Server doesn’t know about it because we set the data across the widget or anything that we want to know server must be marked "Run on Server?

thank you guys for attention

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms