Merge pull request #6910 from akien-mga/navigation2d-loc-to-pos

Navigation2D: Handle location -> position renames
This commit is contained in:
Rémi Verschelde
2023-03-06 11:37:38 +01:00
committed by GitHub
@@ -120,14 +120,14 @@ NavigationServer2D and a NavigationAgent2D for path movement.
set_movement_target(movement_target_position) set_movement_target(movement_target_position)
func set_movement_target(movement_target: Vector2): func set_movement_target(movement_target: Vector2):
navigation_agent.set_target_location(movement_target) navigation_agent.target_position = movement_target
func _physics_process(delta): func _physics_process(delta):
if navigation_agent.is_navigation_finished(): if navigation_agent.is_navigation_finished():
return return
var current_agent_position: Vector2 = global_transform.origin 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 var new_velocity: Vector2 = next_path_position - current_agent_position
new_velocity = new_velocity.normalized() new_velocity = new_velocity.normalized()
@@ -150,8 +150,8 @@ NavigationServer2D and a NavigationAgent2D for path movement.
public Vector2 MovementTarget public Vector2 MovementTarget
{ {
get { return _navigationAgent.TargetLocation; } get { return _navigationAgent.TargetPosition; }
set { _navigationAgent.TargetLocation = value; } set { _navigationAgent.TargetPosition = value; }
} }
public override void _Ready() public override void _Ready()
@@ -179,7 +179,7 @@ NavigationServer2D and a NavigationAgent2D for path movement.
} }
Vector2 currentAgentPosition = GlobalTransform.Origin; Vector2 currentAgentPosition = GlobalTransform.Origin;
Vector2 nextPathPosition = _navigationAgent.GetNextLocation(); Vector2 nextPathPosition = _navigationAgent.GetNextPathPosition();
Vector2 newVelocity = (nextPathPosition - currentAgentPosition).Normalized(); Vector2 newVelocity = (nextPathPosition - currentAgentPosition).Normalized();
newVelocity *= _movementSpeed; newVelocity *= _movementSpeed;