I was writing a piece of code to set the endpoint of a linerenderer to equal the hitpoint of a raycast. Halfway through, I discovered that the raycast itself doesn’t recognize gameobjects or even transforms. When I try to print hit.point, it gives me 0, 0, 0. If I try to return hit.transform, it gives me a null message. I don’t know what’s going on with this.
private var ray : Ray;
private var hit : RaycastHit;
function Update () {
var fwd = transform.TransformDirection (Vector3.forward);
//var lineRenderer : LineRenderer = GetComponent(LineRenderer);
if (Physics.Raycast (transform.position, fwd)) {
//lineRenderer.SetPosition(hit.point);
print(hit.point);
}
}
I commented out the parts dealing with the linerenderer. I haven’t really gotten into that part yet because of the problems I’m having with the raycast.