This setup should be straightforward but I'm running out of ideas on what could be going wrong does anyone have any ideas? I'm fairly certain my code is executing correctly unless I've made a major accident somewhere and haven't realised as I've just been following tutorials on getting the agents to move along a path and most of them use the same code so I suspect it might be my setup that's the issue.



By the way I was doing some double checking on the hierarchy but I get the same results whether or not I place the agent I want to move as a child of the navmeshinstance or not. I'll post some pseudo code, one thing I've noticed is that even if I place the agent really high above the floor it does actually move downwards and I think it might be matching the height of the patrol path node I've setup so maybe I've done something daft with the directions? Now I'm not so sure the more I think about it.
func _physics_process(delta):
if isWalking == true:
animationPlayer.play("Droid_Walk_Pistol")
if hasDetectedPlayer == true:
ChangeDroidLightColourYellow()
if hasDetectedPlayer == false:
ChangeDroidLightColourCyan()
for coneOfVisionRaycast in coneOfVisionRaycasts:
if coneOfVisionRaycast.is_colliding():
raycastCollision = coneOfVisionRaycast.get_collider()
if raycastCollision.is_in_group("Player") and hasDetectedPlayer == false:
hasDetectedPlayer = true
if pathNode < path.size():
var direction = (path[pathNode] - global_transform.origin)
if direction.length() < 1:
pathNode += 1
else:
move_and_slide(direction.normalized() * speed, Vector3.UP)
func MoveTo (targetPosition):
look_at(patrolPath1.global_transform.origin, Vector3.UP)
isIdle = false
isWalking = true
path = navMeshData.get_simple_path(global_transform.origin, targetPosition)
pathNode = 0
func _on_Timer_timeout():
MoveTo(patrolPath1.global_transform.origin)
In fact, now I'm playing with the agent more and putting it at odd angles above the patrol path it is matching up directly to the Y position of the node, how the hell have I done that?