#AnimatableBody3D + BoneAttachment3D works in editor but not in game

3 messages · Page 1 of 1 (latest)

harsh nimbus
#

Hi! I have a character whose animations I want to be able to knock physics objects around. To do this, I made an AnimatableBody3D the child of a BoneAttachment3D. In the editor for the character's scene, when I play an animation, the collision shape moves with the bone. However, when I run the project with the same animation autoplaying, the collision shape gets stuck in its position on the first frame and doesn't move.
I have a few questions:

  • Why is the behaviour different between the editor and the game?
  • How can I get the collider to move with the bone?
  • Is there a better way to do this?
    Attached is the node hierarchy in the character scene, a video of the behaviour in the editor, and a video of the different behaviour in the game (with collision shapes visible).
hallow bison
#

I am not sure AnimatableBody3D works if it's not directly animated through animation player. By your tree structure I am guessing there are no animation tracks for the animatable body, it's just set to follow the transform through bone constrain, I am not sure if that works.

It's working in editor because there is no physics simulation in editor, but when you run game , it tries to interact witht the physics server.
There is an option "sync_to_physics" in the AnimatableBody3d Inspector, disable that and it should work. (It will be able to detect collision but not simulate physics like gravity,drag etc)

Alternatively you can use a PhysicsBone Instead of AnimatableBody, they automatically follow the bones and has collision, they don't simulate physics unless you start the physics simulation through code.

echo jackal
#

At least in 2d, the animateable body will only consider its own transform for physics, not its global transform when a parent moves. So you would have to add a RemoteTransform as the child of the Bone and make it set the global position and rotation of the Body, which you enable "top level" on.