Want to get the last position where an enemy saw my player / 2D

Game is top down perspective, 2D. I am trying to create a way for an enemy to follow the player around obstacles and was thinking how it would probably be convenient to just make an enemy go to the last position where they saw player and try to avoid complicated context steering. Anyways I came to the conclusion that Im not even able to find this last visible position and am a failure.

I have ray casting set and when enemy is able to see the player its following and when there is a wall between it stops. h e l p p l e a s e

after you hit the player with the ray cast set a vecter3 to be the hit.transform and maybe call it something like lastPos then tell the enemy that if it can’t find the player then go to lastPos and look again. I might be able to help more with an example code.

Just Store The Position When Enemy See By Using

Transform Object  = Player.transform.position;