xyz
No, I wrote this code and I know every detail.
Each object randomly assigned to the scene actually has an ID number and a color.
The image below is an example of this.
Then this Line2D will get the color of each targeted object
“if get_collider().color != null:
vl.default_color = get_collider().color
dl.default_color = get_collider().color”
I used this line of code.
Then I wrote code to terminate the length of this after reaching the object, and what I explained and what I wanted actually works correctly for FirstLine, but the same features are not applied for SecondLine.
My only problem now is that the SecondLine does not detect the color of that object and the Line2D length does not end after reaching the object.
This is the problem in general.
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