NavigationPolygon.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="NavigationPolygon" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
  5. </brief_description>
  6. <description>
  7. There are two ways to create polygons. Either by using the [method add_outline] method, or using the [method add_polygon] method.
  8. Using [method add_outline]:
  9. [codeblock]
  10. var polygon = NavigationPolygon.new()
  11. var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  12. polygon.add_outline(outline)
  13. polygon.make_polygons_from_outlines()
  14. $NavigationPolygonInstance.navpoly = polygon
  15. [/codeblock]
  16. Using [method add_polygon] and indices of the vertices array.
  17. [codeblock]
  18. var polygon = NavigationPolygon.new()
  19. var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  20. polygon.set_vertices(vertices)
  21. var indices = PoolIntArray([0, 1, 2, 3])
  22. polygon.add_polygon(indices)
  23. $NavigationPolygonInstance.navpoly = polygon
  24. [/codeblock]
  25. </description>
  26. <tutorials>
  27. <link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>
  28. </tutorials>
  29. <methods>
  30. <method name="add_outline">
  31. <return type="void" />
  32. <argument index="0" name="outline" type="PoolVector2Array" />
  33. <description>
  34. Appends a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
  35. </description>
  36. </method>
  37. <method name="add_outline_at_index">
  38. <return type="void" />
  39. <argument index="0" name="outline" type="PoolVector2Array" />
  40. <argument index="1" name="index" type="int" />
  41. <description>
  42. Adds a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
  43. </description>
  44. </method>
  45. <method name="add_polygon">
  46. <return type="void" />
  47. <argument index="0" name="polygon" type="PoolIntArray" />
  48. <description>
  49. Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
  50. </description>
  51. </method>
  52. <method name="clear_outlines">
  53. <return type="void" />
  54. <description>
  55. Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
  56. </description>
  57. </method>
  58. <method name="clear_polygons">
  59. <return type="void" />
  60. <description>
  61. Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
  62. </description>
  63. </method>
  64. <method name="get_mesh">
  65. <return type="NavigationMesh" />
  66. <description>
  67. Returns the [NavigationMesh] resulting from this navigation polygon. This navmesh can be used to update the navmesh of a region with the [method NavigationServer.region_set_navmesh] API directly (as 2D uses the 3D server behind the scene).
  68. </description>
  69. </method>
  70. <method name="get_outline" qualifiers="const">
  71. <return type="PoolVector2Array" />
  72. <argument index="0" name="idx" type="int" />
  73. <description>
  74. Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script.
  75. </description>
  76. </method>
  77. <method name="get_outline_count" qualifiers="const">
  78. <return type="int" />
  79. <description>
  80. Returns the number of outlines that were created in the editor or by script.
  81. </description>
  82. </method>
  83. <method name="get_polygon">
  84. <return type="PoolIntArray" />
  85. <argument index="0" name="idx" type="int" />
  86. <description>
  87. Returns a [PoolIntArray] containing the indices of the vertices of a created polygon.
  88. </description>
  89. </method>
  90. <method name="get_polygon_count" qualifiers="const">
  91. <return type="int" />
  92. <description>
  93. Returns the count of all polygons.
  94. </description>
  95. </method>
  96. <method name="get_vertices" qualifiers="const">
  97. <return type="PoolVector2Array" />
  98. <description>
  99. Returns a [PoolVector2Array] containing all the vertices being used to create the polygons.
  100. </description>
  101. </method>
  102. <method name="make_polygons_from_outlines">
  103. <return type="void" />
  104. <description>
  105. Creates polygons from the outlines added in the editor or by script.
  106. </description>
  107. </method>
  108. <method name="remove_outline">
  109. <return type="void" />
  110. <argument index="0" name="idx" type="int" />
  111. <description>
  112. Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
  113. </description>
  114. </method>
  115. <method name="set_outline">
  116. <return type="void" />
  117. <argument index="0" name="idx" type="int" />
  118. <argument index="1" name="outline" type="PoolVector2Array" />
  119. <description>
  120. Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
  121. </description>
  122. </method>
  123. <method name="set_vertices">
  124. <return type="void" />
  125. <argument index="0" name="vertices" type="PoolVector2Array" />
  126. <description>
  127. Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method.
  128. </description>
  129. </method>
  130. </methods>
  131. <constants>
  132. </constants>
  133. </class>