How can I make a 3d model move up and down in panda3d (Python)? I looked at tutorials but they didn't help

Hey guys ! So as for a project I need to make a 3d model move up, back, left, right using the arrow keys of a PC. I have been researching a lot but none of the tutorials or websites have helped me completely achieve it. This is my code so far :

#place a character into the maze. at a statrting point
character = loader.loadModel(“doraemon.obj”)#importing my character 3d model
#making character go right
character.setPos(startpos[0], startpos[1], startpos[2])#spawning it in at the start location
character.setScale(0.6, 0.6, 0.6)#scaling it
character.reparentTo(render)#rednering it

def up(self, startpos):#making the character go up
self.posInterval(1.0, Point3(startpos[0], startpos[1]+2, startpos[2]))
startpos[1] = startpos[1]+2
return startpos

def down(self, startpos):#making character go down
self.posInterval(1.0, Point3(startpos[0], startpos[1]-2, startpos[2]))
startpos[1] = startpos[1]-2
return startpos

def right(self, startpos):
self.posInterval(1.0, Point3((startpos[0]+2), startpos[1], startpos[2]))
startpos[0] = startpos[0]+2
return startpos

def left(self, startpos):#making character go left
self.posInterval(1.0, Point3(startpos[0]-2, startpos[1], startpos[2]))
startpos[0] = startpos[0]-2
return startpos

#Making commands for it to move up, down, right and left

character.accept(‘arrow_up’, character.up(character, startpos))
character.accept(‘arrow_down’, character.down(character, startpos))
character.accept(‘arrow_right’, character.right(character, startpos))
character.accept(‘arrow_left’, character.left(character, startpos))

When I run this code I get an error saying " ‘panda3d.core.NodePath’ object has no attribute ‘accept’"
Which I am confused by. Am I not supposed to use character(the model im trying to make move) as the thing I reference with .accept ? Please help

Exactly: The functionality for "accept"ing events isn’t implemented in the NodePath class (and instance of which your “character” variable will presumably hold). Instead, I believe that it’s implemented in the “DirectObject” class (and by extension, in the “ShowBase” class, which inherits from the “DirectObject” class).

As a result, if you want to use “accept”, you presumably want either an instance of “DirectObject” or of “ShowBase”.

If I may, have you looked at the following tutorial? It’s a “beginner’s” tutorial that starts with the fundamentals of using the engine, and then takes one through the building of a simple game, and all the way to the creation of a distributable version–and it does touch on one way to do what you seem to be trying to achieve.

(Albeit that it doesn’t use intervals. But those don’t seem to be the part at which you’re tripping up, so if you prefer to use them, you can perhaps just adapt the tutorial’s approach in order to do so.)

Here’s a link to it: