Changing states of other objects in synch?

Hi… I was wondering is there a good way of changing states of other objects?

I have two objects… Object A and object B… when the state changes in object A… I want to have the state change in object B…

I’ve tried linking the sensor that causes the state change in object A to an actuator in object B. It kinda works… but is a bit messy.

You could use a message to send to both objects that will make them switch state at the same time. That’s the classical way to link state engine of unrelated objects.

You can also do it in Python with the KX_GameObject setState() function.

hey thanks for the reply. I got it working using a message but I’m not sure if messages will be good enough for what I’m doing.

Basically what I’m trying to do is build a breakable geometry system that has dynamics suspended up until it gets collided with by player. I’ve got a table like shape. 4 Pillars and a roof/top. I’ve set up logic bricks/states etc… so that when the player gets near a pillar the pillar becomes dynamic… if the player moves away without colliding with the pillar it switches off again.

If the player knocks into the pillar the pillar falls… and turns on other pillars should it hit them (think domino effect)… it also turns on the physics for the roof/top so it too falls over. I’ve also made sure that the roof keeps the pillars dynamics on… so the roof can push the pillars over if you knock enough of them away.

I’m trying to make the system rely on using properties so that I can just copy more pillars and roofs etc around the level without having to tie them together using object names.

Hmm just thinking, can I send messages only to objects with certain properties… maybe that’s the solution…? That or using a script to get all objects with that property and change state.

It seems clear to me that the 4 pillars and the roof form a single logic entity. In this case, you should only have one state engine for the 5 objects. By using direct link between controller and actuators of these 5 objects, you can make it behave like you want.

Now if you want to duplicate this setup all around the scene, use dupligroup. It will duplicate the logic for each dupli group instance.