The question is answered, right answer was accepted
Physics2D.Raycast problems with vectors
Hello, I have problems with raycast vectors. They are simply directed to some other way On the picture the origin of the blue line is in the center and the script is Testhit=Physics2D.Raycast(oaoao.position, Player.position); Debug.DrawRay (oaoao.position, Player.position , Color.blue);
(Player is the guy to the left). I fixed it by subtracting the vector between them but I want to know why is this happening to get more easy way of fixing Im new at Unity, please help
Answer by DCordoba · Feb 07, 2019 at 10:41 PM
as can be seen on manual, Raycast dont take (Startpoint, Reachpoint) this is linecast, raycast take (Startpoint, Direction)
using descartes, substraction of vector A - vector B gives you the resultant that conect the two vectors, you can use the value to get direction or its magnitude to get distance between them