private void OnCollisionEnter(Collision collision) { var otherLayer = collision.collider.gameObject.layer; if ((BulletLayer & 1 << otherLayer) == 1 << otherLayer) { BulletCore bullet = collision.gameObject.GetComponent <BulletCore>(); Harm(bullet.WeaponDescription); } }
void RpcAddForceOnAll(GameObject bulletObj) { Rigidbody rigid = GetComponent <Rigidbody>(); BulletCore bulletCore = bulletObj.GetComponent <BulletCore>(); Rigidbody bulletRigid = bulletObj.GetComponent <Rigidbody>(); Debug.Assert(bulletCore && bulletRigid); bulletCore.shooterObj = gameObject; bulletRigid.AddForce(rigid.velocity + bodyTr.up * POWER); }
// Use this for initialization private void Awake() { bulletCore = new BulletCore(new Weapon()); launchTime = Time.time; }