My apologies for posting about collisions yet again. I’m new to game dev, let alone Panda3d. I was looking for some advice on the workflow for making collision solids.
I’ve created a simple little house model for a player to walk around in. I used the Blender 2.8 branch of YABEE to export it as an egg. I do this so the geometry for the house also has a collision solid. When I bring that into my game, I’m able to pass through walls if I push against them for long enough. The player model has a simple collisionbox around it, and I’m using the wallpusher handler to manage the collision. I did some research, and if I’m understanding correctly, my egg based collision solid is a collisionpolygon which is kind of buggy, and might be root of the problem. (For extra info, the walls of my house have thickness, they are not just planes. They are 3d boxes and such. Similarly, the collision solid for the walls are polygons around the 3d geometry. I found using 2d planes for the walls meant the player could pass through the collisionpolygon from the backface)
So, what should I be doing? What collision shape should be around my walls? It seems like a lot to create a bunch of collisionboxes around all the walls (especially accounting for doors in the walls). Plus, collisionboxes would need to be made in code, right? I can’t make those in blender and save to the egg…right? What is your typical workflow for setting up collision geometry?
Hmm… I’ve generally had little trouble with polygonal walls. But then I don’t often use a box-collider for my player-characters–perhaps collisions between boxes and polygons are less reliable than collisions between some of the other simple collision-shapes and polygons. To test this, have you tried using a sphere for your player-character instead of a box?
Just to check, by the way: am I correct in guessing that by “wallpusher handler” you mean “CollisionHandlerPusher”? (Or is this handler that I’m forgetting…?)
If I recall correctly, it is possible to generate collision-solids in Blender. I think that in order to do so, when giving a piece of geometry a “collide” tag you would specify the desired type of collision-solid in place of “polyset”.
Oh, one more thought: How are you moving your player-character? Are you applying your own velocity and associated movement logic, and if so, are you updating the character’s velocity after hitting a wall? It occurs to me that passing through a wall might occur if the character’s velocity in the direction towards the wall remains high while in contact with it, potentially allowing the character to “teleport” through. (Especially if a hiccough in the frame-rate causes a larger-than-normal change of position)
Thank you for the reply! I’ve tried out your advice and switched the player to have a sphere around it. It definitely seems to work better than a box, but if I weasel into a corner just right, I can still pass through. My new theory: I read that collision polygons are infinitely thin, so perhaps enough of the sphere is getting through in a single frame to touch the polygon on the other side of the wall, thus I get “pushed” to the other side? I suppose I could make my walls thicker, it just might look silly.
You are correct, I misspoke when I said “wallpusher”, I do mean collisionhandlerpusher.
I’m using Blender 2.8, is it still possible to set this tag? Where do I set it?
My character controller is real simple. There’s a task that’s listening for keystrokes. When you hit ‘w’, ‘a’, etc. It just adds 10 to your position. There’s no velocity tracking or physics set up. I’ll get to more complicated things as I learn them. For now my game is just walking around a house.
I tried slowing down the character movement speed just now, and got even more improvement. So, I think you’re idea that the character’s high speed is causing it to jump through walls is correct. Perhaps it is time I start learning a more advanced controller.
It’s possible–but if you’re just adding 10 to your character’s position on a given frame, with no contribution from the delta-time between frames, then I doubt that it’s the case. After all, you would be moving your character by the same distance in every applicable frame.
It should be possible. I imagine that you have geometry on which you’re setting the tag “polyset descend” (or “polyset keep descend”); in that tag, you would replace “polyset” with another value. This page lists the available values–I do note that it doesn’t list “box” or “cube”, but it might be worth trying one or both of those in case such a collider is implemented, but isn’t documented there.
(You might have to experiment to determine just how the shapes are generated from your geometry.)
If you’re not using “collide” tags, then how are you generating your house’s collision geometry?
As to using non-polygonal collision shapes, if your game has no real verticality–no jumping, or falling, or climbing, or flying, etc.–then you might be well-served by representing your walls with CollisionCapsules/CollisionTubes: I’ve generally found them to be pretty reliable for this purpose.
(If you do use them in this way, note that you might also want to set your CollisionHandlerPusher to only function “horizontally”, so that it doesn’t push your character up or down over or below the tubes/capsules.)
Oh, one more thought: do you have a scale applied to any of your collision-nodes, whether player or house, and whether applied directly to the node or to some parent of the node? Scaling can be a problem for the collision system, I believe.
Thank you for that link! I didn’t realize there was such documentation for the egg file. Exploring this will help me a lot.
I think the 2.8 branch of YABEE does this automatically. I haven’t used the version for 2.7, but from what I’ve read I think the 2.8 branch has less options, and just defaults several of those options. So, I think it was automatically adding tags for me when I exported to egg.
I did look into scaling earlier, and found the notes in the collision documentation about that. Nothing I’m using has any scaling.
I would like to put stairs in the house eventually, which would then lead to potential falling. But, one step at a time. Once I work out my issues here, I’ll move on to the next step. I will definitely explore using other collision shapes with the walls. Thank you again for all your help and advice!