Python/Message Actuator Question

Hey, I’m making an fps and I’m trying to get it so that the character sends a message to the hit object saying that it got hit. So basicly I have a ray set up that gets the hit object. My question is how do I make it so that the “to” section of the message actuator is always set to the hit object. Thanks a bunch!

Here is a simple example using a message actuator and changing the to: during gameplay…

Ok, I know how to change the “to” but here is the problem: to change the “to” you have to use a specific object (followed by “OB”). The way I have it set up is like this:

hitObject = ray.getHitObject()

now how do I make it so that the “to” is “hitObject”

Try using propName =

Or, try GameLogic.sendMessage():

ob = ray.hitObject

# sendMessage(subject, body="", to="", from="")
GameLogic.sendMessage('hit', to=ob)

It should work, but I didn’t test it. :wink:

ok, thanks guys. I got it to work by simply using as the “to” with hitObject set to ray.hitObject. This works fine. Thanks again!