private void _Fire()
 {
     if (Input.GetAxisRaw("Fire1") > 0.0f)
     {
         // delays firing
         if (Time.frameCount % fireRate == 0)
         {
             // var tempBullet = Instantiate(bullet, bulletSpawn.position, Quaternion.identity);
             var tempBullet = bulletManager.Get();
             if (tempBullet)
             {
                 tempBullet.transform.position = bulletSpawn.position;
                 // tempBullet.GetComponent<BulletBehaviour>().direction = bulletSpawn.forward;
                 tempBullet.GetComponent <SphereBehaviour>().velocity = bulletSpawn.forward * bulletManager.bulletSpeed;
                 tempBullet.transform.SetParent(bulletManager.gameObject.transform);
             }
         }
     }
 }
示例#2
0
    private void Fire()
    {
        if (fireSound)
        {
            AudioManager.PlayAtPoint(fireSound, transform.position);
        }
        CameraShaker.ShakeAt(transform.position, recoilShake);
        foreach (var fireOrigin in fireOrigins)
        {
            BulletController bullet = BulletManager.Get(bulletName);
            bullet.lifespan           = lifespan;
            bullet.destroyDelay       = destroyDelay;
            bullet.baseSettings       = baseSettings;
            bullet.transform.position = transform.position + transform.right * fireOrigin.offset.x + transform.up * fireOrigin.offset.y + transform.forward * fireOrigin.offset.z;
            bullet.transform.rotation = transform.rotation * Quaternion.Euler(0, -fireOrigin.rotation, 0);
            float rad = bullet.transform.eulerAngles.y * Mathf.Deg2Rad;
            bullet.Fire(new Vector3(Mathf.Cos(rad) * firePower, 0, -Mathf.Sin(rad) * firePower));
        }

        _recoilCoroutine = StartCoroutine(ExeRecoilCoroutine());
    }