Python interpreter error in the camera movement tutorial?

Hi everyone,

I’m brand new to Panda3D and working with such environments and I’m fairly new to Python, so bear with me if my knowledge of this stuff is a little sketchy.

My problem has to do with running the following code from the Panda3D manual, part F.3 (Controlling the Camera):

from math import pi, sin, cos

from direct.showbase.ShowBase import ShowBase
from direct.task import Task

class MyApp(ShowBase):
 
    def __init__(self):
		ShowBase.__init__(self)
		
		# Load the environment model.
		self.environ = self.loader.loadModel("models/environment")
		# Reparent the model to render.
		self.environ.reparentTo(self.render)
		# Apply scale and position transforms on the model.
		self.environ.setScale(0.25, 0.25, 0.25)
		self.environ.setPos(-8, 42, 0)
		
		# Add the spinCameraTask procedure to the task manager.
        self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")

    # Define a procedure to move the camera.
    def spinCameraTask(self, task):
        angleDegrees = task.time * 6.0
        angleRadians = angleDegrees * (pi / 180.0)
        self.camera.setPos(20 * sin(angleRadians), -20.0 * cos(angleRadians), 3)
        self.camera.setHpr(angleDegrees, 0, 0)
        return Task.cont

app = MyApp()
app.run()

My Python interpreter fails to run this code, producing the following error:

  File "myscript.py", line 19
    self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
IndentationError: unindent does not match any outer indentation level

As far as I understand, this code is indented properly. Is there something wrong with the example code in this tutorial?

Well, I feel like a dunce for posting this problem now…

Turn out that Notepad++ inserts spaces instead of proper tabs if text is copied into the editor (or vice versa, can’t be sure just yet), resulting in tab depth being thrown totally out of whack until I replaced the spaces with tabs.

I’ve turned on “Show Spaces and Tabs” in the View options and it is now plainly obvious when my indenting is correct.

Resolved.