PhysicsDirectSpaceState.xml 5.1 KB

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