click on objects


I know how to make the mouse visible, but when I click anywhere, the sensor activates. I want it to activate only when I click a certain object. how can I achieve this?

I tried linking both a MouseOver and a Left Click so I need both to activate the controller, but if the controller is an “AND” then I can’t use a “python” controller, required to run the script :frowning: im confused.

you can check in python if the sensors are true…

if mouseleft.isPositive and mouseover.isPositive():

THanks. it worked, but only in the first “activation”. After that, either click or mouse over will open it. look at the code

sense = cont.getSensor(“Mover”)
sense2 = cont.getSensor(“Mleft”)
if sense.isPositive and sense2.isPositive():“”)

 I created 2 sense's variables with 2 different sensor names (I think this is what you meant). Maybe I have to "empty" the sense and sense 2 after the first click? can I say

sense = cont.getSensor(“Mover”)
sense2 = cont.getSensor(“Mleft”)
if sense.isPositive and sense2.isPositive():“”)



if sense.isPositive() and sense2.isPositive() :
print “It Works!”

#Tab doesn’t work in this for some reason…

The print might help find your cause. I can’t see any thing wrong with the logic and you shouldn’t have to change the pulse to false or anything. A sensor normally emits two pulses. A positive and a negative. You use the isPositive() function so that it will only activate on a single pulse. The “and” means that both have to be positive.

There is one problem with your code shown, but you probably don’t have that in your script. One of your isPositive() statements doesn’t have parenthesis.

put your code in a

 block on this forum so that we can see the indentation [paste from notepad or whatever... also control+shift+c/x/v are copy/cut/paste from the windows clipboard in blender in windows]

also, fireside is right.  isPositive without the parenthesis doesn't call the method and isn't none [or an empty list or string or tuple] so it evaluates to true.  The code you posted will run regardless of where you click

import GameLogic
import webbrowser
cont = GameLogic.getCurrentController()
sense = cont.getSensor("Mover")
sense2 = cont.getSensor("Mleft")
if sense.isPositive() and sense2.isPositive():"[](")

i corrected the parentheses. It works only the first time lol, but after that, only mouseover triggers it.

something weird happens. It works perfectl the first time, but after that, it gets triggered just by Mouse Over (If I click all over the screen but not on top of the cube, nothing happens, but as soon as I move over the cube without clicking, it opens)… look

plus, the runtime still doesnt incorporate the actions :S nothing happens :frowning:

I don’t know. It seems to be working fairly normally for me. On thing you don’t want to do is put the start up plane for the mouse in front of the cube. It causes a mouseover problem, but not the one your talking about. For me, it only starts a web page when the mouse is over and when it’s clicked no matter how many times. Sometimes I get two copies of the web page, but when I use a print statement there is only one call.
Try putting a print statement right after the open statement like:“”)
print “open statement called”

Then run the program and see how many print statements are made in the console when you just move around the mouse but don’t click. Remember the print statement must be indented exactly like the webbrowser statement.
It might be that blender isn’t reading your mouse release for some reason.

hmm, well, apparently it was my wireless mouse what was causing the problem (I dont know why, or if its possible, but I used the laptops built in mouse and it worked perfectly over and over). HOWEVER, when I export, it still doesnt work :(:frowning: do I need to have a special file apart from the python dll and SDL.dll ?? maybe something for the web browser thingy? or are you just running it in any folder?

ok ok :smiley: I copied the .exe in the blender folder (that has everything) and it worked. So I must need another file besides the SDL.dll and python dll. maybe the python244 folder? whatever it is, now I know it will work as soon as I copy that file lol. thanks! Ill keep on working. Ill take the opportunity to ask,

can there be realtime lighting in the game engine? (if i rotate an object, the lighted face will change)

can there be realtime lighting in the game engine? (if i rotate an object, the lighted face will change)

Yeah. You have to select all the faces in uv face select mode. Then in the modeling buttons you have to click on “light” and then “copy draw mode”