extends Node # TODO: this just doesn't work ## Star scene @export var star : PackedScene ## Affects how many stars will be generated and places on whole system @export var stars_amount = 1000 ## Affects how much space on borders of the star system will be empty @export_range(0, 1) var compress_space_amount = 0.1 ## Shortcut to get_parent() @onready var star_system: StarSystem = get_parent() func _ready(): var compress_multiplier = 1.0 - compress_space_amount var parallax_layers = get_children() var width_halved = star_system.width / 2 var height_halved = star_system.height / 2 for i in range(stars_amount): var star_inst = star.instantiate() var x = randi_range(-width_halved, width_halved) * compress_multiplier var y = randi_range(-height_halved, height_halved) * compress_multiplier # Decides parallax layer which star belongs to var distance = randi_range(0, get_child_count() - 1) parallax_layers[distance].add_child(star_inst) var position = Vector2(x, y) star_inst.position = position print(position)