Search Unity

[2D] Make object with rigidbody follow platform with rigidbody (non-Kinematic)

Discussion in 'Physics' started by ben-maurin, Mar 6, 2017.

  1. ben-maurin

    ben-maurin

    Joined:
    Apr 7, 2016
    Posts:
    47
    Hello,

    As everyone knows, if you put a physic object on a collider and move that collider, the object will not follow the collider. The problem can be solved if only the object has a rigidbody.
    The behavior I want : Make an object with rigidbody2D that move with forces, follow a platform with rigidbody2D movement AND torque. The two objects need to influences each other.

    After looking on internet and testing some stuff I've found 3 solutions that does not completely work :

    1) Make object child of the platform.

    Everyone on internet solve platform problem with that. Ok It works, the object follow movement and torque but... You cannot make a rigidbody parent of an other rigidbody (unless one of them is Kinematic, but I want the object and the platform to be able to move/rotate).
    http://answers.unity3d.com/questions/62497/-you-should-never-have-a-parent-and-child-rigidbod.html

    2) Apply sames forces to platform and object (or deduct forces to apply from velocity of platform)
    This works great for movement when platform do not rotate, but it become really difficult to know what force to apply depending on platform rotation and when torque is applied to the platform.

    3) Having a fake child object (child of platform) and apply delta movement of this object to desired object
    This only make jerky movement and do not take the influence of object to platform and influence of platform to the object. If the object on the platform push the plaftorm or make it rotate a while, there will be double mouvement applied to the object (normal movement + movement from fake object).

    How do you guys handle this? Am I missing something?
    Thanks in advance for your help.