I just got to let you all know that I found the solution to my problems and it's so simple, I feel a bit stupid when I discovered it. Since the enemy is already turning in the direction it's moving through pathfinding, I just point another Raycast3d on it called DoorCast and that is what it uses to open doors. Since the DoorCast doesn't move/rotate, it's always pointing where the enemy is facing. Here's the function for it in the enemy state base class:
func door_opener(door_range = 2):
if parent.door_cast.is_colliding() and parent.door_cast.get_collider().owner is Door:
var d = parent.door_cast.get_collider().owner
var dist_2_door = parent.global_transform.origin.distance_to(d.global_transform.origin)
if dist_2_door <= door_range:
d.open_door_for_enemy(parent)
Now here's how I use it in my chase state:
# --- Normal chase logic ---
enemy.anim_player.play("Uzi_Run", 0, running_anim_speed)
chase_timer += delta
if enemy.opened_a_door == false: #Pathfinding behaves normally if the enemy isn't in a door area and has opened the door!
move_here(enemy.player.global_transform.origin, delta)
enemy.ray.look_at(enemy.player.head.global_transform.origin)
door_opener(3)
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
After failing to do a more complicated solution with ChatGPT, I asked the AI where it got it's ideas from and I realise that it was just making stuff up; my more complicated ideas for a solutions where unprecedented. Realising this, I understood that the AI couldn't help and that older games must have had a simpler solution to the problem I was stressing myself about. That's when it hit me; Raycast! LOL!π€£