I’ve tried to sort this out on my own and looking through the forum, but its wound me up to much!
basically i have collision nodes set up and what to add a transver node to the main character (ralph)
def setupCollisions(self):
# use an event collision handler (sends events on collisions)
self.cHandler = CollisionHandlerEvent()
# set the pattern for the event sent on collision
# "enter" plus the name of the object collided into
self.cHandler.setInPattern("ate-%in")
# make a traverser and make it the default traverser
self.cTrav = CollisionTraverser()
base.cTrav = self.cTrav
# add a sphere around Ralph to collide with the lollipops
# get the bounding sphere of Ralph
bounds = self.Ralph.getChild(0).getBounds()
center = bounds.getCenter()
radius = bounds.getRadius()
cSphere = CollisionSphere(center,radius)
cNode = CollisionNode("Ralph")
cNode.addSolid(cSphere)
cNode.setIntoCollideMask(BitMask32.allOff())
cNodePath = self.Ralph.attachNewNode(cNode)
# add Ralphs's collision node to the traverser as a collider
self.cTrav.addCollider(cNode,self.cHandler)
# traverser = CollisionTraverser('Ralph')
# base.cTrav = traverser
# traverser.addCollider(fromObject, handler)
# add sphere around the lollipops to be collided into
for target in self.targets:
cSphere = CollisionSphere(Point3(0,0,15),15)
cNode = CollisionNode("lollipop")
cNode.addSolid(cSphere)
cNodePath = target.attachNewNode(cNode)
# end setupCollisions
And when i run it i get this error:
Warning: DirectNotify: category 'Interval' already exists
DirectStart: Starting the game.
Known pipe types:
wglGraphicsPipe
(3 aux display modules not yet loaded.)
Traceback (most recent call last):
File "main.py", line 179, in ?
w= World()
File "main.py", line 34, in __init__
self.setupCollisions()
File "main.py", line 155, in setupCollisions
self.cTrav.addCollider(cNode,self.cHandler)
TypeError: CollisionTraverser::add_collider() argument 1 must be NodePath, not C
ollisionNode
Press any key to continue . . .
Any ideas??
i’ve looked through the manual and the forum and tried some of the suggestions but still can’t get it working.
Please Help!