I have a game where I am using a MouseOverAny sensor to simply grab the name of the object the mouse is over. The code of my Python controller hooked up to this MouseOverAny sensor (as well as a MouseClick sensor) is:
| Code: |
clicked = controller.sensors['MouseClick'].positive;
if clicked:
hitObject = controller.sensors['MouseOver'].hitObject;
if hitObject is not None:
print(hitObject.name);
else:
print('Nothing hit!');
|
However, in-game I can only get it to print out "Nothing hit!". Even when I click on a massive object in the game it still prints that out. I have the MouseOver controller set to TRUE level triggering with a frequency of 0 for a Mouse Over Any event in Pulse mode.
Is there perhaps a distance limit to this sensor? Maybe my objects are too far away? I tried moving the camera up close to my object and clicking, but it still printed out "Nothing hit!". What am I doing wrong?