I’m trying to make a keyboard sensor in a parent object, trigger rotation in it’s child. I know that if my actual goal was to cause the child object to rotate on a key press, the best way would be to place the sensor on the child itself. But this is just a test for me to figure out the message actuator. I have a bool property on my child object called goRotate that is set to false. The child object also has a message sensor (not connected to anything else, and filled in with the appropriate subject “rotate”). Also on the child is a property sensor for “equals” goRotate, value= (1, or TRUE. I’ve tried both) which is connected by an “and” controller to the actual rotation actuator. On the parent there is a keyboard sensor “r” connected to the “and” actuator and then the message actuator with to:goRotate, subject:rotate,T/P pressed in with goNoGoRotate bool property (defined in the parent as true) set as the content of the message. When I run it and press r nothing happens. When I change the property sensor to a keyboard sensor just to make sure, the child does rotate when I press the key. If going through all these permutations of the phrase “goRotate” is too much of a pain, all I really want to no is every thing that is needed for a successful message between objects, as there is no documentation online, and my pdf doesn’t solve the problem, it’s not as thurough(How do I spell this? ) as you’d expect.
Hello
Honestly, after reading three lines of your post, I was lost too.
But the Message Actuator oe Sensor is very easy.
Add a Cube to your scene.
Make it an Actor.
Add a Keyboard Sensor with Space key for ex.
Link it to a And and a Message Actuator with “move” or whatever, in the subject field
Now, Add a Message Sensor, with the same word as previously in the subject field.
Link it to And and a Move Actuator with 0.20 in DLoc
Now in Game mode press Space bar and your cube will move ( i hope)
Easy??
Bye
António
Thanks, it works! I may run into trouble later on when I try to pass property information. Maybe passing bool information is useless, due to the way the message sensor works. And if I try to pass any other kind of property it’ll work fine. I guess I’ll see about that eventually. thanks again!
Note that the “To:” field doesn’t work, and also the information in the “Body:” field can only be used from python on the recieving end (and it’s probably not all that useful unless you use it from python on the sending end as well, to give it a property etc)
Or you could jsut cross-link the logic bricks.
Select both the parent and the child objects, and go to the realtime buttons. Click the little “sel” button above the actuators controllers and sensors, now you should be able to connect the controller on your parent dirrectly to the actuator on your child.
I’m actually learning gamepython as part of this. How do you send and recieve using python?
So, the “body” is just text that you can send between python scripts. I think I get it now. And you can “set” the body in one script base on whatever that script figures out, and then you access the message sensor in the other through that objects script and then “get” the body of text. This is cool stuff for shizzle. The gears are turning in my head. I’ve got plans now.
Yep thats how it works:)
messagesactuator.setBody(str(myprop)) #This sets the body to a string version of the prop
GameLogic.addActiveActuator(messageactuator,1)
on other end:
bodies = messagesensor.getBodies() #A list of the bodies of messages we have recieved this frame
for body in bodies:
us.prop = eval(myprop) #Turns the string back into a number and assigns it to our prop