Issues with Collisions, CollisionEvents, and CollisionMasks

Hello there!

I’m very new to using help forums and with Panda3D. I’ve done some reading in the manuals and tried to follow some examples, but I can’t seem to find an article sharing a similar problem (maybe I’m blind, who knows?).

My game uses resources from the Toontown Rewritten Phase Files. I made copies of the models I wanted to use and placed them under the same directory as the .py files. Theoretically, one should be able to clone the GitHub repository and run main.py and everything should run as it currently is.

Basically the player character can run around and throw pies. I recently tried adding collisions to the player and the pies, however it seems only the player character obeys the CollisionHandlers I set up. I am trying to detect when a pie hits the floor or a wall so that I can make the object disappear (at least for now, I might include splatting later). At some points, the pie would obey the CollisionHandlerFloor, but would not detect its CollisionHandlerEvent. At other points, the CollisionHandlerEvent would fire repeatedly, even when the pie did not touch the floor.

I’m not sure exactly what I’m doing wrong, particularly after looking at the manual and consulting a couple of topics here. I’d really appreciate the help!

The link to the GitHub is here: https://github.com/Gamerdude38/PieThrow

Thanks for the assistance!

Hi there, welcome to the forums.

This question is a bit too broad for us to assist you with. If you can come up with an narrower example of your issue (that uses assets you have the rights to), then we can help you further.

You mention that you have a CollisionHandlerFloor and a CollisionHandlerEvent–do you perhaps have them handling the same CollisionNode? If so, and if I’m not much mistaken, you can have only one CollisionHandler for a given CollisionNode.

That said, I’m not sure of why such an issue would produce inconsistent results–I think that it usually just results in the last-applied handler being the one that takes effect. Unless you’re repeatedly applying them, I suppose, in which case it would obey the most recent one at any given moment, I think.

Hmm… If the CollisionHandlerEvent is firing repeatedly, do you perhaps have more than one CollisionNode overlapping in the “pies”? If so, then they might be repeatedly colliding, resulting in odd behaviour. If this is the case, then you might be able to solve the issue by using BitMasks to prevent them from being treated as colliding.

Hey guys, thanks for getting back to me so quick! Next time I got a question for here, I’ll be sure to use the models that come with Panda instead and I’ll try isolating the problem.

In creating a new class to see if I can replicate the problem, I’ve made some headway. Earlier with CollisionHandlerEvents, I was referring to the ones that come with CollisionHandlerPusher and CollisionHandlerFloor, since the manual said that most of the CollisionHandlers inherit from CollisionHandlerEvent. And with what I got so far, the Panda models seem to be detecting collision events at the right time! I find it so strange that similar code is not working in my current program, so I’ll either rewrite the class or remove the collision system, then integrate it back in using what I learned from the new collision example I written.

It seemed quite helpful to have rewritten everything using different models and to get something working. That probably wasn’t expected, Treamous, but your advice helped out a lot already. Thank you guys so much!

Please note that we cannot answer questions relating to the use of models that you have not obtained permission to use.