the simplest implementation is you can make an enumerator for each mode or state, and set a variable of that enumerator to reflect the current state.
Then just use a switch node from the state variable to call different events which will handle what logic should happen after the input press.
That will get a bit messy if you have a lot of states in which case you probably wanna look further into state patterns. Paul gestwicki has some great tutorials on youtube for that I always recommend. There is also a free version of logic driver plugin you might be interested to check out to see if you like that.
Perhaps there is other methods besides a state pattern? That’s the best I know of currently for this sort of thing.
Hi there,
You want a implementation of “ability slots”, which is available in the Action RPG Sample Game, but I am not sure if is also implemented in Lyra. In that sample game, there’s a function called “try activate ability at slot”, and the abilities are available to be purchased from a store UI, meaning one ability at a time.
I will be watching this topic because I want that feature in Lyra too. I’ll share here if I find anything.
Another quick way is using tags. Either actor tags or gameplay tags for more sophisticated workflows.
Pressing 1 adds a tag “slot 1” and removes “slot 2” if present.
Pressing 2 to the same as opposite.
Then, go inside each gameplay ability, and overwrite “can activate ability” adding that query. If ability owner has tag 1, punching can be activated. Else, if player has tag 2, kicking can be activated.
This is what I tried to do.
by activating punching state, i remove the kicking tag.
I was hoping that this would disconnect the kicking input tag with the Ability1 Input Action (mapped to left click), making it so that only the punching input tag is mapped to the ability1 input action, so the punch would be the only thing triggered when i left click.
This will not work. The add/remove tags should be done at input action level, inside your player character logic. Duplicate GE_DynamicTAG and make one for punch (add granted tag “punch” and remove tag “kick”) and one for kick (add granted tag “kick” and remove tag “punch”).
To add and remove tags for every input press of ability mode (punch/kick), get a refence to self, get ability system component, and apply gameplay effect to self. Select the correspondent GE:
→ press 1 - apply GE Punch (adds punch tag and removes kick tag).
→ press 2 - apply GE Kick (adds kick tag and removes punch tag).
Inside the ability, there’s a function called “can activate ability” that can be overwritten with your custom conditions based on player’s tag. Get reference to avatar actor, get the node "has matching gameplay tags? and connect to can activate output boolean.