do anyone know how i can make a door slide using code or animation.
There are various approach, as mentioned you can OnTriggerEnter() that would launch an animation and after a defined time the closing animation is launched.
The main “problem” with it is that if you walk in front of the door but let’s say you are not heading to the door,just passing, the animation is launched. You would then have to make the box collider quite small meaning your player might hit into the door while opening.
A better approach for gameplay but more expensive on resources is to use raycast.
This way the door only opens when you are facing it at a distance, meaning that you are more or less heading for it. Also, the distance could be chosen so that by the time the player is reaching the door, he does not hit into it.
Finally, you could also use a gui appearing when you reach the door asking if you want to open it.
It all depends on what you want to create.
Now you can choose.