I have made small deviations from the course which may have caused it. But if I have the OnTriggerEnter attached to the weaponWeapon first take damage and then do knock-back, the states switch to dead, then impact, then dies again. (Only returned to dead because of how I have the impact set up to remember the state it came from and return to it on exit) From a play point this is unnoticeable but Unity throws warnings about trying to move a CharacterController which is disabled. It took walking through the code in debug to figure the behavior out.
I am slightly confused at how you are managing to end up in the death state with the order the code is in? Or are you actually ending back in the free look state via the impact state and are just not getting the warnings for some reason and with the character controller and animator disabled it doesn’t show?
The knockback shouldn’t be affecting the state, as we’re just adding force to the ForceReceiver… Once Health determines that a killing blow has occurred, the ondeath event should be triggered and the StateMachine should put the character in the Death state. There shouldn’t be any mechanism for returning to another state.
Now, if you damage a Health a 2nd time, this could lead to a death => react to damage => death scenario… your first line in Health.TakeDamage should be checking to see if the character is dead.
I realised that last night. I think i moved the knockback to the forceReceiver because I felt that was more in line with what the ForeceReciever was doing rather than what the health class should be in charge of. But I can see the logic and ended up switching back after the shielding section made it more difficult to do it the other way.