- Home /
 
Barrier script and adding points
I've been following a "make your own cod zombies" tutorial but sadly there hasnt been a video in months so I'm adding the other features in myself. My script is using UnityEngine; using System.Collections;
 public class boardScript : MonoBehaviour {
     public int boards, previousBoards;
     public Animator[] boardAnim;
     public GameObject[] board;
     public AudioClip repairSound;
     public AudioClip bangSound;
     public int pointValue;
     public static int fakeround;
     public static int fakecounter=0;
     // Use this for initialization
     void Start () {
         boardAnim = GetComponentsInChildren<Animator> ();
         for (int i = 0; i < 6; i++)
         {
             boardAnim[i].Play ("boardAnimation" + (i+1).ToString());
         }
         boards = 6;
 
     }
     
     // Update is called once per frame
     void Update () {
         fakeround = GameManagement.roundCounter * 5;
     }
 
     void AddBoard()
     {
                 if (boards < 6) {
                         GetComponent<Renderer> ().enabled = true;
                         board [boards].SetActive (true);
                         boardAnim [boards].Play ("boardAnimation" + (boards + 1).ToString ()); 
                         boards += 1;
                         GetComponent<AudioSource> ().PlayOneShot (repairSound, 1.0f / GetComponent<AudioSource> ().volume);
                         Invoke ("SlamSound", 1f);
                         StartCoroutine (points ());
                         fakecounter += 1;
                         if (fakecounter == fakeround) {
                         StopCoroutine (points ());
                         }
                 }
         }
 
     IEnumerator points(){
         GameManagement.AddPoints(pointValue);
         yield return(0);
         }
 
     void RemoveBoard()
     {
         if(boards > 0)
         {
             board[boards-1].SendMessage("DisableBoard",SendMessageOptions.RequireReceiver);
             boards -= 1;
             
             if(boards == 0)
                 GetComponent<Renderer>().enabled = false;
 
         }
     }
 
     void SlamSound()
     {
         GetComponent<AudioSource>().PlayOneShot (bangSound, 1.0f / GetComponent<AudioSource>().volume);
     }
 }
 
 
 
 
 
 
 
 Now notice where the IENumerator is.  That is called for every board as to "add points" for repairing barriers.  Well as in zombies, they only allow this a certain amount of times each round. I tried to do this by stopping the courutine however it still gets called when repairing barriers.  I really need help with this. I'm lost as to how else to approach this
 
              
               Comment
              
 
               
              You have an awful lot of errors in there, improper syntax etc. I think we could help you easier if it actually worked at least a bit.
It does work actually , perfectly. It's part of a series of scripts.I got it working though. I had it in the answers but I guess it never updated
Your answer
 
             Follow this Question
Related Questions
Zombies keep stopping in mid chase 1 Answer
How to make my zombies move over these windows? 0 Answers
Zombie Spawn Per Round Script 2 Answers
How do i Kill Enemy with Vehicle?? 2 Answers
how is it possible to make a sound based spawning system? 1 Answer