Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | twinpixel | |
Old Version | Published before Godot 3 was released. |
Hi guys,
I’m following Andreas Esaus tutorial on the tool mode:
Here is my code:
tool
extends Area2D
export(String, "A", "B") var keyname = "A" setget set_newkeyname
func _ready():
if !get_tree().is_editor_hint():
print(keyname)
func set_newkeyname(newkeyname):
keyname = newkeyname
if keyname == "A":
get_node("Sprite").set_frame(0)
elif keyname == "B":
get_node("Sprite").set_frame(1)
Switching the keyname/frame within the editor works as expected, but as soon as I press play scene an error is thrown:
Attempt to call function ‘set_frame’ in base ‘null instance’ on a null instance.
What am I doing wrong?
tool scripts are confusing because they work differently than normal scripts. Maybe get_node() doesn’t work inside the editor? I’d look up some other tool scripts for reference.
batmanasb | 2016-04-11 10:51