Skip to content

Commit

Permalink
Replace set_velocity with velocity property
Browse files Browse the repository at this point in the history
  • Loading branch information
skyace65 committed Feb 4, 2024
1 parent c42e54b commit f3364fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
8 changes: 4 additions & 4 deletions tutorials/navigation/navigation_using_navigationagents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ The ``velocity_computed`` signal of the NavigationAgent node must be connected t

.. image:: img/agent_safevelocity_signal.png

Use ``set_velocity()`` on the NavigationAgent node in ``_physics_process()`` to update the agent with the current velocity of the agent's parent node.
Set the ``velocity`` of the NavigationAgent node in ``_physics_process()`` to update the agent with the current velocity of the agent's parent node.

While avoidance is enabled on the agent the ``safe_velocity`` vector will be received with the velocity_computed signal every physics frame.
This velocity vector should be used to move the NavigationAgent's parent node in order to avoidance collision with other avoidance using agents or avoidance obstacles.
Expand Down Expand Up @@ -204,7 +204,7 @@ This script adds basic navigation movement to a :ref:`Node3D <class_Node3D>` wit
var next_path_position: Vector3 = navigation_agent.get_next_path_position()
var new_velocity: Vector3 = global_position.direction_to(next_path_position) * movement_delta
if navigation_agent.avoidance_enabled:
navigation_agent.set_velocity(new_velocity)
navigation_agent.velocity = new_velocity
else:
_on_velocity_computed(new_velocity)

Expand Down Expand Up @@ -237,7 +237,7 @@ This script adds basic navigation movement to a :ref:`CharacterBody3D <class_Cha
var next_path_position: Vector3 = navigation_agent.get_next_path_position()
var new_velocity: Vector3 = global_position.direction_to(next_path_position) * movement_speed
if navigation_agent.avoidance_enabled:
navigation_agent.set_velocity(new_velocity)
navigation_agent.velocity = new_velocity
else:
_on_velocity_computed(new_velocity)

Expand Down Expand Up @@ -271,7 +271,7 @@ This script adds basic navigation movement to a :ref:`RigidBody3D <class_RigidBo
var next_path_position: Vector3 = navigation_agent.get_next_path_position()
var new_velocity: Vector3 = global_position.direction_to(next_path_position) * movement_speed
if navigation_agent.avoidance_enabled:
navigation_agent.set_velocity(new_velocity)
navigation_agent.velocity = new_velocity
else:
_on_velocity_computed(new_velocity)

Expand Down
28 changes: 3 additions & 25 deletions tutorials/navigation/navigation_using_navigationservers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,8 @@ Synchronization for the NavigationServer happens in the middle of the physics fr
The important takeaway is that most NavigationServer changes take effect after the next physics frame and not immediately.
This includes all changes made by navigation related nodes in the scene tree or through scripts.

The following functions will be executed in the synchronization phase only:

- ``map_set_active()``
- ``map_set_up()``
- ``map_set_cell_size()``
- ``map_set_edge_connection_margin()``
- ``region_set_map()``
- ``region_set_transform()``
- ``region_set_enter_cost()``
- ``region_set_travel_cost()``
- ``region_set_navigation_layers()``
- ``region_set_navigation_mesh()``
- ``agent_set_map()``
- ``agent_set_neighbor_dist()``
- ``agent_set_max_neighbors()``
- ``agent_set_time_horizon()``
- ``agent_set_radius()``
- ``agent_set_max_speed()``
- ``agent_set_velocity()``
- ``agent_set_target_velocity()``
- ``agent_set_position()``
- ``agent_set_ignore_y()``
- ``agent_set_callback()``
- ``free()``
.. note::
All setters and delete functions require synchronization.

2D and 3D NavigationServer differences
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -175,7 +153,7 @@ The simplified order of execution for NavigationAgents that use avoidance:

- physics frame starts.
- ``_physics_process(delta)``.
- ``set_velocity()`` on NavigationAgent Node.
- ``velocity`` property is set on NavigationAgent Node.
- Agent sends velocity and position to NavigationServer.
- NavigationServer waits for synchronization.
- NavigationServer synchronizes and computes avoidance velocities for all registered avoidance agents.
Expand Down

0 comments on commit f3364fb

Please sign in to comment.