How to play animations for objects in gameObject [ ] ?
Hey,
so I've created a C# script for a one door to open/close it which looks like this
 using UnityEngine;
 using System.Collections;
 
 public class OpeningDoor : MonoBehaviour
 {
 
     private bool guiShow = false;
     private bool isOpen = false;
     private int rayLength = 10;
     public GameObject door;
 
     void Update()
     {
         RaycastHit hit;
 
         if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, rayLength))
         {
             if (hit.collider.gameObject.tag == "Door")
             {
                 guiShow = true;
                 if (Input.GetKeyDown("e") && isOpen == false)
                 {
                     door.GetComponent<Animation>().Play("DoorOpen");
                     isOpen = true;
                     guiShow = false;
                 }
                 else if (Input.GetKeyDown("e") && isOpen == true)
                 {
                     door.GetComponent<Animation>().Play("DoorClose");
                     isOpen = false;
                     guiShow = false;
                 }
             }
         }
         else
         {
             guiShow = false;
         }
     }
 
     void OnGUI()
     {
         if (guiShow == true && isOpen == false)
         {
             GUI.Box(new Rect(Screen.width / 2, Screen.height / 2, 100, 25), "Press E to Open");
         }
     }
 
 }
it works fine on one door. But how do I make if lets say I have
 public GameObject[] doors;
How do I make each doors to play same DoorOpen/DoorClose animations?
All help is welcome.
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                