Hey there!! ^^ I did this little and simple code and in the inspector the Debug.DrawLine, Draws a huge
diagonal green line … Now, the code still returning the data from the if statement … in other words everything works fine … but why it does make a diagonal and so large diagonal line? Is that fine? o.O
What’s the line supposed to represent? You’re passing the touch position as the first parameter, that’s “The position of the touch in pixel coordinates”, a Vector2 that will have any value inside your phone’s screen resolution.
hit.point, in the other hand is returnig a world position.
Now, Debug.DrawLine expects values in world position, it draws a line in the world from the first parameter to the second one. Your first parameter is being interperted as a world position, probably far away from your camera. So you get a line that comes from some far away point and ends in the hit point.
So, again, what’s that line supposed to display? What you send as the first parameter depends on that answer.
Also, Debug.DrawLine and Physics2D.Raycast are not related in any way, the fact that DrawLine shows something weird doesn’t mean you should worry about the raycast working or not, you’re just drawing the line in the wrong way.