Can your player be running and dead at once?

Swap a pile of bools for one enum.

Can your player be running and dead at once?

The problem

A bool for every state.

bool isIdle;bool isRunning;bool isJumping;bool isDead;

Nothing stops isRunning and isDead both being true. Every extra bool is another way to get it wrong.

Why it happens

Bools multiply.

Four bools can be combined 16 ways. Only four of those make sense.

4 bools→16 combinations
1 enum→4 states

The fix

One enum, one state.

enum PlayerState { Idle, Running, Jumping, Dead } PlayerState _state = PlayerState.Idle;

_state is always exactly one of the four. Impossible combinations can't exist.

Then

Switch on it.

switch ( _state ){    case PlayerState.Running: Run(); break;    case PlayerState.Jumping: Fall(); break;    case PlayerState.Dead: return;}

Each state's logic sits in one place, easy to read and easy to extend.

The rule

Model states, not flags.

One at a time
enum
Independent yes/no
bool
Branch on it
switch