- Home /
Question by
Dmitriy MDV · Jul 25, 2015 at 03:48 PM ·
colliderprefabcollision detectionproperties
Bullet (Prefab) Shooting. Colliders take properties of one
I've realized a bullet and taking damage script. Bullet:
public class BulletDamage : MonoBehaviour {
GetDamage dmg;
public int damage1 = 50;
void OnCollisionEnter (Collision info) {
print ("shot " + info.gameObject + info.collider);
if (info.gameObject.tag == "Enemy") {
dmg = info.collider.GetComponent<GetDamage> ();
dmg.Damage (damage1);
//info.transform.SendMessage ("Damage", damage1, SendMessageOptions.DontRequireReceiver);
//print ("shot " + info.collider);
Destroy (gameObject);
}
}
}
Here's script which takes damage on collider:
public void Damage(int damage)
{
enemyHealth = transform.parent.GetComponent<EnemyHealth> ();
//print (damage); //debug
damageGot = damage * damageCoef;
enemyHealth.GetShot (damageGot);
}
It transforms damage to the mesh with open coef. So, you shot head - get 3x damage. Colliders are created as empty objects as a child of mesh. They work great while raycasting but only leg collider (1 of 3) works while prefab. Unfortunatly for me, it must be prehab. Did anyone deal with this and what may be the proper way to fix this. Tnx :)
Comment
Your answer