Open elmodor opened 1 year ago
Yeah, this has always been an issue with cards: it seems to be an issue with the Bullet physics engine when the collision shape is too thin (the collision shape for cards is actually 5x the height of the mesh!) - I'll have another look at ways to stop it, but I can't guarantee this will be fixed anytime soon :(
Actually, I think the issue is that the collider/mesh seems to be messed up when the scale is changed (in different axes) through the config file only.
Ace if clubs is: Scale: scale = Vector3(6.35, 1, 8.89) Ace of diamond is: scale = Vector3( 6.615, 1.0, 11.310) card_behaviour.webm
See how they behave completely different?
Good spot! I'll have to do some more testing on that.
I've done some testing, and I managed to find the "sweet spot" where the cards change behaviour: setting the X-scale to 6.45 and above causes the card to clip through the table. Independently increasing either the Y-scale or Z-scale does not make a difference. My theory is that this is Bullet making a distinction between thin vs. square collision shapes, and maybe trying to optimise? Or it may just be a straight up bug - but I haven't managed to find anything about this in Godot's issue tracker at all.
I've also tried adjusting the following settings, but to no avail:
The only thing that made a difference was the type of collision shape the table had - currently tables by default use a generic ConvexCollisionShape
to accommodate for any table shape. When I manually added a StaticBody
to the scene with a BoxShape
, the larger cards no longer clipped through the table (but they still did not slow down like the smaller cards tend to do).
A while ago I had the idea of a collision shape "optimiser" - basically, the game would scan the mesh shape on import, and on top of calculating things like the bounding box and average vertex, it would try and determine if a mesh looked close to a cube or a cylinder, in which case it would swap out the generic collision shape with either a BoxShape
or a CylinderShape
. I've yet to figure out how this would work fully, but something like this may end up solving the issue if it is not fixed upstream.
In 0.1.0 Beta 1, I set the thickness of cards to 2 mm, which is the thickness in real world, the problem is solved.
Oh, interesting! Will have a play around with that for different sized cards. One thing I want to keep in mind though is that I don't think the collision shape should be too thick, as cards may look like they are always floating above the table.
Godot 4 has replaced Bullet with Godot Physics. Looks like shifting to Godot 4 will resolve several issues.
Yeah hopefully so! Plus, even if the physics engine in Godot 4 is as wonky as Bullet is currently, there is an alternative we can use in Godot Jolt, which is a drop-in replacement for Godot Physics that is getting a lot of good reception from the community.
Describe the bug Larger cards clip through the table or even disappear complete inside the table when being dropped or tossed around.
To Reproduce Steps to reproduce the behavior:
Expected behavior Proper card physics: Card does not clip into table
Screenshots clipping_1.webm clipping_2.webm
Environment Arch Linux
Version v0.1.0 Beta 1