Problem with rigidbody and complex shape / multiple colliders...

Hi everyone,

I’ve been working on a spaceship for a game for the last couple of months and I’ve got to the point where I’m working on the physics for the ship.

Basically, it’s a spaceship with a 3D interior for the player to walk around and has a cargo hold that contains an exploration vehicle for the player to get into and drive out of the ship onto the surface of whatever planet or asteroid the ship has landed on.

The ship uses mesh colliders for the interior compartments and player-accessible areas. I’m also (currently) using mesh colliders for the hull of the space ship. The exploration vehicle is a separate GameObject within the space ship GO’s hierarchy currently. I’ll unparent its transform when it leaves the ship and make it a child again when it enters later.

The issue I have is this:

When I add a rigidbody to the space ship to allow the use of physics and the colliders so that it can sit realistically on the test planet surface (a standard terrain), it jerks and slides around in a circle constantly, no matter what values I add to the drag and angular drag boxes for the rigidbody.

I have removed the player controller and exploration vehicle from the space ship model and its hierarchy, thinking their colliders may be causing issues, but exactly the same behaviour is exhibited.

The space ship GO is fairly complex, containing a number of 3D meshes, some animated on a keypress (cargo doors etc), and some with mesh colliders due to allowing the player to walk around inside. I have tried deactivating the hull mesh colliders and replacing them with box colliders in an approximate shape, but then the ship falls through the terrain after catching on a wing before it drops through completely.

The only error messages I am getting are Actor::updateMassFromShapes: Compute mesh inertia tensor… I’ve looked up help on these and I’m not using any flat plane rigid bodies. I am, however, attaching a rigidbody to the root space ship GO, but how else can I use a rigidbody with the ship?

Does anyone have any experience of building complex 3D objects like this and applying rigidbodies to them?

Any help would be greatly appreciated. :slight_smile:

EDIT:

The ship GO contains a cargo bay floor that descends using animation. That also has a rigidbody attached.

Think I’ve solved the issue… thanks for your reply, Augusto, it set me on the right track. :slight_smile:

What I did was deactivate each GO within the spaceship GO one-by-one and tested the scene again until I found which GO’s were causing the issue with the ship falling through the ground. I also removed the box colliders approximating the shape of the whole ship as I couldn’t replace the mesh colliders which made the internal parts of the ship solid. Instead, I added three box colliders for invisible ‘feet’ (the ship sits on its hull otherwise) to prevent it resting solely on its mesh colliders, which weren’t working with the terrain.

Then I found that two GO’s in particular were causing the instability and making the ship fall through the ground. They were collections of lights within the ship which all used a flat plane mesh with a “light” texture on them and a light emitter. As I created the planes as default GO’s from Unity, they all had colliders attached. I removed the colliders and now the ship sits pretty on the ground!!

The only issue I have now is those darn annoying “Actor::updateMassFromShapes” errors. I’m assuming these are all to do with the planes, but the only rigidbodies in the ship are the ship itself and the cargo bay floor.

Anyhow, the main issue is sorted so thanks for your steer, Augusto! :slight_smile: