Hello, I have 2 classes (Player, Projectile) and I want to change the spawning position of the Projectile depending on the facing direction of Player. I put a signal in Player for that :
Player.gd
extends CharacterBody2D
signal is_facing_right
func handle_flip():
is_facing_right.emit(false) # or true
I then catch the signal in Projectile
Projectile.gd
extends CharacterBody2D
class_name Projectile
var starting_orientation : bool
func _ready():
parent.connect("is_facing_right", _on_facing_right)
set_starting_position()
func set_starting_position():
print("set_starting_position() : " + str(starting_orientation))
if !starting_orientation:
position = parent.position + Vector2(-starting_offset, 0)
elif starting_orientation:
position = parent.position + Vector2(starting_offset, 0)
func _on_facing_right(value: bool):
print("_on_facing_right() : " + str(starting_orientation))
starting_orientation = value
But when I call it, starting_orientation doesn’t change

Can you show the code where handle_flip is called?
Also it does change? It says false after setting it when set_starting_position is called
It won’t change before you set it
This is before you set it in
@athousandships
Player.gd (just the useful part)
func _physics_process(delta):
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
handle_flip()
func handle_flip():
if Input.get_axis("ui_left", "ui_right") < 0 && !find_child("Sprite2D").flip_h:
find_child("Sprite2D").flip_h = true
scale.x = -scale.x
is_facing_right.emit(false)
elif Input.get_axis("ui_left", "ui_right") > 0 && find_child("Sprite2D").flip_h:
find_child("Sprite2D").flip_h = false
scale.x = -scale.x
is_facing_right.emit(true)
The signal works fine, it’s just Projectile that I can’t understand for now
I don’t see any issue in projectile, it works as expected from the output, when do you want the variable to change instead?
@athousandships
When I need to change the position of Projectile in set_starting_position()
But maybe I need to change the position before instantiate it so I think you were right !
EDIT : I just needed to edit the parent class before it instantiated, before the position were calculated after the instanciate()