I've got a 2d top-down space game, visually similar to Space Rock, which y'all know very well
I have a randomly spawned enemies and a want to spawn them by two and have drawn a line between them. This line moves and changes it's length relatively to the positions of spawned NPC's and move with them together.
Also I've got a RayCast2D node, which should check if something collide with this line between NPC's. I tried to do this.
I added node RayCast2D as a child to node Line2D.
func _process(delta: float) -> void:
if is_instance_valid(target1) and is_instance_valid(target2):
points = to_local(target1.global_position)
points = to_local(target2.global_position)
target1 and 2 are positions of the 2 NPC's, where the line has points. And when I try to set the position of a raycast and to set it's cast direction it just sets the position correctly(or maybe it's already set well because it's child node) but the cast direction is located somewhere far in space, and I have generally no idea, why. I can provide any further info, and... thanks in advance.