I am trying to make a 2d game. I have a character who jumps made of segments, one big and four little ones. all of the segments are planes with colliders and rigid-bodies attached. I want the little segments to swerve behind the big one when i jump. To accomplish this I have attached hinge joints to most of the segments, but this has not worked, the segments swerve but when he jumps he bowls himself over and usually lands on his head.
Does anyone know how I would implement this effect?
any help would be greatly appreciated.
EDIT: for clarification my character is a worm made of five segments, all of which are children of one empty game object representing the character as a whole. The biggest segment is at the front and is the creature's head while the four little ones are the tail. My movement script which I have placed on the head segment, works by changing the head segment's velocity, so the rigid bodies on the tail segments are interfering with my jumping. I would like the head to be the centre of physics and interaction with the world while the tail just gently swerves behind the head when he jumps, not affecting the movement at all.
NOTES: The tail wants to spin the body around, and even a very light tail is enough to do that. Like a 300 pound ice-skater who throws out a 10-pound arm to start spinning. For real, an animal is moving the tail in a very precise way to control their spin. In other words, instinctively running physics "backwards" in it's head. I don't think even state-of-the-art robotics can do that, yet. So, there's no way Unity can make a correct "active" tail.
SOLUTION: The trick to is to wall off the tail from the body. This worked for me: add a child "rump" to the head segment. It could be an empty or a model. Give it a rigidbody set to
For the tail sections, same as before, but connect the first one to the new "rump" (the slot for connectedBody requires a Rigidbody. Using an isKen RB as a frozen connection spot is a trick from the Docs.)
The tail is now stuck to a single point in space, which just happens to follow to head. One problem I had is that the tail can still bend and smack the body, knocking it around. You could just make the joints stiffer. Or, an absolute solution would be to make a wide collider between head/tails on a layer only the tails can hit.
answered Jun 04 '12 at 04:15 PM
Try increasing the main body's Mass, in the rigidbody (can do through the Inspector.)
Unity just sets everything to 1 kilogram(*), regardless of how large the collider is(**). This means physics is acting as if your tail segments are brass and your body is a giant feather pillow -- easily pulled around by the tail.
(*)Kilos are mass and weight? That doesn't sound right.
(**) Maybe they should throw a card for "set default Mass proportional to Collider volume" at the bottom of the scrum pile. But then they'd want to recalc when the collider was resized, but only if they're still on default. Instantiated prefabs have a "never been touched by user" flag. Do things such as Mass have one?
answered Jun 03 '12 at 03:42 PM