- Home /
Question by
GutoThomas · Feb 28, 2012 at 07:27 AM ·
physicslinecast
LineCast always returning true
Hey guys. I don't know what I'm doing wrong because my Linecast method always return true. Even in situation like the one in the print;
Heres the code I'm using for debug:
using UnityEngine;
using System.Collections;
public class tests : MonoBehaviour {
public Transform To;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Physics.Linecast(transform.position, To.position)) {
Debug.DrawLine(transform.position, To.position);
print("Something between");
} else {
print("Clear");
}
}
}
Hope you guys can help me '-' Thanks from now!
Comment
Answer by Eric5h5 · Feb 28, 2012 at 08:30 AM
Use the RaycastHit parameter, so you can do print (hit.collider.name);
and see what it's hitting.
Your answer
![](https://koobas.hobune.stream/wayback/20220613064552im_/https://answers.unity.com/themes/thub/images/avi.jpg)