- Home /
Making complex objects settle under gravity
Hi all,
I'm trying to make piles of junk. ;) For reasons I won't go into here I need random piles of complex objects, and I don't mind the time cost too much because they will only exist for a short time and the player can't interact with them.
My question is how to make complex (often concave) objects settle into a plausible heap under gravity. From what I'm aware you can't collide two concave meshes together.
My first thought is:
Have a rigidbody and two colliders per object - a rough convex collider and a meshcollider.
Start with all using convex colliders only (e.g. turn off meshcolliders).
Drop the objects.
After a little settling time run through the objects one at a time from the bottom to the top. Disable the rigidbody for the object, this is it's final position. Enable their meshcollider and disable the convex collider so things above will settle. This would ensure no concave on concave collisions.
After all objects have been run through, call the process complete.
I don't think the results would be so pretty.
I have heard of other solutions simulating concave objects with jointed convex objects. I'm not sure how stable or performance hungry they are. Also do the physics solvers get more stable answers if you start near the solution or not?
Any help would be appreciated!
JT
Answer by Owen-Reynolds · Mar 22, 2015 at 05:50 PM
Use Compound colliders?
You can assemble standard colliders -- mostly long cubes and capsules -- to create an effectively concave collider. I've only done it with simple L and C shapes -- well, a moving bowl made up of maybe a dozen cube "planks" -- but seems to work fine.
I assume you could even use compound convex Mesh colliders. Like if you needed to build a shape out of wedges, say.
Answer by JedBeryll · Mar 21, 2015 at 06:49 PM
Rigid bodies have a freeze position option that might work for you. Example: rigidbody.constraints = RigidbodyConstraints.FreezeAll;
Thanks for the answer. $$anonymous$$y question is more about how to make multiple concave colliders work, and as far as I understand a frozen rigidbody doesn't allow concave colliders.