I am making a project in Godot 4.3 I am using a gridmap for the map and I have the NavMesh set up correctly, when I am in game I can get it to show me its pathing and it will update correctly accordingly. But for some reason the move_and_slide() function isn't working at all and my NPC is not moving. Any help would be greatly appreciated.
Here is the code in my NavigationAgent3D, I can provide more if needed.
extends NavigationAgent3D
@export var main : Node
@export var manager_ : Node
@export var hurtBoxCollisionShape : CollisionShape3D
var SPEED = 3.0
var reached_target: bool = true
func _ready():
return
target_desired_distance = hurtBoxCollisionShape.shape.radius
func _on_target_reached():
reached_target = true
manager_.entity_state = manager_.ENTITY_STATE.ATTACK
manager_.can_move = false
func _physics_process(delta):
if main and main.player:
target_position = main.player.global_transform.origin
#print ("Player Position: ", main.player.global_transform.origin)
if distance_to_target() > target_desired_distance:
reached_target = false
#print("Distance to target: ", distance_to_target())
manager_.entity_state = manager_.ENTITY_STATE.CHASE
if not reached_target:
var current_location = main.global_transform.origin
var next_location = get_next_path_position()
var new_velocity = (next_location - current_location).normalized() * SPEED
set_velocity(new_velocity)
if not main.is_on_floor():
main.velocity.y -= main.gravity * delta
func _on_velocity_computed(safe_velocity):
main.velocity = main.velocity.move_toward(safe_velocity, .25)
main.move_and_slide(main.velocity)`