Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Timofey |
I want to create a laser, but the end of the line is magnetized to a certain point
extends RayCast2D
func _ready() -> void:
$Line2D.points[0] = Vector2.ZERO
$Line2D.points[1] = Vector2.ZERO
func _physics_process(_delta: float) -> void:
if Input.is_action_pressed("LMB"):
enabled = true
look_at(get_global_mouse_position())
$Line2D.points[0] = position
var colPoint := get_collision_point()
print(colPoint)
$Line2D.points[1] = to_local(colPoint)
else:
enabled = false
$Line2D.points[0] = Vector2.ZERO
$Line2D.points[1] = Vector2.ZERO
preview: https://drive.google.com/file/d/19LV5phdF3h7b4CGzePVmBgppk1x-wrY1/view?usp=sharing