How to make resource unique from script?

Wow! Thanks for this thread from many years ago!

I had a similar problem but with cloning/duplicating Area2Ds but the CollisionShape2D’s actual shape (RectangleShape2D) was still shared even after duplicating. node.duplicate(true) also didn’t change this.

The following now worked:
(Maybe it helps somebody else too)

var new_area_2d := $TemplateArea2D.duplicate()
new_area_2d.get_children()[0].shape = new_area_2d.get_children()[0].shape.duplicate()
1 Like