Godot Version
4.3
Question
I have a hard time to figure out proper syntax between variables, nodes and propertys. There is 2 main things I would like to know :
1 why sometime accessing a node need some “” and dont need it some other time. like $“node” ??
I would like to figure out the proper syntax to access nodes, variables and propertys in my scripts.
2 how to read a node property in gdscript ? let me explain this one with an example : I want to delete my node after a tween. I am fading a light after scaling it up (to make a kind of flashing effect when some laser hit something).
I tryed with light.“energy”, light.energy() and a lot of stuff like $light.energy and with or without the getnode() and nothing seems to work. I’'ve searched that one on the net but all the informations I get is how to set a property and not read it.
func _process(_delta: float) → void:
var tween = create_tween()
tween.tween_property($PointLight2D, “scale”, Vector2(3,3), 0.5)
tween.tween_property($PointLight2D, “energy”, 0, 0.5)
var light = get_node(self.PointLight2D)
if light.energy <= 0.1 :
queue_free()
This is the error I get with this code :
Invalid access to property or key ‘PointLight2D’ on a base object of type ‘Node2D (laser_impact.gd)’.
thank you