![unity – Damage not utilized to the participant unity – Damage not utilized to the participant](https://thefuntrove.com/wp-content/uploads/https://cdn.sstatic.net/Sites/gamedev/Img/apple-touch-icon@2.png?v=9bca23db2259)
[ad_1]
I created a turret firing missile to participant however for some cause the injury isn’t utilized to the participant, and the missile isn’t firing appropriately: collision isn’t triggered. Here’s my code. I can’t perceive what might presumably be the rationale.
public class DamageParticipant : MonoBehaviour
{
public GameObject participant;
personal PlayerHealth _playerHealth;
void Start()
{
if (participant != null)
{
_playerHealth = participant.remodel.GetComponent<PlayerHealth>();
}
else
{
print("participant Gameobject not discovered");
}
}
void OnCollisionEnter(Collision different)
{
print("collision set off works");
if(different.remodel.tag == "Rocket")
{
_playerHealth.playerHealth = _playerHealth.playerHealth - 10;
print(_playerHealth.playerHealth);
}
}
}
public GameObject rocketPrefab;
public GameObject spawnPoint;
personal bool _firing;
public float fireRate;
public bool turretActive = true;
// Update is known as as soon as per body
void Update()
{
if (turretActive)
{
if (!_firing)
{
FireTheRocket();
StartCoroutine(RateOfFire());
}
}
}
void FireTheRocket()
{
Instantiate(rocketPrefab, spawnPoint.remodel.TransformPoint(0, 0, 0), spawnPoint.remodel.rotation);
}
IEnumerator RateOfFire()
{
_firing = true;
yield return new WaitForSeconds(fireRate);
_firing = false;
}
[ad_2]