Skip to content

Instantly share code, notes, and snippets.

@kihira
Created November 24, 2015 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kihira/5c2af37b8dc17def1981 to your computer and use it in GitHub Desktop.
Save kihira/5c2af37b8dc17def1981 to your computer and use it in GitHub Desktop.
private bool gunButtonDown;
public float fireRate;
private float fireTime;
void Update()
{
// Only fire if button is down
if (gunButtonDown && Time.time > nextFire)
{
GunFire();
nextFire = Time.time + fireRate;
}
}
public void GunButtonDown()
{
gunButtonDown = true;
}
public void GunButtonUp()
{
gunButtonDown = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment