Gowydot Yeah this is too complex to follow. I mean not complicated but convoluted as it too has too many hidden refferences and this is a unique system.
What im trying to figure out is something more simple.
Im now rewriting the whole statemachine to include combat actions/states, not sure..
Breaking my head because not sure what references would i need in future so that i dont have to rewrite things later..
For now it seem that what those previous guys did was to have combat moves/states already predefined inside the player, that means if you have n-th amount of weapons that have lets say different animations or states then you would need to predefined these from the get go, so when you pick up weapon you can animate the weapon accordingly.
Another way would be to keep weapon related states on the weapon scene and once you pick it up you add this to your player as being able to execute and switch to those states.
Now that i kinda have an idea, it could look like this:
StateMachine
Run
Walk
Jump
PrimaryAttack
Slash1 #<---- instantiates from weapon
Stab
Kick
Slash2
Swing
Slam
SecondaryAttack
Crouch
And you could maybe make premade scenes that you can add to any or typed weapons and just add more nodes to the scene for the consecutive attacks that can be made to make combo attacks.
Each state controls the character physics.
State switching is based on input
StateMachine is child of Player
Player class checks inputs, and then based on input switches states. And based on how many times you press the same "attack" button you switch to the next state that is from top down (in the scene tree).
Now, this is theoretical, but i think this is gonna be taxing on CPU because you will have large player node tree with lots of branching nodes. Its not gonna be hundreds of thousands but still lots..
Maybe there is better way to do this?...
Someone is whispering Resource .. not sure how could i stack attacks to be executed consecutively if allowed... I could make a resource hmm.. maybe i need to explore this..
I mean States that are input based are finite. The attacks is whats gon be dynamic and unpredicatable. So it makes sense to make them into a resource.