Hello,
I have this script which should create a raycast and print the exact line of the raycast.
Debug.DrawRay(this.transform.position, new Vector3 (1, 1, 0)*7,Color.red,3.0f);
RaycastHit2D hit = Physics2D.Raycast(this.transform.position, new Vector3 (1, 1, 0), 7, hookUpMask);
if (hit.collider != null) {
float distance = Mathf.Abs(hit.point.y - transform.position.y);
Debug.Log (distance);
}
Debug.Break ();
Even though, I have some cases which I can see the line hits the box, but the hit.collider is null...
I attach a couple of images (2D view) which did not trigger the hit.
Obviously it works if the line goes deeper on the box, but not in this case.
Could you help me?
![alt text][1]
![alt text][2]
Thanks.
[1]: /storage/temp/69794-captura-de-pantalla-2016-05-10-a-las-211306.png
[2]: /storage/temp/69795-captura-de-pantalla-2016-05-10-a-las-211311.png
↧