# Interval to LookAt

Small question: I want to implement a 1st person to 3rd person view (which focus on the 1st person object). The idea is to run in parallel a Pos and a hpr intervals.

``````dud.setPos(self.oldCamPos)
hpr =dud.getRelativeVector(render, self.SelectedNP().getPos())
i = base.camera.posInterval(2.0, self.oldCamPos)
j = base.camera.hprInterval(1.5, hpr, blendType = 'easeOut')
x = Parallel(i,j)
x.start()
base.camera.wrtReparentTo(render)``````

Getting the correct hrp so the camera points to the SelectedNP() nodepath at the end of the interval isn’t working (it points up instead of down). Anyone can point out what’s wrong or what would be the best kind of Interval to do this?

My advice would be to parent two dummy nodes to your player, one in a 1st person position and the other in the 3rd person position. Then you would just keep reparenting the camera to whichever dummy node/view you want at the moment.

I don’t believe from a mathematical standpoint that
hpr =dud.getRelativeVector(render, self.SelectedNP().getPos())

is correct (I don’t even think that is anything usefule…). If you were to use getRelativePoint instead, it would return a vector pointed in the direction of the object (as would SelectedNP().getPos()-dud.getRelativeVector() ). Which might be useful in conjection with quaternions and the quatInterval…

I would recommend instead to have two nodes like BrianInSuwan recommends, and then setting the intervals to end at whatever the SelectedNP.getPos(), SelectedNP.getHpr() are. This is probably the most obvious from a coding standpoint, as any other method will require at least a basic knowledge of matrices/quaternions.

No, it didn’t made sense other than I was hoping that Vector here would have been the relative hpr tuple, it isn’t (and not because of a mistaken coordinate system which I though was the problem). The math is actually pretty simple to solve for H and P, I was hoping for a method somewhere to do it on the C++ side.

For now, all that I do is to move back from the 1st person object and up by the same distance and set the P in HPR to -45.0. Works good enough. FOr reasons not explained in theinitial post, the 3rd person can’t be parented to the object in focus.

Thanks.

The third person dummy node doesn’t have to be parented to the object, all it is there for are to provide a way so that you instantly set it’s postion/orientation with setPos() and lookat() and then use its position/orientation to provide as the final destination for the real node and its intervals/movement code.

(I was actually thinking it is hard to get the direction to turn to get from the camera’s current rotation to the desired rotation, but then I realised that intervals do it for you…I generally avoid intervals because they don’t like having the final destination being changed mid-move and they take a time, not a movement speed)