Question by 
               LLIV · Feb 07, 2016 at 08:32 PM · 
                scripting problemscript errorscriptingproblem  
              
 
              Can't get script to repeat
 using UnityEngine;
 using System.Collections;
 [RequireComponent(typeof(LineRenderer))]
 public class Roller : MonoBehaviour {
     public int angle_Neg;
     public Animator Anim;
     private GameObject PlayerOBJ;
     private LineRenderer LR;
     private Transform LE;
     private bool Following = false;
     protected Transform Head,LO;
     public float Charge;
     private bool Fire;
     public float RequiredCharge;
     private float StartTime = -1f;
     public bool Debugging = false;
     public Color Start_C;
     public Color Stop_C;
     public float Cooldown;
     void Start () {
 //        Anim = GetComponent<Animator>();
         LR = GetComponent<LineRenderer>();
         Head = transform.GetChild(1).transform; //Get the head
         LO = Head.GetChild(0).transform;
     }
     void Awake () {
         PlayerOBJ = Settings.PlayerOBJ;
     }
     void Update () {
         if (PlayerOBJ == null ) {
             PlayerOBJ = Settings.PlayerOBJ;
         }
         
 //        Anim.SetBool("ScriptControlsHead",false);
         if (this.transform.GetComponent<AIPath2DTopDown>().CanSeePlayer){
 //        if (!Physics.Linecast (transform.position, PlayerOBJ.transform.position)) {
             FollowPlayer();
             if (!Following) {
                 Following = true;
                 
             }
             if (Following&&StartTime==-1f){
                 StartTime = Time.time;
                 if (Debugging) {Debug.Log (StartTime+"Starting");}
 //                LR.SetColors(Start_C,Stop_C);
             }
             if (StartTime + RequiredCharge > Time.time &&!Fire){
                 float a = Mathf.Lerp(0f,1f,Time.time/RequiredCharge);
                 float c = Mathf.Lerp(0.1f,.01f,Time.time/RequiredCharge);
                 LR.SetWidth(.01f,c);
                 Start_C.a = a;
                 Stop_C.a = a;
                 LR.SetColors(Start_C,Stop_C);
             } else {
                 Fire=true;
                 LR.enabled= false;
                 
                 if (Debugging) {Debug.Log (Fire+"Fire");}
                 float a = Mathf.Lerp(1f,0f,Time.time/RequiredCharge);
                 Start_C.a = a;
                 Stop_C.a = a;
                 LR.SetColors(Start_C,Stop_C);
                 StartCoroutine( Cool());
             }
         } else {
             Following = false;
             LR.enabled = false;
             StartTime = -1f;
             LR.SetWidth(.01f,.1f);
             
         }
     }
     void FollowPlayer () {
         // angle_Neg was added for testing it's just 90deg (to offset the rotation to what it is now)
         LR.SetPosition(0,LO.position);
         LR.SetPosition(1,PlayerOBJ.transform.position);
         Vector3 dir = PlayerOBJ.transform.position - LO.position;
         float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
         Head.rotation = Quaternion.AngleAxis(angle-(angle_Neg), Vector3.forward);
     }
     IEnumerator Shoot () {
 //        if (Fire){LR.enabled= true;}
         LR.SetPosition(0,LO.position);
         LR.SetPosition(1,PlayerOBJ.transform.position);
 //        if (Fire) {yield return new WaitForSeconds(.5f); Fire = false; } else {
 //            LR.enabled = false;
 //        }
         return null;
     }
     int JE = 0;
     IEnumerator Cool () {
         if (JE < 1){
         JE += 1;
         LR.enabled= false;
         yield return new WaitForSeconds(Cooldown);
         } else {
         StartTime = -1f;
         Following = false;
         LR.enabled= true;
         Fire = false;
         JE = 0;
         }
     }
     
 }
I can't get this script to repeat. It runs correctly once but then just dies on me.
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                