Physics2DDirectSpaceState.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Physics2DDirectSpaceState" inherits="Object" category="Core" version="3.1.2">
  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/3.1/tutorials/physics/ray-casting.html</link>
  11. </tutorials>
  12. <methods>
  13. <method name="cast_motion">
  14. <return type="Array">
  15. </return>
  16. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  17. </argument>
  18. <description>
  19. 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 [code][1, 1][/code].
  20. If the shape can not move, the array will be empty.
  21. </description>
  22. </method>
  23. <method name="collide_shape">
  24. <return type="Array">
  25. </return>
  26. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  27. </argument>
  28. <argument index="1" name="max_results" type="int" default="32">
  29. </argument>
  30. <description>
  31. 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.
  32. </description>
  33. </method>
  34. <method name="get_rest_info">
  35. <return type="Dictionary">
  36. </return>
  37. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  38. </argument>
  39. <description>
  40. 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:
  41. [code]collider_id[/code]: The colliding object's ID.
  42. [code]linear_velocity[/code]: The colliding object's velocity [Vector2]. If the object is an [Area2D], the result is [code](0, 0)[/code].
  43. [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].
  44. [code]normal[/code]: The object's surface normal at the intersection point.
  45. [code]point[/code]: The intersection point.
  46. [code]rid[/code]: The intersecting object's [RID].
  47. [code]shape[/code]: The shape index of the colliding shape.
  48. If the shape did not intersect anything, then an empty dictionary is returned instead.
  49. </description>
  50. </method>
  51. <method name="intersect_point">
  52. <return type="Array">
  53. </return>
  54. <argument index="0" name="point" type="Vector2">
  55. </argument>
  56. <argument index="1" name="max_results" type="int" default="32">
  57. </argument>
  58. <argument index="2" name="exclude" type="Array" default="[ ]">
  59. </argument>
  60. <argument index="3" name="collision_layer" type="int" default="2147483647">
  61. </argument>
  62. <argument index="4" name="collide_with_bodies" type="bool" default="true">
  63. </argument>
  64. <argument index="5" name="collide_with_areas" type="bool" default="false">
  65. </argument>
  66. <description>
  67. 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:
  68. [code]collider[/code]: The colliding object.
  69. [code]collider_id[/code]: The colliding object's ID.
  70. [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].
  71. [code]rid[/code]: The intersecting object's [RID].
  72. [code]shape[/code]: The shape index of the colliding shape.
  73. 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.
  74. </description>
  75. </method>
  76. <method name="intersect_point_on_canvas">
  77. <return type="Array">
  78. </return>
  79. <argument index="0" name="point" type="Vector2">
  80. </argument>
  81. <argument index="1" name="canvas_instance_id" type="int">
  82. </argument>
  83. <argument index="2" name="max_results" type="int" default="32">
  84. </argument>
  85. <argument index="3" name="exclude" type="Array" default="[ ]">
  86. </argument>
  87. <argument index="4" name="collision_layer" type="int" default="2147483647">
  88. </argument>
  89. <argument index="5" name="collide_with_bodies" type="bool" default="true">
  90. </argument>
  91. <argument index="6" name="collide_with_areas" type="bool" default="false">
  92. </argument>
  93. <description>
  94. </description>
  95. </method>
  96. <method name="intersect_ray">
  97. <return type="Dictionary">
  98. </return>
  99. <argument index="0" name="from" type="Vector2">
  100. </argument>
  101. <argument index="1" name="to" type="Vector2">
  102. </argument>
  103. <argument index="2" name="exclude" type="Array" default="[ ]">
  104. </argument>
  105. <argument index="3" name="collision_layer" type="int" default="2147483647">
  106. </argument>
  107. <argument index="4" name="collide_with_bodies" type="bool" default="true">
  108. </argument>
  109. <argument index="5" name="collide_with_areas" type="bool" default="false">
  110. </argument>
  111. <description>
  112. Intersects a ray in a given space. The returned object is a dictionary with the following fields:
  113. [code]collider[/code]: The colliding object.
  114. [code]collider_id[/code]: The colliding object's ID.
  115. [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].
  116. [code]normal[/code]: The object's surface normal at the intersection point.
  117. [code]position[/code]: The intersection point.
  118. [code]rid[/code]: The intersecting object's [RID].
  119. [code]shape[/code]: The shape index of the colliding shape.
  120. If the ray did not intersect anything, then an empty dictionary is returned instead.
  121. 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.
  122. </description>
  123. </method>
  124. <method name="intersect_shape">
  125. <return type="Array">
  126. </return>
  127. <argument index="0" name="shape" type="Physics2DShapeQueryParameters">
  128. </argument>
  129. <argument index="1" name="max_results" type="int" default="32">
  130. </argument>
  131. <description>
  132. 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:
  133. [code]collider[/code]: The colliding object.
  134. [code]collider_id[/code]: The colliding object's ID.
  135. [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].
  136. [code]rid[/code]: The intersecting object's [RID].
  137. [code]shape[/code]: The shape index of the colliding shape.
  138. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  139. </description>
  140. </method>
  141. </methods>
  142. <constants>
  143. </constants>
  144. </class>