This recipe will show you how to implement a ribbon trail effect that is often used for emphasizing high-speed movements such as sword slashes, very fast vehicles passing by or, as you will see after finishing this recipe, the fastest running panda in the world.
Follow the instructions of Setting up the game structure found in Chapter 1 before you proceed to create a basic project setup.
The following steps are necessary for implementing the ribbon trail effect:
Add a new file called
Ribbon.py
to the project and add the following code:from direct.task import Task from direct.task.TaskManagerGlobal import taskMgr from panda3d.core import * class RibbonNode(): def __init__(self, pos, damping): self.pos = Vec3(pos) self.damping = damping self.delta = Vec3() def update(self, pos): self.delta = (pos - self.pos) * self.damping self.pos += self.delta class Ribbon(): def __init__(self...