@@ -202,8 +202,7 @@ This script adds basic navigation movement to a Node3D with a NavigationAgent3D
202202
203203 movement_delta = movement_speed * delta
204204 var next_path_position: Vector3 = navigation_agent.get_next_path_position()
205- var current_agent_position: Vector3 = global_position
206- var new_velocity: Vector3 = (next_path_position - current_agent_position).normalized() * movement_delta
205+ var new_velocity: Vector3 = global_position.direction_to(next_path_position) * movement_delta
207206 if navigation_agent.avoidance_enabled:
208207 navigation_agent.set_velocity(new_velocity)
209208 else:
@@ -236,8 +235,7 @@ This script adds basic navigation movement to a CharacterBody3D with a Navigatio
236235 return
237236
238237 var next_path_position: Vector3 = navigation_agent.get_next_path_position()
239- var current_agent_position: Vector3 = global_position
240- var new_velocity: Vector3 = (next_path_position - current_agent_position).normalized() * movement_speed
238+ var new_velocity: Vector3 = global_position.direction_to(next_path_position) * movement_speed
241239 if navigation_agent.avoidance_enabled:
242240 navigation_agent.set_velocity(new_velocity)
243241 else:
@@ -271,8 +269,7 @@ This script adds basic navigation movement to a RigidBody3D with a NavigationAge
271269 return
272270
273271 var next_path_position: Vector3 = navigation_agent.get_next_path_position()
274- var current_agent_position: Vector3 = global_position
275- var new_velocity: Vector3 = (next_path_position - current_agent_position).normalized() * movement_speed
272+ var new_velocity: Vector3 = global_position.direction_to(next_path_position) * movement_speed
276273 if navigation_agent.avoidance_enabled:
277274 navigation_agent.set_velocity(new_velocity)
278275 else:
0 commit comments