|
|
|
|
|
|
{ |
|
|
|
public bool isFired; |
|
|
|
public float maxLength = 25f; |
|
|
|
public float width = 0.5f; |
|
|
|
public float width = 1f; |
|
|
|
public bool animate = false; |
|
|
|
LineRenderer laserRenderer; |
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
|
laserRenderer.SetWidth(width, width); |
|
|
|
laserRenderer.material.SetTextureScale("_MainTex", new Vector2(0.07f, 1.0f)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
laserRenderer.SetWidth(width, width); |
|
|
|
laserRenderer.material.SetTextureOffset("_MainTex", new Vector2(-3 * Time.time, 0.0f)); |
|
|
|
laserRenderer.material.SetTextureOffset("_MainTex", new Vector2(-6 * Time.time, 0.0f)); |
|
|
|
if (Physics.Raycast(transform.position, transform.forward, out hit, maxLength)) |
|
|
|
if (Physics.SphereCast(transform.position, width, transform.forward, out hit, maxLength)) |
|
|
|
laserRenderer.SetPosition(1, new Vector3(0f, 0f, hit.distance / transform.lossyScale.z)); |
|
|
|
float hitLength = Vector3.Distance(hit.point, transform.position); |
|
|
|
laserRenderer.SetPosition(1, new Vector3(0f, 0f, hitLength / transform.lossyScale.z)); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|