Hello everybody!
I need help about the use of the Mouse sensor in Blender.
I have a simply object (named obj0 for example) that has 3 sensors: always, mouse over and left mouse linked to a python controller, so that when I click on it, the script runs and print the name of the object clicked.
So far, so good, but if I duplicate this object and name the copy obj1 for example, when I click on obj0 or obj1, the script returns the name of both objects.
What’s up?
import GameLogic
cont = GameLogic.getCurrentController()
own = cont.owner
s = str(own)
over = cont.sensors.get(‘over_’+s)
click = cont.sensors.get(‘click_’+s)
if (over.positive==1 and click.positive==1):
print (s)
The mouse over event is always negative and so the if statement gives a negative result, but also if I substitute
if (click.positive==1):
the script prints obj0 and obj1…