I just gave BGUI a try a few moments ago and I liked it enough to keep it (obviously ) but that also means I had to trash my previous mouselook script because the mouse is needed to interact with a GUI. I’ve tried changing it so that the middle-mouse button is what tells it to rotate, without locking the cursor at width/2 height/2 (I do want it to lock… but only in the precise spot that the MMB is clicked on, while its being clicked)
After messing around with it for a bit… It “somewhat” works, but its nowhere near how I’d like it to be. Sometimes the camera starts rotating at extreme angles and won’t stop until the next MMB click, and the cursor doesn’t lock.
Any tips, suggestions? Thanks for your time
import GameLogic
import game_core
import Rasterizer
import math
controller = GameLogic.getCurrentController()
obj = controller.owner
mouse = controller.sensors["Mouse"]
click = controller.sensors["mmb"]
rot_LR = controller.actuators["rotLR"]
rot_UD = controller.actuators["rotUD"]
rotationLR = [0.0 ,0.0 ,0.0]
rotationUD = [0.0, 0.0, 0.0]
sensitivity = 25
#width = Rasterizer.getWindowWidth()
#height = Rasterizer.getWindowHeight()
def mouseMove():
x = mouse.position[0]
y = mouse.position[1]
if obj['init'] is False:
obj['x'] = x
obj['y'] = y
obj['init'] = True
return(x, y)
if click.positive:
move = mouseMove()
if move[0] > 0.5: #Fix dumb camera ghosting Left/Right
rotationLR[2] = (move[0] - obj['x']) * GameLogic.emptyC.rotSpeed / sensitivity
elif move[0] < 0.5:
rotationLR[2] = (move[0] - obj['x']) * GameLogic.emptyC.rotSpeed / sensitivity
if move[1] > 0.5: #Fix dumb camera ghosting Up/Down
rotationUD[0] = (move[1] - obj['y']) * GameLogic.emptyC.rotSpeed / sensitivity
elif move[1] < -0.5:
rotationUD[0] = (move[1] - obj['y']) * GameLogic.emptyC.rotSpeed / sensitivity
rot_LR.useLocalDRot = False
rot_UD.useLocalDRot = True
rot_LR.dRot = rotationLR
rot_UD.dRot = rotationUD
controller.activate(rot_LR)
controller.activate(rot_UD)
obj['x'] = move[0] #Record position for next time
obj['y'] = move[1]
Rasterizer.setMousePosition(obj['x'], obj['y'])