I’ve been scratching my head for longer than I’d like to admit while working on a debug tool. In essence, I was trying to call
base.camera.setY(-5)
But no matter what, the camera’s y position wouldn’t change. I even displayed it’s y value in the corner to confirm this.
Eventually, I discovered that if I called
base.disableMouse()
I would then be able to move the camera from the code.
despite this, I would still like to move the camera from the code without disabling the mouse controls.
Considering that the “controlling the camera” section of the panda3d hello world tutorial is able to move the camera from the code without disabling the mouse controls (although you cannot use them), is there something I am doing in my code that prevents this?
My code is more or less as follows:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import NodePath, CollisionNode, CollisionBox, CollisionSegment, Point3, CollisionTraverser
from direct.gui.DirectGui import *
from direct.task import Task
class classBoxSetup(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.cTrav = CollisionTraverser()
base.disableMouse()
cb = CollisionNode('charaBumpHolder')
charaBox = CollisionBox(Point3(0, 0, 0.01), 0.5, 0.5, 0.24)
cb.addSolid(charaBox)
boxNodePath = self.render.attachNewNode(cb)
boxNodePath.show()
title = OnscreenText(text="waiting for update",
style=1, fg=(1, 1, 1, 1), pos=(-0.1, 0.1), scale=.07,
parent=base.a2dBottomRight, mayChange=True)
self.camera.setY(-5)
taskMgr.add(self.cameraTxtUp, "txtUpdate", extraArgs=[title], appendTask= True)
def cameraTxtUp(self, text, task):
text.setText(text= str(base.camera.getY()))
return Task.cont
boxProg = classBoxSetup()
boxProg.run()