Script inherits from native type ‘RigidBody2D’, so it can’t be assigned to an object of type: ‘Node2D’

Apr. 28, 2023

Getting this error while following this tutorial in Godot v4.0.1.

In my case, I had added Node2D. The fix was to right click on the problem node under scene and click Make Scene Root. And then delete Node2D.

Here is what diff looked like:

diff --git a/2d-game-tutorial/Mob.tscn b/2d-game-tutorial/Mob.tscn
index 9eb1630..e720d7f 100644
--- a/2d-game-tutorial/Mob.tscn
+++ b/2d-game-tutorial/Mob.tscn
@@ -48,20 +48,18 @@ animations = {
 radius = 36.0
 height = 100.0

-node name="Mob" type="Node2D"]
-script = ExtResource("1_73gb4")
-
-node name="RigidBody2D" type="RigidBody2D" parent="."]
+node name="RigidBody2D" type="RigidBody2D"]
 collision_mask = 0
 gravity_scale = 2.66454e-15
+script = ExtResource("1_73gb4")

-node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="RigidBody2D"]
+node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
 scale = Vector2(0.75, 0.75)
 sprite_frames = SubResource("SpriteFrames_c1yjy")
 animation = &"walk"

-node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
+node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 rotation = 1.5708
 shape = SubResource("CapsuleShape2D_h1pjc")

-node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="RigidBody2D"]
+node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]