using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyHealthController : MonoBehaviour { public int health = 20; public CameraController cc; public GameObject[] drops; public int selectedDrop; public float probabilityPercentage = 0; public int diceRoll; // Use this for initialization void Start () { cc = Camera.main.GetComponent(); selectedDrop = Mathf.FloorToInt( Random.Range(0, drops.Length)) ; diceRoll = Random.Range(0, 100); } // Update is called once per frame void Update () { if (health <= 0) { if (diceRoll >= probabilityPercentage) { Instantiate(drops[selectedDrop], new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z), Quaternion.identity); } Destroy(this.gameObject); cc.isShakcing = true; } } }