This has been a problem that I've dreaded tackling, since everytime I do it, it always turns into a mess or some sort of spaghetti code. Basically, I don't know how to write a good character controller that I can extend.
If I start writing something, it'll typically break whenever I need to add a feature. But I'm trying to plan ahead now, but all I'm getting is fear of this code and a headache.
I've came up with the basic rules the player character needs to abide by. "Shift" rules modify the current state by some degree, whether be limiting features, modifying the playback animation, or both.
Shift-NormalMovementType
0 = idle
1 = walking
2 = jogging
3 = running
Shift-PanickedAnimation
TRUE if on fire, or being dragged down to the ground
FALSE if else
Shift-InjuredAnimation
TRUE if health < 25% maxHealth
FALSE if else
Shift-TaggingInstant
TRUE if in zone of a tag that only needs 1 hit to complete
FALSE if else
Normal [Default state - on ground]
Shift-PanickedAnimation
Shift-InjuredAnimation
Shift-MovementType
(Ignore if panicked) Shift-TaggingInstant
Normal > Jumping [button press while on ground]
Normal > Falling [no longer on ground]
Normal > Falling Over [injured]
Normal > Level Failed [level objectives missed or out of health, time, etc.]
Normal > Level Complete [level objectives completed]
(Ignore if panicked) Normal > Climbing [button press next to ladder]
(Ignore if panicked) Normal >Tagging Normal [button press within graffiti zone]
Climbing
Shift-TaggingInstant
Climbing > Jumping [player jumped off of the ladder]
Climbing > Falling Over [player injured while on ladder, falling off]
Jumping
Shift-Panicked
(Ignore if panicked) Shift-TaggingInstant
Jumping > Falling [player no longer travelling upwards]
Jumping > Falling Over [player injured mid-air]
Jumping > Drowning [player jumps into water]
Jumping > Normal [player lands on ground]
(Ignore if panicked) Jumping > Climbing [player grabs ladder in midair]
Falling
Shift-Panicked
(Ignore if panicked) Shift-TaggingInstant
Falling > Normal [player lands on ground before injury occurs]
Falling > Falling Over [player gets injured midair or is injured by ground impact]
Falling > Drowning [falls into water]
(Ignore if panicked) Falling > Climbing [latches onto ladder while falling]
TaggingNormal
TaggingNormal > Jumping [jump to stop tagging]
TaggingNormal > Falling Over [injured while tagging]
TaggingNormal > Normal [tag is finished]
Drowning
Drowning > Getting Up [player is placed outside of water and stands up]
Falling Over
Shift-Injured
Falling Over > Drowning [player gets injured, flung off of a platform into water]
Falling Over > Getting Up [player recovers from an injury on land and stands up]
Getting Up
Shift-Injured
Getting Up > Normal [player stands up and resumes normal activities]
Level Failed
Level Complete
What would be the best way to implement a internal player state controller? I'm just looking at this overall and am overwhelmed. Any suggestions? Anyone else have any clever solutions or ideas for their character controllers?
Hi there. My name is Dug. I have just met you, and I love you.