Book Image

Panda3D 1.7 Game Developer's Cookbook

Book Image

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

Table of Contents (20 chapters)
Panda3D 1.7 Game Developer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding an additional camera


A great way to make scenes more interesting is to present them from multiple points of view. This can give a more cinematic feel to a game or might even be a plain necessity if you think of the TV-like replays found in most racing games.

After completing this recipe you will be able to add multiple cameras to the scene and switch between these predefined views.

Getting ready

To follow this recipe, complete the steps described in Setting up the game structure found in Chapter 1 before going on.

How to do it...

Let's create a new scene and look at it from different angles:

  1. Add the highlighted code to Application.py:

    from direct.showbase.ShowBase import ShowBase
    from direct.actor.Actor import Actor
    from direct.interval.FunctionInterval import Func
    
    class Application(ShowBase):
        def __init__(self):
            ShowBase.__init__(self)
            self.pandaActor = Actor("panda", {"walk": "panda-walk"})
            self.pandaActor.reparentTo(render)
            self.pandaActor.loop("walk...