State Machine - 2 states at the same time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BrunoFreezee

So I have a state machine like this:

enum {Move, Attack}
var state = Move

func physics(delta):
    match state:
         Move:
             do_moving()
         Attack:
             do_attack()

And I want to do the attacking (animation or whatever it does), while responding the Move state (like still moving, but change the animation for example), switching the state to Attack should never work i guess, what’s the better solution?

:bust_in_silhouette: Reply From: JimArtificer

This is a good video tutorial about using two state machines together:

Yeah I’ve already saw it some times, I think is too complex and maybe isn’t the best way or the way I’m looking for, but thank you very much anyway!

BrunoFreezee | 2020-07-09 17:37

I don’t have a lot of information to work with from your posts, but I would suggest that you try to master the use of a single state machine before attempting the additional complexity of combining them.
https://www.youtube.com/watch?v=j_pM3CiQwts

JimArtificer | 2020-07-09 21:16