issues With mouse movement

Hello all, I’m not new to coding, however this is my 2nd time using python ever.

Well here we go, my original question is mute. however.

i am running into a slight problem with a code i found at[url]Oh my god!]

Pretty much im attempting to use that code as a basis for movement.

however when i boot up the game i get the following

traceback most recent call last:
file, line 195 in (module)
World()#no need to store to a variable
file,line 160 in __init__
self.avatar = Avatar()
nameerror: global name 'Avatar' is not defined

Now i tried to find out how to fix the issue with the player but to no aval

here is my code so far, any help would be great!

import direct.directbase.DirectStart
from panda3d.core import CollisionTraverser,CollisionNode
from panda3d.core import CollisionHandlerQueue,CollisionRay
from panda3d.core import Filename,AmbientLight,DirectionalLight
from panda3d.core import PandaNode,NodePath,TextNode
from panda3d.core import Vec3,Vec4,BitMask32
from direct.gui.OnscreenText import OnscreenText
from import Actor
from direct.showbase.DirectObject import DirectObject
import random, sys, os, math
from CameraHandlerClass import CameraHandler
from direct.gui.OnscreenImage import OnscreenImage 
from direct.gui.DirectGui import * 
from direct.showbase.DirectObject import DirectObject 
from pandac.PandaModules import * 

import platform
from pandac.PandaModules import loadPrcFileData
loadPrcFileData('','show-frame-rate-meter 1')

from pandac import PandaModules as P #alias PandaModules as P 
import direct.directbase.DirectStart # Start Panda 
from direct.showbase.DirectObject import DirectObject # To listen for Events 
from direct.task import Task # To use Tasks 
from import Actor # To use animated Actors 
from direct.interval import LerpInterval as LERP#alias LerpInterval as LERP 
from direct.fsm import FSM# To use Finite State Machines. 
from direct.showbase.PythonUtil import clampScalar#useful. 
base.cTrav = P.CollisionTraverser()#initialize traverser 
#Collision detection can fail if objects move too fast. (Quantum tunnelling.) 
base.cTrav.setRespectPrevTransform(1)#fluid move prevents quantum tunnelling. 
#Global collision handlers. 
Pusher = P.CollisionHandlerPusher()#Pusher keeps its ward out of things. 
Floor = P.CollisionHandlerFloor()#Floor keeps its ward grounded. 
#collision masks. Use a bitwise or (operator | ) if more than one apply. 
AllM = P.BitMask32.bit(0)#for everything in the world, except display elements 
GroundM = P.BitMask32.bit(1)#the ground. What the floor rays collide with. 
PusherM = P.BitMask32.bit(2)#Solid objects, but not the ground. 
CameraM = P.BitMask32.bit(3)#What shouldn't be between camera and avatar. 
#setup keyboard and mouse 

SPEED = 0.5

class World(DirectObject):

    def __init__(self):
        #initialize movement variables 
        self.speed = speed #moving speed 
        self.point = dest#destination 
        self.vel = 
        #You must call FSM init if you override init. 
        #Avatar scenegraph setup.'avatar prime')#prime: Avatar's primary nodepath. Avatar visible. sure to start above the floor. 
        self.__initActor(**act)#unpacks act dictionary as optional params 
        self.__initSolids(**solid)#same with solid 
        #default to standing state instead of off. 
        camHandler = CameraHandler()
        # Post the instructions

        self.title = addTitle("L.O.T.C: Engine V0.001")
        self.inst1 = addInstructions(0.95, "[ESC]: Quit")
        self.inst2 = addInstructions(0.90, "Rewrite Mouse movement")
        self.inst3 = addInstructions(0.85, "Radar, one click movement")
        self.inst4 = addInstructions(0.80, "lock camera on space to jebus")
    def __initActor(self,model='models/ralph', 
            hprs=(180,0,0,.2,.2,.2),#ralph's Y is backward and he's too big. 
        self.myActor.reparentTo( actor to the prime 
    def __initSolids(self,ray=(0, 0, 1.3, 0, 0, -1),sphere=(0,0,.7,.4)): 
        """Only seperate for organisation, treat it as is part of __init__() . 
        Set collision solids for the avatar.""" 
        #Ralph will have collision solids, so the 
        # visible geometry shouldn't collide at all. 
        # to collide with the terrain & keep ralph grounded 
        #The ground and walls should have separate collision masks otherwise 
        # Pusher can interfere with Floor if the ground gets too steep. 
        #The sphere is set to collide with the other things in 
        # the world which have mask PusherM 
    def update(self,dt): 
        """Call this method in your main loop task.""" update position based on velocity 
   )#let Floor worry about Z 
        #recalc velocity to point to destination 
        self.vel = 
        if self.vel.lengthSquared()<.1:#Then consider yourself arrived. 
            self.request('Stand')#change FSM state 
            self.vel.normalize()#set magnitude to 1 
            self.vel*=self.speed#the magnitude of velocity is speed. 
    def setDestination(self,point): 
        """Go to the point.""" 
        self.point = point 
        pr =, preserve pitch and roll affects all three (HPR) 
        #keep heading but revert pitch and roll.,*pr) 
        #subtracting points yeilds a vector pointing from the 1st to the 2nd 
        self.vel = from position 
        self.vel.normalize()#set magnitude to 1 
        self.vel*=self.speed#the magnitude of velocity is speed. 
        self.request('Run')#change FSM state 
## State handlers. Only define them if something happens at that transition. 
    def enterRun(self): 
        self.myActor.loop("run")#loop the run animation 
    def exitRun(self): 
        self.myActor.stop("run")#stop the run animation 
    def enterStand(self): 
        self.myActor.pose("walk",6)#both feet on the floor 
    #notice that no def exitStand is required. 
class Environ: 
    def __init__(self): = loader.loadModel("models/world") 
        #break the model into the named pieces 
        for word in ('terrain','tree','wall','rock','hedge'): 
            setattr(self,word,'**/%s*'%word))#isn't python fun? 
        #set the collideMasks of the pieces individually 
        self.terrain.setCollideMask(AllM|GroundM|CameraM)#Ground and walls \ 
        self.wall.setCollideMask(AllM|PusherM|CameraM)#should never be between\ 
        self.rock.setCollideMask(AllM|PusherM|CameraM)#camera and avatar. 
        #But it doesn't matter if a tree is in the way. Let the player worry\ 
        self.tree.setCollideMask(AllM|PusherM)#about that. Besides, geom test\ 
        self.hedge.setCollideMask(AllM|PusherM)#for doodads is too expensive. 
#end Environ 
class Marker: 
    def __init__(self): 
        #you probably want to use a different marker model = loader.loadModel('jack'),.1,.1) 
        #this is just a display element, so it shouldn't affect the world. collisions! 
#end Marker 
class World(DirectObject): 
    def __init__(self): 
        self.avatar = Avatar()#setup ralph 
        self.environ = Environ().prime#load environ 
        self.marker = Marker().prime#load marker 
        EdgeScreenTracker(,P.Point3(0,0,1))#setup camera 
        self.last = 0#for calculating dt in gameLoop 
        taskMgr.add(self.gameLoop, "gameLoop")#start the gameLoop task 
    def __setupPicking(self): 
        self.pickerQ = P.CollisionHandlerQueue()#the handler 
        ####uncomment this line to show the collisions: 
    def OnClick(self): 
        """Handle the click event.""" 
        mpos=base.mouseWatcherNode.getMouse()#mouse's screen coordinates 
        #This makes the ray's origin the camera and makes the ray point to mpos 
        #We don't want to traverse now, so wait for panda to do it, then move. 
    def __setDestination(self,task): 
        #find the position of the nearest intersection in renderspace 
        if self.pickerQ.getNumEntries() > 0: 
            self.pickerQ.sortEntries() #this is so we get the closest object 
            self.marker.setPos(self.point)#marker indicates destination 
            self.avatar.setDestination(self.point)#set the destination 
    def gameLoop(self,task): 
        """The main game loop.""" 
        dt = task.time - self.last#time elapsed since the last frame. 
        self.last = task.time#for calculating dt the next time 
        self.avatar.update(dt)#allow avatar to update itself 
        return direct.task.Task.cont#task must return cont to continue a loop 
#end World 
World()#no need to store to a variable 

It looks as though you’ve left out a class included in the code given in that thread: specifically, the “Avatar” class (included in post 2 on the second page, I believe).