Hey,
I tried implementing a 3rd person camera for my application but it seems to produce some issues with the window properties. In the inherited class of ShowBase I add a task via self.taskMgr.add(self.OrbitCameraTask, 'thirdPersonCameraTask')
where OrbitCameraTask is:
def OrbitCameraTask(self,task):
md = self.win.getPointer(0)
if base.mouseWatcherNode.isButtonDown(MouseButton.one()):
self.props.setCursorHidden(True)
self.win.requestProperties(self.props)
x = md.getX()
y = md.getY()
if self.win.movePointer(0, int(self.x_mouse_position), int(self.y_mouse_position)):
self.heading = self.heading - (x - self.x_mouse_position) * 0.5
self.pitch = self.pitch - (y - self.y_mouse_position) * 0.5
if self.pitch > 90:
self.pitch = 90
elif self.pitch <-90:
self.pitch = -90
self.parentnode.setHpr(self.heading, self.pitch,0)
else:
self.props.setCursorHidden(False)
self.win.requestProperties(self.props)
self.x_mouse_position = md.getX()
self.y_mouse_position = md.getY()
return task.cont
When i dont bind the task, I can move the window without any problem, but adding the task resets the window to the original position, when i try to move it.
‘self.props’ is :
self.props = WindowProperties()
self.props.setOrigin(100, 100)
self.props.setSize(int(self.canvas_width), int(self.canvas_height))
self.setBackgroundColor(0,0,0)
Edit:
I think this behaiviour comes from setting the window properties from self.props, right? What would be the right way to hide and show the cursor in this case?