:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/SpringArm3D.xml. .. _class_SpringArm3D: SpringArm3D =========== **继承:** :ref:`Node3D` **<** :ref:`Node` **<** :ref:`Object` 能够动态地将子节点朝碰撞点移动的 3D 射线投射。 .. rst-class:: classref-introduction-group 描述 ---- **SpringArm3D** 会朝它的 Z 轴投射射线或形状,并将所有直接子节点朝碰撞点移动,可以保留一定的边距。可用于第三人称相机,让其在狭窄空间中朝玩家移动(你可能需要在 **SpringArm3D** 的碰撞检查中排除玩家的碰撞体)。 .. rst-class:: classref-introduction-group 教程 ---- - :doc:`使用弹簧臂制作的第三人称相机 <../tutorials/3d/spring_arm>` .. rst-class:: classref-reftable-group 属性 ---- .. table:: :widths: auto +-------------------------------+------------------------------------------------------------------+----------+ | :ref:`int` | :ref:`collision_mask` | ``1`` | +-------------------------------+------------------------------------------------------------------+----------+ | :ref:`float` | :ref:`margin` | ``0.01`` | +-------------------------------+------------------------------------------------------------------+----------+ | :ref:`Shape3D` | :ref:`shape` | | +-------------------------------+------------------------------------------------------------------+----------+ | :ref:`float` | :ref:`spring_length` | ``1.0`` | +-------------------------------+------------------------------------------------------------------+----------+ .. rst-class:: classref-reftable-group 方法 ---- .. table:: :widths: auto +---------------------------+-------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_excluded_object`\ (\ RID\: :ref:`RID`\ ) | +---------------------------+-------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear_excluded_objects`\ (\ ) | +---------------------------+-------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_hit_length`\ (\ ) | +---------------------------+-------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`remove_excluded_object`\ (\ RID\: :ref:`RID`\ ) | +---------------------------+-------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 属性说明 -------- .. _class_SpringArm3D_property_collision_mask: .. rst-class:: classref-property :ref:`int` **collision_mask** = ``1`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_collision_mask**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_collision_mask**\ (\ ) 碰撞检测的目标层。更多信息请参阅文档中的\ `《碰撞层与遮罩》 <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__\ 。 .. rst-class:: classref-item-separator ---- .. _class_SpringArm3D_property_margin: .. rst-class:: classref-property :ref:`float` **margin** = ``0.01`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_margin**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_margin**\ (\ ) 进行碰撞检测时,会给出 SpringArm3D 的一个候选长度。 然后将边距减去该长度,并将该平移应用于该 SpringArm3D 的子对象。 当 SpringArm3D 有一个 :ref:`Camera3D` 作为子节点时,该边距很有用:如果没有边距,该 :ref:`Camera3D` 将被放置在准确的碰撞点上;而有边距时,该 :ref:`Camera3D` 将被放置在靠近碰撞点的地方。 .. rst-class:: classref-item-separator ---- .. _class_SpringArm3D_property_shape: .. rst-class:: classref-property :ref:`Shape3D` **shape** :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_shape**\ (\ value\: :ref:`Shape3D`\ ) - :ref:`Shape3D` **get_shape**\ (\ ) 用于该 SpringArm3D 的 :ref:`Shape3D`\ 。 当该形状被设置后,SpringArm3D 将在其 z 轴上投射该 :ref:`Shape3D`\ ,而不是执行一个射线投射。 .. rst-class:: classref-item-separator ---- .. _class_SpringArm3D_property_spring_length: .. rst-class:: classref-property :ref:`float` **spring_length** = ``1.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_length**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_length**\ (\ ) SpringArm3D 的最大范围。这用作内部使用的射线和形状投射的长度,以计算 SpringArm3D 子节点的所需位置。 要了解有关如何执行形状投射或射线投射的更多信息,请参阅 :ref:`PhysicsDirectSpaceState3D` 文档。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 方法说明 -------- .. _class_SpringArm3D_method_add_excluded_object: .. rst-class:: classref-method |void| **add_excluded_object**\ (\ RID\: :ref:`RID`\ ) :ref:`🔗` 将具有给定 :ref:`RID` 的 :ref:`PhysicsBody3D` 对象,添加到从碰撞检查中排除的 :ref:`PhysicsBody3D` 对象列表中。 .. rst-class:: classref-item-separator ---- .. _class_SpringArm3D_method_clear_excluded_objects: .. rst-class:: classref-method |void| **clear_excluded_objects**\ (\ ) :ref:`🔗` 清空碰撞检测排除 :ref:`PhysicsBody3D` 对象的列表。 .. rst-class:: classref-item-separator ---- .. _class_SpringArm3D_method_get_hit_length: .. rst-class:: classref-method :ref:`float` **get_hit_length**\ (\ ) :ref:`🔗` 返回弹簧臂的当前长度。 .. rst-class:: classref-item-separator ---- .. _class_SpringArm3D_method_remove_excluded_object: .. rst-class:: classref-method :ref:`bool` **remove_excluded_object**\ (\ RID\: :ref:`RID`\ ) :ref:`🔗` 从碰撞检测排除 :ref:`PhysicsBody3D` 对象的列表中移除给定的 :ref:`RID`\ 。 .. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)` .. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)` .. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)` .. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)` .. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)` .. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)` .. |void| replace:: :abbr:`void (无返回值。)`