Using Messages (Scripts)

Hello everyone!

I want to send a Message to a defined object detected by a radar so I use getHitObject() [returns the last object detected by the radar sensor]. But… I don’t know how to fill the “To:” reference for the object in a script. It seems that I can’t!!! How it can be??? Help me please!

PD: I have the same question but in the other way. Once an object received a message from another object… How can I return another message?

Thx!!

Lets say your actuator is called message.
Do this
message.setToPropName(“object”)

Subject can be changed using:
messagesetSubject(“subject”)

Hello!

Using setToPropName(“name”) doesn´t work with “OBItem” for example. Is used to put the name of a property (In case you use setBodyType() to property). I hope you aunderstand me :slight_smile: oh… I hope I find the solution!! Help me please. :slight_smile: Thx!

I had a different approach to this

Create a property on target object called ‘hit’

using python from the detector object get that object using radar (or whatever) and set its property ‘hit’ to true

on that object create a 'property ’ sensor and set it to ‘changed’ then connect this to whatever you want to happen when triggered.

used a propery on the target object and set it from the scipt then used a ‘property changed’

controller on the target object that then triggered what I wanted to do

As far as the other question its just a message sensor connected to a message actuator

hope this makes sense

It works for me.
I attached a .blend for you.
The message actuator is attached to the script on the empty. When you press space the cube should move.

Attachments

example.blend (122 KB)

Thank you everyone,

Andrew-101 is right. I was doing something wrong in my script that blinds me… Really sorry Andrew I was wrong and I didn’t realize so thank you very much!! :slight_smile:

I’m just happy to help :), I didn’t even know if it would work.
I’m going to let you in on a really good tip. Its called dir and it works like this:

print dir(GameLogic)

That will output all the functions that can be used for GameLogic.
You can use this on cont, own, sensors, actuators and everything that has a function on it.

So next time you need to know how to manipulate something just use dir and see if that gives you any clues.