Hi all,
I’m trying to use the CollisionHandlerPusher in conjunction with a CollisionSphere and a CollisionPlane. I modified one of the examples to show my problem:
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *
#initialize traverser
base.cTrav = CollisionTraverser()
#initialize pusher
pusher = CollisionHandlerPusher()
#########
#load a model. reparent it to the camera so we can move it.
smiley = loader.loadModel('smiley')
#smiley.reparentTo(camera)
smiley.reparentTo(render)
smiley.setPos(0.5, 25.0, 0.5)
#create a collision solid for this model
cNode = CollisionNode('smiley')
# if 1: use collision sphere: frowney deflected
# if 0: use collision plane: frowney ignores plane
if 0:
cNode.addSolid (CollisionSphere(0,0,0,1.1))
else:
cNode.addSolid (CollisionPlane (Plane (Vec3 (0, 0, 1), Point3 (0, 0, 0))))
smileyC = smiley.attachNewNode(cNode)
smileyC.node ().setIntoCollideMask (BitMask32.bit (0))
smileyC.show()
#########
#load a model
frowney = loader.loadModel('frowney')
frowney.reparentTo(render)
frowney.setPos(5.0, 25.0, 0.0)
#create a collsion solid for this model
cNode = CollisionNode('frowney')
cNode.addSolid (CollisionSphere(0,0,0,1.1))
frowneyC = frowney.attachNewNode(cNode)
frowneyC.node ().setFromCollideMask (BitMask32.bit (0))
frowneyC.node ().setIntoCollideMask (BitMask32.allOff ())
frowneyC.show()
#########
#add collision node to the traverser and the pusher
base.cTrav.addCollider(frowneyC,pusher)
pusher.addCollider(frowneyC,frowney, base.drive.node())
#########
#have the one ball moving to help show what is happening
frowney.posInterval (5, Point3 (0.0, 25.0, -3.0), startPos = Point3 (0.0, 25.0, 3.0), fluid = 1).loop()
run()
When running the above code, the “frowney” passes right through the collision plane. Should it not stop or do something else?
If the line starting with “if 0:” is replaced with “if 1:” the CollisionPlane is replaced with a CollisionSphere, the move sphere “frowney” is deflected as I would expect it.
What am I doing wrong? Thanks for your help.
Cheerio
pit007