Hello. What am I doing wrong? Here is the code and screenshots with my problem(
When the beam hits the object, it is reduced.
P.S. Im not use WorldSpace coordinate
public class Emitter : MonoBehaviour {
private LineRenderer lr;
void Start ()
{
lr = GetComponent<LineRenderer>();
}
void Update ()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit))
{
if (hit.collider)
{
lr.SetPosition(1, new Vector3(0, 0, hit.distance));
print("Hit: " + hit.distance);
}
}
else
{
lr.SetPosition(1, new Vector3(0, 0, 100));
}
}
}

