I'm trying to get the pathfinding for the enemy working while avoiding obstacles:
extends KinematicBody
var path = []
var path_node = 0
var speed = 13
onready var nav = get_parent()
onready var player = $"../../Player"
func _physics_process(delta):
if path_node < path.size():
var direction = path[path_node] - global_transform.origin
if direction.length() < 1:
path_node += 1
else:
move_and_slide(direction.normalized() * speed, Vector3.UP)
func move_to(target_pos):
path = nav.get_simple_path(global_transform.origin, target_pos)
func _on_Timer_timeout():
move_to(player.global_transform.origin)
Here are the scene and the NavigationMeshInstance's settings:

Problem is, the enemy keeps going through the wall while pathfinding. Any help is appreciated. Thank you!