. Once centered I would like to move the mouse freely as if the it wasn’t set. So my question is, is there a way to setMousePosition and then unset mouse position?
Like:
if control.getSensor("LeftMouseButton") == True:
Rasterizer.unsetMousePosition() <== unset mouse position keeping center coordinates
else:
Rasterizer.setMousePosition(xcenter,ycenter)
for example, if the center of the screen on the y-axis is 300 how can I set y-position to 300 and add and subtract 300 by multiples of 1 as I move the mouse up and down. Ha, I hope this isn’t making it more confusing. Thanks.
well, set mouse position only does so for the frame it’s used in. This means that if you only run the script it’s in (or just that part of the script even) once, it’ll move the mouse to the center, and then let the user move the mouse freely from there afterwards.
If I understand what you want in your example, you want the mouse to be centered until the user does a mouse click? in that case, make a bool property that starts as 1 (called “center” in my example) and use
if LeftMouseButton.isPositive():
owner.center=0
if owner.center==1:
rasterizer.setMousePosition(xcenter,ycenter)
if you just want the mouse to move freely if the mouse button is being held down, you can just use this (I can;t remember the syntax for “if not” in python- it might be “if !whatever”, or something else)
if not LeftmouseButton.isPositive():
rasterizer.setMousePosition(xcenter,ycenter)