import bge, math from bge import render from mathutils import Vector def main(): cont = bge.logic.getCurrentController() own = cont.owner # InclureGet l'objetthe "Camera"child dansobject lenamed script."Camera" camera = own.children['Camera'] # Props cap = True capBascapLow = 20 capHautcapHigh = 120 # PrendreGet lethe sensor "Mouse". mouse = cont.sensors ["Mouse"] # sensib = PropriétéProperty "Sensibilite". on this object named "Sensibilite" sensib = own['Sensibilite'] # Recuperer la taille deGet l'ecran. the center of the screen x = render.getWindowWidth()//2 y = render.getWindowHeight()//2 # Definir le centre de l'ecran. centre_ecranscreen_mid = (x,y) # centrecenter = Centre de l'ecran. Center of the centrescreen center = Vector(centre_ecranscreen_mid) # DefinirGet lathe position deof lathe souris.mouse position_sourismouse_position = Vector(mouse.position) # DéfinirDefine lathe rotation a effectuer. that should be made offset = (position_sourismouse_position-centrecenter)*-sensib*0.0002 ## this has changed: ## if mouse.positive: #This part has changed! # RécupérerGet lathe rotation deof lathe camera. Camrot = camera.localOrientation.to_euler() Camrotx = int(math.degrees(Camrot[0])) print(Camrotx) # Check if new rotation value would be too high if Camrotx + offset.y > capHautcapHigh and cap == True: # Choose offset.y so that: Camrotx + offset.y = CamrotxcapHigh offset.y = math.radians(capHigh - capHaut Camrotx) # Check if new rotation value would be too low elif Camrotx + offset.y < capBascapLow and cap == True: offset.y = capBasmath.radians(capLow - Camrotx) # AppliquerApply the rotation verticalethe the camera. camera.applyRotation(( offset.y, 0, 0), True) # AppliquerApply rotationthe horizontalehorizontal joueur. rotation to the player/parent object own.applyRotation((0, 0, offset.x), True) # Garder le curseur auReset centrethe demouse l'ecran.position render.setMousePosition(x,y) main() 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 = 120 # 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 ## this has changed: ## if mouse.positive: # Récupérer la rotation de la camera. Camrot = camera.localOrientation.to_euler() Camrotx = int(math.degrees(Camrot[0])) print(Camrotx) if Camrotx + offset.y > capHaut and cap == True: offset.y = Camrotx - capHaut if Camrotx + offset.y < capBas and cap == True: offset.y = capBas - Camrotx # Appliquer rotation verticale camera. camera.applyRotation(( offset.y, 0, 0), True) # Appliquer rotation horizontale joueur. own.applyRotation((0, 0, offset.x), True) # Garder le curseur au centre de l'ecran. render.setMousePosition(x,y) main() import bge, math from bge import render from mathutils import Vector def main(): cont = bge.logic.getCurrentController() own = cont.owner # Get the child object named "Camera" camera = own.children['Camera'] # Props cap = True capLow = 20 capHigh = 120 # Get the sensor "Mouse" mouse = cont.sensors ["Mouse"] # sensib = Property on this object named "Sensibilite" sensib = own['Sensibilite'] # Get the center of the screen x = render.getWindowWidth()//2 y = render.getWindowHeight()//2 screen_mid = (x,y) # center = Center of the screen center = Vector(screen_mid) # Get the position of the mouse mouse_position = Vector(mouse.position) # Define the rotation that should be made offset = (mouse_position-center)*-sensib*0.0002 if mouse.positive: #This part has changed! # Get the rotation of the camera Camrot = camera.localOrientation.to_euler() Camrotx = math.degrees(Camrot[0]) print(Camrotx) # Check if new rotation value would be too high if Camrotx + offset.y > capHigh and cap == True: # Choose offset.y so that: Camrotx + offset.y = capHigh offset.y = math.radians(capHigh - Camrotx) # Check if new rotation value would be too low elif Camrotx + offset.y < capLow and cap == True: offset.y = math.radians(capLow - Camrotx) # Apply the rotation the the camera camera.applyRotation(( offset.y, 0, 0), True) # Apply the horizontal rotation to the player/parent object own.applyRotation((0, 0, offset.x), True) # Reset the mouse position render.setMousePosition(x,y) main() I have edited your script just a bit and now it seems to work fine. The main problem with your script was that you applied the rotation first, then checked for the cap and, if the rotation was too big, applied another rotation. I think that this led to the shaking.
The better aproach is to first calculate if the rotation would get too big when adding the offset, and if so just apply as much rotation as needed
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 = 120 # 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 ## this has changed: ## if mouse.positive: # Récupérer la rotation de la camera. Camrot = camera.localOrientation.to_euler() Camrotx = int(math.degrees(Camrot[0])) print(Camrotx) if Camrotx + offset.y > capHaut and cap == True: offset.y = Camrotx - capHaut if Camrotx + offset.y < capBas and cap == True: offset.y = capBas - Camrotx # Appliquer rotation verticale camera. camera.applyRotation(( offset.y, 0, 0), True) # Appliquer rotation horizontale joueur. own.applyRotation((0, 0, offset.x), True) # Garder le curseur au centre de l'ecran. render.setMousePosition(x,y) main() lang-py