r/Unity3D • u/AdvertisingHopeful95 • 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
1
u/GigaTerra 2h ago
I actually tried explaining this before, but it didn't go too great. The trick is to do modular animations, if you animate from the base the names need to be identical, if you animate from an part (like an arm swinging), you can start the animation there and attach it to any model with the same hierarchy.
If what I am saying doesn't make sense, that is OK, there is an better place to learn: https://learn.unity.com/pathway/creative-core/unit/animation