Mouselook and how to initiate camera in certain orientation?

Greetings. I’ve been trying to find out how to get the camera (owner) to be in a certain orientation when the game starts up, but it’s always in a funny angle (not in the angle the object is while editing).

Any suggestion on how to make sure it initiates at start in certain orientation?
Thank you for any tips.

Script is as follows:

import bge
import Rasterizer
import mathutils

render = bge.render

scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
own = cont.owner

screenWidth = render.getWindowWidth()
screenHeight = render.getWindowHeight()

sensorMouse = own.sensors["Mouse"]
actuatorMotion = own.actuators ["Motion"]


#Create showMouse property and use it also as init
if "showCursor" not in own:
    own["showCursor"] = True
    mouseX = 0
    mouseY = 0
    own.worldOrientation = (0, 0, 0) # I tried to set the Orientation here, but didn't seem to work.

#Check if mouse cursor is shown
if own["showCursor"] == False:
#Set mouse sensitivity
sensitivity = 0.001
mouseX = screenWidth//2-sensorMouse.position[0]
mouseY = screenHeight//2-sensorMouse.position[1]

own.applyRotation((mouseY*sensitivity, 0, 0), True)
own.parent.applyRotation((0, 0, mouseX*sensitivity), True)

It seems to me that in the last two rows you rotate both the camera (owner) and its parent (?).

He is applying the first rotation to the owner. The second to parent.

Yeah those lines rotate the view when I move the mouse. That’s not part of the issue :wink:

I think worldOrientation should use brackets and quotes rather than parenthesis maybe.

That’s not the issue; You’re setting the world Orientation to a tuple, which isn’t the wrong idea, except that it is in vector form, not matrix.
If you want to set the worldOrientation, use this …

import bge
import mathutils
#assuming you've got the object already...
object.worldOrientation = mathutils.Matrix()