Help with 2D movement

I need help with my 2D movement script. I was previously using a transform modifier, but that means colliders don’t work. I switched to a rigidbody based system, and now my player won’t move. Where did I go wrong?

public class PlayerController : MonoBehaviour {

    public float walkSpeed = 0.5f;
    public float runSpeed = 2f;
    public float crouchSpeed = .25f;
    public float heightDifference = .43f;

    Transform playerPos;
    Rigidbody2D playerMove;
    SpriteRenderer playerPicture;
    BoxCollider2D playerBox;

    public Sprite walkPicture;
    public Sprite runPicture;
    public Sprite crouchPicture;

    float horMove = 0;
    float vertMove = 0;
    bool running;
    bool crouch;
    Vector2 movement;

   void Start ()
    {
        playerPos = GetComponent<Transform>();
        playerMove = GetComponent<Rigidbody2D>();
        playerPicture = GetComponent<SpriteRenderer>();
        playerBox = GetComponent<BoxCollider2D>();
   }
   
   
   void FixedUpdate ()
    {
        horMove = Input.GetAxis("Horizontal");
        vertMove = Input.GetAxis("Vertical");
        if(horMove != 0 && vertMove !=0)//Corrects for hyptonose
        {
            horMove = horMove * .707f;
            vertMove = vertMove * .707f;
        }

        if (Input.GetKeyDown("left ctrl") || Input.GetKeyDown("right ctrl"))
        {
            if(crouch)
            {
                crouch = false;
                playerMove.position = new Vector2(playerMove.position.x, playerMove.position.y + heightDifference);
            }
            else
            {
                crouch = true;
                playerMove.position = new Vector2(playerMove.position.x, playerMove.position.y - heightDifference);
            }
        }

        if (Input.GetAxis("Run") > 0 && !crouch)
        {
            running = true;
        }
        else
        {
            running = false;
        }

        if (running)
        {
            movement = new Vector2(horMove * runSpeed, vertMove * walkSpeed);
           
        }
        else if(crouch)
        {
            movement = new Vector2(horMove * crouchSpeed, vertMove * crouchSpeed);
        }
        else
        {
            movement = new Vector2(horMove * walkSpeed, vertMove * walkSpeed);
        }

        playerMove.velocity = movement;
        playerPos.position = playerMove.position;
        SpriteManager();
   }

    void SpriteManager() //Will be replaced by an animation manager
    {
        if (running && (horMove != 0 || vertMove != 0))
        {
            playerPicture.sprite = runPicture;
        }
        else if (crouch)
        {
            playerPicture.sprite = crouchPicture;
        }
        else
        {
            playerPicture.sprite = walkPicture;
        }

        if(Input.GetAxis("Horizontal")< 0)
        {
            playerPicture.flipX = true;
        }
        else
        {
            playerPicture.flipX = false;
        }

        if(crouch)
        {
            playerBox.size = new Vector2(1.76f, 2.5f);
        }
        else
        {
            playerBox.size = new Vector2(1.76f, 3.34f);
        }
    }
}

public class PlayerController : MonoBehaviour {

    public float walkSpeed = 0.5f;
    public float runSpeed = 2f;
    public float crouchSpeed = .25f;
    public float heightDifference = .43f;

    Transform playerPos;
    Rigidbody2D playerMove;
    SpriteRenderer playerPicture;
    BoxCollider2D playerBox;

    public Sprite walkPicture;
    public Sprite runPicture;
    public Sprite crouchPicture;

    float horMove = 0;
    float vertMove = 0;
    bool running;
    bool crouch;
    Vector2 movement;

   void Start ()
    {
        playerPos = GetComponent<Transform>();
        playerMove = GetComponent<Rigidbody2D>();
        playerPicture = GetComponent<SpriteRenderer>();
        playerBox = GetComponent<BoxCollider2D>();
   }
   
   
   void FixedUpdate ()
    {
        horMove = Input.GetAxis("Horizontal");
        vertMove = Input.GetAxis("Vertical");
        if(horMove != 0 && vertMove !=0)//Corrects for hyptonose
        {
            horMove = horMove * .707f;
            vertMove = vertMove * .707f;
        }

        if (Input.GetKeyDown("left ctrl") || Input.GetKeyDown("right ctrl"))
        {
            if(crouch)
            {
                crouch = false;
                playerMove.position = new Vector2(playerMove.position.x, playerMove.position.y + heightDifference);
            }
            else
            {
                crouch = true;
                playerMove.position = new Vector2(playerMove.position.x, playerMove.position.y - heightDifference);
            }
        }

        if (Input.GetAxis("Run") > 0 && !crouch)
        {
            running = true;
        }
        else
        {
            running = false;
        }

        if (running)
        {
            movement = new Vector2(horMove * runSpeed, vertMove * walkSpeed);
           
        }
        else if(crouch)
        {
            movement = new Vector2(horMove * crouchSpeed, vertMove * crouchSpeed);
        }
        else
        {
            movement = new Vector2(horMove * walkSpeed, vertMove * walkSpeed);
        }

        playerMove.velocity = movement;
        playerPos.position = playerMove.position;
        SpriteManager();
   }

    void SpriteManager() //Will be replaced by an animation manager
    {
        if (running && (horMove != 0 || vertMove != 0))
        {
            playerPicture.sprite = runPicture;
        }
        else if (crouch)
        {
            playerPicture.sprite = crouchPicture;
        }
        else
        {
            playerPicture.sprite = walkPicture;
        }

        if(Input.GetAxis("Horizontal")< 0)
        {
            playerPicture.flipX = true;
        }
        else
        {
            playerPicture.flipX = false;
        }

        if(crouch)
        {
            playerBox.size = new Vector2(1.76f, 2.5f);
        }
        else
        {
            playerBox.size = new Vector2(1.76f, 3.34f);
        }
    }
}

]
public class PlayerController : MonoBehaviour {

    public float walkSpeed = 0.5f;
    public float runSpeed = 2f;
    public float crouchSpeed = .25f;
    public float heightDifference = .43f;

    Transform playerPos;
    Rigidbody2D playerMove;
    SpriteRenderer playerPicture;
    BoxCollider2D playerBox;

    public Sprite walkPicture;
    public Sprite runPicture;
    public Sprite crouchPicture;

    float horMove = 0;
    float vertMove = 0;
    bool running;
    bool crouch;
    Vector2 movement;

   void Start ()
    {
        playerPos = GetComponent<Transform>();
        playerMove = GetComponent<Rigidbody2D>();
        playerPicture = GetComponent<SpriteRenderer>();
        playerBox = GetComponent<BoxCollider2D>();
   }
 
 
   void FixedUpdate ()
    {
        horMove = Input.GetAxis("Horizontal");
        vertMove = Input.GetAxis("Vertical");
        if(horMove != 0 && vertMove !=0)//Corrects for hyptonose
        {
            horMove = horMove * .707f;
            vertMove = vertMove * .707f;
        }

        if (Input.GetKeyDown("left ctrl") || Input.GetKeyDown("right ctrl"))
        {
            if(crouch)
            {
                crouch = false;
                playerMove.position = new Vector2(playerMove.position.x, playerMove.position.y + heightDifference);
            }
            else
            {
                crouch = true;
                playerMove.position = new Vector2(playerMove.position.x, playerMove.position.y - heightDifference);
            }
        }

        if (Input.GetAxis("Run") > 0 && !crouch)
        {
            running = true;
        }
        else
        {
            running = false;
        }

        if (running)
        {
            movement = new Vector2(horMove * runSpeed, vertMove * walkSpeed);
        
        }
        else if(crouch)
        {
            movement = new Vector2(horMove * crouchSpeed, vertMove * crouchSpeed);
        }
        else
        {
            movement = new Vector2(horMove * walkSpeed, vertMove * walkSpeed);
        }

        playerMove.velocity = movement;
        playerPos.position = playerMove.position;
        SpriteManager();
   }

    void SpriteManager() //Will be replaced by an animation manager
    {
        if (running && (horMove != 0 || vertMove != 0))
        {
            playerPicture.sprite = runPicture;
        }
        else if (crouch)
        {
            playerPicture.sprite = crouchPicture;
        }
        else
        {
            playerPicture.sprite = walkPicture;
        }

        if(Input.GetAxis("Horizontal")< 0)
        {
            playerPicture.flipX = true;
        }
        else
        {
            playerPicture.flipX = false;
        }

        if(crouch)
        {
            playerBox.size = new Vector2(1.76f, 2.5f);
        }
        else
        {
            playerBox.size = new Vector2(1.76f, 3.34f);
        }
    }
}

Replace

 playerMove.velocity = movement;
        playerPos.position = playerMove.position;

with

playerMove.MovePosition(transform.position + movement);

Your rigidbody is moving your transform automatically according to physics laws, never move your transform while you use a rigidbody.

Also,
It’s not necessary to call GetComponent, just call “transform”.
Transform is the only mandatory component for a GameObject, therefore it is already referenced in a Monobehavior.

You also should multiply your movement Vector by Time.fixedDeltaTime.
Your player speed will not be dependant of the speed of the FixedUpdate() function this way.

I recommend that you don’t access the Input class in FixedUpdate. You should get all your input values in Update, because FixedUpdate is not called often enough for accurate polling. There is a potential for dropped inputs.

Thanks. I had to use

playerMove.MovePosition(new Vector2(transform.position.x,transform.position.y) + movement);

instead of your suggestion though. Position is a Vector3.

Edit: And my character still doesn’t move.

The MovePosition function literally teleport your rigidbody to the position you want but takes care of the colliders around him to modify the position before applying it to the transform.

You may print the offset movement you are applying to transform.position and see the value.
If movement is correct, is there any colliders in the scene blocking your character ?

Try to check “Kinematic” onto your rigidbody, it will ignore colliders, your character may move freely into your scene.
If that works, this is definitly a collider preventing your character to move.