コード例 #1
0
 private void Awake()
 {
     //timeLeft = TimeLife;
     Destroy(gameObject, TimeLife);
     collider = GetComponent <Collider2D>();
     transform.SetParent(null);
     body = GetComponent <Rigidbody2D>();
     MoveDirection.Normalize();
     damage = GetComponent <MakeDamage>();
     render = GetComponentInChildren <SpriteRenderer>();
 }
コード例 #2
0
ファイル: Gun.cs プロジェクト: KingPeas/SkytecTestTask
 // Use this for initialization
 void OnEnable()
 {
     if (bullet)
     {
         Bullet newBullet = Instantiate(bullet, transform.position, transform.rotation, null);
         newBullet.gameObject.layer = gameObject.layer;
         newBullet.MoveDirection    = transform.lossyScale.x > 0? transform.right: -transform.right;
         MakeDamage damage = newBullet.GetComponent <MakeDamage>();
         if (damage)
         {
             damage.source = GetComponentInParent <MoveUnitData>();
         }
     }
     gameObject.SetActive(false);
 }