How to disable collision handler pusher temporarily?

I’m trying to disable the collision handler pusher on “smiley” temporarily by doing .stash() on it but it’s not working. “smiley” still gets pushed by “frowney” and the event “smiley-into-frowney” still fires. How can I fix this?
Here’s an example showing this

from panda3d.core import CollisionTraverser, CollisionHandlerPusher, CollisionNode, CollisionSphere
from direct.showbase.ShowBase import ShowBase
from math import cos

class Scene(ShowBase):
    def __init__(self):

        self.smiley = self.loader.loadModel("models/smiley")
        self.frowney = self.loader.loadModel("models/frowney")

        self.cTrav = CollisionTraverser()

        self.smileyColNp = self.smiley.attachNewNode(CollisionNode('smiley'))
        self.smileyColNp.node().addSolid(CollisionSphere(center=(0, 0, 0), radius=1))

        self.frowneyColNp = self.frowney.attachNewNode(CollisionNode('frowney'))
        self.frowneyColNp.node().addSolid(CollisionSphere(center=(0, 0, 0), radius=1))

        self.pusher = CollisionHandlerPusher()
        self.pusher.addCollider(self.smileyColNp, self.smiley)
        self.cTrav.addCollider(self.smileyColNp, self.pusher)

        # ???????

        self.accept("smiley-into-frowney", lambda _event: print("smiley collided into frowney!"))
        self.taskMgr.add(self.update, "update")
    def update(self, task):
        self.frowney.setPos(cos(2*task.time)*5, 0, 0)

        return task.cont

scene = Scene()

stash() only will have an effect on into nodes, not on from nodes.

To disable a from collider, set its from collision mask to 0 or remove it from the traverser/pusher.

1 Like

I must’ve mistakenly thought that self.smiley was the into node. I did .stash() on self.frowney and that worked! Thank you so much