Using Player State?

Creating a player state blueprint is the same as creating any other blueprint class. Right click in the content browser > New Asset > Blueprint Class > All Classes > Player State.

if you name it Master_PlayerSate then you’ll have an option in any blueprint interface to do a cast to Master_PlayerState.

But player state blueprints are empty by default, so you’ll need to add your own variables. If you add one inside the blueprint called MyVariable then drag a pin out from your cast Master_PlayerState in your widget blueprint you’ll see options like Set MyVariable and Get MyVariable.

Also for network purposes be sure to set your GameMode to use Master_PlayerState as its player state class, and set the replication option on each variable in your player state to “Replicate”.



Once you’ve got all that working, take a look at blueprint interfaces here:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html

That will allow you to avoid casting altogether, but it comes with the caveat that you have to create interface functions for each variable in your blueprint.

What I ended up doing after awhile to avoid creating all the extra functions is creating my own data table for my player state, and storing the data table as a single variable in the blueprint. For an MMO with many hundreds/thousands of players this would be pretty inefficient, and you’d want to use an SQL database instead.

For examples of an SQL implementation you should take a look here:

https://sellfy.com/p/fo6a/