0 votes


I am new to Godot so I am sure I am making a simple, stupid mistake, any help is much appreciated.

I am trying to make a node that regularly spawns platforms off screen that will move until they are queue_freed when they make it to the other side of the screen. I am having difficulty when trying to call the .instance method.

I have tried a few different ways to call the floor node variable into the spawning script to no avail. Please help! :)

I am receiving the following error when trying to instance new platforms:

Invalid call. Nonexistant function 'insance' in base 'RigidBody2D'

Godot version: 3.2.1.stable.official

Local Tree:

  • FloorSpawn (Node2D)
    ---- Timer
    ---- Floor (RigidBody2D)

Script (attached to node root):

extends Node2D

onready var new_floor = $Floor

func _on_Timer_timeout():
    var new_floori = new_floor.instance()


extends RigidBody2D

export var speed = -100

func _physics_process(delta):
    move_local_y(delta * speed)

func _on_DieArea_area_entered(area):
in Engine by (12 points)

1 Answer

+3 votes

Your new_floor variable is a reference to an existing node "Floor". Nodes have no such method as instance().

instance() is a method of PackedScene - it takes a saved scene and creates all of its nodes/scripts/etc.

If you want to make a copy of an existing node, you can use duplicate(). Or you can save the floor object as a .tscn and then instance() it as many times as you need.

by (21,932 points)

Aight that makes sense, thank you!!

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 Frequently asked questions and 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 [email protected] with your username.