This is the type of camera I want to achieve - http://youtu.be/3P5rkSh2jJE#t=1m50s - when it stops being first person and follows behind the submarine, though in my demo it will be a space ship. I figured that I should start simple and make one for a racing type of demo, where the camera doesn’t need to roll according to the vehicle’s orientation, but definitely chases it. Here’s an example - https://www.youtube.com/watch?v=4qUMQ04xuCI - notice how the vehicle turns first and then the camera chases it to stay behind.
So far I’ve done this:
if (FOLLOW_BEHIND):
wantPos = render.getRelativePoint(self.fighter, Point3(0, DISTANCE, 0))
else:
wantPos = render.getRelativePoint(self.fighter, Point3(0, -DISTANCE, 0))
lerpPos = base.camera.getPos() + (wantPos - base.camera.getPos()) * globalClock.getDt() * DAMPING
base.camera.setPos(lerpPos)
base.camera.lookAt(self.fighter)
And it works for the racing demo, but what if I wanted to make it follow a ship in space, how would I make the rotation of the camera follow the ship’s rotation? Because the control is like this:
if base.win.movePointer(0, base.win.getXSize()/2, base.win.getYSize()/2):
if (self.keyMap["roll-left"] != 0):
self.lookVec.setZ(self.lookVec.getZ() + 1)
if (self.keyMap["roll-right"] != 0):
self.lookVec.setZ(self.lookVec.getZ() - 1)
self.lookVec = Vec3((x - base.win.getXSize()/2) * -0.1, (y - base.win.getYSize()/2) * 0.1, self.lookVec.getZ())
self.movQuat.setHpr(self.lookVec)
self.fighter.setQuat(self.fighter, self.movQuat)