Hi,
i tried to make the CollisionHandlerFloor works, but i can’t.
in this program, the panda(self.player) 'z coordinate is supposed to be the same as the smiley actor:
import direct.directbase.DirectStart
from direct.showbase import DirectObject
from pandac.PandaModules import *
from direct.actor import Actor
class World(DirectObject.DirectObject):
def __init__(self):
base.ctrav = CollisionTraverser('trverser')
self._createPlayer()
def _createPlayer(self):
#create the panda:
self.player = Actor.Actor('panda')
self.player.reparentTo(render)
cplayer = self.player.attachNewNode(CollisionNode('player'))
cplayer.node().addSolid(CollisionRay(0, 0, 0, 0, 0, -1))
cplayer.show()
# create the smiley(the ground)
smiley = loader.loadModel('smiley')
smiley.reparentTo(render)
self._initSphereShape(smiley)
#Create the collision floor handler
lifter = CollisionHandlerFloor()
base.ctrav.addCollider(cplayer, lifter)
lifter.addCollider(cplayer, self.player)
smiley.posInterval(2, Point3(0, 0, -10), Point3(0, 0, 0)).loop()
def _initSphereShape(self, obj):
bounds = obj.getChild(0).getBounds()
center = bounds.getCenter()
radius = bounds.getRadius()
name = obj.getName()
cnodePath = obj.attachNewNode(CollisionNode(name))
cnodePath.node().addSolid(CollisionSphere(center, radius))
cnodePath.show()
return cnodePath
World()
run()
but the panda doesn’t move: