[Solved] Invalid call. Nonexistent function 'set_global_pos' in base 'bool'.

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

Hey.

I have another problem with one of my scripts. I get the error “Invalid call. Nonexistent function set_global_pos in base ‘bool’.”
The node char_menu is a subscene with a node2d as root.
If menu_act gets true, there is no problem. It moves the subscene to 0, 0. But if it gets false i get the error in the line of the first if statement.

the editor also gives me set_global_pos as suggestion with the variable. so i don’t know what is wrong there. also tried it with set_hidden(), same result :frowning:

Do I overlook something?

extends Node2D

onready var n_menu = get_node("char_menu")
var menu_act = false


func _ready():
	set_fixed_process(true)
	
func _fixed_process(delta):
	if menu_act:
		n_menu.set_global_pos(Vector2(0,0)) #### ERROR
		get_tree().set_pause(true)
	else:
		n_menu.set_global_pos(Vector2(0,-2000))

Thank you!

:bust_in_silhouette: Reply From: bobokox

Oh my god. I feel so stupid. Spending hours now to search for the reason. Another script overwrotes the variable as a bool… maybe i should go to bed…

Sleep is a good thing. =3

avencherus | 2017-04-04 21:53