The check if (samePosition... would not work as intended because actors do not move in every frame when the framerate is higher than the physics framerate. In that case the actor would change its evasion direction almost every frame.
Notes - When the door hits them while it's about to finish closing they will try to walk through the door.
- Considerably more works is needed in making the NPC work out troublesome areas where they get stuck