extends Node2D var fish = CharacterBody2D var life var lifePositon = 0 var lives = 1 # Called when the node enters the scene tree for the first time. func _ready(): life = preload("res://Scenes/Life.tscn") fish = get_tree().get_first_node_in_group("Fish") #fish # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if fish == null: fish = get_tree().get_first_node_in_group("Fish") #fish lives = fish.lives if get_child_count() < lives: var instance = life.instantiate() instance.position = Vector2(lifePositon, 0) add_child(instance) lifePositon += 108 if get_child_count() > lives && lives >= 0: var child = get_child(lives) child.queue_free() lifePositon -= 108 if lives < 0: get_tree().paused = true