public override void Attack() { GameObject clone = Instantiate(projectile, spawnPoint.position, spawnPoint.rotation); PlayerProjectile newBullet = clone.GetComponent <PlayerProjectile>(); newBullet.Fire(transform.forward); }
void Fire() { GameObject bullet = Instantiate(bulletPrefab, rb.position + Vector2.up * bulletVerticalOffset, Quaternion.identity); PlayerProjectile projectile = bullet.GetComponent <PlayerProjectile>(); projectile.Fire(lookDirection); // call animation for firing }
public void Fire() { int direction = 1; if (!isFacingRight) { direction = -1; } if (wallSliding) { direction *= -1; } GameObject bullet = Instantiate(bulletProjectile, this.transform.position + (new Vector3(direction * 0.5f, -0.08f, 0)), Quaternion.identity ); PlayerProjectile projectile = bullet.GetComponent <PlayerProjectile>(); projectile.Fire((int)direction); audioSource.PlayOneShot(fireSound); // call animation for firing }