:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Navigation2DServer.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Navigation2DServer: Navigation2DServer ================== **Inherits:** :ref:`Object` Server interface for low-level 2D navigation access Description ----------- Navigation2DServer is the server responsible for all 2D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. Methods ------- +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`agent_create` **(** **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`agent_is_map_changed` **(** :ref:`RID` agent **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_callback` **(** :ref:`RID` agent, :ref:`Object` receiver, :ref:`StringName` method, :ref:`Variant` userdata=null **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_map` **(** :ref:`RID` agent, :ref:`RID` map **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_max_neighbors` **(** :ref:`RID` agent, :ref:`int` count **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_max_speed` **(** :ref:`RID` agent, :ref:`float` max_speed **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_neighbor_dist` **(** :ref:`RID` agent, :ref:`float` dist **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_position` **(** :ref:`RID` agent, :ref:`Vector2` position **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_radius` **(** :ref:`RID` agent, :ref:`float` radius **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_target_velocity` **(** :ref:`RID` agent, :ref:`Vector2` target_velocity **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_time_horizon` **(** :ref:`RID` agent, :ref:`float` time **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`agent_set_velocity` **(** :ref:`RID` agent, :ref:`Vector2` velocity **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`free` **(** :ref:`RID` object **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`map_create` **(** **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`map_get_cell_size` **(** :ref:`RID` map **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`map_get_closest_point` **(** :ref:`RID` map, :ref:`Vector2` to_point **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`map_get_closest_point_owner` **(** :ref:`RID` map, :ref:`Vector2` to_point **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`map_get_edge_connection_margin` **(** :ref:`RID` map **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector2Array` | :ref:`map_get_path` **(** :ref:`RID` map, :ref:`Vector2` origin, :ref:`Vector2` destination, :ref:`bool` optimize **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`map_is_active` **(** :ref:`RID` nap **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`map_set_active` **(** :ref:`RID` map, :ref:`bool` active **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`map_set_cell_size` **(** :ref:`RID` map, :ref:`float` cell_size **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`map_set_edge_connection_margin` **(** :ref:`RID` map, :ref:`float` margin **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`region_create` **(** **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`region_set_map` **(** :ref:`RID` region, :ref:`RID` map **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`region_set_navpoly` **(** :ref:`RID` region, :ref:`NavigationPolygon` nav_poly **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`region_set_transform` **(** :ref:`RID` region, :ref:`Transform2D` transform **)** const | +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Method Descriptions ------------------- .. _class_Navigation2DServer_method_agent_create: - :ref:`RID` **agent_create** **(** **)** const Creates the agent. ---- .. _class_Navigation2DServer_method_agent_is_map_changed: - :ref:`bool` **agent_is_map_changed** **(** :ref:`RID` agent **)** const Returns true if the map got changed the previous frame. ---- .. _class_Navigation2DServer_method_agent_set_callback: - void **agent_set_callback** **(** :ref:`RID` agent, :ref:`Object` receiver, :ref:`StringName` method, :ref:`Variant` userdata=null **)** const Callback called at the end of the RVO process. ---- .. _class_Navigation2DServer_method_agent_set_map: - void **agent_set_map** **(** :ref:`RID` agent, :ref:`RID` map **)** const Puts the agent in the map. ---- .. _class_Navigation2DServer_method_agent_set_max_neighbors: - void **agent_set_max_neighbors** **(** :ref:`RID` agent, :ref:`int` count **)** const Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. ---- .. _class_Navigation2DServer_method_agent_set_max_speed: - void **agent_set_max_speed** **(** :ref:`RID` agent, :ref:`float` max_speed **)** const Sets the maximum speed of the agent. Must be positive. ---- .. _class_Navigation2DServer_method_agent_set_neighbor_dist: - void **agent_set_neighbor_dist** **(** :ref:`RID` agent, :ref:`float` dist **)** const Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe. ---- .. _class_Navigation2DServer_method_agent_set_position: - void **agent_set_position** **(** :ref:`RID` agent, :ref:`Vector2` position **)** const Sets the position of the agent in world space. ---- .. _class_Navigation2DServer_method_agent_set_radius: - void **agent_set_radius** **(** :ref:`RID` agent, :ref:`float` radius **)** const Sets the radius of the agent. ---- .. _class_Navigation2DServer_method_agent_set_target_velocity: - void **agent_set_target_velocity** **(** :ref:`RID` agent, :ref:`Vector2` target_velocity **)** const Sets the new target velocity. ---- .. _class_Navigation2DServer_method_agent_set_time_horizon: - void **agent_set_time_horizon** **(** :ref:`RID` agent, :ref:`float` time **)** const The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive. ---- .. _class_Navigation2DServer_method_agent_set_velocity: - void **agent_set_velocity** **(** :ref:`RID` agent, :ref:`Vector2` velocity **)** const Sets the current velocity of the agent. ---- .. _class_Navigation2DServer_method_free: - void **free** **(** :ref:`RID` object **)** const Destroy the RID ---- .. _class_Navigation2DServer_method_map_create: - :ref:`RID` **map_create** **(** **)** const Create a new map. ---- .. _class_Navigation2DServer_method_map_get_cell_size: - :ref:`float` **map_get_cell_size** **(** :ref:`RID` map **)** const Returns the map cell size. ---- .. _class_Navigation2DServer_method_map_get_closest_point: - :ref:`Vector2` **map_get_closest_point** **(** :ref:`RID` map, :ref:`Vector2` to_point **)** const Returns the point closest to the provided ``to_point`` on the navigation mesh surface. ---- .. _class_Navigation2DServer_method_map_get_closest_point_owner: - :ref:`RID` **map_get_closest_point_owner** **(** :ref:`RID` map, :ref:`Vector2` to_point **)** const Returns the owner region RID for the point returned by :ref:`map_get_closest_point`. ---- .. _class_Navigation2DServer_method_map_get_edge_connection_margin: - :ref:`float` **map_get_edge_connection_margin** **(** :ref:`RID` map **)** const Returns the edge connection margin of the map. The edge connection margin is a distance used to connect two regions. ---- .. _class_Navigation2DServer_method_map_get_path: - :ref:`PackedVector2Array` **map_get_path** **(** :ref:`RID` map, :ref:`Vector2` origin, :ref:`Vector2` destination, :ref:`bool` optimize **)** const Returns the navigation path to reach the destination from the origin, while avoiding static obstacles. ---- .. _class_Navigation2DServer_method_map_is_active: - :ref:`bool` **map_is_active** **(** :ref:`RID` nap **)** const Returns true if the map is active. ---- .. _class_Navigation2DServer_method_map_set_active: - void **map_set_active** **(** :ref:`RID` map, :ref:`bool` active **)** const Sets the map active. ---- .. _class_Navigation2DServer_method_map_set_cell_size: - void **map_set_cell_size** **(** :ref:`RID` map, :ref:`float` cell_size **)** const Set the map cell size used to weld the navigation mesh polygons. ---- .. _class_Navigation2DServer_method_map_set_edge_connection_margin: - void **map_set_edge_connection_margin** **(** :ref:`RID` map, :ref:`float` margin **)** const Set the map edge connection margin used to weld the compatible region edges. ---- .. _class_Navigation2DServer_method_region_create: - :ref:`RID` **region_create** **(** **)** const Creates a new region. ---- .. _class_Navigation2DServer_method_region_set_map: - void **region_set_map** **(** :ref:`RID` region, :ref:`RID` map **)** const Sets the map for the region. ---- .. _class_Navigation2DServer_method_region_set_navpoly: - void **region_set_navpoly** **(** :ref:`RID` region, :ref:`NavigationPolygon` nav_poly **)** const Sets the navigation mesh for the region. ---- .. _class_Navigation2DServer_method_region_set_transform: - void **region_set_transform** **(** :ref:`RID` region, :ref:`Transform2D` transform **)** const Sets the global transformation for the region.