BoneHeadSpark
Member
I made a custom projectile, just something for an enemy to throw to try and kill the player, but it seems to hurt the player as soon as it spawns.
I got the code directly from the guide on here
void OnCollisionEnter(Collision collision)
{
Destroy(gameObject, 1);
var health = m_Character.GetComponent<Health>();
if (health != null)
{
health.Damage(Damage); // Inflict damage on the character.
}
}
But the projectile I made doesn't even touch the player before hurting them. Any idea why? Interestingly, my projectile still destroys itself 1 second after touching the enemy, so it clearly recognizes when its touching the player. The damage just happens way before it touches them.
I got the code directly from the guide on here
void OnCollisionEnter(Collision collision)
{
Destroy(gameObject, 1);
var health = m_Character.GetComponent<Health>();
if (health != null)
{
health.Damage(Damage); // Inflict damage on the character.
}
}
But the projectile I made doesn't even touch the player before hurting them. Any idea why? Interestingly, my projectile still destroys itself 1 second after touching the enemy, so it clearly recognizes when its touching the player. The damage just happens way before it touches them.