I’m working on a way to allow the player to kill monsters/destroy barricades. I have it mostly complete but for some reason, this one script isn’t working how it should.
void OnCollisionEnter ( Collision c ){
if (weaponType == WeaponType.Missile) {
if (c.gameObject.GetComponent<Damageable>() != null) {
Debug.Log("yes");
Damageable damageable = c.gameObject.GetComponent<Damageable>();
damageable.ApplyDamage( damage );
}
Destroy(this.gameObject);
}
}
I have a gameObject with the Damageable script attached and I know the collision script runs because the bolt destroys itself (the second line runs perfectly) on collision but the Debug.Log function isn’t run.
If someone could tell me why the second If statement doesn’t run and how I would make it work, I would greatly appreciate it.