I'm trying to build a simple user interface in Blender Game Engine. 2 buttons (launch and quit).
Each button got a "Mousse Over" and "Left Button" sensors connect to a one Python controller.
Here my script menu.py:
import bge cont = bge.logic.getCurrentController() own = cont.owner OverLancer = cont.sensors['Over.Lancer'] ClickLancer = cont.sensors['Click.Lancer'] OverQuitter = cont.sensors['Over.Quitter'] ClickQuitter = cont.sensors['Click.Quitter'] if OverLancer.positive and ClickLancer.positive : print("lancer") if OverQuitter.positive and ClickQuitter.positive : print("Quitter")
Nothing works as expected. I got the error "sensor not found" for all of them and I don't understand where I'm wrong. I saw as well something strange. My sensor names change like that .Blender add .001 sometime ...why?
And there is old deleted code line in the error message, again strange.
Python script error - object 'Bouton lancer', controller 'And.002': Traceback (most recent call last): File "menu.py", line 6, in <module> print (cont.sensors) KeyError: 'requested item "Over.Lancer" does not exist'
For example "print (cont.sensors)" is not present in menu.py !?!?
If anybody got an idea, it's will be great.