Debug.DrawRay is not working

I am new to Unity,

I am trying to make a character controller with collision (2D, top-down).
however, it will only collide if the player is going up, left, or right, not down.

I tried to use Debug.DrawRay, to try and find out how to fix this, but it just won’t work at all, I’m not sure if it is a problem with my client or what, but there is no ray being drawn.

private void playerMovement ()
{
    //for constructing the vector
    float movex = 0;
    float movey = 0;
      
    //getting input
    if (Input.GetKey(KeyCode.W)) {
        movey = 1f;
        walkDir = 1;
    
    }
    if (Input.GetKey(KeyCode.S)) {
        movey = -1f;
        walkDir = 2;
    }
    if (Input.GetKey(KeyCode.A)) {
        movex = -1f;
        walkDir = 3;
    }
    if (Input.GetKey(KeyCode.D)) {
        movex = 1f;
        walkDir = 4;
    }
    // for animation
    bool isIdle = movey == 0 && movex == 0;
    // Movement vectors
    moveDir = new Vector3(movex, movey);
    lastMoveDir = moveDir;
    
    // Calculate movement vectors for all directions
    Vector3 moveUp = new Vector3(0, 1);
    Vector3 moveDown = new Vector3(0, -1);
    Vector3 moveLeft = new Vector3(-1, 0);
    Vector3 moveRight = new Vector3(1, 0);
    
    // Calculated movement positions for all directions
    Vector3 targetMovePositionUp = transform.position + moveUp * speed * Time.deltaTime;
    Vector3 targetMovePositionDown = transform.position + moveDown * speed * Time.deltaTime;
    Vector3 targetMovePositionLeft = transform.position + moveLeft * speed * Time.deltaTime;
    Vector3 targetMovePositionRight = transform.position + moveRight * speed * Time.deltaTime;
    
    // Collision checks for all directions
    bool canMoveUp = !CheckCollision(targetMovePositionUp, moveUp);
    bool canMoveDown = !CheckCollision(targetMovePositionDown, moveDown);
    bool canMoveLeft = !CheckCollision(targetMovePositionLeft, moveLeft);
    bool canMoveRight = !CheckCollision(targetMovePositionRight, moveRight);
    
    // Determine the final move direction
    if (movex > 0 && canMoveRight) {
        transform.position = targetMovePositionRight;
    } else if (movex < 0 && canMoveLeft) {
        transform.position = targetMovePositionLeft;
    } else if (movey > 0 && canMoveUp) {
        transform.position = targetMovePositionUp;
    } else if (movey < 0 && canMoveDown) {
        transform.position = targetMovePositionDown;
    }
// Function to check collision
bool CheckCollision(Vector3 targetPosition, Vector3 direction)
{    
        float raycastOffset = 0.05f;
        Vector3 raycastStart = transform.position + direction.normalized * raycastOffset;
        Debug.DrawRay(raycastStart, direction.normalized * speed * Time.deltaTime, Color.red);
    
        RaycastHit2D hit = Physics2D.Raycast(raycastStart, direction.normalized, speed * Time.deltaTime);
    
        return hit.collider != null && hit.collider.CompareTag("solid");
    }
    
    //for animation
    isWalkingBool = moveDir != Vector3.zero;
}

Add fourth float argument for duration.

Debug.DrawRay ( start , dir , Color.red , 1f )
// DrawRay ( Vector3 start , Vector3 dir , Color color , float duration )