I have a little game, where I want to drop instances of a ball (RigidBody2D). My setup looks like this:
And I am adding some randomness to the size of the balls and then changing the CollisionShape2D to that random-ish shape like so:
However, every time I make another instance of this ball, the CollisionShape2D changes for every instance currently present in the main scene.
I read on the internet that I should make the CollisionShape2D unique, but that did not work at all.
I think you misunderstand, what needs to be unique is the shape resource inside the CollisionShape2D node (resources are shared by default). You need to create a new instance but change the shape resource to a new unique copy like: $CollisionShape2D.shape = $CollisionShape2D.shape.duplicate(true)
Setting the duplicate method to true makes that the resources inside that element to also duplicate. By doing so, you created a “unique” version of the shape inside that collisionshape node you duplicated.