+1 vote

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_linear_velocity(Vector3(x, 0, z) * SPEED)
in Engine by (254 points)

1 Answer

+2 votes
Best answer


It's add_child

Boy do I feel stoopid...

by (254 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.