- Home /
Rigidbody2D: Follow other Rigidbody2D strictly
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.
[2]: /storage/temp/148485-testproject.zip
Answer by lgarczyn · Nov 08, 2019 at 06:30 PM
You need to execute the follower script on Update, and make sure its execution happens after RigidBody2D. And here's the kicker, the reflection should really not be a rigidbody. If it's not actually doing any calculations, it should at worst be a kinematic rigidbody, and use the MovePosition command.
Last thing, you can do reflections using two cameras, you do not need to duplicate all your objects.
Your answer
![](https://koobas.hobune.stream/wayback/20220612214528im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
increasing knockback of a rigidbody as received damage increases (like super smash) 1 Answer
Recalculating collisions after Physics2D.IgnoreLayerCollision()? 1 Answer
Child GameObject can't use MovePosition on parent's Rigidbody2D? 3 Answers
How to make physics relative to moving parent 1 Answer
Inconsistent gravity/random forces/solver problem? (forum crosspost) 0 Answers