2
\$\begingroup\$

Trying to make an object that is affected by rigidbody physics in exactly the same way as the object it's linked to. So torque, velocity, and any resultant torque or velocity from a collision.

This image demonstrates what I mean:

I've tried using FixedJoint2D, my objects share velocity but do not share torque, applying torque doesn't do anything to either object, it seems locked. I tried using other joints, such as DistantJoint2D(doesn't match y value, only separation value), TargetJoint2D(immediately negates velocity), RelativeJoint2D(The closest to actually working, but glitches out when torque is applied, it acts on a centre of mass between the two connected objects and the objects sort of spin around each other, sometimes getting closer together or farther apart)

I also can't just apply the transform position and rotation to the second object, since these objects will be colliding with moving objects. The objects that they collide with slide into the squares and are pinched away when using this method.

So I need to know if there is a way to use the FixedJoint2D or RelativeJoint2D or another method or joint that I do not know of to achieve this same effect. Perhaps applying the collision forces happening to one object to the other but it needs to be immediate and I don't know how to apply the collision from one object to another.

\$\endgroup\$
1
\$\begingroup\$

This is a really interesting question and had me thinking about it. I don't think it's a physics question because you want a non physical response. In A you want the left hand block to hover in the air where as, physically, I would expect A to fall and constrain to block B too. So I am not sure that this is a physics problem.

Your diagram shows that B is always responding to the other objects and A merely following? if that is the case then I'd simply have A as a trigger, mimicking what B does, with a linear translate, and having no effect on the simulation. That would certainly produce the effects you've designed.

If you want B to respond to A's physical interactions, and vice versa then I would have an overlap sphere on both of the bodies. When the bodies come close to something that will effect them the rigidbody for that body is switched on, and the other body's is switched off and it's welded in it's relative position. In effect the other body becomes a ghost.

Where this breaks down is when you have both bodies trying to react to different impulses. There again I think that is impossible because you could well get opposing inputs. One body could be hit left, the other could be hit right, and you can't resolve those conflicting inputs so you would need to only ever nominate one dominate.

\$\endgroup\$
  • \$\begingroup\$ I ended up solving this by syncing the rigidbody velocity, and angular velocity, while lerping the "mirror" towards the master object. \$\endgroup\$ – Wafer Oct 20 '16 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.