Invalid call. Nonexistent function 'add_node' in base 'Spatial (main.gd)'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By imekon
:warning: Old Version Published before Godot 3 was released.

I’m try to create an instance of a scene, and I’m getting the above error. The top level node is a Spatial and it won’t let me add a child node to it?

Here are some variables used later:

onready var main = get_tree().get_root().get_node("main")
onready var ballScene = preload("res://ball.scn")

This function fires the ball:

func fire_ball():
    var ball = ballScene.instance()
    var x = sin(deg2rad(-yaw))
    var z = -cos(deg2rad(yaw))
    var pos = get_translation() + Vector3(x, 0, z) * 5
    ball.set_translation(pos)
    ball.set_linear_velocity(Vector3(x, 0, z) * SPEED)
    main.add_ball(ball)
:bust_in_silhouette: Reply From: imekon

D’oh!

It’s add_child

Boy do I feel stoopid…