Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DanniloSN | |
Old Version | Published before Godot 3 was released. |
I need help with a script instances, here the code:
#Script instructions
extends Node
var currentScene = null
var PlayerName = "Mike"
func _ready():
currentScene = get_tree().get_root().get_child(get_tree().get_root().get_child_count() -1)
Globals.set("MAX_POWER_LEVEL",9000)
func setScene(scene):
currentScene.queue_free()
var s = ResourceLoader.load(scene) #ERROR HERE ERROR HERE
currentScene = s.instance()
get_tree().get_root().add_child(currentScene)
func getPlayerName():
return PlayerName
# Script call
extends Node
func _ready():
set_process(true)
func _process(delta):
if(Input.is_mouse_button_pressed(BUTTON_LEFT)):
get_node("/root/global").setScene("res://Scenes/in_game_bot")
Edited by moderator: Please use code formatting (see the “{ }” button).
Did you double check that this path and filename is correct? “res://Scenes/ingamebot”
atze | 2016-07-26 06:29
am getting the same error but on the s.instance. Please help.
Attempt to call function ‘setScene’ in base ‘null instance’ on a null instance. (Error)
showing this error at :
get_node(“/root/global”).setScene(“res://SecondScene.scn”)
and i also tried, get_node(“/root/global”).setScene(“res://SecondScene.tscn”)
yeeshu06 | 2017-02-20 11:02