Not sure how add_child works

Hi, sorry if this question is a little silly, but I’m very new to Godot and I’m not sure how add_child works.

So I’m trying to create some sort of cannon that will continuously shoot bubbles (the bubbles are a scene of their own)

Here’s the current code :

extends Node2D

var timer = 0
var bubble = "res://Scenes/Objects/bubble.tscn"

func _process(delta):

	timer += delta
	if timer >= 32 * delta:

		timer = 0
		self.add_child(bubble)

(the 32 is currently just a magic number. I will change it once I get the actual bubble spawning to work)

It gives me this error when I try to run it :
E 0:00:01:0540 bubble_gun.gd:13 @ _process(): Parameter “p_child” is null.

Thank you!!!

1 Like