I working on a MouseLook script, but the Cap system doesnt work great (When i move too rapidly to the Cap, the camera does ugly jumps).
I explain, my cap upper is set at 160 degree, my camera start at 90 degree, when i move rapidly my mouse up, the camera goes over 160 degrees (more speed, more excessive angle)and rapidly after, the script set the angle at 160 degree, its verry ugly, i dont want the angle goes over my cap value.
i will give you my script for better details.
Maybe the rotation system i used is not correct…
Does someone know how exactly work the cap/rotation system of the MouseMove script by Riyuzakisan?
Its a really cool idea, good work.
But i need this for my fps template, and in the game, we only see as the player view, there is no drivable vehicle or anything. and if i need another camera, i just have to switch to the new camera.
Your script can be usefull for my GTA-like project.
is there something missing you need?
it is pretty performant…
your muddeling with overcomplications…
since my script uses the players body as a reference and you can adjust the min max of each property, it can’t ever go outside the limit, its impossible,
see mouseLook script (not mouse generate?)
rot = own.parent.worldOrientation.to_euler()
rot.x += own[‘x’]
own.worldOrientation=rot
this is the core of the mouselook.
just make the head invisible, set to,wire view in object tab, and parent your camera to it,
add logic and or python to body to drive any movment scheme.
connect an Mouse movement sensor with the name “Mousemove” and an always sensor to an Python controller and switch to modul it is optimazed for you to an First_Person_Cam_Script.
'''
MouseLook by the_cannibal
'''
from bge import logic, render
import mathutils
def Cam_Movement(cont):
own = cont.owner
scene = logic.getCurrentScene()
rotSpeed = 0.005
capBas = 20
capHaut = 160
mouse = cont.sensors["Mousemove"]
render.setMousePosition(int(render.getWindowWidth() / 2), int(render.getWindowHeight() / 2))
x = (render.getWindowWidth() / 2 - mouse.position[0])
y = (render.getWindowHeight() / 2 - mouse.position[1])
if not mouse.positive:
x = 0
y = 0
own.applyRotation((0 , 0, int(x) * rotSpeed), False)
camOri = own.localOrientation
vec1 = mathutils.Vector([camOri[0][2], camOri[1][2], camOri[2][2]])
vec2 = mathutils.Vector([0.0, 0.0, 1.0])
rads = mathutils.Vector.angle(vec2, vec1)
angle = rads * (180/ 3.14)
if (angle > (90 + capHaut/2) and y > 0) or (angle < (90 - capBas/2) and y < 0) == True:
own.applyRotation((0, 0, 0), True)
else:
own.applyRotation((int(y) * rotSpeed, 0, 0), True)
render.setMousePosition(int(render.getWindowWidth() / 2), int(render.getWindowHeight() / 2))