title: How can I create instances of a unity class in order to have multiple instances of the class running simultaneously w/o interrupting each other
body: <p>I am working on a city builder game and trying to create a crop growing system. This issue is with 2 different scripts, a placement manager and a farm timer. The placement manager class detects mousedown events and will setTile to my farm tilemap based off of the click location and the selected tile. The farm timer class contains a method which is called when a farm tile is set in the placement manager which then starts the timer using the update method to countdown from 60.</p>
  <p>3 if statements check for 45, 30, and 15 seconds and calls another method in the placement manager which will set the tile to its respective growth stage tile. This works when only placing a single crop, but when there are multiple it starts the timer over with whichever tile was placed last.</p>
  <p>I am guessing I need to find a way to create new instances of the class but I am also wondering if there would be a better way???</p>
  <p><strong>PlacementManager.cs</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public void Update()
  {
      if (Input.GetMouseButtonDown(0) &amp;&amp; isIndexSet)
      {
          Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
          Location = farmGround.WorldToCell(pos);
          Location.z = 0;
          //6 is a carrot crop
          if(curIndex == 6 &amp;&amp; isSpaceOpen())
          {
              PlacePlant();
              CurrencyManager.Instance.currency -= 1;
              //FarmTimer.instance.PlantPlaced(&quot;Carrot&quot;, Location);
              timer.PlantPlaced(&quot;Carrot&quot;, Location);
          }
          if(curIndex &lt; 6 &amp;&amp; isSpaceOpen())
          {
              PlaceBuilding();
              CurrencyManager.Instance.currency -= 5;
          }
      }
  }
      
  public void ChangePlantTile(int index, Vector3Int selectedLocation)
  {
      farmPlants.SetTile(selectedLocation, plants[index]);
  }
  </code></pre>
  <p><strong>FarmTimer.cs</strong></p>
  <pre class="lang-cs prettyprint-override"><code>private string carrotChk1 = &quot;Farm_36 (UnityEngine.Tilemaps.Tile)&quot;;
  private string carrotChk2 = &quot;Farm_35 (UnityEngine.Tilemaps.Tile)&quot;;
  private string carrotChk3 = &quot;Farm_34 (UnityEngine.Tilemaps.Tile)&quot;;
  
  private int curIndex;
  private bool isIndexSet = false;
  public Tile[] tiles;
  public Tile[] plants;
      
  void Update()
  {
      if (isTimerActive == true)
      { 
          if(plant == &quot;Carrot&quot;)
          {
              CarrotTimer();
          }
      
      }
  }
      
  public void CarrotTimer()
  {
      if (m_time &lt; 45f &amp;&amp; m_time &gt; 30f 
          &amp;&amp; FarmMap.GetTile(selectedLocation).ToString() != carrotChk1)
      {
          curIndex = 0;
          PlacementManager.Instance.ChangePlantTile(curIndex, selectedLocation);
          curIndex++;
      }
      else if (m_time &lt; 15f &amp;&amp; m_time &gt; 1 
              &amp;&amp; FarmMap.GetTile(selectedLocation).ToString() != carrotChk2)
      {
          PlacementManager.Instance.ChangePlantTile(curIndex, selectedLocation);
          curIndex++;
      }
      else if (m_time &lt; 1f
              &amp;&amp; FarmMap.GetTile(selectedLocation).ToString() != carrotChk3)
      {
          PlacementManager.Instance.ChangePlantTile(curIndex, selectedLocation);
          curIndex = 0;
          isTimerActive = false;
      }
  }
  </code></pre>
  <p>For Testing purposes I am checking for the index of the carrot crop but I have 5 other crops which I plan to create the same functionality with.</p>