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?
Here is my faulty script:
import bge, math from bge import render from mathutils import Vector def main(): cont = bge.logic.getCurrentController() own = cont.owner # Inclure l'objet "Camera" dans le script. camera = own.children['Camera'] # Props cap = True capBas = 20 capHaut = 160 # Prendre le sensor "Mouse". mouse = cont.sensors ["Mouse"] # sensib = Propriété "Sensibilite". sensib = own['Sensibilite'] # Recuperer la taille de l'ecran. x = render.getWindowWidth()//2 y = render.getWindowHeight()//2 # Definir le centre de l'ecran. centre_ecran = (x,y) # centre = Centre de l'ecran. centre = Vector(centre_ecran) # Definir la position de la souris. position_souris = Vector(mouse.position) # Définir la rotation a effectuer. offset = (position_souris-centre)*-sensib*0.0002 if mouse.positive: # Récupérer la rotation de la camera. Camrot = camera.localOrientation.to_euler() Camrotx = int(math.degrees(Camrot[0])) print(Camrotx) # Appliquer rotation verticale camera. camera.applyRotation(( offset.y, 0, 0), True) if Camrotx > capHaut and cap == True: Camrot[0] = math.radians(capHaut+0.99) camera.localOrientation = Camrot.to_matrix() if Camrotx < capBas and cap == True: Camrot[0] = math.radians(capBas+0.01) camera.localOrientation = Camrot.to_matrix() # Appliquer rotation horizontale joueur. own.applyRotation((0, 0, offset.x), True) # Garder le curseur au centre de l'ecran. render.setMousePosition(x,y) main() I dont want to use the Mouse Actuator for MouseLook.
Thanks.