[Bf-committers] BGE improvements: States and state engine support

Kent Mein mein at cs.umn.edu
Tue Jun 10 16:15:24 CEST 2008

In reply to Benoit Bolsee (benoit.bolsee at online.be):

Hi Benoit,

I could be way off base here so don't take this email as law or
anything.  ;)

Its already possible to do a state machine with the current logic
bricks, I think it would be nice to stream line things and make the
logic bricks a bit easier to read/setup but the basics are already there
(I Think your over thinking this a little.)

Here is a simple example:
Just add a property name it state change type to int and set it to 1.

Then add a Sensor change it to property change the value to 1 (state 1)
Then connect it to and and some logic say move it X.
Then add a change of state by doing the following,
	Add another and, link it to our first if we are in state 1,
	Then add a check to see if we have moved X.
	If so change property to State 2.

For this example State 2 is our end state ;)

Note if you were drawing this on paper you would want something like

		State		1			2
Condition |---------------------------------|-----------------------|
 x >= X	  |		state = 2           |     END               |
 always   |             x= x+ X             |     END               |

Would be nice to change the logic bricks so you can do something like
this, note the reason I mention this is Your conditions are your
controllers sort of and you pretty much want to reuse them as
well sometimes.  (Although you maybe don't need to all the time...
The above example could also be written with x>=X and state 2 left


More information about the Bf-committers mailing list