So I want to set values, like scale, of a packedscene from the editor from another scene.
I want “Candlestick” to set the scale of “Top” which is within “Body Hollow” (see below).
The problem is when I run “Body Hollow” scene everything works perfect. But, when I run “Candlestick” it just doesn’t work. I have tried using $Node instead of Signals it grabs the “Body Hollow” node, but then I get a null error on calling body_hollow.scale_x (ofcourse I slighty change the code).
The point is it acts as if “Top” does not exist!
I am trying to find an answer to such a simple problem and yet I can not.
Please help me find a solution. I am going crazy!
Thank you in advance!
Handlestick Tree
Body Hollow Tree
# Attach this to Candlestick
class_name Candlestick
extends Node2D
@export var body_hollow: BodyHollow
func _ready():
print("Candlestick is running...")
func _process(_delta):
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
body_hollow.scale_x(200)
# Attach this to "Body Hollow"
class_name BodyHollow
extends Node2D
signal scale_changed(_x: float)
func scale_x(_x: float) -> void:
scale_changed.emit(_x)
func _process(_delta):
if Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT):
scale_x(200)
# Attach this to "Top"
class_name BodyHollowHandles
extends Sprite2D
# Connect this "scale_changed" signal from "Body Hollow"
func _on_body_hollow_scale_changed(_x):
scale.x = _x
scale.y = _x
Christos Rymenidis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.