#Creating/rewriting a complex character controller

4 messages · Page 1 of 1 (latest)

stark shoal
#

I'm thinking about rewriting the character controller in my game project and wondering what's the best way to handle a complex character controller which relies on states for it's logic. Currently I'm using unity's animation state machine since the states for the controller are heavily coupled with the animations (i.e. only specific actions can be done when certain animations are playing) but recently as the states become more complex, the limitations of the animation state machine are becoming apparent.

What's the best way to handle this sort of thing?

digital ember
#

hi gerf I have send Dm plz check

stark shoal
#

If you don't have anything to say even remotely related to my question, please don't reply. And also do not send me unsolicited DMs.

junior vine
#

Honestly I'd see if I could maybe simplify the controller, break it up.
Like.. Define possible "actions" as functions:

private void CheckJump( CharacterStateData data) {
 if( data.isGrounded) {
// do your jump
}
}

Then define my action space:

private Dictionary<State, List<Action<CharacterStateData>>> actionSpace = new thatbullshit {
  State.Idle, new List<>() { CheckJump, other stuff },
  other states and their actions
} ;

And then just calling on your possible actions when you're in appropriate state
Each action is responsible for itself, checking if it should happen, and your dictionary is what manages which actions are possible in what state..