please help me to clear this error(coroutine(Firelaser)couldn’t be started).i get it when i play game.here is the script.laser is not working .help plz its my final year project
LASER SCRIPT
using UnityEngine;
using System.Collections;
public class laserscript : MonoBehaviour {
LineRenderer line;
void Start ()
{
line=gameObject.GetComponent<LineRenderer>();
line.enabled=false;
Screen.lockCursor=true;
}
void Update ()
{
if(Input.GetButtonDown("Fire1"))
{
StopCoroutine("FireLaser");
StartCoroutine("FireLaser");
}
}
IEnumerator firelaser()
{
line.enabled=true;
while(Input.GetButton("Fire1"))
{
Ray ray=new Ray(transform.position,transform.forward);
line.SetPosition(0,ray.origin);
line.SetPosition(1,ray.GetPoint(100));
yield return null;
}
line.enabled=false;
}
}