Boundaries in a RPG

What is the most effective way to make boundaries in an RPG(non-tiles)? The main character can’t walk into an NPC, wall or enemy but can walk anywhere else? I’m far into making an RPG but I’m stuck at this point, what should I do?