Download

Are PlayerState methods called from the server?

So, im working on a game and im not really familliar with unreal, im learning quite everything, days after days, working on my project.
From what i read, PlayerState class are class that are present on both the server and clients. So i was wondering what was hapenning when you were calling a method of a PlayerState Child class.
In my case, i think about building my game so all my players have a PlayerState child class that contain a “Champion” class, which is a custom abstract class.
Here’s that abstract class :



#pragma once

#include "MyPlayerState.h"
#include "CoreMinimal.h"

/**
*
*/
class MYPROJECT4_API MyChampions
{
public:
MyChampions();
~MyChampions();

virtual void Spell_1() = 0;
virtual void Spell_2() = 0;
virtual void Spell_3() = 0;
virtual void Spell_4() = 0;
virtual void UltimateSpell() = 0;
virtual void BasicSpell() = 0;

protected:
//Identity
std::string m_ChampionName;
std::string m_ChampionClass;

//Sustain
int m_ChampionHealthPoints;
int m_ChampionTemporaryHealthPoints;

int m_ChampionShieldPoints;
int m_ChampionTemporaryShieldPoints;

int m_ChampionSourcePoints;
int m_ChampionTemporarySourcePoints;

int m_ChampionArmorDivFactor;
int m_ChampionArmorSubFactor;

//Spells
int m_FocusRate;
int m_Spell_1_Steps;
int m_Spell_2_Steps;
int m_Spell_3_Steps;
int m_Spell_4_Steps;
int m_Ultimate_Steps;
int m_BasicSpell;
};


So if ever i do PlayerState.Champion.Spell_1() for exemple, and that methods modify a specific value of a selected PlayerState, will that modify that call the method on the server, so modify the value on the server, and then replicate it on the clients? with other words, is that organization network friendly?
Also another question, not about unreal itself but network in games in general. I don’t know if the client should just send its inputs to the server, and then the server to do stuffs considering those inputs, or if the client should ask to call some function following some input and then the server indeed call those functions or not.
Tho i might just be missing some unreal features that actually dont needs me to think about those stuffs, cause yeah i know really not a lot about it, so don’t hesitate to guide me into the right way!

If you’re not familiar with UE4, then it’s way too early to even consider multiplayer. UE4 has a very deeply embedded multiplayer system but you must know your way around ‘regular’ UE before getting started with it, or none of it will make sense.

The abstract class approach is odd, and it’s not really going to work with UE anyway. If you need a custom player state, you should create a class that extends from APlayerState rather embed raw C++ inside it.

I would suggest looking at Epic’s example projects like ShooterGame (found on the launcher) to get an idea of how UE4 code typically looks. That is a complete multiplayer FPS sample project, and there are a few others like it too. Just go into the “learn” tab of the launcher to find them.

I’ll take a look then!
Also, about the abstract class, it’s not a custom player state it’s just a class where i can storage some data about a part of my gameplay, here champions, but it’s not implicitly linked to players, only his concrete childs can become a part of my player state so i can refer to it.
I thought that could be the best way to create that part of my game (btw it’s not really raw C++, i still created it from unreal as a custom class, so it’s not just a class created from visual for exemple, that would be total raw c++) and introduce it by an extension of player state, but not AS an extension of player state, i might be wrong tho, how would you do that ?
I don’t understand why building it from an extended player state, like all childs of that abstract class will not necessary be linked to a player, so why should it be a player state extension?