blob: 45c6aca2d7742eb7b38090e05d2108e0d80a8ebf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
using UnityEngine;
using System.Collections;
public class PlayerShootingScript : MonoBehaviour {
public bool canShoot;
public GameObject Bullet;
public float Firerate = 1f;
float fireCounter = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if (canShoot)
{
if (Input.GetAxis("Fire") == 1)
{
if (fireCounter > Firerate)
{
fireCounter = 0;
gameObject.GetComponent<AudioSource>().Play();
Instantiate(Bullet, gameObject.transform.position, Quaternion.identity);
}
}
fireCounter += Time.deltaTime;
}
}
}
|