Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Lapsyy |
I want to change my timer’s time in another scene, my code is currently like this
func _on_btn_easy_pressed():
get_node("/root/world/spawner_enemy").time = (2.5)
get_tree().change_scene("res://stages/stage_game.tscn")
pass
while my code on the spawner_enemy, i have
var time = 2.5 setget set_time
func set_time(new_value):
time = new_value
$Timer.wait_time = time
pass
but all i get is node not found: /root/world/spawner_enemy
or Invalid set index ‘time’ (on base: ‘null instance’) with value of type ‘float’.
help?
In which scene is your spawner_enemy
? If it is in stage_game
, you should move your line of code after you changed to that scene. Before, the node is not here because it’s not added yet.
Zylann | 2019-03-29 13:46
The error “Invalid set index ‘time’ (on base: ‘null instance’) with value of type ‘float’.” appears when i do that
Lapsyy | 2019-03-29 14:01
The code you posted shows the opposite. In any case, it means the node is not currently in the scene when you call it (or not at the correct path).
Zylann | 2019-03-29 19:30