Character sate machine
-- Tom Sloper -- sloperama.com
Vahab, are you asking how to draw a state machine diagram? http://www.uml-diagrams.org/state-machine-diagrams.html
diagram, you can show diagrammatically how a character needs to transition from
walking to other states. That diagram would be useful for your programmers and your
artists. Such a diagram is a useful design communication tool.
You used the term "hierarchical fsm" but what does that mean? And are you really
asking a game design question, or are you instead asking a programming question or
a visual arts question?
-- Tom Sloper -- sloperama.com
Reading it over, it looks like a programming question but I'm not exactly sure what the problem is.
It loos like the commens could mean he wants to show the current state on the screen as a data visualization, or it could mean he wants to run the states and transitions within his game. Or it might mean something different.
It doesn't look like a game design topic. Moving to For Beginners.
i draw a hierarchical fsm for character controller, but i want to find a true way to show attack in hierarchical fsm and communication with character movement, for example player are moving forward and want to aiming and fire or crouch and aim and fire or . . . .
As far as I know, in hierarchical state machines, the higher layers are not really active, in the sense that they are jumping between states.
So a higher level state "going home" makes sense, that has an automaton inside it that handles character movement. The movement state machine can jump between states, for example, a step with one leg could be a state, and you'd get "step left" / "step right" alternatingly at the lower level.
The "going home" higher state is mostly a reminder what you are doing, it does not jump around while you are moving. It can however decide "home!" (that is, "stop moving, we have arrived"), or it can decide to change to another state, say "find food". Then the movement state machine in "going home" stops, and another state machine inside "find food" starts.
The whole point here is that higher level "going home" or "find food" is a single state, that you don't leave.
What you are aiming for, seems more like parallel state machines. You have a "walk" state machine, and an "aim+fire" state machine running in parallel. (I have trouble seeing aiming and firing as mostly independent state machines, I think you either aim or you fire (or do neither),
All these activities are mostly independent of each other.
In parallel state machines, each state machine can operate on its own, the "walk" state machine can switch states for its legs, and the aim+fire state machine can switch state between firing and aiming.
If you need a coordinated action of both state machines, eg "die", you have a synchronized edge, usually with an event name on it. Such an edge must be taken by all state machines or by none. (At least that is the traditional way of doing things in parallel state machines.)
Vahab, are you asking how to draw a state machine diagram? http://www.uml-diagrams.org/state-machine-diagrams.html
no,i draw a hierarchical fsm for character controller, but i want to find a true way to show attack in hierarchical fsm and communication with character movement,for example player are moving forward and want to aiming and fire or crouch and aim and fire or . . . .in state machine now way to show this state!!!im sorry for my bad english
I don't think you want a rigid state machine for a player character, or AI logic in general. Did you mean you wanted a state machine to swap between the animations of a character?
i draw a hierarchical fsm for character controller, but i want to find a true way to show attack in hierarchical fsm and communication with character movement, for example player are moving forward and want to aiming and fire or crouch and aim and fire or . . . .As far as I know, in hierarchical state machines, the higher layers are not really active, in the sense that they are jumping between states.
So a higher level state "going home" makes sense, that has an automaton inside it that handles character movement. The movement state machine can jump between states, for example, a step with one leg could be a state, and you'd get "step left" / "step right" alternatingly at the lower level.
The "going home" higher state is mostly a reminder what you are doing, it does not jump around while you are moving. It can however decide "home!" (that is, "stop moving, we have arrived"), or it can decide to change to another state, say "find food". Then the movement state machine in "going home" stops, and another state machine inside "find food" starts.
The whole point here is that higher level "going home" or "find food" is a single state, that you don't leave.
What you are aiming for, seems more like parallel state machines. You have a "walk" state machine, and an "aim+fire" state machine running in parallel. (I have trouble seeing aiming and firing as mostly independent state machines, I think you either aim or you fire (or do neither),
All these activities are mostly independent of each other.
In parallel state machines, each state machine can operate on its own, the "walk" state machine can switch states for its legs, and the aim+fire state machine can switch state between firing and aiming.
If you need a coordinated action of both state machines, eg "die", you have a synchronized edge, usually with an event name on it. Such an edge must be taken by all state machines or by none. (At least that is the traditional way of doing things in parallel state machines.)