- Edited
I'm trying to replicate the way the Line in the panels of The Witness works.
I got 2 different approaches working one using tiles and another one using a Line2D with a head composed by 4 raycast that collide with the tiles of a collision tilemap.
https://github.com/IIGreed/Witness-Line
The last one is the one that looks the best, because the line doesn't snap from tile to tile it grows as you move the mouse. But snapping the mouse to one axis in order to get the pefect tile cordenades so I can backtrack is giving me some trouble unlike the first Tilemap version and I think that my approach with the raycast is a mess. Does anyone have Ideas of how to improve this?
The problems to solve are:
When changing from moving in the X axis to the Y axis the head of the line can get off-center
I guess I could using 8 raycast one on every corner, but this would make fitting into spaces like this where you don't have a corner to align perfectly, hard to fit in.
The reason why the Raycast is so long is because if it wasn't colliding at all times to tell me the distance at times the line go throught the collisions because I was positioning the line pass where it needed to collide.
Other problem is the backtrack but I imagine once I fix the first problem related to the snapping of the line I will always get the same Position when I travel to a tile so I can just check for the last tile in the "route" array holding all the points position and if you are backtracking remove the last point in the line, hopefully this would be seamless and there would be no snapping.