How to resize the CollisionShape2D node in an extended scene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By brandogs

I have created a basic character scene in a project and had planned to extend it to create different characters.

The basic character has an Area2D node called MeleeHit containing a CollisionShape2D node, which I am using to hit enemies with.

I extended the scene to add a new character, and this character has a different melee animation, and as a result a differently sized and positioned MeleeHit CollisionShape2D.

I can move the CollisionShape2D node just fine, but when I change the shape itself, the change takes effect in the scene that I extended, as well as all scenes that extend this scene.

Is it possible to resize a CollisionShape2D node without also resizing the node in the parent, and as a result, all scene that inherit from the parent?

:bust_in_silhouette: Reply From: kidscancode

The shape data in a CollisionShape2D (contained in its shape property) is a Shape2D resource object. Resources are shared - aka passed by reference - so each of your shapes is the same one.

You can either select “Make Unique” in the shape dropdown or use duplicate() in code to make a unique copy of the shape for your other objects.