I figured it out!
It turns out it wasn't my code that was the problem, it was the navmesh itself!
In the first screenshot, I showed the navmesh in the editor, but the centre of that mesh was at the corner:

So what I did was go to Blender, selected the navMesh in the file and applied the transform (Space > Search "Apply Object Transform"), which makes the centre of the area the centre of the mesh.

After rearranging the code a little bit, it worked!
My code as of right now, I just need to fix some minor issues with the movement of the AI themselves, but this works, and you guys have my full permission to use this for your own games. Assuming anyone here actually develops 3D games and needs an easy pathfinding code:
#AI.gd
var velocity = Vector3()
export(int) var topSpeed = 5
export(int) var acceleration = 1
onready var _topSpeed = topSpeed
onready var _acceleration = acceleration
onready var decceleration = acceleration / 2
onready var currentTarget = get_node(target)
var previousTarget
var currentDirection = Vector3()
export(float) var turnSpeed = 1
var enemySpotted = false
var navMesh
var followPath = Vector3Array()
var currentPathNode = 0
const PATH_COOLER = 0.3
onready var pathTimer = PATH_COOLER
func FollowTargetPath(target, delta, isEnemy):
if followPath.size():
if currentPathNode < followPath.size() and pathTimer > 0:
dist = get_translation().distance_to(followPath[currentPathNode])
if dist < minDistance:
currentPathNode += 1
print(currentPathNode)
else:
translate(FollowTarget(followPath[currentPathNode], delta, isEnemy))
pathTimer -= delta
else:
#translate(FollowTarget(target, delta, isEnemy))
followPath = Vector3Array()
currentPathNode = 0
pathTimer = PATH_COOLER
else:
followPath = navMesh.get_simple_path(get_translation(), target, true)
#This is where the following logic happens, it basically slowly turns to the target, and walks forward until it's too close to it, where it returns (0,0,0) to let the function
# calling it know that it's too close to the target, for it to change target if it's not going after the enemy.
func FollowTarget(target, delta, isEnemy):
dist = get_translation().distance_to(getTargetPosition())
if dist > minDistance:
turn_to(target, turnSpeed, delta)
if abs(velocity.z) < _topSpeed:
velocity.z -= _acceleration * delta
if isEnemy:
nextAnim = wapen + "Running"
else:
nextAnim = wapen + "Walking"
else:
if !enemySpotted:
changeAnim("Staundin 4", wapen + "Staundin")
return Vector3(0, 0, 0)
return velocity
----------
#LevelMain.gd (Where the Navmesh is):
export(NodePath) var navigationMesh
onready var navMesh = get_node(navigationMesh) setget , getNavMesh
func getNavMesh():
return navMesh
func getPath(start, end):
var begin = navMesh.get_closest_point(start)
var p = navMesh.get_simple_path(begin, end, false)
return Array(p)
If you can't be bothered, however, you can try Gokudomatic2's eco-FPS-walker, linked in the other answer to this question by (I assume) the author themself.