Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Rigidbody2D: Follow other Rigidbody2D strictly

Discussion in 'Physics' started by ErikSchulze, Nov 8, 2019.

  1. ErikSchulze

    ErikSchulze

    Joined:
    Apr 4, 2017
    Posts:
    1
    I want to do something that actually sounds pretty simple: Make one Rigidbody2D follow another Rigidbody2D strictly, so that they have the same position, collisions and general behaviour.
    Using rb2d.position = other.position; (rb2d and other both being of type Rigidbody2D and having the exact same configuration) inside FixedUpdate leads to other being behind rb2d not just visually, but also collisions differ:

    In this picture, pink is other, and it collides at a different distance than rb2d.
    I tried setting the velocity of rb2d in Update instead of FixedUpdate, I tried following in Update instead of FixedUpdate, I tried different ScriptExecutionOrders, nothing worked.
    When I use transforms to realize the follow inside Update, there is no visually visible distance between the two, but the collisions do differ.
    My use case is that I want to make a platformer with a player reflection following strictly on the x-axis but differing on the y-axis, but I ran into problems with the reflection glitching through platforms due to the physics differences to the player.
    I attached a small sample project containing the logic from which the screenshot was taken.
     

    Attached Files: