Having trouble setting unique properties per instance

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

im just messing around trying to get familiar with godot in general, and i keep coming across a similar problem, an example is:

extends Area2D

@onready var texture_rect = $TextureRect
@onready var collider = $CollisionShape2D

@onready var length = texture_rect.get_size().x

func _ready():
	collider.shape.set_size(Vector2(length, 4))
	collider.set_position(Vector2(length/2, 7))

My issue is that whenever this node is instanced, it sets the CollistionShape2D’s size for every instance, rather than just for the current one. How can i set properties to be exclusive for each instance?

:bust_in_silhouette: Reply From: gate120

Set the shape in the CollsionShape2D Local to Scene in the editor.

enter image description here

Thanks! :smiley: appreciate it

DofDeef | 2023-04-10 10:05