How do professional game developers deal with enemies entering doors?
I'm a beginner indie game developer working on a first person shooter in the Godot game engine and I've ran into a problem that I just want to talk to professional game developers about.
I just want to know the best way/solution to the problem of having enemies that have to chase the player down through door ways with doors in them that may or not be closed. I know that they're old games that have solutions to this problem like Perfect Dark for the N64. I also know that they're games with more advance enemy AI that seem to have solved this problem.
They're multiple aspect to the problem/solution. I'll list two of them here:
Multiple enemies try to enter a single doorway at once and they get stuck behind each other or phase through each other- The only solution to the problem I have is using the avoidance feature that Godot has for pathfinding but, that causes the pathfinding to look weird; it's hard to explain. A more proper solution would involve having the enemies take turns to enter the door or have them go through the door in a line but, I don't know how to do that.
Enemies that get stuck behind open doors when trying to chase down the player - I've partially came up for a solution to this problem. Since enemies in my game turn to face the direction they're moving in while pathfinding, I give the enemies a raycast that always stay in front of them and it helps them to detect doors while chasing the player. When an enemy detects a door, the script for the door and the enemy collaborate with each other to make sure that the enemy can move through the door way. Doors would open for enemies chasing the player, while the enemy would then chase after nodes that would lead it through that doorway without getting stuck and then resume chasing down the enemy directly.
I'll even show some of the the code for it on the enemy side:
````
if enemy.opened_a_door == false: #Pathfinding behaves normally if the enemy isn't in a door area and has opened the door!
var to_player = enemy.global_position.direction_to(enemy.player.global_position)
var desired_pos = enemy.player.global_position - to_player * chase_stop_distance
move_here(desired_pos, delta)
enemy.ray.look_at(enemy.player.head.global_transform.origin)
door_opener(5)
elif enemy.opened_a_door == true:#Enemy has to enter door that it opened without getting stuck behind it now.
var Dist_2_target = enemy.global_transform.origin.distance_to(enemy.away_from_door)
move_here(enemy.away_from_door,delta)
if Dist_2_target < 1:#Once enemy is no safely away from the door, opened_a_door is turned false; ensuring regular pathfinding.
enemy.opened_a_door = false
Anyway, the problem that I have is that enemies do sometimes get stuck behind doors and I don't know how to fix it or why. Do you have any reading material on this specific problem that would be helpful?




