I want to make a Bubble Shooter style work with Godot 4.3. First of all, I drew a virtual line to target objects from the bottom and first I created RayCast2D and then I added 2 Line2Ds as its child node. As you can see in the video below, the first line works and takes the color of the object I am targeting, but the second virtual line is active as a continuation of the first line when I target the edges, but it does not detect objects and after reaching the object, it does not take the color of the object and does not end its length. How can I solve these two problems?
Thank you for your help.
Screenshot:
My Code:
extends RayCast2D
@onready var vl = $FirstLine
@onready var dl = $SecondLine
var vector_line_length = 600
@onready var manager = $"../../../Manager"
var default_color: Color = Color(0.388,0.643,0.969,1)
func _physics_process(_delta: float) -> void:
if not $"../../Control3".was_shooted or not $"../../Control4".was_shooted or not $"../../Control5".was_shooted:
vl.visible = true
dl.visible = true
if $"../../Control3".can_be_shot or $"../../Control4".can_be_shot or $"../../Control5".can_be_shot:
look_at(get_global_mouse_position())
if is_colliding():
if not manager.items.has(get_collider()):
var collision_point = to_local(get_collision_point())
vl.default_color = default_color
dl.default_color = default_color
vl.points[1].x = collision_point.x
dl.position = collision_point
dl.rotation_degrees = (rotation_degrees * 2) * -1
dl.visible = true
else:
var collision_point = to_local(get_collision_point())
if get_collider().color != null:
vl.default_color = get_collider().color
dl.default_color = get_collider().color
else:
vl.default_color = default_color
dl.default_color = default_color
vl.points[1].x = collision_point.x
dl.visible = false
else:
vl.default_color = default_color
vl.points[1].x = vector_line_length
dl.visible = false
else:
vl.visible = false
dl.visible = false