I am making a tank game. In the project the mesh looks something like:
Tank
Tracks
Turret
The problem is when I put the mesh collider on the tracks it conflicts with the mesh collider in the turret, so I had to put the turret as trigger. However, now when I go over a hill the turret just separates from the tracks.
Ok, first a rigidbody is a single physics object that always works totally on it’S own. Never have a rigidbody as child of another moving object. You also shouldn’t use Meshcolliders for moving objects. It’s better to use primitive colliders (see compound colliders) for rigidbodies. If you have multiple rigidbodies that shouldn’t collide with each other, use either Physics.IgnoreCollision or Layer-based collision (collision matrix) to control which object can collide with what.
Your hierarchy looks a bit strange to me. Shouldn’t it be something like
-Tracks // This is the Rigidbody
-Tank // this is the tank body that can rotate above the tracks / base
-Turret // this is the turret on top of the tank
Tank and Turret shoudn’z be rigidbodies. Just move them manually by rotate them locally with Transform.Rotate or set Transform.localRotation / Transform.localEulerAngles manually.