Pretty much what the title says, i'm trying to code the weapons of a game and now that i've started implementing the reload mechanic i've started to wonder if should give the weapons a state machine to for example be able to cancel the reload if i fire while the reload is happening or other similar stuff.
Has anyone encountered the same issue? What is the best solution for it in your experience?

    gorrrroto i can probably get away with implementing whatever i need without making use of state machines but it'd be nice to hear what the more experienced among you fellow devs have to say

    I would just make use of integers and booleans for all of that myself, have a boolean like isReloading as an example, then play appropriate animation or do whatever while reloading and have the fire animation play.

      Lethn that's pretty much what i ended up going for!! I made a timer that starts when the reload() function is triggered and only finishes the reload once the timer finishes and sends the timeout signal. If the weapon is fired while the timer is still counting in gets stopped

        gorrrroto To be fair though, the issue of states vs booleans etc. is something of a debate topic here, I'm of the opinion unless you're doing something particularly complex like a full character model AAA style which requires fancy animation blending techniques among other things you don't really 'need' a state machine but other devs seem to think they're the golden age of software and should be used more frequently. On my own workflow as an example, I've got villager models going with something like 20+ animations, haven't used a single state machine for them and the AI behaviour is going to be fairly complex, it's all down to your personal circumstances really. I think if you want more control over your animations and smoothing transitions out then yes go for a state machine but that's down to experimentation.