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"]
render.setMousePosition(int(screenWidth//2),(int(screenHeight//2)))
#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:
Rasterizer.showMouse(False)
else:
Rasterizer.showMouse(True)
#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)
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 …