PhysicsBody2D.xml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="PhysicsBody2D" inherits="CollisionObject2D" version="4.0">
  3. <brief_description>
  4. Base class for all objects affected by physics in 2D space.
  5. </brief_description>
  6. <description>
  7. PhysicsBody2D is an abstract base class for implementing a physics body. All *Body2D types inherit from it.
  8. </description>
  9. <tutorials>
  10. <link title="Physics introduction">https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html</link>
  11. </tutorials>
  12. <methods>
  13. <method name="add_collision_exception_with">
  14. <return type="void" />
  15. <argument index="0" name="body" type="Node" />
  16. <description>
  17. Adds a body to the list of bodies that this body can't collide with.
  18. </description>
  19. </method>
  20. <method name="get_collision_exceptions">
  21. <return type="PhysicsBody2D[]" />
  22. <description>
  23. Returns an array of nodes that were added as collision exceptions for this body.
  24. </description>
  25. </method>
  26. <method name="move_and_collide">
  27. <return type="KinematicCollision2D" />
  28. <argument index="0" name="linear_velocity" type="Vector2" />
  29. <argument index="1" name="test_only" type="bool" default="false" />
  30. <argument index="2" name="safe_margin" type="float" default="0.08" />
  31. <description>
  32. Moves the body along the vector [code]linear_velocity[/code]. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
  33. The body will stop if it collides. Returns a [KinematicCollision2D], which contains information about the collision.
  34. If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given.
  35. [code]safe_margin[/code] is the extra margin used for collision recovery (see [member CharacterBody2D.collision/safe_margin] for more details).
  36. </description>
  37. </method>
  38. <method name="remove_collision_exception_with">
  39. <return type="void" />
  40. <argument index="0" name="body" type="Node" />
  41. <description>
  42. Removes a body from the list of bodies that this body can't collide with.
  43. </description>
  44. </method>
  45. <method name="test_move">
  46. <return type="bool" />
  47. <argument index="0" name="from" type="Transform2D" />
  48. <argument index="1" name="linear_velocity" type="Vector2" />
  49. <argument index="2" name="collision" type="KinematicCollision2D" default="null" />
  50. <argument index="3" name="safe_margin" type="float" default="0.08" />
  51. <description>
  52. Checks for collisions without moving the body. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.
  53. Virtually sets the node's position, scale and rotation to that of the given [Transform2D], then tries to move the body along the vector [code]linear_velocity[/code]. Returns [code]true[/code] if a collision would occur.
  54. [code]collision[/code] is an optional object of type [KinematicCollision2D], which contains additional information about the collision (should there be one).
  55. [code]safe_margin[/code] is the extra margin used for collision recovery (see [member CharacterBody2D.collision/safe_margin] for more details).
  56. </description>
  57. </method>
  58. </methods>
  59. <members>
  60. <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" override="true" default="false" />
  61. </members>
  62. </class>