Hi guys, I want to create a “Measure Gun” which fires a laser beam and then prints the distance between the gun point and the hit point. Heres my code
if(Input.GetButton("Fire1")){
if(Physics.Raycast(transform.position,Vector3.forward,hit,Mathf.Infinity)){
lineRenderer.enabled = true;
lineRenderer.SetPosition(0, transform.position);
lineRenderer.SetPosition(1, hit.point);
print("Distance = " + Vector3.Distance(transform.position, hit.point));
}
}
I attached this script with the gunPoint(gameobject from which laser is fired).
But the problem here is that the other end of the laser beam gets snapped to certain points… The gunPoint end is fine but the other end is not smooth…