I need to know this so I can continue making my project. c:
Look at point:
camera.lookAt(point)
Look in direction of vector:
camera.lookAt(camera.getPos() + vector)
If you have angles that you want to use, then you can treat the camera like any other NodePath, I believe:
camera.setHpr(hAngle, pAngle, rAngle)
# Or
camera.setH(hAngle)
camera.setP(pAngle)
camera.setR(rAngle)
Like rdb and Thaumaturge stated, you can control your camera by calling the lookAt() method or the setHpr() method. Here is an example of setting a camera’s position away from the panda model, and making it look at the panda:
from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.panda = loader.loadModel("models/panda-model")
self.panda.reparentTo(render)
self.panda.setScale(0.005)
self.panda.setPos(0, 0, 0)
self.cam.setPos(0, -1000, 0)
self.cam.lookAt(self.panda)
app = MyApp()
app.run()
In this case, self.cam is the camera NodePath. I recommend using ‘camera’ if you’re using DirectBase and ‘self.cam’ if you’re using ShowBase like I am.