Hey! is_target_reachable() in $NavigationAgent3D causes powerful lags. FPS down to 2-4 when monster can't reach me. Is this a problem with the engine, or am I using this function incorrectly?
My code:
extends CharacterBody3D
var player = null
var starting = false
func _ready():
add_to_group("monsters")
func _physics_process(delta: float) -> void:
if !starting: return
$NavigationAgent3D.set_target_position(player.global_transform.origin)
reached()
func _on_navigation_agent_3d_velocity_computed(safe_velocity):
velocity = velocity.move_toward(safe_velocity, 0.25)
set_up_direction(Vector3.UP)
move_and_slide()
func set_player(p):
player = p
func _on_timer_timeout():
starting = true
func reached():
var origin = global_transform.origin
if $NavigationAgent3D.is_target_reachable():
prints ("YES", randf())
var target = $NavigationAgent3D.get_next_path_position()
var velocitym = (target - origin).normalized() * 5
$NavigationAgent3D.set_velocity(velocitym)