Camera following ship in space (6 Degrees of Freedom)

This is the type of camera I want to achieve - - 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 - - notice how the vehicle turns first and then the camera chases it to stay behind.

So far I’ve done this:

			wantPos = render.getRelativePoint(self.fighter, Point3(0, DISTANCE, 0))
			wantPos = render.getRelativePoint(self.fighter, Point3(0, -DISTANCE, 0))
		lerpPos = + (wantPos - * globalClock.getDt() * DAMPING

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 (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 - * -0.1, (y - * 0.1, self.lookVec.getZ())
			self.fighter.setQuat(self.fighter, self.movQuat)

I may be missing something–I’m a little dozy today–but the only problems that I see offhand are the use of a hard-coded “up” vector in the call to “getRelativePoint” and no indication of an “up” vector for the camera in the call to “lookAt”.

In “getRelativePoint”, I think that you might be able to simply use “self.fighter.getQuat().getUp()”; in fact, thinking about it, you should be able to dispense with “getRelativePoint” entirely and just use “wantPos = self.fighter.getQuat(render).getUp()”. (Note, however: if you find that this gives you the wrong direction, try other directions–that is, “getRight” and “getForward”–and the negations of these, as your model’s orientation may not be as expected.)

With regards to “lookAt”, I see that there is a version that takes an “up” vector, but “headsUp” might be a better bet.

Thanks, I made some adjustments according to your explanation and got this:

			wantVec = self.fighter.getQuat(render).getForward()
			wantPos = self.fighter.getPos() + wantVec
			wantVec = self.fighter.getQuat(render).getBack()
			wantPos = self.fighter.getPos() + wantVec
		lerpPos = + (wantPos - * globalClock.getDt() * DAMPING, self.fighter.getQuat(render).getUp())

It works as I intended, so thank you.