private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Enemy") { if (other.gameObject.GetComponent <EnemyControler>().GetColor() == ButtonColorControler.GetLastPressedColor()) { other.gameObject.GetComponent <EnemyHealthManager>().HurtEnemy(damateToGive); } Destroy(gameObject); } }
// Update is called once per frame void Update() { if (isFiring) { shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; //reset to full value BulletControler newBullet; newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation) as BulletControler; newBullet.setColor(ButtonColorControler.GetLastPressedColor()); } } else { shotCounter = 0; } }