Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

AnimatableBody2D

继承: StaticBody2D < PhysicsBody2D < CollisionObject2D < Node2D < CanvasItem < Node < Object

无法被外力移动的 2D 物理物体。手动移动时会影响路径上的其他物体。

描述

可动画的 2D 物理物体。无法因外力和接触而移动,但可以通过代码、AnimationMixerAnimationMixer.callback_mode_process 设为 AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_PHYSICS)、RemoteTransform2D 等方法手动移动。

AnimatableBody2D 发生移动时,会对线速度和角速度进行估算,并用于影响其路径上的其他物理物体。因此适用于移动平台、门等移动的对象。

属性

bool

sync_to_physics

true


属性说明

bool sync_to_physics = true

  • void set_sync_to_physics ( bool value )

  • bool is_sync_to_physics_enabled ( )

如果为 true,则物体的运动将与物理帧同步。当通过 AnimationPlayer 为运动设置动画时,例如在移动的平台上,这个功能很有用。不要PhysicsBody2D.move_and_collide一起使用。