PhysicsDirectSpaceState.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="PhysicsDirectSpaceState" inherits="Object" category="Core" version="3.1">
  3. <brief_description>
  4. Direct access object to a space in the [PhysicsServer].
  5. </brief_description>
  6. <description>
  7. Direct access object to a space in the [PhysicsServer]. 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="PhysicsShapeQueryParameters">
  19. </argument>
  20. <argument index="1" name="motion" type="Vector3">
  21. </argument>
  22. <description>
  23. Checks whether the shape can travel to a point. 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].
  24. If the shape can not move, the returned array will be [0, 0].
  25. </description>
  26. </method>
  27. <method name="collide_shape">
  28. <return type="Array">
  29. </return>
  30. <argument index="0" name="shape" type="PhysicsShapeQueryParameters">
  31. </argument>
  32. <argument index="1" name="max_results" type="int" default="32">
  33. </argument>
  34. <description>
  35. Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters] 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.
  36. </description>
  37. </method>
  38. <method name="get_rest_info">
  39. <return type="Dictionary">
  40. </return>
  41. <argument index="0" name="shape" type="PhysicsShapeQueryParameters">
  42. </argument>
  43. <description>
  44. Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters] object, against the space. If it collides with more than one shape, the nearest one is selected. The returned object is a dictionary containing the following fields:
  45. [code]collider_id[/code]: The colliding object's ID.
  46. [code]linear_velocity[/code]: The colliding object's velocity [Vector3]. If the object is an [Area], the result is [code](0, 0, 0)[/code].
  47. [code]normal[/code]: The object's surface normal at the intersection point.
  48. [code]point[/code]: The intersection point.
  49. [code]rid[/code]: The intersecting object's [RID].
  50. [code]shape[/code]: The shape index of the colliding shape.
  51. If the shape did not intersect anything, then an empty dictionary is returned instead.
  52. </description>
  53. </method>
  54. <method name="intersect_ray">
  55. <return type="Dictionary">
  56. </return>
  57. <argument index="0" name="from" type="Vector3">
  58. </argument>
  59. <argument index="1" name="to" type="Vector3">
  60. </argument>
  61. <argument index="2" name="exclude" type="Array" default="[ ]">
  62. </argument>
  63. <argument index="3" name="collision_mask" type="int" default="2147483647">
  64. </argument>
  65. <argument index="4" name="collide_with_bodies" type="bool" default="true">
  66. </argument>
  67. <argument index="5" name="collide_with_areas" type="bool" default="false">
  68. </argument>
  69. <description>
  70. Intersects a ray in a given space. The returned object is a dictionary with the following fields:
  71. [code]collider[/code]: The colliding object.
  72. [code]collider_id[/code]: The colliding object's ID.
  73. [code]normal[/code]: The object's surface normal at the intersection point.
  74. [code]position[/code]: The intersection point.
  75. [code]rid[/code]: The intersecting object's [RID].
  76. [code]shape[/code]: The shape index of the colliding shape.
  77. If the ray did not intersect anything, then an empty dictionary is returned instead.
  78. 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.
  79. </description>
  80. </method>
  81. <method name="intersect_shape">
  82. <return type="Array">
  83. </return>
  84. <argument index="0" name="shape" type="PhysicsShapeQueryParameters">
  85. </argument>
  86. <argument index="1" name="max_results" type="int" default="32">
  87. </argument>
  88. <description>
  89. Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters] object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields:
  90. [code]collider[/code]: The colliding object.
  91. [code]collider_id[/code]: The colliding object's ID.
  92. [code]rid[/code]: The intersecting object's [RID].
  93. [code]shape[/code]: The shape index of the colliding shape.
  94. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  95. </description>
  96. </method>
  97. </methods>
  98. <constants>
  99. </constants>
  100. </class>