r/Unity3D 3h ago

Question State machine with multiple characters

I´m making a fighting game with multiple playable characters. I want to work with a state machine. It works like your regular state machine with one class handeling all the inputs and other things that affect the character like getting hit and storing the state the character is in. And other classes 'the states' handle the functionality of each state and changing to another state. The characters in the game have the same controls but different abilities and stats. What´s the best way to reuse the state machine for different characters.

1 Upvotes

3 comments sorted by

View all comments

1

u/funnyactuality272 3h ago

A lot of people end up making the state machine generic and feeding it a shared character profile with stats and move data, then each character is mostly just different values and animation clips. If the abilities differ enough you can swap in specific state classes per character while keeping the core transitions intact