Example #1
0
    private void Shoot(float speedMagnitude)
    {
        Vector2 shootDir = input.IsShooting()?  input.GetShootAxis() : IsAssistModeOn.Value? GetClosestEnemyDir() : input.GetShootAxis();

        if (bullet == null || Mathf.Approximately(shootDir.magnitude, 0))
        {
            return;
        }
        //float angle = Vector2.Angle(Vector2.right, lastMovement.normalized);
        //angle = lastMovement.y < 0 ? - angle : angle;
        float            angle      = Vector2.SignedAngle(Vector2.right, shootDir.normalized);
        PlayerProjectile projectile = Instantiate(bullet,
                                                  transform.position,
                                                  Quaternion.Euler(0, 0, angle));

        projectileStats.SetProjectileStats(playerStats);
        projectile.SetPlayerProjectileStats(speedMagnitude, projectileStats);
        SoundSystem.Instance.PlaySound(shootSound);
    }