The mean of this <
is this <
and the mean of this >
is this >
.
I replaced it and it’s worked!
anyway this script is very old try this is much easy and customizable for the newer versions:
The upper script I converted to work at the newer versions:
######################################################
#
# MouseLook.py Blender 2.55 or newer!
#
# Adapted by ProperVandal from 2.49 source at tutorialsforblender3d.com
#
# Released under the Creative Commons Attribution 3.0 Unported License.
#
# If you use this code, please include this information header.
#
######################################################
import bge
def main():
# set default values
Sensitivity = 0.0010
Invert = 1
Capped = False
controller = bge.logic.getCurrentController()
obj = controller.owner
gameScreen = gameWindow()
move = mouseMove(gameScreen, controller, obj)
sensitivity = mouseSen(Sensitivity, obj)
invert = mousePitch(Invert, obj)
capped = mouseCap(Capped, move, invert, obj)
useMouseLook(controller, capped, move, invert, sensitivity)
centerCursor(controller, gameScreen)
def gameWindow():
width = bge.render.getWindowWidth()
height = bge.render.getWindowHeight()
return (width, height)
def mouseMove(gameScreen, controller, obj):
mouse = controller.sensors["MouseLook"]
width = gameScreen[0]
height = gameScreen[1]
x = width/2 - mouse.position[0]
y = height/2 - mouse.position[1]
if 'mouseInit' in obj == False:
obj['mouseInit'] = True
x = 0
y = 0
if not mouse.positive:
x = 0
y = 0
return (x, y)
def mouseSen(sensitivity, obj):
if 'Adjust' in obj == True:
if obj['Adjust'] < 0.0:
obj['Adjust'] = 0.0
sensitivity = obj['Adjust'] * sensitivity
return sensitivity
def mousePitch(invert, obj):
if 'Invert' in obj == True:
if obj['Invert'] == True:
invert = -1
else:
invert = 1
return invert
def mouseCap(capped, move, invert, obj):
if 'Cap' in obj == True:
import Mathutils
if obj['Cap'] > 180:
obj['Cap'] = 180
if obj['Cap'] < 0:
obj['Cap'] = 0
camOrient = obj.orientation
camZ = [camOrient[0][2], camOrient[1][2], camOrient[2][2]]
vec1 = Mathutils.Vector(camZ)
camParent = obj.parent
parentOrient = camParent.orientation
parentZ = [parentOrient[0][2], parentOrient[1][2], parentOrient[2][2]]
vec2 = Mathutils.Vector(parentZ)
angle = Mathutils.AngleBetweenVecs(vec1, vec2)
capAngle = obj['Cap']
moveY = move[1] * invert
if (angle > (90 + capAngle/2) and moveY > 0) or (angle < (90 - capAngle/2) and moveY < 0) == True:
capped = True
return capped
###############################################
# define useMouseLook
def useMouseLook(controller, capped, move, invert, sensitivity):
# get up/down movement
if capped == True:
upDown = 0
else:
upDown = move[1] * sensitivity * invert
# get left/right movement
leftRight = move[0] * sensitivity * invert
# Get the actuators
act_LeftRight = controller.actuators["LeftRight"]
act_UpDown = controller.actuators["UpDown"]
# set the values
act_LeftRight.dRot = [ 0.0, 0.0, leftRight]
act_LeftRight.useLocalDRot = False
act_UpDown.dRot = [ upDown, 0.0, 0.0]
act_UpDown.useLocalDRot = True
# Use the actuators
controller.activate(act_LeftRight)
controller.activate(act_UpDown)
#############################################
# define center mouse cursor
def centerCursor(controller, gameScreen):
# extract width and height from gameScreen
width = gameScreen[0]
height = gameScreen[1]
# Get sensor named MouseLook
mouse = controller.sensors["MouseLook"]
# get cursor position
pos = mouse.position
# if cursor needs to be centered
if pos != [ int(width/2), int(height/2)]:
# Center mouse in game windowp
bge.render.setMousePosition(int(width/2), int(height/2))
# already centered. Turn off actuators
else:
# Get the actuators
act_LeftRight = controller.actuators["LeftRight"]
act_UpDown = controller.actuators["UpDown"]
# turn off the actuators
controller.deactivate(act_LeftRight)
controller.deactivate(act_UpDown)
##############################################
# Run program
main()
and all fine.
Thanks.