[Possible Bug] Problem instantiating a StaticBody2d and then changing its properties...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ferhand
:warning: Old Version Published before Godot 3 was released.

Yes, as I say in the title:

I have a node Creator to instance a StaticBody2D wich has as childrens a CollisionShape2D, with the circle2D shape and two sprites nodes.

What I do is:

var ball_node = preload('res://scenes/ballz/Ball.tscn')
var ball = ball_node.instance()
ball.bubble_texture = textures["bubble"][size]
ball.ball_texture = textures[type][size]
ball.set_pos(self.get_pos())
ball.__update()
self.get_parent().add_child(ball)

Inside the Ball node script it checks the bubble_texture size to set it to the radius of the shape2D.

Actually it does what should do, but each time a new Ball is instanced all the created ballz update de new bubble_texture size to their shape2D radius.

It is annoying to see all the balls move as if they were haunted…

Can someone help me??

:bust_in_silhouette: Reply From: eons

The balls are all sharing the same shape Resource, that is why when you change the shape on one, changes on all of them.

You can replace the shape with a duplicate or create a new one instead of changing the size (set_shape on the body).

Thanks a lot…!

Any way I figureout that in the morning so all is working now…but thanks eons

ferhand | 2017-11-30 00:22