Windows

This has been stumping me: I’ve been trying to make ‘windows’ with a bar on the top that you can drag around like in…well, Windows. And i made the bar and parented everything to it and made a fun little script (which you can view below), however the problem is, it has like a one or two frame delay in readjusting to the mouse’s position, so if I move the mouse fairly fast the mouse, for just a frame or two, is NOT over the bar, and if you consult my script, you will see that this will make it stop following the mouse. (Kinda hard to explain, sorry : / )

any help?

import GameLogic as g
cont = g.getCurrentController()
own = cont.getOwner()
mouseOver = cont.getSensor("mouseOver")
mouseClick = cont.getSensor("mouseClick")
if mouseOver.isPositive() and mouseClick.isPositive():
  own.setPosition(mouseOver.getHitPosition())
  

shit, move this to support please.

EDIT: my bad lots of error :stuck_out_tongue: here’s a better one:

import GameLogic as g
cont = g.getCurrentController()
own = cont.getOwner()
mouseover = cont.getSensor("mouseover")
mouseOverany = cont.getSensor("mouseOverany")
mouseClick = cont.getSensor("mouseClick")
if mouseover.isPositive() and mouseClick.isPositive():
 own.bool = 1
if own.bool == 1:
 if mouseOverany.isPositive():
  own.setPosition(mouseOverany.getHitPosition())
#create another sensor of the click but with "inv" triggered
mouseUnclick = cont.getSensor("mouseUnclick")
if mouseUnclick.isPositive():
 own.bool = 0

be sure to have a huge plane at the background.
EDIT: and put the mouse over any to pulsed mode

I atached an exemple here, the empty is moved by an IPO and is adding the cubes with this script on, have fun moving them around :stuck_out_tongue:

Attachments

dragfile.blend (131 KB)

That’s SO CLOSE, the only problem is: if I am dragging an object, and i move my mouse fast, so the object is not long touching my mouse, but following closely behind it, and while this is happening, I hit a SECOND (or third, fourth…) box, it is pulled into the awesome power of my cursor! I’m a busy man who doesn’t have the time to set up a simple variable to prevent this sort of happening. This is where a nice man(woman? Can’t be sure) like you comes in. :stuck_out_tongue:

Scabostica created windows in blender. If I were you, I would talk to him if you can’t get an answer.

peace,
-nick

Thanks Mico27!