0 votes

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?

asked May 28 in Engine by brandogs (20 points)

1 Answer

+1 vote
Best answer

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.

answered May 28 by kidscancode (17,164 points)
selected May 29 by brandogs
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.