Tanzan said:
so you could have an immobilized component which has or direct bools or also components like frozen,hold person (spell) and unconcsious , dead etc. and then let each of those components be controlled by there own system…this could work fine….until you have states that fall in more then one group…
I believe you're spending too many cycles trying to over-engineer a solution rather than implement something that functions and then iterate on it when you identify a problem.
That said, if we take freezing an entity, that can involve a few aspects:
- Physics component sets adequate mass to avoid force/movement being applicable, i.e. doesn't move.
- Model's animations are suspended.
- Particle effects or additional game objects may be spawned, such as icicles.
The above already involves several systems including Physics, Animation, Particle, and the EntitySpawner. How you intend to represent this frozen state can be as simple as having a boolean flag on the PlayerController or you could represent it more specialized with the introduction of a Frozen component. There isn't a right answer here and performance will always be the deciding factor. So for the time being, pick a pattern and go with it.
With regard to being dead, that can easily be derived from a Health component with a value of 0. At the moment it reaches 0, the character can no longer move, possibly using the mass trick like we did for the frozen scenario. The HealthSystem would notify the animation system to play the death animation. The death animation itself has keyframes that also can notify other work to be done, such as playing sound effects as the death animation plays back.
You will inevitability hit a situation that will make you re-evaluate certain decisions and that's normal, embrace that, refactor, and your code will get even more resilient. But spending time trying to find the magic bullet just ends up being wasted cycles you could have been moving forward making the game.