0 votes

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)
asked Aug 19, 2017 in Engine by imekon (229 points)

1 Answer

+1 vote
Best answer

D'oh!

It's add_child

Boy do I feel stoopid...

answered Aug 19, 2017 by imekon (229 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.