"This node has no shape" but it does have an inherited shape

Godot Version

4.2.2 stable windows

Question

I have my player_A CharacterBody2D node, and under it is an Area2D, under which is a CollisionShape2D. This specific player_A node is an inherited scene from my base player scene, therefore the area2d and collisionshape2d are inherited from that.

I do this because I want the hurtbox information to be easily editable no matter how many different player variations I have, and I want to have the freedom to individually manipulate the properties of the hurtbox for each player variation.

But collisions aren’t working with this setup (they did when i was directly using the base player node). Furthermore, on the player_A scene, I get a warning saying “this node has no shape […] consider adding a CollisionShape2D or CollisionPolygon2D as a child”. This confuses me, because player_A clearly does have a collision area as a child - you’re telling me just because it’s inherited, it doesn’t work?

Is there anything I’m doing wrong? Is there any way to make an area2D inherited by various nodes and still work? If not, how can I make my player hitbox be easily editable for every variation? Any help is appreciated.

I sounds like you have this set up?

2024-08-03-192600_265x195_scrot

In this case the CharacterBody2D needs it’s own child CollisionShape2D, it does not take from the Area2D’s children

2024-08-03-192659_263x188_scrot

I tried removing the Area2D altogether and replacing it with just a CollisionShape2D and adapting the collision script to the new CollisionShape2D, and the warning is gone, but no collisions work still. Doesn’t help either that I can’t set collision layers for Area2Ds, which means I can’t have multiple different collision shapes for different purposes under one node.

Did you try what I recommended? Can you show your scene tree, I figure the Area2D will be useful so you should keep it in.

image
image
This is my scene tree for both the base player and base enemy node.

Oh well, adding the Area2D back in shouldn’t be too hard in case I need it.

In this example it’s very difficult for th enemy to tell the Hurtbox apart from the Hitbox, that’s probably why you started with an Area2D for a Hitbox

What’s your suggestion on the best way to do things here?

Adding an Area2D with Hitbox as it’s child collision shape

I added an Area2D with a copy of Hurtbox as a child, without removing Hurtbox from Player, reattached and adapted the script from Hurtbox to the new Area2D, and did the same for Enemy, but collisions still don’t work, not to mention there are now twice as many collision shapes that make a visual mess.

It would help to be more specific. Do I remove the CollisionShape2Ds from the parent now that I have the Area2D? Surely that’s not it, because I’d be back where I started. Do I have the script only on the Area2Ds? Do I have the script both on the Area2Ds and CollisionShape2Ds? How am I supposed to easily edit the hitbox information when there are two separate CollisionShape2Ds for each hitbox?

I would recommend this layout, with the Area2D named “Hitbox”.

I do not know your exact use case is, but I am confident you can attach a script to the CharacterBody2D and manipulate and use the Area and CollisionShapes much more effectively in this layout.

I managed to get it working, thank you so much! Now all I have to do is figure out what to do with twice the collision shapes muddying up my visuals, and possibly lowering performance.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.