Hi all !
I need help to solve a vector 2D problem. In my project, a 2D isometric game, I'm trying to implement the gun fire logic. The player aims using his mouse cursor in a way that when he shoots, the "bullet" follow a line that starts from his position and ends on the mouse position.
For that I use Raycasting technique as explained in https://docs.godotengine.org/en/3.0/tutorials/physics/ray-casting.html and the method
Dictionary intersect_ray ( Vector2 from, Vector2 to, Array exclude=[ ], int collision_layer=2147483647 )
For the moment, it works very well, collisions are detected correctly but only between the player position and the mouse position. What I want instead is to find the coordinates of the intersection point between the "line" formed by the player position, the cursor position and the map boundaries. So the second point that I'll pass to
intersect_ray will be located somewhere on the boundaries of the map. In this way the collisions will be checked from the player position and until the line reach the map boundaries.
Just to be sure you can check the images bellow to clarify what I'm talking about. Just imagine that the image borders are the map boundaries.
this is what I have currently
this is what I want
I don't know how to approach the problem. Have you idea ? Do you have any ideas ?