How do I capture an initial LMB event please


(Rob) #1

How do I capture an initial LMB event only please.

I can use mouse over and LMB to grab an object. I would like the code to not respond to LMB and mouse over if LMB occurs before the mouseover event.

Thanks

Rob.


(Carl) #2

if you use python:

import GameLogic as g

c = g.getCurrentController()

LMB = c.getSensor('LMB')
MO = c.getSensor('MO')

#then if you only want the LMB to respond if MO is active:

if MO.isPositive():
 if LMB.isPositive():
  #your code for execution here...

(this way LMB isn’t checked unless MO is active)

Otherwise, using only LogicBricks, you could have the mouseover sensor set a property (mo for instance) to 1 and then have a second mouseover sensor with the false sense pulse set the property back to 0:

then you could use the LMB sensor and a property sensor for ‘mo = 1’ and an ‘AND’ controller execute what it you want to do…

good luck

Carl


(Rob) #3

Thanks for the reply. The thing I am trying to stop happening is when I pick an oblject up with the mouse and then move it over another object (that can be picked up) the objects get swapped. Hence wanting the initial push of he LMB to be distinct from it being held down.

I think I need to set a property specific to the object the mouse is over when it is initially presssed. Tricky this and I don’t have the time at the moment. I’ll try again sometime soon.

Rob.


(saluk) #4

Have a property called clicked, set it to zero. On the mouseover and left mouse AND this prop is zero, set this flag to 1. When you let go of left mouse, (left mouse with INV checked) drop the object and set the clicked to zero again.