I’m currently attempting to convert an old script I had for use with 2.57, but haven’t had much luck in getting it to work so far. I need a mouse look script which can be constrained in both the x and y dimensions. Does anyone have such a script? The current one I have looks like this:
from bge import logic as g from bge import events from bge import render as r c = g.getCurrentController() o = c.owner from math import sin, cos import mathutils if (g.InGame == 1 or g.InGame == 2): midx = r.getWindowWidth()/2 midy = r.getWindowHeight()/2 r.setMousePosition(int(midx), int(midy)) mouse = c.sensors['Move'] if o['ago'] < 0.0: r.showMouse(0) r.setMousePosition(int(r.getWindowWidth()/2), int(r.getWindowHeight()/2)) deltax = 0 deltay = 0 else: deltax = midx - mouse.position deltay = midy - mouse.position dt = o['now'] - o['ago'] o['ago'] = o['now'] osz = o['sz'] # Z Axis Rotation ocz = o['cz'] zrot = (3.141592654 * -1 * g.MouseSens) * dt* deltax szrot = sin(zrot) czrot = cos(zrot) o['cz'] = -osz*szrot + ocz*czrot o['sz'] = osz*czrot + ocz*szrot osx = o['sx'] # X Axis Rotation ocx = o['cx'] xrot = (3.141592654 * g.MouseInvert * g.MouseSens) * dt* deltay sxrot = sin(xrot) cxrot = cos(xrot) o['cx'] = -osx*sxrot + ocx*cxrot o['sx'] = osx*cxrot + ocx*sxrot if o['cx'] < 0.7: # Up/Down Constraint o['cx'] = ocx o['sx'] = osx if o['cz'] < 0.5: # Left/Right Constraint o['cz'] = ocz o['sz'] = osz o.localOrientation([ \ [ o['cz'], o['sz']*o['cx'], o['sz']*o['sx'] ], \ [ -o['sz'], o['cz']*o['cx'], o['cz']*o['sx'] ], \ [ 0, -o['sx'], o['cx'] ] ] )
Far from the simplest out there I know…
Current error when I try run this is:
TypeError: ‘mathutils.Matrix’ object is not callable
Any ideas what this means and how it can be fixed?