PhysicsDirectSpaceState.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. <argument index="0" name="shape" type="PhysicsShapeQueryParameters" />
  16. <argument index="1" name="motion" type="Vector3" />
  17. <description>
  18. Checks how far a [Shape] can move without colliding. All the parameters for the query, including the shape, are supplied through a [PhysicsShapeQueryParameters] 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 [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.
  21. </description>
  22. </method>
  23. <method name="collide_shape">
  24. <return type="Array" />
  25. <argument index="0" name="shape" type="PhysicsShapeQueryParameters" />
  26. <argument index="1" name="max_results" type="int" default="32" />
  27. <description>
  28. 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.
  29. </description>
  30. </method>
  31. <method name="get_rest_info">
  32. <return type="Dictionary" />
  33. <argument index="0" name="shape" type="PhysicsShapeQueryParameters" />
  34. <description>
  35. 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:
  36. [code]collider_id[/code]: The colliding object's ID.
  37. [code]linear_velocity[/code]: The colliding object's velocity [Vector3]. If the object is an [Area], the result is [code](0, 0, 0)[/code].
  38. [code]normal[/code]: The object's surface normal at the intersection point.
  39. [code]point[/code]: The intersection point.
  40. [code]rid[/code]: The intersecting object's [RID].
  41. [code]shape[/code]: The shape index of the colliding shape.
  42. If the shape did not intersect anything, then an empty dictionary is returned instead.
  43. </description>
  44. </method>
  45. <method name="intersect_ray">
  46. <return type="Dictionary" />
  47. <argument index="0" name="from" type="Vector3" />
  48. <argument index="1" name="to" type="Vector3" />
  49. <argument index="2" name="exclude" type="Array" default="[ ]" />
  50. <argument index="3" name="collision_mask" type="int" default="2147483647" />
  51. <argument index="4" name="collide_with_bodies" type="bool" default="true" />
  52. <argument index="5" name="collide_with_areas" type="bool" default="false" />
  53. <description>
  54. Intersects a ray in a given space. The returned object is a dictionary with the following fields:
  55. [code]collider[/code]: The colliding object.
  56. [code]collider_id[/code]: The colliding object's ID.
  57. [code]normal[/code]: The object's surface normal at the intersection point.
  58. [code]position[/code]: The intersection point.
  59. [code]rid[/code]: The intersecting object's [RID].
  60. [code]shape[/code]: The shape index of the colliding shape.
  61. If the ray did not intersect anything, then an empty dictionary is returned instead.
  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 [PhysicsBody]s or [Area]s, respectively.
  63. </description>
  64. </method>
  65. <method name="intersect_shape">
  66. <return type="Array" />
  67. <argument index="0" name="shape" type="PhysicsShapeQueryParameters" />
  68. <argument index="1" name="max_results" type="int" default="32" />
  69. <description>
  70. 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:
  71. [code]collider[/code]: The colliding object.
  72. [code]collider_id[/code]: The colliding object's ID.
  73. [code]rid[/code]: The intersecting object's [RID].
  74. [code]shape[/code]: The shape index of the colliding shape.
  75. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time.
  76. </description>
  77. </method>
  78. </methods>
  79. <constants>
  80. </constants>
  81. </class>