I was following a tutorial which I found really helpful by the way and it made setting up some decent navmesh AI in 3.5 pretty straight forward. However I've run into problems with tweaking the accuracy in certain aspects. Something else that I've run into is that look_at() breaks the pathfinding entirely and I'm not sure why.
Here's my agent setup and my code so far, not only is look_at() causing me an issue, but there's this strange drifting affect that happens when the droid stops as you can see in the video and it sinks into the ground. Everything else is working fine, I think that on the if statement when the droid stops it's cancelling out the code that's keeping it on the ground but I'm going to experiment with that.

func _ready():
ChangeDroidLightColourCyan()
navigationAgent.set_target_location(patrolPath1.global_transform.origin)
func _physics_process(_delta):
# look_at(patrolPath1.global_transform.origin, Vector3.UP)
if navigationAgent.is_target_reached():
isWalking = false
elif not navigationAgent.is_target_reached():
var currentPosition = global_transform.origin
var target = navigationAgent.get_next_location()
var velocity = Vector3()
var normal = groundCheck.get_collision_normal()
absNormal = Vector3(abs(normal.x), abs(normal.y), abs(normal.z))
inverseFloorNormal = Vector3(1,1,1) - absNormal
velocity = ((target - currentPosition) * inverseFloorNormal).normalized() * 10
navigationAgent.set_velocity(velocity)
isWalking = true
if isWalking == true:
animationPlayer.play("Droid_Walk_Pistol")
elif isWalking == false:
animationPlayer.play("Droid_Idle_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
func _on_NavigationAgent_velocity_computed(safe_velocity):
set_linear_velocity(safe_velocity)
Oh! I just had a classic moment after posting, for the sliding I'm pretty sure it's to do with me using a rigidbody for the movement and set_linear_velocity, I need to work out how to stop the sliding behaviour.