instance of floor not spawning

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

i’m trying to basically generate connecting rooms but i can’t get the instanced scene to spawn, the is the code i am working with.

extends Node

var instanced_Floor = preload("res://assets/scenes/floor.scn");
var floor1 = instanced_Floor.instance();

func generate():
    floor1.set_transform(0,0,0);
    get_parent().add_child(floor1);

func _ready():

    pass

Why does it occur to me that generate is never called?

Bojidar Marinov | 2016-03-23 09:11

it doesn’t work anyways

extends Node

var instanced_Floor = preload("res://assets/scenes/floor.scn");
var floor1 = instanced_Floor.instance();

func generate():
    floor1.set_translation(Vector3(0,0,0));
    get_parent().add_child(floor1);

func _ready():
    generate()
    pass

1997 | 2016-03-23 12:58

Can you add a TestCube at (0,0,0), and ensure it is visible by the camera?

Bojidar Marinov | 2016-03-23 13:45

i can guarantee that the floor mesh is visible, it’s just not spawning. also i have other floating objects in the scene so the camera is working.

1997 | 2016-03-23 14:35

anyone have any ideas?

1997 | 2016-03-28 17:44

@1997 What happens when you move var floor1 = instanced_Floor.instance(); inside func generate():?

Bojidar Marinov | 2016-03-29 08:03

:bust_in_silhouette: Reply From: 1997

so basically I don’t know how I got it to work but here is the working code.

extends Node

 var room = preload("res://assets/scenes/floor.scn");

func generate():

    var room_intance = room.instance();
    room_intance.set_name("room")
    room_intance.set_translation(Vector3(0,4,0));
    add_child(room_intance);

func _ready():
    generate()
    pass