xyz
I set the Raycast2Ds as you said and the second Raycast is now active and the second Raycast is now visible and working the way I want it to.
But the problem here is that now the SecondLine color added to the second Raycast is not the same as the first one.
I think the second Raycast does not have the properties of the first Raycast.
How can I fix this, my code is below.
extends RayCast2D
@onready var vl = $FirstRay
@onready var dl = $SecondRay
@onready var one = $FirstRay/FirstLine
@onready var two = $SecondRay/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())
one.default_color = default_color
two.default_color = default_color
one.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:
one.default_color = get_collider().color
two.default_color = get_collider().color
else:
one.default_color = default_color
two.default_color = default_color
one.points[1].x = collision_point.x
dl.visible = false
else:
one.default_color = default_color
one.points[1].x = vector_line_length
dl.visible = false
else:
vl.visible = false
dl.visible = false