Player Movement - Not moving at all

Hello everyone

I realise how many times something similar has been asked although I didn’t find anything that related to the code and problem I have

I have a script to move my character(player) The script should be fine and it does not have any errors, although when I press play I try to use the arrows and it does not work and I don’t know why.
I am a total beginner in Unity, although I already read some documentation.

Here is the code. I appreciate any help you can give me, thanks

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

Direction currentDir;
Vector2 input;
bool isMoving = false;
Vector3 startPos;
Vector3 endPos;
float t;

public float walkSpeed = 3f;

// Update is called once per frame
void Update()
{

    if (isMoving)
    {
        input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        if (Mathf.Abs(input.x) > input.y)
            input.y = 0;
        else
            input.x = 0;

        if (input != Vector2.zero)
        {
            StartCoroutine(Move(transform));
        }
    }

}

public IEnumerator Move(Transform entity)
{

    isMoving = true;
    startPos = entity.position;
    t = 0;

    endPos = new Vector3(startPos.x + System.Math.Sign(input.x), startPos.y +
        System.Math.Sign(input.y), startPos.z);

    while (t < 1f)
    {
        t += Time.deltaTime * walkSpeed;
        entity.position = Vector3.Lerp(startPos, endPos, t);
        yield return null;
    }

    isMoving = false;
    yield return 0;

}


enum Direction
{
    North,
    East,
    South,
    West
}
    }

Well, reading your code tells me that isMoving never turns true.

Comment out the if (isMoving) {} test in update, it should fix it.

Assuming I guessed correctly what you are trying to do, you probably need something like this. If it is not yet moving and player gives some kind of input we start coroutine Move().

void Update()
{
    Vector2 input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
    if (input.magnitude > 0 && !isMoving)
    {
        if (Mathf.Abs(input.x) > input.y)
            input.y = 0;
        else
            input.x = 0;

        if (input != Vector2.zero)
        {
            StartCoroutine(Move(transform));
        }
    }
}

In your coroutine there is also small issue as your while-loop has yield return null which will not wait at all meaning it will be ran as fast as the device is capable of running it, but you are using Time.deltaTime that uses frame rate timings. Not totally sure what you want, but I guess you should change your yield return null to yield return new WaitForEndOfFrame().