class_springarm.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/SpringArm.xml.
  6. .. _class_SpringArm:
  7. SpringArm
  8. =========
  9. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A helper node, mostly used in 3rd person cameras.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. The SpringArm node is a node that casts a ray (or collision shape) along its z axis and moves all its direct children to the collision point, minus a margin.
  15. The most common use case for this is to make a 3rd person camera that reacts to collisions in the environment.
  16. The SpringArm will either cast a ray, or if a shape is given, it will cast the shape in the direction of its z axis.
  17. If you use the SpringArm as a camera controller for your player, you might need to exclude the player's collider from the SpringArm's collision check.
  18. .. rst-class:: classref-reftable-group
  19. Properties
  20. ----------
  21. .. table::
  22. :widths: auto
  23. +---------------------------+----------------------------------------------------------------+----------+
  24. | :ref:`int<class_int>` | :ref:`collision_mask<class_SpringArm_property_collision_mask>` | ``1`` |
  25. +---------------------------+----------------------------------------------------------------+----------+
  26. | :ref:`float<class_float>` | :ref:`margin<class_SpringArm_property_margin>` | ``0.01`` |
  27. +---------------------------+----------------------------------------------------------------+----------+
  28. | :ref:`Shape<class_Shape>` | :ref:`shape<class_SpringArm_property_shape>` | |
  29. +---------------------------+----------------------------------------------------------------+----------+
  30. | :ref:`float<class_float>` | :ref:`spring_length<class_SpringArm_property_spring_length>` | ``1.0`` |
  31. +---------------------------+----------------------------------------------------------------+----------+
  32. .. rst-class:: classref-reftable-group
  33. Methods
  34. -------
  35. .. table::
  36. :widths: auto
  37. +---------------------------+--------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`add_excluded_object<class_SpringArm_method_add_excluded_object>` **(** :ref:`RID<class_RID>` RID **)** |
  39. +---------------------------+--------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`clear_excluded_objects<class_SpringArm_method_clear_excluded_objects>` **(** **)** |
  41. +---------------------------+--------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`get_hit_length<class_SpringArm_method_get_hit_length>` **(** **)** |
  43. +---------------------------+--------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`remove_excluded_object<class_SpringArm_method_remove_excluded_object>` **(** :ref:`RID<class_RID>` RID **)** |
  45. +---------------------------+--------------------------------------------------------------------------------------------------------------------+
  46. .. rst-class:: classref-section-separator
  47. ----
  48. .. rst-class:: classref-descriptions-group
  49. Property Descriptions
  50. ---------------------
  51. .. _class_SpringArm_property_collision_mask:
  52. .. rst-class:: classref-property
  53. :ref:`int<class_int>` **collision_mask** = ``1``
  54. .. rst-class:: classref-property-setget
  55. - void **set_collision_mask** **(** :ref:`int<class_int>` value **)**
  56. - :ref:`int<class_int>` **get_collision_mask** **(** **)**
  57. The layers against which the collision check shall be done. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  58. .. rst-class:: classref-item-separator
  59. ----
  60. .. _class_SpringArm_property_margin:
  61. .. rst-class:: classref-property
  62. :ref:`float<class_float>` **margin** = ``0.01``
  63. .. rst-class:: classref-property-setget
  64. - void **set_margin** **(** :ref:`float<class_float>` value **)**
  65. - :ref:`float<class_float>` **get_margin** **(** **)**
  66. When the collision check is made, a candidate length for the SpringArm is given.
  67. The margin is then subtracted to this length and the translation is applied to the child objects of the SpringArm.
  68. This margin is useful for when the SpringArm has a :ref:`Camera<class_Camera>` as a child node: without the margin, the :ref:`Camera<class_Camera>` would be placed on the exact point of collision, while with the margin the :ref:`Camera<class_Camera>` would be placed close to the point of collision.
  69. .. rst-class:: classref-item-separator
  70. ----
  71. .. _class_SpringArm_property_shape:
  72. .. rst-class:: classref-property
  73. :ref:`Shape<class_Shape>` **shape**
  74. .. rst-class:: classref-property-setget
  75. - void **set_shape** **(** :ref:`Shape<class_Shape>` value **)**
  76. - :ref:`Shape<class_Shape>` **get_shape** **(** **)**
  77. The :ref:`Shape<class_Shape>` to use for the SpringArm.
  78. When the shape is set, the SpringArm will cast the :ref:`Shape<class_Shape>` on its z axis instead of performing a ray cast.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_SpringArm_property_spring_length:
  82. .. rst-class:: classref-property
  83. :ref:`float<class_float>` **spring_length** = ``1.0``
  84. .. rst-class:: classref-property-setget
  85. - void **set_length** **(** :ref:`float<class_float>` value **)**
  86. - :ref:`float<class_float>` **get_length** **(** **)**
  87. The maximum extent of the SpringArm. This is used as a length for both the ray and the shape cast used internally to calculate the desired position of the SpringArm's child nodes.
  88. To know more about how to perform a shape cast or a ray cast, please consult the :ref:`PhysicsDirectSpaceState<class_PhysicsDirectSpaceState>` documentation.
  89. .. rst-class:: classref-section-separator
  90. ----
  91. .. rst-class:: classref-descriptions-group
  92. Method Descriptions
  93. -------------------
  94. .. _class_SpringArm_method_add_excluded_object:
  95. .. rst-class:: classref-method
  96. void **add_excluded_object** **(** :ref:`RID<class_RID>` RID **)**
  97. Adds the :ref:`PhysicsBody<class_PhysicsBody>` object with the given :ref:`RID<class_RID>` to the list of :ref:`PhysicsBody<class_PhysicsBody>` objects excluded from the collision check.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_SpringArm_method_clear_excluded_objects:
  101. .. rst-class:: classref-method
  102. void **clear_excluded_objects** **(** **)**
  103. Clears the list of :ref:`PhysicsBody<class_PhysicsBody>` objects excluded from the collision check.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_SpringArm_method_get_hit_length:
  107. .. rst-class:: classref-method
  108. :ref:`float<class_float>` **get_hit_length** **(** **)**
  109. Returns the spring arm's current length.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_SpringArm_method_remove_excluded_object:
  113. .. rst-class:: classref-method
  114. :ref:`bool<class_bool>` **remove_excluded_object** **(** :ref:`RID<class_RID>` RID **)**
  115. Removes the given :ref:`RID<class_RID>` from the list of :ref:`PhysicsBody<class_PhysicsBody>` objects excluded from the collision check.
  116. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  117. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  118. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  119. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`