Panda3d Collisions made simple

today I added a new snippet regarding the CollisionHandlerGravity class and how to use it to spice up a scene. Go up to grab it

step10 added: how to octreefy a collision mesh to improve the overall fps performance, with blender source and infos. Up you go

Theres a bug in your code ^^; you have two commands for the same letter “w”.

of course was put on purpose, just to see if somebody was still interested to this thread :wink:

thankyou adr for the hint, now all should be OK

astelix you’re doing a great job making this. I usally tell people to come here first if they have any problems with collision. They usally see what they did wrong and get it fix perty fast.

I think these examples should be added to some sorta “help pack” to show off what panda can do and how to do it.

Pluse, haven’t you notice the number of “collision help questions” have gon down by a lot, lol?

hah a huge step to decrease carbon emissions and keep the planet green! :slight_smile:
OT: BTW I actually found a nice resource to monitor carbon emissions by country (not very up-to-date though)

Now add a small wall into step10 so I can see whats wrong with my collision and octrees:P

indeed that is definitely on my to-do list but I guess would be the last step of the tutorial, where I’ll put all the steps together to have a big scene with lotta things stuffed into. But before that I would make one or two steps talking about particle physics and another one about fluid collisions (kinda bullets showcase) so I guess we won’t see that too soon.

Hi,

I eagerly went over the tutorial. Very well written. It helped me get a much better grasp of the Panda collision system.
After reading the 10 steps, I’m still having problems finding the right approach for the specific game I’m trying to write (a 2.5d platformer - the characters are 2d, and the platforms are 3d boxes).
Any suggestions as how to approach the collisions in such a game (I’m especially having a hard time figuring how to handle the “floors” - It seems I’ll need to know the collision direction (for stopping/starting a fall and so forth)).

Thanks,
Ogga

hi Ogga welcome here.
For the info you provided above, the first thing I’ll do will be to treat your 2.5d avatars as it was 3D, so i.e. you just switch what is now the smiley model in one of these steps with your flat avatar and keep parenting with 3D colliders. As simple as it sounds. So, try by yourself to modify step9 smiley with one of your characters and see if you are able to make it work, otherwise come back here with your code and we’ll see together what is wrong.

Hi Astelix,

Thanks for the friendly response.
Your suggestion is basically what I’m doing.
My issues (in a nutshell) are:

  1. How can I deal with floor collisions? In the tutorial examples the floors are terrains. In my game the floors are a bunch of floating boxes.
  2. How can I know the direction of the collision (if it is from below then the avatar can stop falling, if from the side can stop walking and keep falling etc.).

Thanks again,
Ogga

well the first question I guess is redundant cos is included in the 2nd when you said “if it is from below then the avatar can stop falling”.
To solve your problem, as is to have colliding boxes as you need, you must build’em as I built the scene for steps 7-8 where you have your box visible geometry mesh, 1 collider mesh for the top surface, that you’ll mask as FLOOR_MASK in your script and 1 collider mesh for the left and right side (those exposed horizontally to the avatar) marked as WALL_MASK. Once you got modeled a box in this way, you may the load and fill your scene with this kind of colliding boxes ad libitum. Now, just try by yourself a working little scene startring from step7 with a couple of boxes and a steering avatar and let me know, either if work or not.

OK. I’ll give it a try.
I understand the approach of making each wall a collider-mesh (top as floor, sides as walls).
What I don’t quite understand is which collision-solid I should use as collider-meshes.
Is there a chance you could perhaps post a small piece of code showing how, given a box model, you would set up the into-collider-solids for the floor and walls of this box-model?
I’m sure that would get me started on the right track.

that crossed my mind - your inquiry uncovered indeed a hole in my snippets that definitely need to fill - I’m actually going to end a couple of new snips, then I’ll add a new one ASAP talking about your issues.

today I reorganized the whole stuff to be splitted in beginner and advanced so those who already got a little startup in collision could jump the first part - then I added a couple of new snippets showing out how to use the isInView method as a cheap way to fake collision detection of objects falling inside a frustum. Go up and grab’em out

as requested by Ogga I made a 2.5D collision sample - it is a whole level of a imaginary game - Plz don’t blame the author for not to be a great level: it is just for learning purposes. :wink:
as usual go on top to grab it

I’m going through the exercises but I’m stuck on the first one. When I run the program with my own egg I get the error “!collider is empty…”.
I’m converting from 3d max 2010
my egg file reads as :
{ Z-Up }

character {
{ 1 }
“Scene Root” {
Sphere01 {
Sphere01 { Sphere descend keep }
Sphere01.verts {
0 {
6.9763 1.23258 14.0568
{ -3.29839e-008 -1.49672e-008 1 }…
please help

well, at a first glance looks you aren’t respecting the same model construct - in all my steps I ain’t never used the ‘keep’ keyword therefore I use to have a visible geometry mesh and a collider mesh and do not use a single mesh for both tasks - that’s why my script gave you words.
The problem is that I conceived the whole stuff following the modeler sources as well and to go with blender not max so if you’re going to follow this path I suggest you to down blender in your PC (it’s free after all), open the .blend model source for the step your digging, see what inside and try to reproduce the same object structure.

First - Thank you so much astelix for creating these tutorials! They have greatly sped up my learning of Panda3D collisions. :smiley:

Second - I’m having a problem with my geometry and ‘Polyset descend.’ I’ve got a scene in Blender with 5 pieces of collision mesh and they are all parented together like this:

collide1

  • collide2
    • collide3
      • collide4
        • collide5

Each one has the property Collide, ‘Polyset descend.’ Unfortunately, only the first collide1 works and my character walks through collide2-5 without triggering a collision. I’m setting up the wallcollider like it was done in the intermediate step2 example:

self.wallcollider=self.hallway.find("**/collide1")

Any idea what I’m missing?

yep, you’re missing the advanced step2 :slight_smile:
you’re going to do something advanced - but correctly made - that I hinted in that step (to be precise in the windmill.blend “Notes On Making Of”). Anyhow it is a chicken exporter limitation - it recognize and export correctly just the first nesting level therefore what you’ve done it is not correctly exported.