Player Rigidbody 2D has velocity but doesn't actually move

I’ve tried searching for an answer to this and come up with nothing. My player movement was working fine until I made a bunch of changes to my game and went back to check on things, and now my player will not move at all. Animations are working fine, and when I use debug.log it shows the rigidbody velocity I would expect, but the player is stuck in one place, and when I try to move it manually in the inspector while I’m in play mode, it doesn’t move, either. My rigidbody is set as Dynamic.

Here’s the relevant code:

    void Update()
    {
        playerMoving = false;

        if (moveDirection.x > 0.5f || moveDirection.x < -0.5f)
        {
            myRigidBody.velocity = new Vector2(moveDirection.x * moveSpeed, 0f);
            playerMoving = true;
            lastMove = new Vector2(moveDirection.x, 0f);
            anim.SetFloat("MoveX", moveDirection.x);
            anim.SetFloat("MoveY", 0f);
        }

        if (moveDirection.y > 0.5f || moveDirection.y < -0.5f)
        {
            myRigidBody.velocity = new Vector2(0f, moveDirection.y * moveSpeed);
            playerMoving = true;
            lastMove = new Vector2(0f, moveDirection.y);
            anim.SetFloat("MoveX", 0f);
            anim.SetFloat("MoveY", moveDirection.y);
        }

        if (moveDirection.x < 0.5f && moveDirection.x > -0.5f)
        {
            myRigidBody.velocity = new Vector2(0f, myRigidBody.velocity.y);
        }

        if (moveDirection.y < 0.5f && moveDirection.y > -0.5f)
        {
            myRigidBody.velocity = new Vector2(myRigidBody.velocity.x, 0f);
        }

        anim.SetBool("Moving", playerMoving);
        anim.SetFloat("LastMoveX", lastMove.x);
        anim.SetFloat("LastMoveY", lastMove.y);
        lastMoveVec3 = new Vector3(lastMove.x, lastMove.y, 1f);
    }

Wild guess: maybe the animator is overriding the player’s transform position, so it ignores any changes made by the physics system (or any other system for that matter)?

Check whether your animation clips set any values for the player’s transform.

This is one of the reasons why using a version control system (git, plastic, svn, etc) comes in handy: you could just go back to a previous version of your project and see what changes caused this issue, problem solved in just a few minutes! :wink:

Also time scale is worth checking. I think physics does not get simulated at 0.