I’m trying to set up a simple player character on top of a terrain object. I tried to reparent the camera to the player Actor in order to get the camera to follow it:
def LoadPlayer(self):
player = DW_Dplayer.DragonPlayer()
base.camera.reparentTo(player)
and got this error:
NodePath.reparent_to() argument 1 must be panda3d.core.NodePath, not DragonPlayer
Which means I need my class to inherit from the NodePath class:
import panda3d
from direct.actor.Actor import Actor
from panda3d.core.NodePath import NodePath
class DragonPlayer(NodePath):
def __init__(self):
self.actor = Actor('low_poly_dragon.egg',{
'Idle':'low_poly_dragon-Idle.egg',
'Walk':'low_poly_dragon-Walk.egg',
'Run':'low_poly_dragon-Run.egg',
'Sprint':'low_poly_dragon-Sprint.egg',
'Flap':'low_poly_dragon-Flap.egg'})
self.actor.setPos(100,100,200)
self.actor.reparentTo(render)
which leads to this:
No module named ‘panda3d.core.PandaNode’; ‘panda3d.core’ is not a package
I need a guiding hand because I obviously have no idea what I’m doing XP
I would advise against inheriting from NodePath. NodePath is a C++ class, which has some oddities when subclassing in Python. Since your class already has an Actor, I would reccomend you reparent the camera to that actor: