title: How to move a sprite with the WASD keys in a 2D game?
body: <p>I want my sprite to move either up or down or left or right, I don't want any other movement such as north-west or south-east; it needs to be either up, down, right or left. There are similar posts like this on the internet but I was wondering why mine wasn't working. It doesn't initiate any movement in the game. </p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class PlayerMovement : MonoBehaviour
  {
  
      public Sprite Up;
      public Sprite Down;
      public Sprite Right;
      public Sprite Left;
      public float speed;
  
  
      // Update is called once per frame
      void Update()
      {
  
          Vector3 move = transform.position;
  
          if (Input.GetKey(KeyCode.W))
          {
              GetComponent&lt;SpriteRenderer&gt;().sprite = Up;
              move.z += speed * Time.deltaTime;
          }
          if (Input.GetKey(KeyCode.A))
          {
              GetComponent&lt;SpriteRenderer&gt;().sprite = Left;
              move.x -= speed * Time.deltaTime; 
          }
          if (Input.GetKey(KeyCode.D))
          {
              GetComponent&lt;SpriteRenderer&gt;().sprite = Right;
              move.x += speed * Time.deltaTime;
          }
          if (Input.GetKey(KeyCode.S))
          {
              GetComponent&lt;SpriteRenderer&gt;().sprite = Down;
              move.y -= speed * Time.deltaTime;
          }
  
        transform.position = move; 
      }
  }
  </code></pre>
  
  <p>For what I am looking for, I don't think I need rigidBody as most people include in their movement. I'm still a beginner so an in-depth explanation of why my code isn't working and what I could do to fix it would be helpful. Thanks. </p>