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