I'm actually working on a 2D game, and stumbled upon something rather strange in Unity. The issue occurs pretty specifically, so the description will be long:
In the scene, I have a flying object, controlled by the player. It has a rigidbody set as follows: Mass=1, Drag=0, Angular Drag=0.05, Gravity=false, Kinematic=false. So far, so good, the script worked flawlessly, and collide as expected in other physical objects.
Our client asked us to create platforms upon which the enemies could walk, but the player would fly through. A simple collider with IgnorePhysics(GameObject with Player tag) did the trick. The script still worked, no issue until then.
I added a cube on the platform, to test if it would fall through or not. The cube effectively collide with the platform, just as usual, and rest upon it.
But now, as soon as the player hit the cube, it get pushed back in the opposite direction until it hit another surface. It happens like when a non-gravity object is pushed by something: a force is applied and continue forever without friction. (But it does not bounce the same way on other objects. I can only suppose it comes from the force inputed to the objects during the collision, but I can't know for sure)
Example: if I hit the underside of the cube, my avatar will drift towards the ground until I hit it, no matter its speed in other direction. If I hit the upperside, it'll just fly out of the screen, towards the y-infinite.
The script is a classic gameobject.transform.position = Vector3.MoveTowards, so it input no forces whatsoever. Thus, I can't counter the inverse force.
The thing bothering me is that the avatar never had this kind of drift before, even though it collided other objects.
My question is: How can I negate the new force input from the collision for the avatar? (optionnaly: why does it occurs only in this case? I'm puzzled by this case)