So while trying to get better at panda3d i tried to forge some script. and met an issue when trying to make my collisions work. It does detect it, but no effect of Pusher is visible and even though when calling show on cnode path the meshes are correct it never does anything. The error i get is
(all display modules loaded.)
:collide(error): Invalid attempt to detect collision from CollisionPolygon!
This means that a CollisionPolygon object was added to a
CollisionTraverser as if it were a colliding object. However,
no implementation for this kind of object has yet been defined
to collide with other objects.
My actual code is composed of multiple scripts, but thatâs where i define the cNodes and append them to traverser and pusher
from panda3d.core import CollisionNode, CollisionPolygon, CollisionHandlerPusher, CollideMask
from reference import REFERENCE
class cone():
CONES = {}
speed = 1
NAMEID = 'cone'
@classmethod
def getInstances(cls,id):
if id == -1:
return cls.CONES
else:
try:
return cls.CONES[id]
except Exception as e:
REFERENCE.ReturnExceptionPretty(e)
def __new__(cls, *args, **kwargs):
obj = object.__new__(cls)
cls.CONES[len(cls.CONES)] = obj
return obj
def __init__(self,where,ctrav,pusher):
self.id = self.getId()
self.model = loader.loadModel(REFERENCE.loadTexturePath('cone_phy.bam'))
self.node = render.attachNewNode(f'{self.NAMEID}{self.id}')
x, y, z = where
self.model.setPos(x, y, z)
self.node.setPos(x, y, z)
self.model.reparentTo(self.node)
self.cNodeP = self.model.find("**/+CollisionNode")
self.cNodeP.node().setIntoCollideMask(CollideMask.bit(0))
self.cNodeP.show()
pusher.horizontal = True
pusher.addCollider(self.cNodeP, self.model)
ctrav.addCollider(self.cNodeP, pusher)
def getId(self):
for k,v in self.CONES.items():
if v == self:
return k
I did assume that all colliding things which use pusher handler should share same instance of pusher, but Iâm not sure thatâs correct.