PhysicsDirectSpaceState.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="PhysicsDirectSpaceState" inherits="Object" version="3.3">
  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.3/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 how far a [Shape] can move without colliding. All the parameters for the query, including the shape, are supplied through a [PhysicsShapeQueryParameters] object.
  22. 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.
  23. [b]Note:[/b] Any [Shape]s that the shape is already colliding with e.g. inside of, will be ignored. Use [method collide_shape] to determine the [Shape]s that the shape is already colliding with.
  24. </description>
  25. </method>
  26. <method name="collide_shape">
  27. <return type="Array">
  28. </return>
  29. <argument index="0" name="shape" type="PhysicsShapeQueryParameters">
  30. </argument>
  31. <argument index="1" name="max_results" type="int" default="32">
  32. </argument>
  33. <description>
  34. 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.
  35. </description>
  36. </method>
  37. <method name="get_rest_info">
  38. <return type="Dictionary">
  39. </return>
  40. <argument index="0" name="shape" type="PhysicsShapeQueryParameters">
  41. </argument>
  42. <description>
  43. 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:
  44. [code]collider_id[/code]: The colliding object's ID.
  45. [code]linear_velocity[/code]: The colliding object's velocity [Vector3]. If the object is an [Area], the result is [code](0, 0, 0)[/code].
  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_ray">
  54. <return type="Dictionary">
  55. </return>
  56. <argument index="0" name="from" type="Vector3">
  57. </argument>
  58. <argument index="1" name="to" type="Vector3">
  59. </argument>
  60. <argument index="2" name="exclude" type="Array" default="[ ]">
  61. </argument>
  62. <argument index="3" name="collision_mask" 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. Intersects a ray in a given space. The returned object is a dictionary with the following fields:
  70. [code]collider[/code]: The colliding object.
  71. [code]collider_id[/code]: The colliding object's ID.
  72. [code]normal[/code]: The object's surface normal at the intersection point.
  73. [code]position[/code]: The intersection point.
  74. [code]rid[/code]: The intersecting object's [RID].
  75. [code]shape[/code]: The shape index of the colliding shape.
  76. If the ray did not intersect anything, then an empty dictionary is returned instead.
  77. 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.
  78. </description>
  79. </method>
  80. <method name="intersect_shape">
  81. <return type="Array">
  82. </return>
  83. <argument index="0" name="shape" type="PhysicsShapeQueryParameters">
  84. </argument>
  85. <argument index="1" name="max_results" type="int" default="32">
  86. </argument>
  87. <description>
  88. 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:
  89. [code]collider[/code]: The colliding object.
  90. [code]collider_id[/code]: The colliding object's ID.
  91. [code]rid[/code]: The intersecting object's [RID].
  92. [code]shape[/code]: The shape index of the colliding shape.
  93. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  94. </description>
  95. </method>
  96. </methods>
  97. <constants>
  98. </constants>
  99. </class>