Third Person Camera View

Hello all!
I am trying to modify the Roaming Ralph example to force the camera to stay directly behind Ralph (and facing the same direction) at all times, a traditional 3rd Person chase view. This seems like a fairly simple task considering the camera rotation code is already in place, but I am unable to get this working properly…

I’ve tried various combinations of base.camera.setPos / lookAt but just cannot get any satisfactory results. My camera always ends up spinning out of control.

Any help/suggestions would be appreciated!

Remove the entire camera control part. Its very easy.

Just reparent the camera to Ralph. if you do now base.camera.setPos it will set the position relative to ralph now. The camera now moves and rotates along with Ralph.

If you want a “3rd Person chase view” then you have to do a little more work.

Have a look at the last SOARX demo (https://discourse.panda3d.org/viewtopic.php?p=11372#11372). It features a nice camera system for Ralph. You can also change camera distance using the mouse wheel and even switch to first person mode. Try playing around with the resilience factor to change how fast the camera follows the players movements.

The JSBSim demo (https://discourse.panda3d.org/viewtopic.php?t=2822) has a more simple version of this camera control style, perhaps better suited for learning.

enn0x