class_physics2ddirectspacestate.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Physics2DDirectSpaceState.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Physics2DDirectSpaceState:
  5. Physics2DDirectSpaceState
  6. =========================
  7. **Inherits:** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Direct access object to a space in the :ref:`Physics2DServer<class_physics2dserver>`.
  12. Member Functions
  13. ----------------
  14. +--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`Array<class_array>` | :ref:`cast_motion<class_Physics2DDirectSpaceState_cast_motion>` **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape **)** |
  16. +--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`Array<class_array>` | :ref:`collide_shape<class_Physics2DDirectSpaceState_collide_shape>` **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape, :ref:`int<class_int>` max_results=32 **)** |
  18. +--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Dictionary<class_dictionary>` | :ref:`get_rest_info<class_Physics2DDirectSpaceState_get_rest_info>` **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape **)** |
  20. +--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Array<class_array>` | :ref:`intersect_point<class_Physics2DDirectSpaceState_intersect_point>` **(** :ref:`Vector2<class_vector2>` point, :ref:`int<class_int>` max_results=32, :ref:`Array<class_array>` exclude=[ ], :ref:`int<class_int>` collision_layer=2147483647 **)** |
  22. +--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Dictionary<class_dictionary>` | :ref:`intersect_ray<class_Physics2DDirectSpaceState_intersect_ray>` **(** :ref:`Vector2<class_vector2>` from, :ref:`Vector2<class_vector2>` to, :ref:`Array<class_array>` exclude=[ ], :ref:`int<class_int>` collision_layer=2147483647 **)** |
  24. +--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Array<class_array>` | :ref:`intersect_shape<class_Physics2DDirectSpaceState_intersect_shape>` **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape, :ref:`int<class_int>` max_results=32 **)** |
  26. +--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. Description
  28. -----------
  29. Direct access object to a space in the :ref:`Physics2DServer<class_physics2dserver>`. It's used mainly to do queries against objects and areas residing in a given space.
  30. Member Function Description
  31. ---------------------------
  32. .. _class_Physics2DDirectSpaceState_cast_motion:
  33. - :ref:`Array<class_array>` **cast_motion** **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape **)**
  34. Checks how far the shape can travel toward a point. Note that both the shape and the motion are supplied through a :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` object. The method will return an array with two floats between 0 and 1, both representing a fraction of ``motion``. 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.
  35. If the shape can not move, the array will be empty (``dir.empty()==true``).
  36. .. _class_Physics2DDirectSpaceState_collide_shape:
  37. - :ref:`Array<class_array>` **collide_shape** **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape, :ref:`int<class_int>` max_results=32 **)**
  38. Checks the intersections of a shape, given through a :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` object, against the space. The resulting array contains a list of points where the shape intersects another. Like with :ref:`intersect_shape<class_Physics2DDirectSpaceState_intersect_shape>`, the number of returned results can be limited to save processing time.
  39. .. _class_Physics2DDirectSpaceState_get_rest_info:
  40. - :ref:`Dictionary<class_dictionary>` **get_rest_info** **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape **)**
  41. Checks the intersections of a shape, given through a :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` object, against the space. If it collides with more than one shape, the nearest one is selected. Note that this method does not take into account the ``motion`` property of the object. The returned object is a dictionary containing the following fields:
  42. ``collider_id``: The colliding object's ID.
  43. ``linear_velocity``: The colliding object's velocity :ref:`Vector2<class_vector2>`. If the object is an :ref:`Area2D<class_area2d>`, the result is ``(0, 0)``.
  44. ``metadata``: The intersecting shape's metadata. This metadata is different from :ref:`Object.get_meta<class_Object_get_meta>`, and is set with :ref:`Physics2DServer.shape_set_data<class_Physics2DServer_shape_set_data>`.
  45. ``normal``: The object's surface normal at the intersection point.
  46. ``point``: The intersection point.
  47. ``rid``: The intersecting object's :ref:`RID<class_rid>`.
  48. ``shape``: The shape index of the colliding shape.
  49. If the shape did not intersect anything, then an empty dictionary (``dir.empty()==true``) is returned instead.
  50. .. _class_Physics2DDirectSpaceState_intersect_point:
  51. - :ref:`Array<class_array>` **intersect_point** **(** :ref:`Vector2<class_vector2>` point, :ref:`int<class_int>` max_results=32, :ref:`Array<class_array>` exclude=[ ], :ref:`int<class_int>` collision_layer=2147483647 **)**
  52. Checks whether a point is inside any shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
  53. ``collider``: The colliding object.
  54. ``collider_id``: The colliding object's ID.
  55. ``metadata``: The intersecting shape's metadata. This metadata is different from :ref:`Object.get_meta<class_Object_get_meta>`, and is set with :ref:`Physics2DServer.shape_set_data<class_Physics2DServer_shape_set_data>`.
  56. ``rid``: The intersecting object's :ref:`RID<class_rid>`.
  57. ``shape``: The shape index of the colliding shape.
  58. Additionally, the method can take an array of objects or :ref:`RID<class_rid>`\ s that are to be excluded from collisions, or a bitmask representing the physics layers to check in.
  59. .. _class_Physics2DDirectSpaceState_intersect_ray:
  60. - :ref:`Dictionary<class_dictionary>` **intersect_ray** **(** :ref:`Vector2<class_vector2>` from, :ref:`Vector2<class_vector2>` to, :ref:`Array<class_array>` exclude=[ ], :ref:`int<class_int>` collision_layer=2147483647 **)**
  61. Intersects a ray in a given space. The returned object is a dictionary with the following fields:
  62. ``collider``: The colliding object.
  63. ``collider_id``: The colliding object's ID.
  64. ``metadata``: The intersecting shape's metadata. This metadata is different from :ref:`Object.get_meta<class_Object_get_meta>`, and is set with :ref:`Physics2DServer.shape_set_data<class_Physics2DServer_shape_set_data>`.
  65. ``normal``: The object's surface normal at the intersection point.
  66. ``position``: The intersection point.
  67. ``rid``: The intersecting object's :ref:`RID<class_rid>`.
  68. ``shape``: The shape index of the colliding shape.
  69. If the ray did not intersect anything, then an empty dictionary (``dir.empty()==true``) is returned instead.
  70. Additionally, the method can take an array of objects or :ref:`RID<class_rid>`\ s that are to be excluded from collisions, or a bitmask representing the physics layers to check in.
  71. .. _class_Physics2DDirectSpaceState_intersect_shape:
  72. - :ref:`Array<class_array>` **intersect_shape** **(** :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` shape, :ref:`int<class_int>` max_results=32 **)**
  73. Checks the intersections of a shape, given through a :ref:`Physics2DShapeQueryParameters<class_physics2dshapequeryparameters>` object, against the space. Note that this method does not take into account the ``motion`` property of the object. The intersected shapes are returned in an array containing dictionaries with the following fields:
  74. ``collider``: The colliding object.
  75. ``collider_id``: The colliding object's ID.
  76. ``metadata``: The intersecting shape's metadata. This metadata is different from :ref:`Object.get_meta<class_Object_get_meta>`, and is set with :ref:`Physics2DServer.shape_set_data<class_Physics2DServer_shape_set_data>`.
  77. ``rid``: The intersecting object's :ref:`RID<class_rid>`.
  78. ``shape``: The shape index of the colliding shape.
  79. The number of intersections can be limited with the second parameter, to reduce the processing time.