Exemplo n.º 1
0
    void Update()
    {
        if (instance == null)
        {
            GameModeManagerBase.SetManagerInstance(ref instance);
        }

        if (instance.mState == GameModeManagerBase.State.Paused)
        {
            return;
        }

        string fireButton = "";

        if (player.name == "Player 1")
        {
            fireButton = "Fire1";
        }

        if (player.name == "Player 2")
        {
            fireButton = "Fire2";
        }

        if (Input.GetButton(fireButton) && Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            GameObject clone = instance.GetBulletSpawner()
                               .Spawn(shotSpawn.position, shotSpawn.rotation, player);
            rb          = clone.GetComponent <Rigidbody>();
            rb.velocity = clone.transform.forward * bulletSpeed;
        }
    }
Exemplo n.º 2
0
 private void AimAndFire()
 {
     if (Time.time > nextFire)
     {
         nextFire = Time.time + FireRate;
         GameObject clone = instance.GetBulletSpawner().Spawn(gameObject);
         clone.transform.position = transform.position;
         clone.transform.LookAt(targetPosition);
         clone.GetComponent <Rigidbody>().velocity = clone.transform.forward * BulletSpeed;
     }
 }