but panda doesnt seem to like while loops, so you’ll have to setup a task ie:
def __init__(self):
taskMgr.add(self.cameraLoop,'cameraFollowTask')
def cameraLoop(self,task):
# this task makes the camera follow the player in 3rd person view
speed = 6.0 # ft/s
offset = Vec3(0,15,7)
dt = globalClock.getDt()
currPos = camera.getPos()
desiredPos = self.player.getPos()+self.player.getQuat().xform(offset)
direction = Vec3(desiredPos-currPos)
if (direction.length()>speed*dt):
direction.normalize()
camera.setPos(camera.getPos()+direction*speed*dt)
else:
camera.setPos(desiredPos)
camera.lookAt(self.player,Point3(0,0,4))
# return Task.cont if you want the task to keep running
# if it should only run once, dont return it.
return Task.cont
You can find more (and better) info on tasks in the manual.