- Home /
How should I structure an object with a mix of rigidbody and non rigidbody children?
I have a spaceship.
Empty Gameobject attached
Turret Mount attached - this can turn from side to side. It's a rigidbody, with a fixed joint.
Turret body attached - rigidbody, on a hinge join, only allowing side to side rotation
Turret Head attached - rigidbody on a hinge joint, only allowing up/down rotation
This worked fine before. But, reading through some posts, it seems to be better to use physics for movement control of the spaceship, so I made the spaceship a rigidbody, and made the empty gameobject a rigidbody, with a fixed joint attached tothe spaceship. Turret mount is attached to the empty gameobject.
This doesn't appear to work well. Everything but my spaceship has .01 mass, no drag, no angular drag. And yet, I guess because the turret is on top of my ship, the ship slowly rotates up.
Honestly, I felt more comfortable handling spaceship control when it wasn't a rigidbody, but I wasn't able to make it bank properly. I just want very simple spaceship "pizza box" control.
Answer by Orion 1 · May 27, 2010 at 07:58 AM
I think you have to make a decision here
either have the spaceship be rigidbody, and the attachments be non-rigidbodies (don't use joints, but just the hierarchy and rotate them via a simple script if need be)
or your attachments rigidbody and attached via joints (although right now I don't see the point in it, tbh)
Your movement glitches probably come through the different rigidbodies interacting. Generally using joints for something like this doesn't quite give the desired outcome.
Concerning your spaceship's movement, you'll have to decide if you want "real-space-like-realistic-inertia-based-movement" (kinda like asteroids) or "the-spaceships-are-actually-like-aircrafts-but-in-space" (like in star wars). I don't quite get which one you're looking for.
Honestly, I would be tickled pink to get rid of the joints on my turrets, but I had a real hard time restricting their rotations to certain axis, and certain degrees without using the hinge joints. But, I think I will revisit this. It seems to me that physics is one of those things that seems to solve a problem at first, but can easily become an even greater evil :)
It certainly does, especially when you start caring about performance physics will be back to haunt you.
What sort of angles do you need your turrets to be?