2D RPG Opening a Door with Sprites

I have a 2D sprite character and I want if the player presses w or up for him to be able to check if there is a door behind him, and if it’s openable then it should try to open it. Has anyone run into this problem or know how this can be done?

Since the sprites all exist on the same plane I assume that a raycast won’t work. And if I were to use a collider to act as a trigger how would I go about doing it that way? Would I have to add it to a cached transform variable then if w is pressed and door!=null then open door?

Depends. For example you can use tilemap if it fits your game. Or you can set trigger colider on door and check player’s position on collision etc…