In this recipe you will learn how to program a simple camera system that follows an object smoothly, without giving the impression of being glued to the back of the target.
See the recipe Setting up the game structure to create the basic application framework for the following steps.
Let's build a third person camera system:
Add this code to
Application.py
:from direct.showbase.ShowBase import ShowBase from direct.actor.Actor import Actor from panda3d.core import Vec3 from direct.interval.IntervalGlobal import * from FollowCam import FollowCam class Application(ShowBase): def __init__(self): ShowBase.__init__(self) self.world = loader.loadModel("environment") self.world.reparentTo(render) self.world.setScale(0.5) self.world.setPos(-8, 80, 0) self.panda = Actor("panda", {"walk": "panda-walk"}) self.panda.reparentTo(render) self.panda.setHpr(270, 0, 0)...