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>(); }
// 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); }