How to dynamically change collision for animated imported .fbx model door

Godot Version

Godot Engine 4.3

Question

Hello! I have animated blast door in Blender. Blast door have two animations - “Open” and “Close”. During “Open” animation the door at first appears to be closed then it opens. During “Close” animation the door at first appears to be opened then it closes.

Now my problem is… well the model with these animations is imported .fbx file.
of course because it’s a door I would need to y’know change “CollisionShape3D” position according exactly to the animation, so how I can do that and what’s the best way to do that?

Animation also have specific mode of ease - “in-and-out” so it would be quite problematic at first to just follow lerping the movement linear.

What I mean is on this screenshot (at first i wanted to post a video but it’s higher than 8 mb):

Usually objects like these consist of separate meshes/nodes with their own collision, and those get animated.

If you don’t want to go through the process of reworking that, you can remove all collision from the door, and manually attach collision shapes to each door bone instead using the BoneAttachment3D node, as well as adding a separate collision shape(s) for the surrounding wall.

2 Likes

Thank you for your answer!

I have placed BoneAttachment3D node to my Skeleton3D node which is part of the imported .fbx model instantiated scene.

Now the problem is that when I add CollisionShape3D node the Godot Engine says that CollisionShape3D should be children of a node which inherits CollisionObject3D.

Basically, this means that I should put CollisionShape3D as a children either of the Area3D, StaticBody3D, RigidBody3D, CharacterBody3D or others.

What should I choose? Should I choose AnimatableBody3D for my case?

EDIT: Should I categorize things a little? Like for the door frame I would use StaticBody3D and for the animated blast door parts I would use AnimatableBody3D?

For a door I would do StaticBody3D, since I assume you don’t want it to move by an outside force other than your script/animations

RigidBody3D would be something like for a ball bouncing and you need to resolve what happens to it through a physics engine (jolt or godot physics)

CharacterBody3D is normally reserved for player controlled scenes

Area3D is for detection of objects around (so a script will know what the player is around essentially) (example: Like a enemies detection range or the player is near this item so auto pick it up)

3 Likes

Well, what about the movable door parts? The left blast door part and right blast door part that open?

I mean I could for the blast door frame use StaticBody3D because it’s static and not movable in my animation. But what about the movable parts?

That’s what I mean from these screenshots:

Still use a StaticBody3D

What is the purpose of AnimatableBody3D then? I mean its name quite states that it’s animatable… and y’know bones are animated and well this means the collisions should be animated… idk.

In this case StaticBody doesn’t mean that it cannot move, but it cannot be moved by physics forces from other nodes, only animated by itself.

I’ll be honest I didn’t even know about that node lol, it looks better than static to me for this purpose.

It seems to be mostly used for moving platforms though.

I am sorry but you’re quite wrong about AnimatableBody3D.

I mean the documentation states about this node that:

A 3D physics body that can’t be moved by external forces. When moved manually, it affects other bodies in its path.

So uh technically this is what I need but now I am not sure…

I will try both. I will try StaticBody3D and if things go wrong I will try AnimatableBody3D.

I will say what worked the best.

StaticBody3D does the same thing

A static 3D physics body. It can’t be moved by external forces or contacts, but can be moved manually by other means such as code

That’s why it might be specific for moving platforms and such, so when it detects a player of ball on it, the body on top will move with the platform

append: It isn’t the exactly the same but has similar properties

1 Like

I noticed, sorry about that.

In this case the difference is that StaticBody3D cannot apply forces to other bodies, but AnimatableBody3D can apply forces to other bodies.

so for example: AnimatableBody3D could push a box in it’s way if the box is a RigidBody3D, but StaticBody3D couldn’t do that.

When AnimatableBody3D is moved, its linear and angular velocity are estimated and used to affect other physics bodies in its path. This makes it useful for moving platforms, doors, and other moving objects.

StaticBody3D is useful for completely static objects like floors and walls, as well as moving surfaces like conveyor belts and circular revolving platforms (by using constant_linear_velocity and constant_angular_velocity).

3 Likes

Thank you @mrcook and @marcythejinx for your answers.

But now I’ve encountered other problem… that quite confuses me.

I’ve put the StaticBody3D with CollisionShape3D node as a part of it. Then I’ve added “Box” collision mesh to it. It has size of 1,1,1 (x,y,z).

But for some reason the collision box is HUGE.

It’s HUGE only when applied to BoneAttachment3D. When it’s part of Node3D it has normal size.

From the screenshot the cyan border is the collision box.

I would assume that when used with BoneAttachment3D the StaticBody3D inherits the scale of the bone it is attached to, and that might be why it’s larger.

Wow, that’s quite… complicates and ruins things I assume…

I don’t think it’s quite normal I mean is there any way around? The door is properly scaled in terms of meters and now I can’t scale the collision box same way using meters…

What happens when you move the StaticBody3D just as the child of the Skeleton3D? Does it still scale weird, does it animate?

When StaticBody3D is part of Skeleton3D the collision box is still HUGE. At the same time when StaticBody3D is part of Skeleton3D it’s of course not animated to the specific bone I need it to be animated. It’s just stays at the same one place.

Right now I’ve tried to scale the collision box. But the measurement is obscure and crazy. Like cmon the collision box with the size of 0.003 (x,y,z) is okay and correctly aligns to my model BUT it’s still weird and obscure.

I guess I will go along with it. I hope nothing in the game engine breaks because of such values of the collision box size.

So I assume you made this model in blender and then imported it into godot as a .GLTF or a .blend?