Skip to content

Commit

Permalink
Merge pull request #6910 from akien-mga/navigation2d-loc-to-pos
Browse files Browse the repository at this point in the history
Navigation2D: Handle location -> position renames
  • Loading branch information
akien-mga authored Mar 6, 2023
2 parents fe156d0 + 35ce6f0 commit d4b83e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tutorials/navigation/navigation_introduction_2d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ NavigationServer2D and a NavigationAgent2D for path movement.
set_movement_target(movement_target_position)

func set_movement_target(movement_target: Vector2):
navigation_agent.set_target_location(movement_target)
navigation_agent.target_position = movement_target

func _physics_process(delta):
if navigation_agent.is_navigation_finished():
return

var current_agent_position: Vector2 = global_transform.origin
var next_path_position: Vector2 = navigation_agent.get_next_location()
var next_path_position: Vector2 = navigation_agent.get_next_path_position()

var new_velocity: Vector2 = next_path_position - current_agent_position
new_velocity = new_velocity.normalized()
Expand All @@ -150,8 +150,8 @@ NavigationServer2D and a NavigationAgent2D for path movement.

public Vector2 MovementTarget
{
get { return _navigationAgent.TargetLocation; }
set { _navigationAgent.TargetLocation = value; }
get { return _navigationAgent.TargetPosition; }
set { _navigationAgent.TargetPosition = value; }
}

public override void _Ready()
Expand Down Expand Up @@ -179,7 +179,7 @@ NavigationServer2D and a NavigationAgent2D for path movement.
}

Vector2 currentAgentPosition = GlobalTransform.Origin;
Vector2 nextPathPosition = _navigationAgent.GetNextLocation();
Vector2 nextPathPosition = _navigationAgent.GetNextPathPosition();

Vector2 newVelocity = (nextPathPosition - currentAgentPosition).Normalized();
newVelocity *= _movementSpeed;
Expand Down

0 comments on commit d4b83e2

Please sign in to comment.