2D Physics - Inertia and inherited motion.
Do 2D rigid body hierarchies pass/inherit motion down the chain?
For example, I have an empty game object scripted to move horizontally back and forth between two points in a scene.
I have parented a simple rectangular sprite to this object. The sprite has a 2D rigidbody and a hinge joint component on it. The anchor point is set at the end of the sprite (on the empty game object center), and the sprite is rotated so that it "hangs" down vertically.
When I play the scene, the sprite moves back and forth, following the movement of its parent. I would also expect it to swing as it does so, due to the hinge joint and the rigidbody, but it does not swing. Its rotation remains fixed, completely vertical as it moves.
Do 2d rigidbodies only react to collisions? If so, is there another method that allows them to inherit motion and inertia?
Answer by greg725 · Oct 13, 2017 at 11:57 PM
Did some tweaking. The sprite now "swings" as expected.
Originally, I had made an empty game object "translateX" and scripted it to translate back and forth, and made the sprite a child of that.
What I changed was to add a new sprite "mover" to the scene, add a Rigidbody 2D component to that, and then parent "mover" to "translateX".
The "swinging" sprite is no longer parented to "translateX", but is attached to the "mover" sprite with the Connected Rigid Body parameter of a Hinge Joint 2D.
Haven't tested beyond this simple setup, but it seems to work now.