Useful Gameplay Abilities System

Hello!

I’ve been searching and thinking about this for a while now. In every tutorial, be it about inventory, player stats, or the Gameplay Ability System, it’s always on one level. Like if everyone wants to avoid the problems you’ll get if you change levels. All the stats reset, the inventory is lost, and for the GAS, it’s even more complicated. I would like that, when you activate an effect, it stays activated across multiple levels. Ex: Activate “Sprint”. The player starts running, enters a doorway, changes levels, and still sprints. After a certain duration, the effect wore off.

The first reflex I have is: either we use a save mechanism or we use the GameInstance. On the GameInstance, I could add a pointer to a system that holds all stats, and when the player needs to know something (like health, for example), it queries that system on the GameInstance?

The inventory should not be on the player directly… It needs some kind of backend structure on the GameInstance ? Same for quests.

But what about the abilities? I’m about to start coding my own “Ability Manager” accessible from the GameInstasnce (like if GameInstance is the singleton in a service locator pattern?), that can know which abilities are active, the cooldown, and which are available for a given character.

Do you think I’m on the right path here? Maybe there is some kind of “DontDestroyOnLoad” magic that I don’t know of?

In a real game, not a YouTube tutorial, are we using the GameInstance?

Thanks.

you are on the right path for sure !

the main concept you can search off is “persistent data”
basicly you have the gameinstance, that it will be there for the whole session.
up to the closure of the app, so yes you can place character info there and never lose them.

Between session you can save data on files with saveslots

Levels and players can be changed and unloaded
so yes if you want to share stuff from one level to another gameinstance is perfect.

Beside there are also Player states !
PlayerState

1 Like

Sounds like a simple way to do it to me.

For player specific stuff like inventory or health I just getting from save file on level load because I have autosave running pretty regular anyways.

It worked adding the stats to the GameInstance, but now what if I want to make it multiplayer? I’m a little confused now…

If I want the “Health” to be persistent between levels, I need to put it on the GameInstance… Each client has its own GameInstance, but it’s not replicated to other clients or the server. So each stat I put there is for the local client only?

Or I could duplicate the variable on the character, replicate that one, and update it using the one on the GameInstance ?

The PlayerState would have made so much sense for this, but it’s not persistent between levels (or I’m missing something).

Or perhaps I should keep all the stats on the player like they do in Youtubes tutorials and use the GameInstance to temporarily store them there, change levels, and read them back in the other level?

I would really appreciate it if we could sort this question out. I think it’s a relatively important one if one wants to do a real game, right ?

P.S. I know there is the GAS plugins that does all that, but all I want is to learn how to do it.

Thanks

hi man ,
never got myself in the multiplayer for now .
So i cant really asnwer for sure, but:

I got this awesome video here

and more complex ui documentation