How to use a raycast 2d with tilemaps?

So I want to check the tiles around my player, specifically I want to check if there are walls directly north, east, south, or west, so I can use that information later on. How can I do this? Here is what I’ve got, but it doesn’t seem to be working.

   void CollisionCheck() {
        RaycastHit2D northCheck = Physics2D.Raycast(transform.position, Vector2.up, 1);
        RaycastHit2D eastCheck = Physics2D.Raycast(transform.position, Vector2.right, 1);
        RaycastHit2D southCheck = Physics2D.Raycast(transform.position, Vector2.down, 1);
        RaycastHit2D westCheck = Physics2D.Raycast(transform.position, Vector2.left, 1);

        if (northCheck.collider.tag.Contains ("Wall")) {
            canMoveNorth = false;
            Debug.Log("Wall north");
        }
        else {
            canMoveNorth = true;
        }
    }

Oh boy is this a fun one,

So what I would do is, I’m guessing the player is also using some tile-based movement system, check directly which tiles are next to the player without using a ray every time.
Maybe a little something like this,

Use this if you don’t know where your character is in reference to the tilemap,

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

public class helpUNITY : MonoBehaviour
{
    Tilemap tilemp;
    
    void Start()
    {
        //ASSIGN YOUR TILEMAP HERE
        tilemp = GameObject.Find("YOUR TILEMAP NAME").GetComponent<Tilemap>();
    }

   
    void Update()
    {
        Vector3Int playerPOS = tilemp.WorldToCell( //PLAYERPOSITION CONVERTED TO VECTOR3INT);
    }
}

Use this next part to check if there are walls around the player using built in Vector3Int systems,

This is the whole script, if any of these return not null, it’s because there is a wall there;

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Tilemaps;
    
    public class helpUNITY : MonoBehaviour
    {
        Tilemap tilemp;
        
        void Start()
        {
            //ASSIGN YOUR TILEMAP HERE
            tilemp = GameObject.Find("YOUR TILEMAP NAME").GetComponent<Tilemap>();
        }
    
       
        void Update()
        {
            Vector3Int playerPOS = //PLAYERPOSITION CONVERTED TO VECTOR3INT));
DIRCheck(playerPOS);
        }
    
        void DIRCheck(Vector3Int playerposition)
        {
            Vector3Int echeck = new Vector3Int(playerposition.x + 1, playerposition.y, playerposition.z);
            Vector3Int wcheck = new Vector3Int(playerposition.x - 1, playerposition.y, playerposition.z);
            Vector3Int scheck = new Vector3Int(playerposition.x, playerposition.y - 1, playerposition.z);
            Vector3Int ncheck = new Vector3Int(playerposition.x, playerposition.y +1, playerposition.z);
            //THIS IS KINDA A LAZY WAY TO DO IT BUT WORKS
            tilemp.GetTile(echeck); //EAST CHECK
            tilemp.GetTile(wcheck); //WEST CHECK
            tilemp.GetTile(ncheck); //NORTH CHECK
            tilemp.GetTile(scheck); //SOUTH CHECK
            Debug.Log( "North" + ncheck + "East" + echeck + "West" + wcheck + "South" + scheck);
        }
    }