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