PhysicsServer3D
继承: Object
用于访问低阶 3D 物理的服务器接口。
描述
PhysicsServer3D 是负责所有 3D 物理的服务器。它可以直接创建和操作所有物理对象:
Space(空间)是用于物理仿真的自包含世界。它包含实体、区域和关节。可以对其状态进行查询,获取碰撞和相交信息,并且可以修改部分仿真参数。
Shape(形状)是球形、盒形、圆柱形、多边形等几何形状。加入到实体/区域中就可以用来进行碰撞检测,还可以带有相对于实体/区域原点的额外变换。实体/区域中可以添加多个(变换后的)形状,并且可以使用不同的局部变换将单个形状多次添加到实体/区域中。
Body(实体)是物理对象,可以处于静态、运动学或刚性模式。可以对其状态进行查询和更新(例如位置、速度等)。可以设置力的集成回调,自定义实体的物理特性。
Area(区域)是空间中的区块,可用于检测进入和离开它的实体和区域。可以设置实体的监视回调,报告进入/离开的实体形状,同样可以设置区域的监视回调。通过设置区域参数,可以在区域内覆盖重力和阻尼。
Joint(关节)是两个实体之间或一个实体相对于某个点的约束。可以调整关节偏置和弹簧关节的放松长度等参数。
PhysicsServer3D 中的物理对象可以独立创建和操作;不必将它们绑定到场景树中的节点。
注意:所有 3D 物理节点都在内部使用这个物理服务器。将物理节点添加到场景树,就会导致在物理服务器中创建相应的物理对象。刚体节点会注册回调,该回调会(在每次物理更新时)使用物理服务器中相应实体对象的变换更新该节点的变换。区域节点会注册回调,用来通知区域节点与物理服务器中相应区域对象的重叠。射线投射节点会查询物理服务器中相关空间的直接状态。
方法
枚举
enum JointType: 🔗
JointType JOINT_TYPE_PIN = 0
该 Joint3D 为 PinJoint3D。
JointType JOINT_TYPE_HINGE = 1
该 Joint3D 为 HingeJoint3D。
JointType JOINT_TYPE_SLIDER = 2
该 Joint3D 为 SliderJoint3D。
JointType JOINT_TYPE_CONE_TWIST = 3
该 Joint3D 为 ConeTwistJoint3D。
JointType JOINT_TYPE_6DOF = 4
该 Joint3D 为 Generic6DOFJoint3D。
JointType JOINT_TYPE_MAX = 5
代表 JointType 枚举的大小。
enum PinJointParam: 🔗
PinJointParam PIN_JOINT_BIAS = 0
固定对象试图保持彼此位置关系的力度。
越高越强。
PinJointParam PIN_JOINT_DAMPING = 1
被固定的物体试图保持彼此速度关系的力度。
越高越强。
PinJointParam PIN_JOINT_IMPULSE_CLAMP = 2
如果高于 0,则此值是此 Joint3D 施加在其末端的冲量的最大值。
enum HingeJointParam: 🔗
HingeJointParam HINGE_JOINT_BIAS = 0
两个物体向不同方向移动时被拉回到一起的速度。
HingeJointParam HINGE_JOINT_LIMIT_UPPER = 1
铰链上的最大旋转。
HingeJointParam HINGE_JOINT_LIMIT_LOWER = 2
铰链上的最小旋转。
HingeJointParam HINGE_JOINT_LIMIT_BIAS = 3
垂直于铰链的轴线上的旋转得到纠正的速度。
HingeJointParam HINGE_JOINT_LIMIT_SOFTNESS = 4
There is currently no description for this enum. Please help us by contributing one!
HingeJointParam HINGE_JOINT_LIMIT_RELAXATION = 5
该值越低,旋转速度越慢。
HingeJointParam HINGE_JOINT_MOTOR_TARGET_VELOCITY = 6
目标马达的目标速度。
HingeJointParam HINGE_JOINT_MOTOR_MAX_IMPULSE = 7
马达的最大加速度。
enum HingeJointFlag: 🔗
HingeJointFlag HINGE_JOINT_FLAG_USE_LIMIT = 0
如果为 true,铰链具有最大和最小旋转。
HingeJointFlag HINGE_JOINT_FLAG_ENABLE_MOTOR = 1
如果为 true,则马达将转动铰链。
enum SliderJointParam: 🔗
SliderJointParam SLIDER_JOINT_LINEAR_LIMIT_UPPER = 0
阻尼发生前轴心点之间在 X 轴上的最大差异。
SliderJointParam SLIDER_JOINT_LINEAR_LIMIT_LOWER = 1
阻尼发生前轴心点之间在 X 轴上的最小差异。
SliderJointParam SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS = 2
一旦超过极限,应用于滑块轴上移动的系数。越低,运动越慢。
SliderJointParam SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION = 3
超出限制后的补偿。数值越低,损失的速度能量越多。
SliderJointParam SLIDER_JOINT_LINEAR_LIMIT_DAMPING = 4
一旦超过滑块的极限,阻尼的数量。
SliderJointParam SLIDER_JOINT_LINEAR_MOTION_SOFTNESS = 5
只要滑块在限制范围内,就应用于滑块轴上移动的系数。越低,运动越慢。
SliderJointParam SLIDER_JOINT_LINEAR_MOTION_RESTITUTION = 6
滑块限制内的恢复量。
SliderJointParam SLIDER_JOINT_LINEAR_MOTION_DAMPING = 7
滑块内部的阻尼量受到限制。
SliderJointParam SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS = 8
应用于在垂直于滑块的轴上移动的系数。
SliderJointParam SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION = 9
当移动穿过垂直于滑块的轴时的恢复量。
SliderJointParam SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING = 10
当移动穿过垂直于滑块的轴时的阻尼量。
SliderJointParam SLIDER_JOINT_ANGULAR_LIMIT_UPPER = 11
滑块旋转的上限。
SliderJointParam SLIDER_JOINT_ANGULAR_LIMIT_LOWER = 12
滑块旋转的下限。
SliderJointParam SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS = 13
一旦超过极限,应用于所有旋转的系数。
SliderJointParam SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION = 14
超过限制时旋转的恢复量。
SliderJointParam SLIDER_JOINT_ANGULAR_LIMIT_DAMPING = 15
超过极限时旋转的阻尼量。
SliderJointParam SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS = 16
应用于所有极限旋转的因子。
SliderJointParam SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION = 17
极限内旋转的恢复量。
SliderJointParam SLIDER_JOINT_ANGULAR_MOTION_DAMPING = 18
极限内旋转的阻尼量。
SliderJointParam SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS = 19
应用于垂直于滑块的轴上的所有旋转的因子。
SliderJointParam SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION = 20
垂直于滑块的轴上的旋转恢复量。
SliderJointParam SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING = 21
垂直于滑块的轴上的旋转阻尼量。
SliderJointParam SLIDER_JOINT_MAX = 22
代表 SliderJointParam 枚举的大小。
enum ConeTwistJointParam: 🔗
ConeTwistJointParam CONE_TWIST_JOINT_SWING_SPAN = 0
摆动是围绕垂直于扭转轴的轴线,从一边到另一边的旋转。
摆动跨度定义了沿摆动轴旋转多少不会得到校正。
可以被定义为 ConeTwistJoint3D 中的松动。
如果低于 0.05,该行为将被锁定。
ConeTwistJointParam CONE_TWIST_JOINT_TWIST_SPAN = 1
扭转是绕扭转轴的旋转,此值定义了关节可以扭转多远。
如果低于 0.05,则扭转被锁定。
ConeTwistJointParam CONE_TWIST_JOINT_BIAS = 2
摆动或扭转的速度。
越高,速度越快。
ConeTwistJointParam CONE_TWIST_JOINT_SOFTNESS = 3
Joint3D 的扭曲弹性,如果太低,就需要更大的力才能扭曲关节。
ConeTwistJointParam CONE_TWIST_JOINT_RELAXATION = 4
定义两侧的摆动速度和扭转速度差异同步的速度。
enum G6DOFJointAxisParam: 🔗
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_LOWER_LIMIT = 0
轴心点的轴之间的最小差异。
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_UPPER_LIMIT = 1
轴心点的轴之间的最大差异。
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS = 2
应用于跨轴移动的因子。越低,运动越慢。
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_RESTITUTION = 3
轴运动的恢复量。速度越低,能量损失越多。
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_DAMPING = 4
发生在跨轴线性运动的阻尼量。
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY = 5
关节的线性马达试图达到的速度。
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT = 6
线性马达在试图达到目标速度时可以施加的最大力。
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_SPRING_STIFFNESS = 7
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_SPRING_DAMPING = 8
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisParam G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT = 9
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_LOWER_LIMIT = 10
负方向的最小旋转,以脱离和绕轴旋转。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_UPPER_LIMIT = 11
正方向的最小旋转,以挣脱和绕轴旋转。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS = 12
乘以所有轴旋转的因子。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_DAMPING = 13
跨该轴的旋转阻尼量。值越低,发生的阻尼就越多。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_RESTITUTION = 14
在各轴上的旋转恢复量。值越低,发生的恢复量越大。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_FORCE_LIMIT = 15
围绕 Z 轴旋转时,可能发生的最大力。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_ERP = 16
当校正轴旋转中的极限交叉时,该误差容限因子定义了校正的减慢程度。越低越慢。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY = 17
轴上电机的目标速度。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT = 18
马达在轴上的最大加速度。
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS = 19
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_SPRING_DAMPING = 20
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisParam G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT = 21
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisParam G6DOF_JOINT_MAX = 22
代表 G6DOFJointAxisParam 枚举的大小。
enum G6DOFJointAxisFlag: 🔗
G6DOFJointAxisFlag G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT = 0
设置时,可以在给定的范围内做线性运动。
G6DOFJointAxisFlag G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT = 1
设置时,可以做旋转运动。
G6DOFJointAxisFlag G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING = 2
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisFlag G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING = 3
There is currently no description for this enum. Please help us by contributing one!
G6DOFJointAxisFlag G6DOF_JOINT_FLAG_ENABLE_MOTOR = 4
设置时,存在跨这些轴的旋转马达。
G6DOFJointAxisFlag G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR = 5
设置时,存在跨这些轴的线性马达,以指定的速度为目标。
G6DOFJointAxisFlag G6DOF_JOINT_FLAG_MAX = 6
代表 G6DOFJointAxisFlag 枚举的大小。
enum ShapeType: 🔗
ShapeType SHAPE_WORLD_BOUNDARY = 0
Constant for creating a world boundary shape (used by the WorldBoundaryShape3D resource).
ShapeType SHAPE_SEPARATION_RAY = 1
Constant for creating a separation ray shape (used by the SeparationRayShape3D resource).
ShapeType SHAPE_SPHERE = 2
Constant for creating a sphere shape (used by the SphereShape3D resource).
ShapeType SHAPE_BOX = 3
Constant for creating a box shape (used by the BoxShape3D resource).
ShapeType SHAPE_CAPSULE = 4
Constant for creating a capsule shape (used by the CapsuleShape3D resource).
ShapeType SHAPE_CYLINDER = 5
Constant for creating a cylinder shape (used by the CylinderShape3D resource).
ShapeType SHAPE_CONVEX_POLYGON = 6
Constant for creating a convex polygon shape (used by the ConvexPolygonShape3D resource).
ShapeType SHAPE_CONCAVE_POLYGON = 7
Constant for creating a concave polygon (trimesh) shape (used by the ConcavePolygonShape3D resource).
ShapeType SHAPE_HEIGHTMAP = 8
Constant for creating a heightmap shape (used by the HeightMapShape3D resource).
ShapeType SHAPE_SOFT_BODY = 9
Constant used internally for a soft body shape. Any attempt to create this kind of shape results in an error.
ShapeType SHAPE_CUSTOM = 10
Constant used internally for a custom shape. Any attempt to create this kind of shape results in an error when using Godot Physics or Jolt Physics.
enum AreaParameter: 🔗
AreaParameter AREA_PARAM_GRAVITY_OVERRIDE_MODE = 0
常量,用于在一个区域中设置/获取重力覆盖模式。有关可能的值,请参阅 AreaSpaceOverrideMode。
AreaParameter AREA_PARAM_GRAVITY = 1
常量,用于设置/获取区域中的重力强度。
AreaParameter AREA_PARAM_GRAVITY_VECTOR = 2
常量,用于设置/获取区域中的重力向量/中心。
AreaParameter AREA_PARAM_GRAVITY_IS_POINT = 3
常量,用于设置/获取区域中的重力向量是方向,还是中心点。
AreaParameter AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE = 4
常量,用于设置/获取重力强度等于 AREA_PARAM_GRAVITY 控制的重力的距离。例如,在半径为 100 米且表面重力为 4.0 m/s² 的行星上,将重力设置为 4.0,并将单位距离设置为 100.0。重力会根据平方反比定律衰减,因此在该示例中,重力在距中心 200 米处将为 1.0 m/s²(距离的两倍,重力的 1/4),在距中心 50 米处为 16.0 m/s²(距离的一半,重力的 4 倍),依此类推。
仅当单位距离为正数时,上述情况才成立。当该属性被设置为 0.0 时,无论距离如何,重力都将保持不变。
AreaParameter AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE = 5
常量,用于在一个区域中设置/获取线性阻尼覆盖模式。有关可能的值,请参阅 AreaSpaceOverrideMode。
AreaParameter AREA_PARAM_LINEAR_DAMP = 6
常数,用于设置/获取区域的线性阻尼系数。
AreaParameter AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE = 7
常量,用于在一个区域中设置/获取角度阻尼覆盖模式。有关可能的值,请参阅 AreaSpaceOverrideMode。
AreaParameter AREA_PARAM_ANGULAR_DAMP = 8
常数,用于设置/获取区域的角度阻尼系数。
AreaParameter AREA_PARAM_PRIORITY = 9
常量,用于设置/获取区域的优先级(处理顺序)。
AreaParameter AREA_PARAM_WIND_FORCE_MAGNITUDE = 10
常量,用于设置/获取特定于某个区域的风力大小。风力仅施加于 SoftBody3D 节点。其他物理体目前不会受到风的影响。
AreaParameter AREA_PARAM_WIND_SOURCE = 11
常量,用于设置/获取 3D 向量,该向量指定区域特定的风吹来的原点。
AreaParameter AREA_PARAM_WIND_DIRECTION = 12
常量,用于设置/获取 3D 向量,该向量指定区域特定的风吹的方向。
AreaParameter AREA_PARAM_WIND_ATTENUATION_FACTOR = 13
常量,用于设置/获取风力随距其原点的距离而减小的指数速率。
enum AreaSpaceOverrideMode: 🔗
AreaSpaceOverrideMode AREA_SPACE_OVERRIDE_DISABLED = 0
该区域不影响重力/阻尼。这些区域的存在通常只是为了检测碰撞、以及物体是否进入或离开它们。
AreaSpaceOverrideMode AREA_SPACE_OVERRIDE_COMBINE = 1
该区域将其重力/阻尼值加到目前已经计算出的结果上。这样一来,许多重叠的区域可以结合它们的物理运算来创建有趣的效果。
AreaSpaceOverrideMode AREA_SPACE_OVERRIDE_COMBINE_REPLACE = 2
该区域将其重力/阻尼值加到目前已经计算出的结果上。然后停止考虑其余区域,甚至是默认区域。
AreaSpaceOverrideMode AREA_SPACE_OVERRIDE_REPLACE = 3
该区域将替换所有重力/阻尼,甚至是默认值,并停止考虑其余区域。
AreaSpaceOverrideMode AREA_SPACE_OVERRIDE_REPLACE_COMBINE = 4
该区域将替换目前已经计算出的任何重力/阻尼,但仍将继续计算其余区域,直到默认区域。
enum BodyMode: 🔗
BodyMode BODY_MODE_STATIC = 0
常量,用于静态物体。在这种模式下,物体只能由用户代码移动,移动时不会与路径上的其他物体发生碰撞。
BodyMode BODY_MODE_KINEMATIC = 1
常量,用于运动学物体。在这种模式下,物体只能由用户代码移动,会与路径上的其他物体发生碰撞。
BodyMode BODY_MODE_RIGID = 2
常量,用于刚体。在这种模式下,物体可以被其他物体推动,能够对其施加力。
BodyMode BODY_MODE_RIGID_LINEAR = 3
常量,用于线性刚体。在这种模式下,物体不能旋转,只有线速度受外力影响。
enum BodyParameter: 🔗
BodyParameter BODY_PARAM_BOUNCE = 0
常量,用于设置/获取物体的反弹系数。
BodyParameter BODY_PARAM_FRICTION = 1
常量,用于设置/获取物体的摩擦力。
BodyParameter BODY_PARAM_MASS = 2
常量,用于设置/获取物体的质量。
BodyParameter BODY_PARAM_INERTIA = 3
常量,用于设置/获取物体的惯性。
BodyParameter BODY_PARAM_CENTER_OF_MASS = 4
常量,用于设置/获取物体的质心位置,使用该物体的局部坐标系。
BodyParameter BODY_PARAM_GRAVITY_SCALE = 5
常量,用于设置/获取物体的重力倍数。
BodyParameter BODY_PARAM_LINEAR_DAMP_MODE = 6
常量,用于设置/获取物体的线性阻尼模式。可能的值见 BodyDampMode。
BodyParameter BODY_PARAM_ANGULAR_DAMP_MODE = 7
常量,用于设置/获取物体的角度阻尼模式。可能的值见 BodyDampMode。
BodyParameter BODY_PARAM_LINEAR_DAMP = 8
常数,用于设置/获取物体的线性阻尼系数。
BodyParameter BODY_PARAM_ANGULAR_DAMP = 9
常数,用于设置/获取物体的角度阻尼系数。
BodyParameter BODY_PARAM_MAX = 10
代表 BodyParameter 枚举的大小。
enum BodyDampMode: 🔗
BodyDampMode BODY_DAMP_MODE_COMBINE = 0
物体的阻尼值将被加到区域中所设置的值或默认值上。
BodyDampMode BODY_DAMP_MODE_REPLACE = 1
物体的阻尼值会替换区域中所设置的值或默认值。
enum BodyState: 🔗
BodyState BODY_STATE_TRANSFORM = 0
常量,用于设置/获取物体的当前变换矩阵。
BodyState BODY_STATE_LINEAR_VELOCITY = 1
常量,用于设置/获取物体的当前线速度。
BodyState BODY_STATE_ANGULAR_VELOCITY = 2
常量,用于设置/获取物体的当前角速度。
BodyState BODY_STATE_SLEEPING = 3
常量,用于使物体沉睡/唤醒,或得到它是否在沉睡。
BodyState BODY_STATE_CAN_SLEEP = 4
常量,用于设置/获取物体是否可以休眠。
enum AreaBodyStatus: 🔗
AreaBodyStatus AREA_BODY_ADDED = 0
当对象进入区域的任一形状时,区域回调函数接收的第一个参数值。
AreaBodyStatus AREA_BODY_REMOVED = 1
当对象退出区域的任一形状时,区域回调函数接收的第一个参数值。
enum ProcessInfo: 🔗
ProcessInfo INFO_ACTIVE_OBJECTS = 0
常量,用以获取未休眠的对象的数量。
ProcessInfo INFO_COLLISION_PAIRS = 1
常量,用以获取可能的碰撞数。
ProcessInfo INFO_ISLAND_COUNT = 2
常量,用以获取可能发生碰撞的空间区块数。
enum SpaceParameter: 🔗
SpaceParameter SPACE_PARAM_CONTACT_RECYCLE_RADIUS = 0
常量,用于设置/获取一对物体在其碰撞状态被重新计算之前的最大移动距离。
SpaceParameter SPACE_PARAM_CONTACT_MAX_SEPARATION = 1
常量,用于设置/获取两个形状间的最大距离,超过该距离后它们将被视为分离,接触将被弃置。
SpaceParameter SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION = 2
常量,用于设置/获取两个形状互相穿透的最大距离,超过该距离后将视为碰撞。
SpaceParameter SPACE_PARAM_CONTACT_DEFAULT_BIAS = 3
常量,用于设置/获取所有物理接触的默认求解器偏差。求解器偏差是控制两个对象在重叠后“反弹”的程度的一个系数,以避免由于数值不精确而使它们处于该状态。
SpaceParameter SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD = 4
常量,用于设置/获取活跃的阈值线速度。一个被标记为线性速度和角速度都可能不活跃的物体将在给定的时间后进入睡眠状态。
SpaceParameter SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD = 5
常量,用于设置/获取活动的阈值角速度。一个被标记为线性和角速度都可能不活跃的物体,在给定的时间后将会进入睡眠状态。
SpaceParameter SPACE_PARAM_BODY_TIME_TO_SLEEP = 6
常量,用于设置/获得最大的活动时间。一个被标记为线速度和角速度都可能不活动的物体,在这个时间之后将被置入睡眠状态。
SpaceParameter SPACE_PARAM_SOLVER_ITERATIONS = 7
常量,用于设置/获取接触和约束的求解器迭代次数。迭代次数越多,碰撞和约束就越准确。然而,更多的迭代需要更多的 CPU 能力,这会降低性能。
enum BodyAxis: 🔗
BodyAxis BODY_AXIS_LINEAR_X = 1
There is currently no description for this enum. Please help us by contributing one!
BodyAxis BODY_AXIS_LINEAR_Y = 2
There is currently no description for this enum. Please help us by contributing one!
BodyAxis BODY_AXIS_LINEAR_Z = 4
There is currently no description for this enum. Please help us by contributing one!
BodyAxis BODY_AXIS_ANGULAR_X = 8
There is currently no description for this enum. Please help us by contributing one!
BodyAxis BODY_AXIS_ANGULAR_Y = 16
There is currently no description for this enum. Please help us by contributing one!
BodyAxis BODY_AXIS_ANGULAR_Z = 32
There is currently no description for this enum. Please help us by contributing one!
方法说明
void area_add_shape(area: RID, shape: RID, transform: Transform3D = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), disabled: bool = false) 🔗
向区域添加一个形状,以及一个变换矩阵。形状通常通过它们的索引来引用,因此你应该跟踪哪个形状具有给定的索引。
void area_attach_object_instance_id(area: RID, id: int) 🔗
将区域分配给Object的子类,因此它可以存在于节点树中。
void area_clear_shapes(area: RID) 🔗
从一个区域移除所有形状。它不会删除形状,因此它们可以稍后重新分配。
在物理服务器中创建一个 3D 区域对象,并返回标识该区域的 RID。所创建区域的默认设置包括设置为 1 的碰撞层和遮罩,以及设置为 false 的 monitorable。
使用 area_add_shape() 向其添加形状,使用 area_set_transform() 设置其变换,使用 area_set_space() 将区域添加到一个空间。如果希望该区域可被检测,请使用 area_set_monitorable()。
int area_get_collision_layer(area: RID) const 🔗
返回该区域所属的物理层。
int area_get_collision_mask(area: RID) const 🔗
返回该区域能够接触的物理层。
int area_get_object_instance_id(area: RID) const 🔗
获取区域分配给的对象的实例 ID。
Variant area_get_param(area: RID, param: AreaParameter) const 🔗
返回区域参数值。可用参数列表位于 AreaParameter 常量上。
RID area_get_shape(area: RID, shape_idx: int) const 🔗
返回区域的第 n 个形状的 RID。
int area_get_shape_count(area: RID) const 🔗
返回分配给区域的形状数量。
Transform3D area_get_shape_transform(area: RID, shape_idx: int) const 🔗
返回区域内形状的变换矩阵。
RID area_get_space(area: RID) const 🔗
返回分配给该区域的空间。
Transform3D area_get_transform(area: RID) const 🔗
返回区域的变换矩阵。
void area_remove_shape(area: RID, shape_idx: int) 🔗
从区域中移除一个形状。它不会删除形状,因此可以稍后重新分配。
void area_set_area_monitor_callback(area: RID, callback: Callable) 🔗
设置该区域的区域监视回调。当任何其他(形状)区域进入或退出(形状)给定区域时,将调用此回调,并且必须采用以下五个参数:
一个整数
status:AREA_BODY_ADDED 或 AREA_BODY_REMOVED 取决于其他区域的形状是进入还是退出该区域,一个整数
instance_id:附加到其他区域的ObjectID,一个整数
area_shape_idx:进入或退出该区域的其他区域的形状索引,一个整数
self_shape_idx:其他区域进入或退出的区域的形状索引。
通过计算(或跟踪)进入和退出的形状,可以确定一个区域(及其所有形状)是第一次进入还是最后一次退出。
void area_set_collision_layer(area: RID, layer: int) 🔗
将区域分配给一个或多个物理层。
void area_set_collision_mask(area: RID, mask: int) 🔗
设置区域将监控的物理层。
void area_set_monitor_callback(area: RID, callback: Callable) 🔗
设置区域的实体监视器回调。当任何其他(形状的)实体进入或退出(形状的)给定区域时,将调用此回调,并且必须采用以下五个参数:
一个整数
status:AREA_BODY_ADDED 或 AREA_BODY_REMOVED 取决于其他实体形状是否进入或退出该区域,一个整数
instance_id:附加到该实体上的ObjectID,一个整数
body_shape_idx:进入或离开该区域的实体形状索引,一个整数
self_shape_idx:实体进入或离开的区域的形状索引。
通过计算(或跟踪)进入和退出的形状,可以确定一个实体(及其所有形状)是第一次进入还是最后一次退出。
void area_set_monitorable(area: RID, monitorable: bool) 🔗
There is currently no description for this method. Please help us by contributing one!
void area_set_param(area: RID, param: AreaParameter, value: Variant) 🔗
设置面积参数的值。可用参数列表位于 AreaParameter 常量上。
void area_set_ray_pickable(area: RID, enable: bool) 🔗
设置可使用光线拾取的对象。
void area_set_shape(area: RID, shape_idx: int, shape: RID) 🔗
用另一种形状代替一种形状。旧的形状由它的索引选择,新的形状由它的RID选择。
void area_set_shape_disabled(area: RID, shape_idx: int, disabled: bool) 🔗
There is currently no description for this method. Please help us by contributing one!
void area_set_shape_transform(area: RID, shape_idx: int, transform: Transform3D) 🔗
设置区域形状的变换矩阵。
void area_set_space(area: RID, space: RID) 🔗
为该区域指定一个空间。
void area_set_transform(area: RID, transform: Transform3D) 🔗
设置区域的变换矩阵。
void body_add_collision_exception(body: RID, excepted_body: RID) 🔗
将一个物体添加到免于碰撞的物体列表中。
void body_add_constant_central_force(body: RID, force: Vector3) 🔗
在不影响旋转的情况下,添加一个恒定的方向力,该力会随着时间的推移而持续施加,直到使用 body_set_constant_force(body, Vector3(0, 0, 0)) 清除。
这相当于在实体的质心处使用 body_add_constant_force()。
void body_add_constant_force(body: RID, force: Vector3, position: Vector3 = Vector3(0, 0, 0)) 🔗
向实体添加一个恒定的定位力,持续施加,直到用 body_set_constant_force(body, Vector3(0, 0, 0)) 清除。
position 是在全局坐标中距实体原点的偏移量。
void body_add_constant_torque(body: RID, torque: Vector3) 🔗
在不影响位置的情况下,添加一个恒定的旋转力,随着时间的推移而持续施加,直到使用 body_set_constant_torque(body, Vector3(0, 0, 0)) 清除。
void body_add_shape(body: RID, shape: RID, transform: Transform3D = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0), disabled: bool = false) 🔗
添加一个形状到物体,以及一个变换矩阵。形状通常通过它们的索引来引用,因此你应该跟踪哪个形状具有给定的索引。
void body_apply_central_force(body: RID, force: Vector3) 🔗
在不影响旋转的情况下,施加一个方向力。力是时间相关的,意味着每次物理更新都会施加。
这相当于在实体的质心处使用 body_apply_force()。
void body_apply_central_impulse(body: RID, impulse: Vector3) 🔗
在不影响旋转的情况下,施加一个定向冲量。
冲动是时间无关的!每帧施加一个冲量将产生依赖于帧速率的力。出于这个原因,它应该只在模拟一次性影响时使用(否则使用“_force”函数)。
这相当于在实体的质心处使用 body_apply_impulse()。
void body_apply_force(body: RID, force: Vector3, position: Vector3 = Vector3(0, 0, 0)) 🔗
对实体施加一个定位力。力是时间相关的,意味着每次物理更新都会被施加。
position 是在全局坐标中距实体原点的偏移量。
void body_apply_impulse(body: RID, impulse: Vector3, position: Vector3 = Vector3(0, 0, 0)) 🔗
向实体施加一个定位冲量。
冲量是时间无关的!每帧施加一个冲量将产生一个依赖于帧速率的力。出于这个原因,它应该只在模拟一次性影响时使用(否则使用“_force”函数)。
position 是在全局坐标中距实体原点的偏移量。
void body_apply_torque(body: RID, torque: Vector3) 🔗
在不影响位置的情况下,施加一个旋转力。力是时间相关的,这意味着每次物理更新都会施加。
void body_apply_torque_impulse(body: RID, impulse: Vector3) 🔗
在不影响位置的情况下,向实体施加一个旋转冲量。
冲量是时间无关的!每帧施加一个冲量将产生一个依赖于帧速率的力。出于这个原因,它应该只在模拟一次性影响时使用(否则使用“_force”函数)。
void body_attach_object_instance_id(body: RID, id: int) 🔗
将区域分配给Object的子类,因此它可以存在于节点树中。
void body_clear_shapes(body: RID) 🔗
从物体上移除所有碰撞形状。
在物理服务器中创建一个 3D 物体对象,并返回标识它的 RID。所创建区域的默认设置包括设置为 1 的碰撞层和遮罩,以及设置为 BODY_MODE_RIGID 的物体模式。
使用 body_add_shape() 为其添加形状,使用 body_set_state() 设置其变换,使用 body_set_space() 将该物体添加到一个空间。
int body_get_collision_layer(body: RID) const 🔗
返回物体所属的物理层或层。
int body_get_collision_mask(body: RID) const 🔗
返回物体可以碰撞的物理层或层。
float body_get_collision_priority(body: RID) const 🔗
返回该物体的碰撞优先级。
Vector3 body_get_constant_force(body: RID) const 🔗
返回在每次物理更新期间,该物体被施加的总的恒定位置的力。
参阅 body_add_constant_force() 和 body_add_constant_central_force()。
Vector3 body_get_constant_torque(body: RID) const 🔗
返回在每次物理更新期间,该物体被施加的总的恒定旋转的力。
参阅 body_add_constant_torque()。
PhysicsDirectBodyState3D body_get_direct_state(body: RID) 🔗
返回该物体的 PhysicsDirectBodyState3D。如果该物体已被销毁或从物理空间中移除,则返回 null。
int body_get_max_contacts_reported(body: RID) const 🔗
返回可报告的最大接触数。见 body_set_max_contacts_reported()。
BodyMode body_get_mode(body: RID) const 🔗
返回物体模式。
int body_get_object_instance_id(body: RID) const 🔗
获取区域分配给的对象的实例 ID。
Variant body_get_param(body: RID, param: BodyParameter) const 🔗
返回物体参数的值。可用参数列表位于 BodyParameter 常量上。
RID body_get_shape(body: RID, shape_idx: int) const 🔗
返回物体的第 n 个碰撞形状的 RID。
int body_get_shape_count(body: RID) const 🔗
返回分配给物体的碰撞形状数量。
Transform3D body_get_shape_transform(body: RID, shape_idx: int) const 🔗
返回物体碰撞形状的变换矩阵。
RID body_get_space(body: RID) const 🔗
返回分配给物体的空间的 RID。
Variant body_get_state(body: RID, state: BodyState) const 🔗
返回物体的状态。
bool body_is_axis_locked(body: RID, axis: BodyAxis) const 🔗
There is currently no description for this method. Please help us by contributing one!
bool body_is_continuous_collision_detection_enabled(body: RID) const 🔗
如果为 true,则启用连续碰撞检测模式。
bool body_is_omitting_force_integration(body: RID) const 🔗
如果物体省略了标准力积分,则返回 true。参见 body_set_omit_force_integration()。
void body_remove_collision_exception(body: RID, excepted_body: RID) 🔗
从免于碰撞的实体列表中删除实体。
连续碰撞检测尝试预测运动物体碰撞的位置,而不是在碰撞时移动物体并纠正其运动。
void body_remove_shape(body: RID, shape_idx: int) 🔗
从物体上移除一个碰撞形状。碰撞形状不会被从内存中删除,所以它可以在之后被重复使用。
void body_reset_mass_properties(body: RID) 🔗
根据形状恢复默认惯性和质心,以取消之前使用 body_set_param() 设置的任何自定义值。
void body_set_axis_lock(body: RID, axis: BodyAxis, lock: bool) 🔗
There is currently no description for this method. Please help us by contributing one!
void body_set_axis_velocity(body: RID, axis_velocity: Vector3) 🔗
设置轴速度。给定向量轴上的速度将被设置为给定向量长度。这对跳跃行为很有用。
void body_set_collision_layer(body: RID, layer: int) 🔗
设置物体所属的物理层或层。
void body_set_collision_mask(body: RID, mask: int) 🔗
设置物理层或身体可以碰撞的层。
void body_set_collision_priority(body: RID, priority: float) 🔗
设置该物体的碰撞优先级。
void body_set_constant_force(body: RID, force: Vector3) 🔗
设置该物体在每次物理更新时应用的总恒定位置力。
见 body_add_constant_force() 和 body_add_constant_central_force()。
void body_set_constant_torque(body: RID, torque: Vector3) 🔗
设置该物体在每次物理更新时应用的总恒定旋转力。
void body_set_enable_continuous_collision_detection(body: RID, enable: bool) 🔗
如果为 true,则启用连续碰撞检测模式。
连续碰撞检测尝试预测运动物体碰撞的位置,而不是在碰撞时移动物体并纠正其运动。
void body_set_force_integration_callback(body: RID, callable: Callable, userdata: Variant = null) 🔗
将物体的自定义力积分回调函数设置为 callable。使用空的 Callable(Callable())清除自定义回调。
函数 callable 将在标准力积分之前的每个物理刻度被调用(参见 body_set_omit_force_integration())。例如,它可用于根据与其他物体的接触更新物体的线速度和角速度。
如果 userdata 不为 null,则函数 callable 必须接受以下两个参数:
state:一个 PhysicsDirectBodyState3D,用于检索和修改物体的状态,userdata:一个 Variant;其值将是传递到该方法的userdata。
如果 userdata 为 null,则 callable 必须仅接受 state 参数。
void body_set_max_contacts_reported(body: RID, amount: int) 🔗
设置要报告的最大接触数。物体可以记录与其他物体的接触。将最大接触数设置为大于 0 的数字可以启用此功能。
void body_set_mode(body: RID, mode: BodyMode) 🔗
设置物体的模式。
void body_set_omit_force_integration(body: RID, enable: bool) 🔗
设置物体是否省略标准力集成。如果 enable 为 true,则物体不会自动使用施加的力、力矩、阻尼来更新自身的线速度和角速度。在这种情况下可以使用 body_set_force_integration_callback() 来手动更新线速度和角速度。
设置 RigidBody3D.custom_integrator 属性时会调用该方法。
void body_set_param(body: RID, param: BodyParameter, value: Variant) 🔗
设置物体参数。可用参数列表位于 BodyParameter 常量上。
void body_set_ray_pickable(body: RID, enable: bool) 🔗
如果设置了 enable,则将该物体设置为可通过射线拾取。
void body_set_shape(body: RID, shape_idx: int, shape: RID) 🔗
用一个给定的物体形状代替另一个。旧的形状是通过其索引选择的,新的是通过其 RID 选择的。
void body_set_shape_disabled(body: RID, shape_idx: int, disabled: bool) 🔗
There is currently no description for this method. Please help us by contributing one!
void body_set_shape_transform(body: RID, shape_idx: int, transform: Transform3D) 🔗
设置物体形状的变换矩阵。
void body_set_space(body: RID, space: RID) 🔗
给物体分配一个空间(见 space_create())。
void body_set_state(body: RID, state: BodyState, value: Variant) 🔗
设置物体的状态。
void body_set_state_sync_callback(body: RID, callable: Callable) 🔗
将物体的状态同步回调函数设置为 callable。清空回调请使用空的 Callable(Callable())。
每个物理帧都会调用一次 callable 函数,前提是该对象在上一个物理周期中处于活动状态,并且可以用于从物理服务器获取最新状态.
callable 函数的参数如下:
state:类型为 PhysicsDirectBodyState3D,用于获取物体的状态。
bool body_test_motion(body: RID, parameters: PhysicsTestMotionParameters3D, result: PhysicsTestMotionResult3D = null) 🔗
如果从空间中的给定点沿着运动向量移动会导致碰撞,则返回 true。传递 PhysicsTestMotionParameters3D 可以设置运动参数。还可以传递 PhysicsTestMotionResult3D,从而返回其他信息。
Creates a 3D box shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the box's half-extents.
Creates a 3D capsule shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the capsule's height and radius.
RID concave_polygon_shape_create() 🔗
Creates a 3D concave polygon shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the concave polygon's triangles.
float cone_twist_joint_get_param(joint: RID, param: ConeTwistJointParam) const 🔗
获取锥体扭转关节的参数。
void cone_twist_joint_set_param(joint: RID, param: ConeTwistJointParam, value: float) 🔗
设置锥体扭转关节的参数。
RID convex_polygon_shape_create() 🔗
Creates a 3D convex polygon shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the convex polygon's points.
Creates a custom shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the shape's data.
Note: Custom shapes are not supported by the built-in physics servers, so calling this method always produces an error when using Godot Physics or Jolt Physics. Custom physics servers implemented as GDExtensions may support a custom shape.
Creates a 3D cylinder shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the cylinder's height and radius.
销毁由 PhysicsServer3D 创建的任何对象。如果传入的 RID 不是由 PhysicsServer3D 创建的对象,则会向控制台发送错误。
bool generic_6dof_joint_get_flag(joint: RID, axis: Axis, flag: G6DOFJointAxisFlag) const 🔗
返回通用六自由度关节的标志值。
float generic_6dof_joint_get_param(joint: RID, axis: Axis, param: G6DOFJointAxisParam) const 🔗
返回通用六自由度关节的参数值。
void generic_6dof_joint_set_flag(joint: RID, axis: Axis, flag: G6DOFJointAxisFlag, enable: bool) 🔗
设置通用六自由度关节的标志值。
void generic_6dof_joint_set_param(joint: RID, axis: Axis, param: G6DOFJointAxisParam, value: float) 🔗
设置通用六自由度关节的参数值。
int get_process_info(process_info: ProcessInfo) 🔗
返回由 process_info 指定的物理引擎状态的取值。
RID heightmap_shape_create() 🔗
Creates a 3D heightmap shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the heightmap's data.
bool hinge_joint_get_flag(joint: RID, flag: HingeJointFlag) const 🔗
获取铰链关节标志。
float hinge_joint_get_param(joint: RID, param: HingeJointParam) const 🔗
获取铰链关节参数。
void hinge_joint_set_flag(joint: RID, flag: HingeJointFlag, enabled: bool) 🔗
设置铰链关节标志。
void hinge_joint_set_param(joint: RID, param: HingeJointParam, value: float) 🔗
设置铰链关节参数。
void joint_clear(joint: RID) 🔗
There is currently no description for this method. Please help us by contributing one!
There is currently no description for this method. Please help us by contributing one!
void joint_disable_collisions_between_bodies(joint: RID, disable: bool) 🔗
设置附加至该 Joint3D 的物体能否互相碰撞。
int joint_get_solver_priority(joint: RID) const 🔗
获取该 Joint3D 的优先级。
JointType joint_get_type(joint: RID) const 🔗
返回该 Joint3D 的类型。
bool joint_is_disabled_collisions_between_bodies(joint: RID) const 🔗
返回附加至该 Joint3D 的物体能否互相碰撞。
void joint_make_cone_twist(joint: RID, body_A: RID, local_ref_A: Transform3D, body_B: RID, local_ref_B: Transform3D) 🔗
There is currently no description for this method. Please help us by contributing one!
void joint_make_generic_6dof(joint: RID, body_A: RID, local_ref_A: Transform3D, body_B: RID, local_ref_B: Transform3D) 🔗
将关节设置为通用六自由度(6DOF)关节。请使用 generic_6dof_joint_set_flag() 和 generic_6dof_joint_set_param() 来设置关节的标志和参数。
void joint_make_hinge(joint: RID, body_A: RID, hinge_A: Transform3D, body_B: RID, hinge_B: Transform3D) 🔗
There is currently no description for this method. Please help us by contributing one!
void joint_make_pin(joint: RID, body_A: RID, local_A: Vector3, body_B: RID, local_B: Vector3) 🔗
There is currently no description for this method. Please help us by contributing one!
void joint_make_slider(joint: RID, body_A: RID, local_ref_A: Transform3D, body_B: RID, local_ref_B: Transform3D) 🔗
There is currently no description for this method. Please help us by contributing one!
void joint_set_solver_priority(joint: RID, priority: int) 🔗
设置该 Joint3D 的优先级。
Vector3 pin_joint_get_local_a(joint: RID) const 🔗
返回关节在关节物体 A 的局部空间中的位置。
Vector3 pin_joint_get_local_b(joint: RID) const 🔗
返回关节在关节物体 B 的局部空间中的位置。
float pin_joint_get_param(joint: RID, param: PinJointParam) const 🔗
获取钉固关节参数。
void pin_joint_set_local_a(joint: RID, local_A: Vector3) 🔗
设置关节在关节物体 A 的局部空间中的位置。
void pin_joint_set_local_b(joint: RID, local_B: Vector3) 🔗
设置关节在关节物体 B 的局部空间中的位置。
void pin_joint_set_param(joint: RID, param: PinJointParam, value: float) 🔗
设置钉固关节的参数。
RID separation_ray_shape_create() 🔗
Creates a 3D separation ray shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the shape's length and slide_on_slope properties.
void set_active(active: bool) 🔗
激活或停用 3D 物理引擎。
Variant shape_get_data(shape: RID) const 🔗
Returns the shape data that configures the shape, such as the half-extents of a box or the triangles of a concave (trimesh) shape. See shape_set_data() for the precise format of this data in each case.
float shape_get_margin(shape: RID) const 🔗
返回形状的碰撞边距。
注意:Godot Physics 中并未使用,所以始终返回 0。
ShapeType shape_get_type(shape: RID) const 🔗
返回形状的类型。
void shape_set_data(shape: RID, data: Variant) 🔗
Sets the shape data that configures the shape. The data to be passed depends on the shape's type (see shape_get_type()):
SHAPE_SEPARATION_RAY: a dictionary containing the key
"length"with a float value and the key"slide_on_slope"with a bool value,SHAPE_SPHERE: a float that is the radius of the sphere,
SHAPE_BOX: a Vector3 containing the half-extents of the box,
SHAPE_CAPSULE: a dictionary containing the keys
"height"and"radius"with float values,SHAPE_CYLINDER: a dictionary containing the keys
"height"and"radius"with float values,SHAPE_CONVEX_POLYGON: a PackedVector3Array of points defining a convex polygon (the shape will be the convex hull of the points),
SHAPE_CONCAVE_POLYGON: a dictionary containing the key
"faces"with a PackedVector3Array value (with a length divisible by 3, so that each 3-tuple of points forms a face) and the key"backface_collision"with a bool value,SHAPE_HEIGHTMAP: a dictionary containing the keys
"width"and"depth"with int values, and the key"heights"with a value that is a packed array of floats of lengthwidth * depth(that is a PackedFloat32Array, or a PackedFloat64Array if Godot was compiled with theprecision=doubleoption), and optionally the keys"min_height"and"max_height"with float values,SHAPE_SOFT_BODY: the input
datais ignored and this method has no effect,SHAPE_CUSTOM: the input
datais interpreted by a custom physics server, if it supports custom shapes.
void shape_set_margin(shape: RID, margin: float) 🔗
设置形状的碰撞边距。
注意:这在 Godot 物理中未被使用。
float slider_joint_get_param(joint: RID, param: SliderJointParam) const 🔗
获取滑动关节参数。
void slider_joint_set_param(joint: RID, param: SliderJointParam, value: float) 🔗
获取滑动关节参数。
void soft_body_add_collision_exception(body: RID, body_b: RID) 🔗
将给定物体添加到免于碰撞的物体列表中。
void soft_body_apply_central_force(body: RID, force: Vector3) 🔗
将力分配并施加到所有点上。力是时间相关的,应在每次物理更新时施加。
void soft_body_apply_central_impulse(body: RID, impulse: Vector3) 🔗
将冲量分配并施加到所有点上。
冲量与时间无关!如果每帧都施加冲量会得到与帧率相关的力。因此只应在模拟一次性冲击时使用(否则请使用“_force”函数)。
void soft_body_apply_point_force(body: RID, point_index: int, force: Vector3) 🔗
将力施加到某个点上。力是时间相关的,应在每次物理更新时施加。
void soft_body_apply_point_impulse(body: RID, point_index: int, impulse: Vector3) 🔗
将冲量施加到某个点上。
冲量与时间无关!如果每帧都施加冲量会得到与帧率相关的力。因此只应在模拟一次性冲击时使用(否则请使用“_force”函数)。
创建一个新的柔性物体并返回其内部 RID。
AABB soft_body_get_bounds(body: RID) const 🔗
返回给定柔性物体在全局坐标中的边界。
int soft_body_get_collision_layer(body: RID) const 🔗
返回给定柔性物体所属的物理层。
int soft_body_get_collision_mask(body: RID) const 🔗
返回给定柔性物体可以碰撞的物理层。
float soft_body_get_damping_coefficient(body: RID) const 🔗
返回给定柔性物体的阻尼系数。
float soft_body_get_drag_coefficient(body: RID) const 🔗
返回给定柔性物体的阻力系数。
float soft_body_get_linear_stiffness(body: RID) const 🔗
返回给定柔性物体的线性刚度。
Vector3 soft_body_get_point_global_position(body: RID, point_index: int) const 🔗
返回给定柔性物体点在全局坐标中的当前位置。
float soft_body_get_pressure_coefficient(body: RID) const 🔗
返回给定柔性物体的压力系数。
float soft_body_get_shrinking_factor(body: RID) const 🔗
返回给定柔性物体的收缩系数。
int soft_body_get_simulation_precision(body: RID) const 🔗
返回给定柔性物体的模拟精度。
RID soft_body_get_space(body: RID) const 🔗
返回分配给给定柔性物体的空间的 RID。
Variant soft_body_get_state(body: RID, state: BodyState) const 🔗
返回给定的柔性物体状态。
注意:Godot 的默认物理实现不支持 BODY_STATE_LINEAR_VELOCITY、BODY_STATE_ANGULAR_VELOCITY、BODY_STATE_SLEEPING 或 BODY_STATE_CAN_SLEEP。
float soft_body_get_total_mass(body: RID) const 🔗
返回分配给给定柔性物体的总质量。
bool soft_body_is_point_pinned(body: RID, point_index: int) const 🔗
返回给定的柔性物体点是否已固定。
void soft_body_move_point(body: RID, point_index: int, global_position: Vector3) 🔗
将给定的柔性物体点移动到全局坐标中的某个位置。
void soft_body_pin_point(body: RID, point_index: int, pin: bool) 🔗
根据 pin 的值固定或取消固定给定的柔性物体点。
注意:固定一个点可以有效地使其成为运动学的,从而防止其受到力的影响,但你仍然可以使用 soft_body_move_point() 移动它。
void soft_body_remove_all_pinned_points(body: RID) 🔗
取消固定给定柔性物体的所有点。
void soft_body_remove_collision_exception(body: RID, body_b: RID) 🔗
从免于碰撞的物体列表中移除给定的物体。
void soft_body_set_collision_layer(body: RID, layer: int) 🔗
设置给定柔性物体所属的物理层。
void soft_body_set_collision_mask(body: RID, mask: int) 🔗
设置给定柔性物体可以碰撞的物理层。
void soft_body_set_damping_coefficient(body: RID, damping_coefficient: float) 🔗
设置给定柔性物体的阻尼系数。当施加力时,较高的值会更明显地减慢物体的速度。
void soft_body_set_drag_coefficient(body: RID, drag_coefficient: float) 🔗
设置给定柔性物体的阻力系数。较高的值会增加该物体的空气阻力。
注意:Godot 的默认物理实现当前未使用该值。
void soft_body_set_linear_stiffness(body: RID, stiffness: float) 🔗
设置给定柔性物体的线性刚度。较高的值将导致物体更僵硬,而较低的值将增加物体的弯曲能力。该值可以介于 0.0 和 1.0 (含)之间。
void soft_body_set_mesh(body: RID, mesh: RID) 🔗
设置给定柔性物体的网格。
void soft_body_set_pressure_coefficient(body: RID, pressure_coefficient: float) 🔗
设置给定柔性物体的压力系数。模拟物体内部的压力积聚。较高的值会增加该效果的强度。
void soft_body_set_ray_pickable(body: RID, enable: bool) 🔗
设置在使用对象拾取时给定柔性物体是否可拾取。
void soft_body_set_shrinking_factor(body: RID, shrinking_factor: float) 🔗
设置给定柔性物体的收缩系数。
void soft_body_set_simulation_precision(body: RID, simulation_precision: int) 🔗
设置给定柔性物体的模拟精度。增加该值将改善模拟结果,但会影响性能。请小心使用。
void soft_body_set_space(body: RID, space: RID) 🔗
为给定的柔性物体分配一个空间(请参阅 space_create())。
void soft_body_set_state(body: RID, state: BodyState, variant: Variant) 🔗
设置给定物体的给定物体状态。
注意:Godot 的默认物理实现不支持 BODY_STATE_LINEAR_VELOCITY、BODY_STATE_ANGULAR_VELOCITY、BODY_STATE_SLEEPING 或 BODY_STATE_CAN_SLEEP。
void soft_body_set_total_mass(body: RID, total_mass: float) 🔗
设置给定柔性物体的总质量。
void soft_body_set_transform(body: RID, transform: Transform3D) 🔗
设置给定柔性物体的全局变换。
void soft_body_update_rendering_server(body: RID, rendering_server_handler: PhysicsServer3DRenderingServerHandler) 🔗
请求物理服务器通过 rendering_server_handler 接口用给定柔性物体点的最新位置更新渲染服务器。
创建一个空间。空间是物理引擎的参数集合,可以分配给区域或主体。它可以通过 area_set_space() 分配给一个区域,或者通过 body_set_space() 分配给一个主体。
PhysicsDirectSpaceState3D space_get_direct_state(space: RID) 🔗
返回空间的状态,即 PhysicsDirectSpaceState3D。该对象可用于进行碰撞/相交的查询。
float space_get_param(space: RID, param: SpaceParameter) const 🔗
返回空间参数的值。
bool space_is_active(space: RID) const 🔗
返回该空间是否是活动的。
void space_set_active(space: RID, active: bool) 🔗
将空间标记为活动空间。它不会有效果,除非它被分配到一个区域或物体。
void space_set_param(space: RID, param: SpaceParameter, value: float) 🔗
设置空间参数的值。可用参数列表位于 SpaceParameter 常量上。
Creates a 3D sphere shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the sphere's radius.
RID world_boundary_shape_create() 🔗
Creates a 3D world boundary shape in the physics server, and returns the RID that identifies it. Use shape_set_data() to set the shape's normal direction and distance properties.