I figured "oh i should use an enum instead of a scattered collection of 100 booleans" which is probably true but i ended up just doing what i did with the booleans and end up with anomalies like
if (IsGrounded() && rb.linearVelocity.magnitude > 0.01f && (pc.plrState == playerState.IDLE || pc.plrState == playerState.IN_AIR) && pc.plrState != playerState.IN_CANNON) {
pc.plrState = playerState.WALKING;
}
This is TERRIBLE code (and i think you will agree)
-# a quick explanation on each: isgrounded (is grounded), checking if they're moving with velocity, checking if they're idle or in the air is because I need it to switch, also for SOME reason if I fall to the ground it wont let me sprint, even though im in the walking state (print statement can confirm) unless this check is here. And lastly in cannon because if the player is on the ground and try to enter the cannon it just switches back to my grounded code and breaks physics (but that's a sepeerate problem that I do have plans to fix later)
(for context this is my enum)
public enum playerState {
IDLE,
WALKING,
SPRINTING,
GLIDING,
IN_AIR,
IN_CANNON
}
it has led to some improvement in the readibility and maintainability of my code, big plusses in that department.
Does anyone have any just ideas of how I could potentially improve this system? I want to make good scalable code as I add features into the game but it's really weird right now and I dont want to have 1 billion &&s and ||s in a single if else statement. This might also lead to the same unpredictability and bugginess that can come from the booleans that I wanted to avoid.