title: Item Drop After Enemy Death
body: <p>Here is the revised code that is almost fully functioning. I've commented where the last couple bugs are located. Basically, the randNum is being called every frame because this code is inside of an update function. When the enemy dies, the HP value is 0 and I need to maybe reload the enemyHP to anything over 0. However, is this the best approach? Because it may alter my other enemies Hp? </p>
  
  <p>The second issue is when the enemy dies, all other enemies of this type spawn an item. How do I fix it to where it only spawns on the enemy that has died? I'm thinking because my Epos variable has grabbed the components of all enemies is the problem. I think I need a better approach? </p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  
  public class ItemDrop : MonoBehaviour
  {
    [SerializeField]
    private GameObject[] itemList; // Stores the game items
    private int itemNum; // Selects a number to choose from the itemList
    private int randNum; // chooses a random number to see if loot os dropped- Loot chance
    private Transform Epos; // enemy position
  
  
  private void Start()
  {
  
      Epos = GetComponent&lt;Transform&gt;();
      Debug.Log(itemList);
  }
  private void Update()
  {
      if(EnemyDMG.enemyHP &lt;= 0)
      {
  
  
  
          // This number get's called non-stop after enemy dies
          // This causes non-stop item drops
          // I need to know the logic to make this code happen only once per kill
              randNum = Random.Range(0, 101); // 100% total for determining loot chance;
              Debug.Log("Random Number is " + randNum);
  
          // The code below runs now and instantiates objects
          // However, all of the similar enemies that are alive drop items
           // at their location. I need to know how to make an item drop
          // only at the lace the enemy was killed
          if(randNum &gt;= 95) // Star Tablet drop itemList[2] currently
          {
  
              itemNum = 2;// grabs the star tab
              Instantiate(itemList[itemNum], Epos.position, Quaternion.identity);
  
  
          }
          else if(randNum &gt; 75 &amp;&amp; randNum &lt; 95) // Extra life drop itemList[1] currently
          {
  
              itemNum = 1;// grabs the star tab
              Instantiate(itemList[itemNum], Epos.position, Quaternion.identity);
  
          }
          else if(randNum &gt; 40 &amp;&amp; randNum &lt;= 75)// Health Heart drop itemList[0] currently
          {
  
              itemNum = 0;// grabs the star tab
              Instantiate(itemList[itemNum], Epos.position, Quaternion.identity);
  
          }
      }
    }
  
  
   }
  </code></pre>