void Shoot() { GameObject b = Instantiate(BulletPrefab, _bulletExit.position, Quaternion.identity); Rigidbody2D rb = b.GetComponent <Rigidbody2D>(); Bullet_Script bs = b.GetComponent <Bullet_Script>(); bs.Config(BulletDmg, "Enemy"); rb.velocity = -_bulletExit.transform.up * BulletForce; }
void OnTriggerEnter2D(Collider2D c) { Bullet_Script b = c.GetComponent <Bullet_Script>(); if (b != null) { if (b.Owner == "Player") { Destroy(b.gameObject); Death(); } } }
void Shoot() { ChangeAmmo(-1); trigger = false; shootTime = 0.8f; GameObject bulletPrefab = Instantiate(bullet, attackPoint.position, Quaternion.identity); Bullet_Script b = bulletPrefab.GetComponent <Bullet_Script>(); b.Fire(characterDirection, 800); animator.SetTrigger("isShooting"); }
void OnTriggerEnter2D(Collider2D c) { Debug.Log("Player hit"); Bullet_Script b = c.transform.GetComponent <Bullet_Script>(); if (b != null) { if (b.Owner == "Enemy") { Debug.Log("Player hit by bullet"); TakeDamage(b.Damage); Destroy(b.gameObject); } } }