class_navigation.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Navigation.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Navigation:
  6. Navigation
  7. ==========
  8. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Mesh-based navigation and pathfinding node.
  13. Properties
  14. ----------
  15. +-------------------------------+-------------------------------------------------------+
  16. | :ref:`Vector3<class_Vector3>` | :ref:`up_vector<class_Navigation_property_up_vector>` |
  17. +-------------------------------+-------------------------------------------------------+
  18. Methods
  19. -------
  20. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Vector3<class_Vector3>` | :ref:`get_closest_point<class_Navigation_method_get_closest_point>` **(** :ref:`Vector3<class_Vector3>` to_point **)** |
  22. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Vector3<class_Vector3>` | :ref:`get_closest_point_normal<class_Navigation_method_get_closest_point_normal>` **(** :ref:`Vector3<class_Vector3>` to_point **)** |
  24. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Object<class_Object>` | :ref:`get_closest_point_owner<class_Navigation_method_get_closest_point_owner>` **(** :ref:`Vector3<class_Vector3>` to_point **)** |
  26. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Vector3<class_Vector3>` | :ref:`get_closest_point_to_segment<class_Navigation_method_get_closest_point_to_segment>` **(** :ref:`Vector3<class_Vector3>` start, :ref:`Vector3<class_Vector3>` end, :ref:`bool<class_bool>` use_collision=false **)** |
  28. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`PoolVector3Array<class_PoolVector3Array>` | :ref:`get_simple_path<class_Navigation_method_get_simple_path>` **(** :ref:`Vector3<class_Vector3>` start, :ref:`Vector3<class_Vector3>` end, :ref:`bool<class_bool>` optimize=true **)** |
  30. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`navmesh_add<class_Navigation_method_navmesh_add>` **(** :ref:`NavigationMesh<class_NavigationMesh>` mesh, :ref:`Transform<class_Transform>` xform, :ref:`Object<class_Object>` owner=null **)** |
  32. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`navmesh_remove<class_Navigation_method_navmesh_remove>` **(** :ref:`int<class_int>` id **)** |
  34. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`navmesh_set_transform<class_Navigation_method_navmesh_set_transform>` **(** :ref:`int<class_int>` id, :ref:`Transform<class_Transform>` xform **)** |
  36. +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. Description
  38. -----------
  39. Provides navigation and pathfinding within a collection of :ref:`NavigationMesh<class_NavigationMesh>`\ es. By default these will be automatically collected from child :ref:`NavigationMeshInstance<class_NavigationMeshInstance>` nodes, but they can also be added on the fly with :ref:`navmesh_add<class_Navigation_method_navmesh_add>`. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on.
  40. Property Descriptions
  41. ---------------------
  42. .. _class_Navigation_property_up_vector:
  43. - :ref:`Vector3<class_Vector3>` **up_vector**
  44. +----------+----------------------+
  45. | *Setter* | set_up_vector(value) |
  46. +----------+----------------------+
  47. | *Getter* | get_up_vector() |
  48. +----------+----------------------+
  49. Defines which direction is up. By default this is ``(0, 1, 0)``, which is the world up direction.
  50. Method Descriptions
  51. -------------------
  52. .. _class_Navigation_method_get_closest_point:
  53. - :ref:`Vector3<class_Vector3>` **get_closest_point** **(** :ref:`Vector3<class_Vector3>` to_point **)**
  54. Returns the navigation point closest to the point given. Points are in local coordinate space.
  55. ----
  56. .. _class_Navigation_method_get_closest_point_normal:
  57. - :ref:`Vector3<class_Vector3>` **get_closest_point_normal** **(** :ref:`Vector3<class_Vector3>` to_point **)**
  58. Returns the surface normal at the navigation point closest to the point given. Useful for rotating a navigation agent according to the navigation mesh it moves on.
  59. ----
  60. .. _class_Navigation_method_get_closest_point_owner:
  61. - :ref:`Object<class_Object>` **get_closest_point_owner** **(** :ref:`Vector3<class_Vector3>` to_point **)**
  62. Returns the owner of the :ref:`NavigationMesh<class_NavigationMesh>` which contains the navigation point closest to the point given. This is usually a :ref:`NavigationMeshInstance<class_NavigationMeshInstance>`. For meshes added via :ref:`navmesh_add<class_Navigation_method_navmesh_add>`, returns the owner that was given (or ``null`` if the ``owner`` parameter was omitted).
  63. ----
  64. .. _class_Navigation_method_get_closest_point_to_segment:
  65. - :ref:`Vector3<class_Vector3>` **get_closest_point_to_segment** **(** :ref:`Vector3<class_Vector3>` start, :ref:`Vector3<class_Vector3>` end, :ref:`bool<class_bool>` use_collision=false **)**
  66. Returns the navigation point closest to the given line segment. When enabling ``use_collision``, only considers intersection points between segment and navigation meshes. If multiple intersection points are found, the one closest to the segment start point is returned.
  67. ----
  68. .. _class_Navigation_method_get_simple_path:
  69. - :ref:`PoolVector3Array<class_PoolVector3Array>` **get_simple_path** **(** :ref:`Vector3<class_Vector3>` start, :ref:`Vector3<class_Vector3>` end, :ref:`bool<class_bool>` optimize=true **)**
  70. Returns the path between two given points. Points are in local coordinate space. If ``optimize`` is ``true`` (the default), the agent properties associated with each :ref:`NavigationMesh<class_NavigationMesh>` (radius, height, etc.) are considered in the path calculation, otherwise they are ignored.
  71. ----
  72. .. _class_Navigation_method_navmesh_add:
  73. - :ref:`int<class_int>` **navmesh_add** **(** :ref:`NavigationMesh<class_NavigationMesh>` mesh, :ref:`Transform<class_Transform>` xform, :ref:`Object<class_Object>` owner=null **)**
  74. Adds a :ref:`NavigationMesh<class_NavigationMesh>`. Returns an ID for use with :ref:`navmesh_remove<class_Navigation_method_navmesh_remove>` or :ref:`navmesh_set_transform<class_Navigation_method_navmesh_set_transform>`. If given, a :ref:`Transform2D<class_Transform2D>` is applied to the polygon. The optional ``owner`` is used as return value for :ref:`get_closest_point_owner<class_Navigation_method_get_closest_point_owner>`.
  75. ----
  76. .. _class_Navigation_method_navmesh_remove:
  77. - void **navmesh_remove** **(** :ref:`int<class_int>` id **)**
  78. Removes the :ref:`NavigationMesh<class_NavigationMesh>` with the given ID.
  79. ----
  80. .. _class_Navigation_method_navmesh_set_transform:
  81. - void **navmesh_set_transform** **(** :ref:`int<class_int>` id, :ref:`Transform<class_Transform>` xform **)**
  82. Sets the transform applied to the :ref:`NavigationMesh<class_NavigationMesh>` with the given ID.