I’m not sure if this is possible, but is it possible for values of a node to be linked in a way?
(for context 'm on the newbie side)
For example let’s say I have two Node2Ds, and I want both of them to have the same scale, that way if I set one’s scale to 2, the other will reflect that as well.
Weather that’s possible or not, is it possible to have a parent node pass it’s certain values down to it’s children live?
In my example I have two ColorRect nodes beneath a Node2D, currently I have something like this:
@onready var terrain: ColorRect = $Terrain
@export var timeSpeed = 0.5
func _ready():
terrain.material.set_shader_parameter("time_speed", timeSpeed)
And though this works when run, it doesn’t show visual changes in the editor.(I’m doing a lot of shader work so I need to constantly check visual changes)
What you can do is add both nodes to the same group and use get_tree().call_group() to set both nodes at the same time, example:
# Let's suppose you have the node_1 and node_2,
# both with this script attached.
func _ready() -> void:
add_to_group("my_group")
func set_shader_param(p_value) -> void:
material.set_shader_parameter("param", p_value)
# In any place you want to adjust both nodes at the same time
func call_both_nodes() -> void:
# Set both node scale to 2
get_tree().call_group("my_group", "set", "scale", Vector2(2, 2))
# Call set_shader_param on both nodes
get_tree().call_group("my_group", "set_shader_param", 10)