The shape of CollisionShape2D is shared between seperate instances of the same scene

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

I want to use animation player to change the shape of the characters hitbox based on the attack used, but when resizing the shape of their hitbox through animation player, every other instance of that character scene has their collision shape re-sized as well, not just the one that went through the animation.

Everything else like the transform of CollisionShape2D doesn’t affect the other instances of that character, so why is shape different?

:bust_in_silhouette: Reply From: kidscancode

This is by design. The shape property of a CollisionShape2D is a Shape2D resource. Resource objects are passed by reference, so both instances are sharing the same shape resource.

If you want them to be unique you can choose “Make unique” on the resource in the Inspector, or you can duplicate() it in code.

I’ve chosen “Make Unique”, which didn’t work for some reason but I found that under “edit” I can tick “Local to scene” which worked, thanks!

Slimeydragon | 2021-05-28 09:11

:bust_in_silhouette: Reply From: endaye

Check it in the “Local To Scene” box, and you can save your shape in the scene locally.