State?

I just downloaded blender 2.47 and I am a bit confused… now there is ‘state’ added and the motion actuator is different… anyone have any good tutorials on how to use the new GE?

Well, the new state panel is to configure your object to have some Controllers only when you are in concrete states. For example, if you press Space and you are in state 1 (first box selected) you can add and actuator (state and make add for the second box). If you select in the object in the state panel the second box and add another sensor (keybord one, key G) and a controller conected to an actuator that moves in the Y axis for example, when you press P and the game start if you press key G nothing happens because your object is in the state 1. However, if you press Space, you object change to state 1 and 2 (that why you have put add in the controller state) and then you can use both sensors (key space only available in state 1, and G only available in state 2). I hope this could help you!
Good luck!

Thank you. You explained perfectly and I already have it working. This is a great new feature!

So state is pretty much like another sensor?

As I see it state is like not having to have a property on the player for ex. “floor” To know if your on ice or dirt, instead you just change states.

@andrew 101… not really…

states are more like groups of logic bricks that can be turned on and off… or you can do really cool things like… inverting states… eg. when state 1 and 2 are on… state 3 is off… and when you hit a key or whatever… you could have state 1 and 2 off while state 3 is on…

You can also copy the state… eg. if state 1 is on… the copy that to state 2… making state 1 and 2 on.

You can also turn them off using sub.

You can control whether states are on or off by using the state actuator. If you want to change state as soon a motion actuator is fired… you can use the actuator sensor… this detects changes in any actuators… then just hook it up to the sate actuator to set the on and off values of your states.

You can do some really cool things with states and the new controllers… eg. you can change state then use the delay actuator to make it change back again after some time.

I did this in a game I’m making… where you can only hit a block if the other player is not hitting it… (using the XOR controller…) so I had two collision sensors… one for player 1 and the other for player 2… connected via an XOR (so it only works if one sensor is positive while the other is negative) to a 2d filter and a state actuator that inverts first state(the on switch so to speak) to off and the second state (the off switch) to on. (I turned off the first state so it can’t continually turn on)…

then in state 2… I made an off switch… so again I had two collision sensors connected to an XOR controller… connected to a remove filter actuator and a invert state actuator…

So what happens is the player hit the switch… the filter turns on… if you hit it again the filter turns off. But both players cannot hit the switch at exactly the same time. If you don’t do this the framerate goes down because the filter gets turned on and on and on…etc

To mix it up even further… I also chucked on a delay sensor and an AND controller to the filter remove act and the state actuator… so if the players turn the switch on… they can turn it off and… if they never turn if off… it will do so after some time has passed… this is all without any coding… which is sweet

I’m not sure if it’s working yet but Ben2610 is making it works so you can have sensor shared between more than one state… to save time and processing.

the other cool thing is that they are making a lot of this available through python as well… hope that helps clear things up… I am planning on making a tutorial when I have time and understand it better.

Personally I like to use states to organise and test out new logic and actuators etc with out messing up the old ones. It can save a lot of time if you separate some of the logic via states… and then when you run the game… you run it with the test state on.

I’m not sure if it’s working yet but Ben2610 is making it works so you can have sensor shared between more than one state… to save time and processing.

This is now implemented but unfortunately too late for 2.47, only in SVN

Kirado explained it very well, I just want to add two things:

The new State button in the sensor and actuator column header is very useful to only show sensors and actuators attached to the selected state => clears-up a lot the logic bricks display.

Sensors that are not attached to any active state during the game are completely removed from the logic system => great saving of performance. To get the most out of this feature, define “light” idle states when the objects are not active. For example with just a message sensor to wake them up and put them in an active state with the more CPU hungry sensors like ray, radar, etc.