Godot 3d Error "E 0:00:05:0814 main.gd:26 @ _process(): Condition "!is_inside_tree()" is true. Returning: Transform3D()

Godot 3d Error "E 0:00:05:0814 main.gd:26 @ _process(): Condition “!is_inside_tree()” is true. Returning: Transform3D()
Posted
Posted by mfkw1 Oct 22 at 8:28 |
I got the error message:

E 0:00:05:0814 main.gd:26 @ _process(): Condition “!is_inside_tree()” is true. Returning: Transform3D() <C++ Source> scene/3d/node_3d.cpp:345 @ get_global_transform() main.gd:26 @ _process()

In godot 4.3 when i was spawning a object then setting its position, this is my code.

func _process(_delta: float) → void:
var enimies = $Enemies.get_children()
if enimies.is_empty() == true:
print_debug(“All enimies killed, next round!”)
stage += 1
next_stage.emit(stage)
var scene = load(“res://objects/enemy.tscn”)
var enimie = scene.instantiate()
enimie.player = $Player
enimie.global_position = enime_spawns.pick_random()
$Enemies.add_child(enimie)

This was what I tried:

func _process(_delta: float) → void:
var enimies = $Enemies.get_children()
if enimies.is_empty() == true:
print_debug(“All enimies killed, next round!”)
stage += 1
next_stage.emit(stage)
var scene = load(“res://objects/enemy.tscn”)
var enimie = scene.instantiate()
enimie.player = $Player
$Enemies.add_child(enimie)
enimie.global_position = enime_spawns.pick_random()

but now it doesn’t move the object

You need to add the new enemy to the scene first and afterwards set the variables like player and position

1 Like

how do i do that?

Instead of this:

Try this:

var enimie = scene.instantiate()
$Enemies.add_child(enimie)
enimie.player = $Player
enimie.global_position = enime_spawns.pick_random()

I just changed the order of the lines