- Home /
Question by
easygaming · Jan 21, 2016 at 09:34 AM ·
raycasthitdrawline
Debug.Drawline position is slightly over the clicked position
When I draw a line to the hit point by raycasting, it is drawn slightly upper position constantly than where the mouse button is clicked. It is also same when I use 'DrawRay' instead.
Did I miss something in the code below? Thanks for any of your help in advance.
if (Input.GetMouseButton(0))
{
Ray ray;
RaycastHit hit;
Vector3 vt = Input.mousePosition;
ray = Camera.main.ScreenPointToRay(vt);
var lm5 = (1 << layMan);
if (Physics.Raycast(ray, out hit, float.MaxValue, lm5))
{
Debug.DrawLine(transform.position, hit.point, Color.yellow, 1.5f);
}
}
PS. You can see the yellow line upper than the center point that I clicked in the below picture.
Comment
Your answer
Follow this Question
Related Questions
How to register if my Raycast hits nothing(Solved) 2 Answers
Hit distance Change light range 1 Answer
How to hit two object with one raycast? 2 Answers
Need help with Third person shooter 0 Answers
Help Playing "Sound Clip" on RayCastHit? (RayCast help?) 2 Answers