I want to add another ball in the game as soon as the ball hits the power up.(pong game)

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

hello I’m making a super pong game that has a power up that adds another ball to the game. The next ball should appear in the center of the screen.

    extends Node2D

var collect = false


func _physics_process(delta):
	$Area2D/AnimatedSprite.play("Spin")



func _on_Area2D_body_entered(body):
	print(body.name)
	if body.name=="Ball"&&collect==false:
		collect = true
		$Collection.play()
		$AnimationPlayer.play("Fade")
		$Area2D/AnimatedSprite.stop()
		var ball =  load("res://ball/Ball.tscn").instance()
		ball.global_position = Vector2(0,0)

the orb plays the animation and sounds but the ball doesn’t load into the game.

:bust_in_silhouette: Reply From: exuin

You will need to add the ball into the scene tree. Call the add_child() method on the node you would like to be the parent of the ball.