Physics2DDirectSpaceState.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Physics2DDirectSpaceState" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  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 title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link>
  11. <link title="Ray-casting">$DOCS_URL/tutorials/physics/ray-casting.html</link>
  12. </tutorials>
  13. <methods>
  14. <method name="cast_motion">
  15. <return type="Array" />
  16. <argument index="0" name="shape" type="Physics2DShapeQueryParameters" />
  17. <description>
  18. Checks how far a [Shape2D] can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a [Physics2DShapeQueryParameters] object.
  19. Returns an array with the safe and unsafe proportions (between 0 and 1) of the motion. The safe proportion is the maximum fraction of the motion that can be made without a collision. The unsafe proportion is the minimum fraction of the distance that must be moved for a collision. If no collision is detected a result of [code][1.0, 1.0][/code] will be returned.
  20. [b]Note:[/b] Any [Shape2D]s that the shape is already colliding with e.g. inside of, will be ignored. Use [method collide_shape] to determine the [Shape2D]s that the shape is already colliding with.
  21. </description>
  22. </method>
  23. <method name="collide_shape">
  24. <return type="Array" />
  25. <argument index="0" name="shape" type="Physics2DShapeQueryParameters" />
  26. <argument index="1" name="max_results" type="int" default="32" />
  27. <description>
  28. 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.
  29. </description>
  30. </method>
  31. <method name="get_rest_info">
  32. <return type="Dictionary" />
  33. <argument index="0" name="shape" type="Physics2DShapeQueryParameters" />
  34. <description>
  35. 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. If the shape did not intersect anything, then an empty dictionary is returned instead.
  36. [b]Note:[/b] 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:
  37. [code]collider_id[/code]: The colliding object's ID.
  38. [code]linear_velocity[/code]: The colliding object's velocity [Vector2]. If the object is an [Area2D], the result is [code](0, 0)[/code].
  39. [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].
  40. [code]normal[/code]: The object's surface normal at the intersection point.
  41. [code]point[/code]: The intersection point.
  42. [code]rid[/code]: The intersecting object's [RID].
  43. [code]shape[/code]: The shape index of the colliding shape.
  44. </description>
  45. </method>
  46. <method name="intersect_point">
  47. <return type="Array" />
  48. <argument index="0" name="point" type="Vector2" />
  49. <argument index="1" name="max_results" type="int" default="32" />
  50. <argument index="2" name="exclude" type="Array" default="[ ]" />
  51. <argument index="3" name="collision_layer" type="int" default="2147483647" />
  52. <argument index="4" name="collide_with_bodies" type="bool" default="true" />
  53. <argument index="5" name="collide_with_areas" type="bool" default="false" />
  54. <description>
  55. Checks whether a point is inside any solid shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
  56. [code]collider[/code]: The colliding object.
  57. [code]collider_id[/code]: The colliding object's ID.
  58. [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].
  59. [code]rid[/code]: The intersecting object's [RID].
  60. [code]shape[/code]: The shape index of the colliding shape.
  61. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  62. 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 [PhysicsBody2D]s or [Area2D]s, respectively.
  63. [b]Note:[/b] [ConcavePolygonShape2D]s and [CollisionPolygon2D]s in [code]Segments[/code] build mode are not solid shapes. Therefore, they will not be detected.
  64. </description>
  65. </method>
  66. <method name="intersect_point_on_canvas">
  67. <return type="Array" />
  68. <argument index="0" name="point" type="Vector2" />
  69. <argument index="1" name="canvas_instance_id" type="int" />
  70. <argument index="2" name="max_results" type="int" default="32" />
  71. <argument index="3" name="exclude" type="Array" default="[ ]" />
  72. <argument index="4" name="collision_layer" type="int" default="2147483647" />
  73. <argument index="5" name="collide_with_bodies" type="bool" default="true" />
  74. <argument index="6" name="collide_with_areas" type="bool" default="false" />
  75. <description>
  76. Checks whether a point is inside any solid shape, in a specific canvas layer given by [code]canvas_instance_id[/code]. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
  77. [code]collider[/code]: The colliding object.
  78. [code]collider_id[/code]: The colliding object's ID.
  79. [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].
  80. [code]rid[/code]: The intersecting object's [RID].
  81. [code]shape[/code]: The shape index of the colliding shape.
  82. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  83. 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 [PhysicsBody2D]s or [Area2D]s, respectively.
  84. [b]Note:[/b] [ConcavePolygonShape2D]s and [CollisionPolygon2D]s in [code]Segments[/code] build mode are not solid shapes. Therefore, they will not be detected.
  85. </description>
  86. </method>
  87. <method name="intersect_ray">
  88. <return type="Dictionary" />
  89. <argument index="0" name="from" type="Vector2" />
  90. <argument index="1" name="to" type="Vector2" />
  91. <argument index="2" name="exclude" type="Array" default="[ ]" />
  92. <argument index="3" name="collision_layer" type="int" default="2147483647" />
  93. <argument index="4" name="collide_with_bodies" type="bool" default="true" />
  94. <argument index="5" name="collide_with_areas" type="bool" default="false" />
  95. <description>
  96. Intersects a ray in a given space. The returned object is a dictionary with the following fields:
  97. [code]collider[/code]: The colliding object.
  98. [code]collider_id[/code]: The colliding object's ID.
  99. [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].
  100. [code]normal[/code]: The object's surface normal at the intersection point.
  101. [code]position[/code]: The intersection point.
  102. [code]rid[/code]: The intersecting object's [RID].
  103. [code]shape[/code]: The shape index of the colliding shape.
  104. If the ray did not intersect anything, then an empty dictionary is returned instead.
  105. 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 [PhysicsBody2D]s or [Area2D]s, respectively.
  106. </description>
  107. </method>
  108. <method name="intersect_shape">
  109. <return type="Array" />
  110. <argument index="0" name="shape" type="Physics2DShapeQueryParameters" />
  111. <argument index="1" name="max_results" type="int" default="32" />
  112. <description>
  113. Checks the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields:
  114. [code]collider[/code]: The colliding object.
  115. [code]collider_id[/code]: The colliding object's ID.
  116. [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].
  117. [code]rid[/code]: The intersecting object's [RID].
  118. [code]shape[/code]: The shape index of the colliding shape.
  119. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  120. </description>
  121. </method>
  122. </methods>
  123. <constants>
  124. </constants>
  125. </class>