//////////////////////////////////////////////////////////// public void Damage(int damage, float knockback) { if (ableToBeDamaged == true) { animator.Play("Hit_001"); //ableToBeDamaged = false; health -= damage; if (health <= 0) { head.GetComponent <AudioSource>().clip = deathSoundList.GetRandomSound(); head.GetComponent <AudioSource>().Play(); psBlood.Play(); scriptEnabled = false; if (Random.Range(0, 100) <= 1) { GameObject.Find("GameManager").GetComponent <GameManager>().SpawnHealthItem(transform.position); } } else { GetComponent <Rigidbody>().AddForce(-transform.forward * knockback, ForceMode.Impulse); //GetComponent<Rigidbody>().AddForce( transform.up * knockback / 2.0f, ForceMode.Impulse ); StartCoroutine(damageShield()); } } }
//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // // SHOOT FUNCTIONS // //////////////////////////////////////////////////////////// public void ShootBullet(int _index) { ////////////////////////////// // MAKE BULLET READY ////////////////////////////// Vector3 pos = Vector3.forward * 2; Vector3 newPos = transform.TransformPoint(pos); ////////////////////////////// // SHOOT BULLET ////////////////////////////// GameObject bullet = Instantiate(projectiles[_index], codingTrash); bullet.transform.position = newPos; bullet.transform.rotation = Quaternion.LookRotation(player.transform.position - transform.position); bullet.GetComponent <Basic_Enemy_Musketball>().Activate(); audioSource.clip = shootSoundList.GetRandomSound(); audioSource.Play(); }