This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
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?

in Engine by (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.

by (22,191 points)
selected by
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.