Topic was automatically imported from the old Question2Answer platform.
Asked By
ThreeSpark
I’m trying to make a point in my line2D follow the position of my mouse. I already have the mouse position working, but I can’t get the point to follow the mouse. If I do $Line2D.set_point_position(0, mouse_pos) it doesn’t follow the mouse, it goes to a seemingly random position.
I solved it! $Line2D.set_point_position(0, get_transform().affine_inverse() * mouse_pos)
I know this is several years late, but I was working on a sample project for myself and came across the issue you were working on here. I think I came up with maybe a simpler or better way to solve the thing you were doing - at least it’s simpler in my head.
Earlier in my code I acquired the laser’s collision point like this:
if rayCast2d.is_colliding():
laser_end = to_local(rayCast2d.get_collision_point())