Physics2DDirectSpaceState.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Physics2DDirectSpaceState" inherits="Object" category="Core" version="3.1">
  3. <brief_description>
  4. Direct access object to a space in the [Physics2DServer].
  5. </brief_description>
  6. <description>
  7. Direct access object to a space in the [Physics2DServer]. It's used mainly to do queries against objects and areas residing in a given space.
  8. </description>
  9. <tutorials>
  10. <link>https://docs.godotengine.org/en/latest/tutorials/physics/ray-casting.html</link>
  11. </tutorials>
  12. <demos>
  13. </demos>
  14. <methods>
  15. <method name="cast_motion">
  16. <return type="Array">
  17. </return>
  18. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  19. </argument>
  20. <description>
  21. Checks how far the shape can travel toward a point. Note that both the shape and the motion are supplied through a [Physics2DShapeQueryParameters] object. The method will return an array with two floats between 0 and 1, both representing a fraction of [code]motion[/code]. The first is how far the shape can move without triggering a collision, and the second is the point at which a collision will occur. If no collision is detected, the returned array will be [1, 1].
  22. If the shape can not move, the array will be empty.
  23. </description>
  24. </method>
  25. <method name="collide_shape">
  26. <return type="Array">
  27. </return>
  28. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  29. </argument>
  30. <argument index="1" name="max_results" type="int" default="32">
  31. </argument>
  32. <description>
  33. Checks the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time.
  34. </description>
  35. </method>
  36. <method name="get_rest_info">
  37. <return type="Dictionary">
  38. </return>
  39. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  40. </argument>
  41. <description>
  42. Checks the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. If it collides with more than one shape, the nearest one is selected. Note that this method does not take into account the [code]motion[/code] property of the object. The returned object is a dictionary containing the following fields:
  43. [code]collider_id[/code]: The colliding object's ID.
  44. [code]linear_velocity[/code]: The colliding object's velocity [Vector2]. If the object is an [Area2D], the result is [code](0, 0)[/code].
  45. [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data].
  46. [code]normal[/code]: The object's surface normal at the intersection point.
  47. [code]point[/code]: The intersection point.
  48. [code]rid[/code]: The intersecting object's [RID].
  49. [code]shape[/code]: The shape index of the colliding shape.
  50. If the shape did not intersect anything, then an empty dictionary is returned instead.
  51. </description>
  52. </method>
  53. <method name="intersect_point">
  54. <return type="Array">
  55. </return>
  56. <argument index="0" name="point" type="Vector2">
  57. </argument>
  58. <argument index="1" name="max_results" type="int" default="32">
  59. </argument>
  60. <argument index="2" name="exclude" type="Array" default="[ ]">
  61. </argument>
  62. <argument index="3" name="collision_layer" type="int" default="2147483647">
  63. </argument>
  64. <argument index="4" name="collide_with_bodies" type="bool" default="true">
  65. </argument>
  66. <argument index="5" name="collide_with_areas" type="bool" default="false">
  67. </argument>
  68. <description>
  69. Checks whether a point is inside any shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
  70. [code]collider[/code]: The colliding object.
  71. [code]collider_id[/code]: The colliding object's ID.
  72. [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data].
  73. [code]rid[/code]: The intersecting object's [RID].
  74. [code]shape[/code]: The shape index of the colliding shape.
  75. Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody]s or [Area]s, respectively.
  76. </description>
  77. </method>
  78. <method name="intersect_point_on_canvas">
  79. <return type="Array">
  80. </return>
  81. <argument index="0" name="point" type="Vector2">
  82. </argument>
  83. <argument index="1" name="canvas_instance_id" type="int">
  84. </argument>
  85. <argument index="2" name="max_results" type="int" default="32">
  86. </argument>
  87. <argument index="3" name="exclude" type="Array" default="[ ]">
  88. </argument>
  89. <argument index="4" name="collision_layer" type="int" default="2147483647">
  90. </argument>
  91. <argument index="5" name="collide_with_bodies" type="bool" default="true">
  92. </argument>
  93. <argument index="6" name="collide_with_areas" type="bool" default="false">
  94. </argument>
  95. <description>
  96. </description>
  97. </method>
  98. <method name="intersect_ray">
  99. <return type="Dictionary">
  100. </return>
  101. <argument index="0" name="from" type="Vector2">
  102. </argument>
  103. <argument index="1" name="to" type="Vector2">
  104. </argument>
  105. <argument index="2" name="exclude" type="Array" default="[ ]">
  106. </argument>
  107. <argument index="3" name="collision_layer" type="int" default="2147483647">
  108. </argument>
  109. <argument index="4" name="collide_with_bodies" type="bool" default="true">
  110. </argument>
  111. <argument index="5" name="collide_with_areas" type="bool" default="false">
  112. </argument>
  113. <description>
  114. Intersects a ray in a given space. The returned object is a dictionary with the following fields:
  115. [code]collider[/code]: The colliding object.
  116. [code]collider_id[/code]: The colliding object's ID.
  117. [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data].
  118. [code]normal[/code]: The object's surface normal at the intersection point.
  119. [code]position[/code]: The intersection point.
  120. [code]rid[/code]: The intersecting object's [RID].
  121. [code]shape[/code]: The shape index of the colliding shape.
  122. If the ray did not intersect anything, then an empty dictionary is returned instead.
  123. Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody]s or [Area]s, respectively.
  124. </description>
  125. </method>
  126. <method name="intersect_shape">
  127. <return type="Array">
  128. </return>
  129. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  130. </argument>
  131. <argument index="1" name="max_results" type="int" default="32">
  132. </argument>
  133. <description>
  134. Checks the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. Note that this method does not take into account the [code]motion[/code] property of the object. The intersected shapes are returned in an array containing dictionaries with the following fields:
  135. [code]collider[/code]: The colliding object.
  136. [code]collider_id[/code]: The colliding object's ID.
  137. [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data].
  138. [code]rid[/code]: The intersecting object's [RID].
  139. [code]shape[/code]: The shape index of the colliding shape.
  140. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  141. </description>
  142. </method>
  143. </methods>
  144. <constants>
  145. </constants>
  146. </class>