MrFastDie icon

Untitled

MrFastDie | PRO | 12/07/16 11:46:26 PM UTC | 0 ⭐ | 277 👁️ | Never ⏰ | []
C# |

1 KB

|

None

|

0 👍

/

0 👎

using UnityEngine;
using System.Collections;
 
public class PlayerShooting : MonoBehaviour {
 
    public GameObject bulletPrefab;
 
    public float fireDelay = 0.25f;
    public  float cooldownTimer = 0f;
 
    void Update () {
        cooldownTimer -= Time.deltaTime;
        if (gameObject.tag == "Player1" && RandomKeys.player1trigger) {
            RandomKeys.player1trigger = false;
            //shoot
            cooldownTimer = fireDelay;
 
 
            Vector3 offset = transform.rotation * new Vector3(0, 0.7f, 0);
 
            Instantiate(bulletPrefab, transform.position + offset, transform.rotation);
 
        } else if (gameObject.tag == "Player2" && RandomKeys.player2trigger) {
            RandomKeys.player2trigger = false;
            //shoot
            cooldownTimer = fireDelay;
 
 
            Vector3 offset = transform.rotation * new Vector3(0, 0.7f, 0);
 
            Instantiate(bulletPrefab, transform.position + offset, transform.rotation);
 
        }
    }
}

Comments