Collision between trimesh-shaped physicsbodies.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By frankjrix

(This is a copy of my earlier post on reddit.)

I was toying around with 3D physics, and I have two questions regarding trimeshes.

First, I noticed that bodies whose collision is handled by trimesh shapes can’t detect each other, and after a bit of research I found out that this is not considered much of an issue. I’m thus wondering if there’s any workaround to it, except adding a second layer of convex (primitive maybe) shapes (which would kinda defeat the point of having the auto trimesh shape, I guess) and if there’s any specific reason to this behavior (performance?).

Secondly, rigidbodies using a trimesh seem to have an inconsistent behavior, often (but not always, which is even more puzzling) not responding properly to gravity. Let’s say I make a simple pole, angle it 45°, and drop it on a staticbody floor; if the pole shape is convex, the pole behaves as expected, landing its lower end first, and rotating until it’s flat on the ground. If it has a trimesh shape, It correctly falls until its lower end lands, and then most of the time it remains eerily angled at 45° (seemingly stopping all calculations), while sometimes it behaves like the convex.

I’ll be very thankful for any insight I can get on this.

EDIT: I think the second part has to do with a misplaced origin point in the model.

:bust_in_silhouette: Reply From: Magso

The trimesh collider doesn’t have any volume and will clip through other colliders if it slightly intersects them. They’re mostly used for staticbodies to interact with other rigid/kinematicbodies in the scene using physics based methods such as add_force() and move_and_slide(). Using methods like translate() or set_translation() will simply clip straight through.

Plus it’s amazing that Godot supports rigidbody trimesh collision at all, given that the Unity rigidbody outright ignores any mesh collider (trimesh collider) attached to the GameObject and as far as I know Unreal only uses convex colliders.

Well that actually makes a lot of sense now! Thank you for the insight!

frankjrix | 2020-03-06 00:27