Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | touqeer11 | |
Old Version | Published before Godot 3 was released. |
So, I just wanted to make a “build” function that creates an instance of the building (given as parameter to this func. and right now its only ‘House’). I made another scene ‘House.tscn’ and a kinematicBody2D node ‘House’, but that requires its scene path to create its instance on clicking the left mouse button.So I created a variable in House’s script that stores the scene path(“res://Scenes/House.tscn”).But to get that variable in my ‘World’ script when I enter the correct node path it gives me error “Attempt to call function ‘get_node’ in base ‘null instance’ on a null instance.”
I tried get_node(“…/House”) and get_node(“/root/House”) but they aren’t working. But when I instanced the House scene as World’s child and tried get_node(“/House”) it worked. I used the get path func. in House’s script and that gave me ‘/root/House’ .
I’m new to godot (this is my first que on the forum) , so I may be doing something ridiculously wrong without knowing it.!
error in World script
House script