Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Godot: star spawning and re-routing the star_taken signal to the main scene
extends Node2D
export (PackedScene) var Star
signal star_was_taken
export (int) var total_stars = 0
export (int) var stars_found = 0
func _ready():
var pos_curve = $ItemPositions.get_curve()
total_stars = pos_curve.get_point_count()
for i in range(0, total_stars):
var star = Star.instance()
star.position = pos_curve.get_point_position(i)
star.connect("star_taken", self, "on_star_taken")
func on_star_taken():
stars_found += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment