void Shoot() { if (canShoot && Input.GetKeyDown(KeyCode.Space)) { GameObject bullet = Instantiate(prefabBullet, transform.position, transform.rotation) as GameObject; PlayerBullet bulletScript = bullet.GetComponent <PlayerBullet>(); int dir = GetFaceDirection(); bulletScript.SetBulletSpeed(speed * dir); canShoot = false; } }