extends Node2D

var Water: Node2D
var water_spawned = false
var a = false
# Called when the node enters the scene tree for the first time.
func _ready():
	Water = load("res://firstlevel/Water/Water.tscn").instance()


func _on_WaterSpawn_body_entered(body):
	if body.name == "Player":
		if body.Speed < 0 and water_spawned: # Left
			for child in get_parent().get_children():
				if child.name == "Water":
					child.queue_free()
					water_spawned = false
		else: # Right
			get_parent().add_child(Water)
			water_spawned = true
