2D Rigidbodies getting stuck on scene's origin.

For some unknown reason some of my game objects with a rigidbody2D are getting stuck on the scene’s origin.
So far this has only happened with objects that are instantiated at runtime. They behave as if there was a “Rigibody2D.MovePosition(Vector2.zero)” in their update.

This issue also happens in a very erratic way, as in the objects it affects seem to be “chosen” at random, and sometimes the issue doesn’t occur at all. However this issue seems to happen a lot more frequently when I run the scene on android devices.

Edit 1: I’ve tried removing all scripts that handled the 2D rigidbodies in any way, but the issue still persisted, so I’m pretty sure its not related to any of my custom scripts.

Edit 2: For the time being I’ve replaced the 2D rigibodies by 3D ones and things have been working fine.

I’m using version 5.1.2p2, although the issue still occurred in the unpatched version of 5.1.2.

Well, here’s hoping someone can shed a light in this is issue.

Cheers.

I had the same issue changing my code from using transform.translate() to rigidBody.movePosition().

What I had to end up doing was keeping track of the starting x,y coordinate at each update.

public class MyClass : MonoBehaviour
{
    private float startX, startY;

    private void Awake ()
    {
        startX = transform.localPosition.x;
        startY = transform.localPosition.y;
    }

    private void FixedUpdate ()
    {
        // get your delta X and Y before this using whatever inputs you're using

        Vector2 move = new Vector2(startX + deltaX, startY + deltaY);
        
        myRigidBody.MovePosition (move);

        //set the new startX and startY
        startX += deltaX;
        startY += deltaY;
    }
}