Check this video to see what is going on:
In general, I have some trouble making my nav agent smart. Currently, in order to open a door, my logic says "If the agent distance between him and the door < 4 && he's looking at the door, then open the door."
If the agent tries to open the door from the inside, then this logic works perfectly. He just pushes the door. But in this case, where the agent tries to open the door from the opposite direction (he must pull the door), sometimes he gets stuck.
Basically, if someone can tell me how to to make the agent open the door from a distance where the door will open before the player can reach it (so it won't hit him or block him) AND at the same time the agent is smart enough to not open nearby doors that he is not supposed to open, then this is exactly what I'm trying to achieve.
The reason that I also check “If the agent is looking at the door” is to prevent him from opening doors that he is not supposed to. For example, he might pass next to a door but 90% of when he passes next to a door he's actually not looking at it, so the door is not opening. This is why I implemented it like that. But of course, there is still a possibility that he might be close to the door and looking at it while he's not intended to open the door.
Thank you!